forked from 2amigos/yii2-ckeditor-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCKEditorTrait.php
65 lines (61 loc) · 1.99 KB
/
CKEditorTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\ckeditor;
use yii\helpers\ArrayHelper;
/**
* CKEditorTrait has common methods for both CKEditor and CKEditorInline widgets.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\ckeditor
*/
trait CKEditorTrait
{
/**
* @var string the toolbar preset. It can be any of the following:
*
* - basic: will load the configuration on presets/basic.php
* - full: will load the configuration on presets/full.php
* - standard: will load the configuration on presets/standard.php
* - custom: configuration will be based on [[clientOptions]].
*
* Defaults to 'standard'. It is important to note that any configuration item of the loaded presets can be
* overrided by [[clientOptions]]
*/
public $preset = 'standard';
/**
* @var array the options for the CKEditor 4 JS plugin.
* Please refer to the CKEditor 4 plugin Web page for possible options.
* @see http://docs.ckeditor.com/#!/guide/dev_installation
*/
public $clientOptions = [];
/**
* Initializes the widget options.
* This method sets the default values for various options.
*/
protected function initOptions()
{
$options = [];
switch ($this->preset) {
case 'custom':
$preset = null;
break;
case 'basic':
case 'full':
case 'standard':
$preset = 'presets/' . $this->preset . '.php';
break;
default:
$preset = 'presets/standard.php';
}
if ($preset !== null) {
$options = require($preset);
}
$this->clientOptions = ArrayHelper::merge($options, $this->clientOptions);
}
}