welcome.class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Loads the welcome page
  4. *
  5. * @package modx
  6. * @subpackage manager.controllers
  7. */
  8. class WelcomeManagerController extends modManagerController {
  9. /**
  10. * Whether or not to show the welcome screen
  11. * @var boolean $showWelcomeScreen
  12. */
  13. public $showWelcomeScreen = false;
  14. /**
  15. * The current, active dashboard for the user
  16. * @var null|modDashboard $dashboard
  17. */
  18. public $dashboard = null;
  19. /**
  20. * Check for any permissions or requirements to load page
  21. * @return bool
  22. */
  23. public function checkPermissions() {
  24. return $this->modx->hasPermission('home');
  25. }
  26. /**
  27. * Register custom CSS/JS for the page
  28. * @return void
  29. */
  30. public function loadCustomCssJs() {
  31. $this->addJavascript($this->modx->getOption('manager_url').'assets/modext/widgets/modx.panel.welcome.js');
  32. $this->addJavascript($this->modx->getOption('manager_url').'assets/modext/sections/welcome.js');
  33. $this->addHtml('<script type="text/javascript">
  34. Ext.onReady(function() {
  35. MODx.load({
  36. xtype: "modx-page-welcome"
  37. ,dashboard: '.$this->modx->toJSON($this->dashboard->toArray()).'
  38. });
  39. });
  40. </script>');
  41. if ($this->showWelcomeScreen) {
  42. $url = $this->modx->getOption('welcome_screen_url',null,'http://misc.modx.com/revolution/welcome.20.html');
  43. $this->addHtml('<script type="text/javascript">
  44. // <![CDATA[
  45. Ext.onReady(function() { MODx.loadWelcomePanel("'.$url.'"); });
  46. // ]]></script>');
  47. }
  48. }
  49. /**
  50. * Custom logic code here for setting placeholders, etc
  51. * @param array $scriptProperties
  52. * @return array
  53. */
  54. public function process(array $scriptProperties = array()) {
  55. $placeholders = array();
  56. $this->checkForWelcomeScreen();
  57. $this->dashboard = $this->modx->user->getDashboard();
  58. $placeholders['dashboard'] = $this->dashboard->render($this);
  59. return $placeholders;
  60. }
  61. /**
  62. * Check to show if we need to show the Welcome Screen for the user
  63. * @return void
  64. */
  65. public function checkForWelcomeScreen() {
  66. if ($this->modx->getOption('welcome_screen',null,false)) {
  67. $this->showWelcomeScreen = true;
  68. /** @var modSystemSetting $setting */
  69. $setting = $this->modx->getObject('modSystemSetting','welcome_screen');
  70. if ($setting) {
  71. $setting->set('value',false);
  72. $setting->save();
  73. }
  74. /** @var modUserSetting $setting */
  75. $setting = $this->modx->getObject('modUserSetting',array(
  76. 'key' => 'welcome_screen',
  77. 'user' => $this->modx->user->get('id'),
  78. ));
  79. if ($setting) {
  80. $setting->set('value',false);
  81. $setting->save();
  82. }
  83. $this->modx->reloadConfig();
  84. }
  85. }
  86. /**
  87. * Return the pagetitle
  88. *
  89. * @return string
  90. */
  91. public function getPageTitle() {
  92. return $this->modx->lexicon('dashboard');
  93. }
  94. /**
  95. * Return the location of the template file
  96. * @return string
  97. */
  98. public function getTemplateFile() {
  99. return 'welcome.tpl';
  100. }
  101. /**
  102. * Specify the language topics to load
  103. * @return array
  104. */
  105. public function getLanguageTopics() {
  106. return array('welcome','configcheck');
  107. }
  108. }