-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.class.php
85 lines (77 loc) · 3.16 KB
/
index.class.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* The main ClientConfig Manager Controller.
* In this class, we define stuff we want on all of our controllers.
*/
abstract class ClientConfigManagerController extends modExtraManagerController {
/** @var ClientConfig $clientconfig */
public $clientconfig = null;
/**
* Initializes the main manager controller. In this case we set up the
* ClientConfig class and add the required javascript on all controllers.
*/
public function initialize() {
/* Instantiate the ClientConfig class in the controller */
$path = $this->modx->getOption('clientconfig.core_path', null, $this->modx->getOption('core_path') . 'components/clientconfig/') . 'model/clientconfig/';
$this->clientconfig =& $this->modx->getService('clientconfig', 'ClientConfig', $path);
// MODX 3.x automatically adds asterisks to required fields, MODX 2.x doesn't.
$modxVersion = $this->modx->getVersionData();
$reqAsterisk = version_compare($modxVersion['full_version'], '3.0.0-dev', '>=') ? '' : '*';
/* Add the main javascript class and our configuration */
$this->addJavascript($this->clientconfig->config['jsUrl'].'mgr/clientconfig.class.js');
$this->addCss($this->clientconfig->config['cssUrl'].'mgr/clientconfig.css');
$this->addHtml('<script type="text/javascript">
Ext.onReady(function() {
ClientConfig.config = '.$this->modx->toJSON($this->clientconfig->config).';
ClientConfig.reqAsterisk = "' . $reqAsterisk . '";
});
</script>');
}
/**
* Defines the lexicon topics to load in our controller.
* @return array
*/
public function getLanguageTopics() {
return array('clientconfig:default');
}
/**
* We can use this to check if the user has permission to see this
* controller. We'll apply this in the admin section.
* @return bool
*/
public function checkPermissions() {
return true;
}
public function loadRichTextEditor()
{
$useEditor = $this->modx->getOption('use_editor');
$whichEditor = $this->modx->getOption('which_editor');
if ($useEditor && !empty($whichEditor))
{
/* invoke OnRichTextEditorInit event */
$onRichTextEditorInit = $this->modx->invokeEvent('OnRichTextEditorInit',array(
'editor' => $whichEditor,
'elements' => array('foo'),
));
if (is_array($onRichTextEditorInit))
{
$onRichTextEditorInit = implode('', $onRichTextEditorInit);
}
$this->setPlaceholder('onRichTextEditorInit', $onRichTextEditorInit);
}
}
}
/**
* The Index Manager Controller is the default one that gets called when no
* action is present. It's most commonly used to define the default controller
* which then hands over processing to the other controller ("home").
*/
class IndexManagerController extends ClientConfigManagerController {
/**
* Defines the name or path to the default controller to load.
* @return string
*/
public static function getDefaultController() {
return 'home';
}
}