index.class.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * The main ClientConfig Manager Controller.
  4. * In this class, we define stuff we want on all of our controllers.
  5. */
  6. abstract class ClientConfigManagerController extends modExtraManagerController {
  7. /** @var ClientConfig $clientconfig */
  8. public $clientconfig = null;
  9. /**
  10. * Initializes the main manager controller. In this case we set up the
  11. * ClientConfig class and add the required javascript on all controllers.
  12. */
  13. public function initialize() {
  14. /* Instantiate the ClientConfig class in the controller */
  15. $path = $this->modx->getOption('clientconfig.core_path', null, $this->modx->getOption('core_path') . 'components/clientconfig/') . 'model/clientconfig/';
  16. $this->clientconfig =& $this->modx->getService('clientconfig', 'ClientConfig', $path);
  17. /* Add the main javascript class and our configuration */
  18. $this->addJavascript($this->clientconfig->config['jsUrl'].'mgr/clientconfig.class.js');
  19. $this->addCss($this->clientconfig->config['cssUrl'].'mgr/clientconfig.css');
  20. $this->addHtml('<script type="text/javascript">
  21. Ext.onReady(function() {
  22. ClientConfig.config = '.$this->modx->toJSON($this->clientconfig->config).';
  23. });
  24. </script>');
  25. }
  26. /**
  27. * Defines the lexicon topics to load in our controller.
  28. * @return array
  29. */
  30. public function getLanguageTopics() {
  31. return array('clientconfig:default');
  32. }
  33. /**
  34. * We can use this to check if the user has permission to see this
  35. * controller. We'll apply this in the admin section.
  36. * @return bool
  37. */
  38. public function checkPermissions() {
  39. return true;
  40. }
  41. public function loadRichTextEditor()
  42. {
  43. $useEditor = $this->modx->getOption('use_editor');
  44. $whichEditor = $this->modx->getOption('which_editor');
  45. if ($useEditor && !empty($whichEditor))
  46. {
  47. /* invoke OnRichTextEditorInit event */
  48. $onRichTextEditorInit = $this->modx->invokeEvent('OnRichTextEditorInit',array(
  49. 'editor' => $whichEditor,
  50. 'elements' => array('foo'),
  51. ));
  52. if (is_array($onRichTextEditorInit))
  53. {
  54. $onRichTextEditorInit = implode('', $onRichTextEditorInit);
  55. }
  56. $this->setPlaceholder('onRichTextEditorInit', $onRichTextEditorInit);
  57. }
  58. }
  59. }
  60. /**
  61. * The Index Manager Controller is the default one that gets called when no
  62. * action is present. It's most commonly used to define the default controller
  63. * which then hands over processing to the other controller ("home").
  64. */
  65. class IndexManagerController extends ClientConfigManagerController {
  66. /**
  67. * Defines the name or path to the default controller to load.
  68. * @return string
  69. */
  70. public static function getDefaultController() {
  71. return 'home';
  72. }
  73. }