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