示例#1
0
 /**
  * Set default names for views and models
  *
  * @param	array An optional associative array of configuration settings.
  * @return	void
  */
 protected function _setDefaultNames($config = array())
 {
     parent::_setDefaultNames($config);
     $prefix = strtolower($this->getName());
     $suffix = strtolower($this->getNameSuffix());
     // Grid view name
     if (array_key_exists('list_view', $config)) {
         $this->_listView = $config['list_view'];
     } else {
         if (EInflector::isSingular($this->_defaultView)) {
             $this->_listView = EInflector::pluralize($this->_defaultView);
         } else {
             $this->_listView = $this->_defaultView;
         }
     }
     // Edit view name
     if (array_key_exists('item_view', $config)) {
         $this->_itemView = $config['item_view'];
     } else {
         $singularView = EInflector::singularize($this->_listView);
         if (!empty($singularView)) {
             $this->_itemView = $singularView;
         } else {
             if (!empty($suffix)) {
                 $this->_itemView = $suffix;
             } else {
                 $this->_itemView = $prefix;
             }
         }
     }
 }
示例#2
0
 /**
  * Dispatch the component
  *
  * @param $config array An optional config array for controller
  * @return void
  */
 public static function dispatch($config = array())
 {
     $prefix = empty($config['prefix']) ? null : $config['prefix'];
     unset($config['prefix']);
     try {
         $controller = EController::getInstance($prefix, $config);
         $controller->execute(JRequest::getCmd('task'));
         $controller->redirect();
     } catch (Exception $e) {
         JError::raiseError($e->getCode(), $e->getMessage());
     }
 }
 public function filters()
 {
     return CMap::mergeArray(parent::filters(), array('accessControl'));
 }
示例#4
0
 public function getViewFile($viewName)
 {
     // Adds simple themeing support to console applications
     if (Yii::app() instanceof CConsoleApplication) {
         if (Yii::app()->theme && Yii::app()->theme != "") {
             $themeName = Yii::app()->theme;
             if (strpos($viewName, '.')) {
                 // Replace application.modules[_core].MODULEID.widgets.views
                 //      in
                 //          webroot.themes.CURRENTTHEME.views.MODULEID.widgets
                 $viewNameTheme = $viewName;
                 $viewNameTheme = str_replace('application.views.', 'webroot.themes.' . $themeName . '.views.', $viewNameTheme);
                 $viewNameTheme = preg_replace('/application\\.modules(?:_core)?\\.(.*?)\\.views\\.(.*)/i', 'webroot.themes.' . $themeName . '.views.\\1.\\2', $viewNameTheme);
                 $viewFile = Yii::getPathOfAlias($viewNameTheme);
                 if (is_file($viewFile . '.php')) {
                     return Yii::app()->findLocalizedFile($viewFile . '.php');
                 }
             }
         }
     }
     return parent::getViewFile($viewName);
 }
示例#5
0
 /**
  * Add a JavaScript to the renderPartial method to fire an event at the body tag, when the view loaded successfully
  */
 public function renderPartial($view, $data = null, $return = false, $processOutput = false)
 {
     if (Yii::app()->request->isAjaxRequest) {
         // get module id if exists
         $moduleID = "";
         if ($this->module != null) {
             $moduleID = $this->module->id;
         }
         /**
          * Fire an event with the following params:
          * @param1 String controllerID
          * @param2 String moduleID
          * @param3 String actionID
          * @param4 String view path
          */
         Yii::app()->clientScript->registerScript("autoAjaxEventFire", "\$('body').trigger('ajaxLoaded', ['" . $this->id . "', '" . $moduleID . "', '" . $this->action->id . "', '" . $view . "']);", CClientScript::POS_END);
     }
     return parent::renderPartial($view, $data, $return, $processOutput);
 }
示例#6
0
 public function render($view, $data = null, $return = false)
 {
     $this->publishResources();
     parent::render($view, $data, $return);
 }