2014-05-14 13:24:20 +00:00
|
|
|
<?php namespace Backend\FormWidgets;
|
|
|
|
|
|
|
|
|
|
use Backend\Classes\FormWidgetBase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rich Editor
|
|
|
|
|
* Renders a rich content editor field.
|
|
|
|
|
*
|
|
|
|
|
* @package october\backend
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
|
|
|
|
class RichEditor extends FormWidgetBase
|
|
|
|
|
{
|
2015-02-28 03:43:34 +00:00
|
|
|
//
|
|
|
|
|
// Configurable properties
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var boolean Determines whether content has HEAD and HTML tags.
|
|
|
|
|
*/
|
|
|
|
|
public $fullPage = false;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Object properties
|
|
|
|
|
//
|
|
|
|
|
|
2014-05-14 13:24:20 +00:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
2015-02-28 01:43:53 +00:00
|
|
|
protected $defaultAlias = 'richeditor';
|
2014-05-14 13:24:20 +00:00
|
|
|
|
2014-06-06 11:38:34 +00:00
|
|
|
/**
|
2015-02-28 03:43:34 +00:00
|
|
|
* {@inheritDoc}
|
2014-06-06 11:38:34 +00:00
|
|
|
*/
|
2015-02-28 03:43:34 +00:00
|
|
|
public function init()
|
|
|
|
|
{
|
|
|
|
|
$this->fillFromConfig([
|
|
|
|
|
'fullPage',
|
|
|
|
|
]);
|
|
|
|
|
}
|
2014-06-06 11:38:34 +00:00
|
|
|
|
2014-05-14 13:24:20 +00:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
$this->prepareVars();
|
|
|
|
|
return $this->makePartial('richeditor');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepares the list data
|
|
|
|
|
*/
|
|
|
|
|
public function prepareVars()
|
|
|
|
|
{
|
2014-06-06 11:38:34 +00:00
|
|
|
$this->vars['fullPage'] = $this->fullPage;
|
2014-05-14 13:24:20 +00:00
|
|
|
$this->vars['stretch'] = $this->formField->stretch;
|
|
|
|
|
$this->vars['size'] = $this->formField->size;
|
|
|
|
|
$this->vars['name'] = $this->formField->getName();
|
2015-01-04 22:45:04 +00:00
|
|
|
$this->vars['value'] = $this->getLoadValue();
|
2014-05-14 13:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-24 08:14:36 +00:00
|
|
|
public function onGetPageLinks()
|
|
|
|
|
{
|
|
|
|
|
$links = [
|
|
|
|
|
['name' => 'Select a page...', 'url' => false],
|
|
|
|
|
['name' => 'Some url', 'url' => 'some/url'],
|
|
|
|
|
['name' => 'Other thing', 'url' => 'else/thing'],
|
|
|
|
|
['name' => 'More', 'url' => 'more/thing']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return ['links' => $links];
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 13:24:20 +00:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function loadAssets()
|
|
|
|
|
{
|
2014-09-14 00:57:17 +00:00
|
|
|
$this->addCss('css/richeditor.css', 'core');
|
2015-02-14 05:40:50 +00:00
|
|
|
$this->addJs('js/build-min.js', 'core');
|
2014-09-14 00:57:17 +00:00
|
|
|
}
|
2014-10-10 21:50:05 +00:00
|
|
|
}
|