Example #1
0
 public function edit()
 {
     MRequest::setVar('hidemainmenu', 1);
     MRequest::setVar('view', 'edit');
     MRequest::setVar('edit', true);
     parent::display();
 }
 public function init()
 {
     parent::init();
     $this->idLanguage = Manager::getConf('options.language');
     $msgDir = Manager::getAppPath('conf/report');
     Manager::$msg->file = 'messages.' . $this->idLanguage . '.php';
     Manager::$msg->addMessages($msgDir);
 }
Example #3
0
 public function init()
 {
     parent::init();
     $userPhone = yii::app()->user->getState('msisdn');
     if (!$userPhone) {
         $this->redirect('/event/register');
     }
 }
Example #4
0
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     $actionArray = array("createcomment", "createanswer", "createsyscomment", "createreply", "dialogue", "personal", "inbox", "mytopic", "deletemessage", "deletequestion", "deletearticle");
     if (in_array($action->getId(), $actionArray)) {
         if (Yii::app()->user->isGuest) {
             throw new CHttpException(404, '请先登录!');
         }
     }
     return true;
 }
Example #5
0
 public function renderHandler()
 {
     $view = Manager::getView($this->getApplication(), $this->getModule(), 'handler', $this->getAction());
     $page = Manager::getPage();
     if ($go = $page->redirectTo) {
         //mdump('redirecting: ' . $go);
         $this->setResult(new MRedirect($view, $go));
     } else {
         if ($window = $page->window) {
             $this->setResult(new MBrowserWindow());
         } else {
             if ($binary = $page->binary) {
                 //mdump('binary: ' . $binary);
                 $this->setResult(new MRenderBinary($binary));
             } else {
                 if ($download = $page->download) {
                     //mdump('download: ' . $download);
                     $this->setResult(new MRenderBinary($download, false));
                 } else {
                     if ($prompt = $page->prompt) {
                         $page->clearContent();
                         parent::renderPrompt($prompt);
                     } else {
                         if (Manager::isAjaxCall()) {
                             //mdump('mhandler:: renderjson');
                             $render = new MRenderJSON();
                             if (!$this->getResult()) {
                                 $this->setResult($render);
                             }
                         } else {
                             //mdump('mhandler:: renderpage');
                             $render = new MRenderPage();
                             if (!$this->getResult()) {
                                 $this->setResult($render);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function init()
 {
     parent::init();
     $this->idLanguage = Manager::getSession()->idLanguage;
 }
Example #7
0
 /**
  * Creates the URL suitable for pagination.
  * This method is mainly called by pagers when creating URLs used to
  * perform pagination. The default implementation is to call
  * the controller's createUrl method with the page information.
  * You may override this method if your URL scheme is not the same as
  * the one supported by the controller's createUrl method.
  * @param MController $controller the controller that will create the actual URL
  * @param integer $page the page that the URL should point to. This is a zero-based index.
  * @return string the created URL
  */
 public function createPageUrl($controller, $page)
 {
     $params = $this->params === null ? $_GET : $this->params;
     if ($page > 0) {
         // page 0 is the default
         $params[$this->pageVar] = $page + 1;
     } else {
         unset($params[$this->pageVar]);
     }
     if ($this->route) {
         return url($this->route, $params);
     } else {
         $uri = preg_replace('/' . $this->pageVar . '=\\d*/', '', $controller->getRequest()->uri);
         return curl($uri, $params);
     }
 }
 public function init()
 {
     parent::init();
     $this->idLanguage = Manager::getConf('fnbr20.lang');
 }
 public function init()
 {
     parent::init();
 }
Example #10
0
 public function __construct()
 {
     parent::__construct();
 }
Example #11
0
 public static function getInstance($prefix, $config = array())
 {
     if (is_object(self::$instance)) {
         return self::$instance;
     }
     // Get the environment configuration.
     $basePath = array_key_exists('base_path', $config) ? $config['base_path'] : MPATH_COMPONENT;
     $format = MRequest::getWord('format');
     $command = MRequest::getVar('task', 'display');
     // Check for array format.
     $filter = MFilterInput::getInstance();
     if (is_array($command)) {
         $command = $filter->clean(array_pop(array_keys($command)), 'cmd');
     } else {
         $command = $filter->clean($command, 'cmd');
     }
     // Check for a controller.task command.
     if (strpos($command, '.') !== false) {
         // Explode the controller.task command.
         list($type, $task) = explode('.', $command);
         // Define the controller filename and path.
         $file = self::createFileName('controller', array('name' => $type, 'format' => $format));
         $path = $basePath . '/controllers/' . $file;
         // Reset the task without the controller context.
         MRequest::setVar('task', $task);
     } else {
         // Base controller.
         $type = null;
         $task = $command;
         // Define the controller filename and path.
         $file = self::createFileName('controller', array('name' => 'controller', 'format' => $format));
         $path = $basePath . '/' . $file;
         $backupfile = self::createFileName('controller', array('name' => 'controller'));
         $backuppath = $basePath . '/' . $backupfile;
     }
     // Get the controller class name.
     $class = ucfirst($prefix) . 'Controller' . ucfirst($type);
     // Include the class if not present.
     if (!class_exists($class)) {
         // If the controller file path exists, include it.
         if (file_exists($path)) {
             require_once $path;
         } elseif (isset($backuppath) && file_exists($backuppath)) {
             require_once $backuppath;
         } else {
             throw new InvalidArgumentException(MText::sprintf('MLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $type, $format));
         }
     }
     // Instantiate the class.
     if (class_exists($class)) {
         self::$instance = new $class($config);
     } else {
         throw new InvalidArgumentException(MText::sprintf('MLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class));
     }
     return self::$instance;
 }