示例#1
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Define standard task mappings.
     // Value = 0
     $this->registerTask('unpublish', 'publish');
     // Value = 2
     $this->registerTask('archive', 'publish');
     // Value = -2
     $this->registerTask('trash', 'publish');
     // Value = -3
     $this->registerTask('report', 'publish');
     $this->registerTask('orderup', 'reorder');
     $this->registerTask('orderdown', 'reorder');
     // Guess the option as com_NameOfController.
     if (empty($this->option)) {
         $this->option = 'com_tz_portfolio_plus';
     }
     // Guess the JText message prefix. Defaults to the option.
     if (empty($this->text_prefix)) {
         $this->text_prefix = strtoupper($this->option);
     }
     // Guess the list view as the suffix, eg: OptionControllerSuffix.
     if (empty($this->view_list)) {
         $r = null;
         if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) {
             throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
         }
         $this->view_list = strtolower($r[2]);
     }
 }
示例#2
0
 /**
  * Method to get a model object, loading it if required.
  *
  * @param   string  $name    The model name. Optional.
  * @param   string  $prefix  The class prefix. Optional.
  * @param   array   $config  Configuration array for model. Optional.
  *
  * @return  object  The model.
  *
  * @since   12.2
  */
 public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true))
 {
     if (empty($name)) {
         $name = $this->context;
     }
     return parent::getModel($name, $prefix, $config);
 }
示例#3
0
 protected function _getViewHtml($context, &$article, $params, $layout = null)
 {
     list($extension, $vName) = explode('.', $context);
     $input = JFactory::getApplication()->input;
     $addon_id = $input->getInt('addon_id');
     $addon = TZ_Portfolio_PlusPluginHelper::getPlugin($this->_type, $this->_name);
     if (!$addon_id || $addon_id && $addon_id == $addon->id) {
         tzportfolioplusimport('controller.legacy');
         $result = true;
         // Check task with format: addon_name.addon_view.addon_task (example image.default.display);
         $adtask = $input->get('addon_task');
         if ($adtask && strpos($adtask, '.') > 0 && !$addon_id) {
             list($plgname, $adtask) = explode('.', $adtask, 2);
             if ($plgname == $this->_name) {
                 $result = true;
                 $input->set('addon_task', $adtask);
             } else {
                 $result = false;
             }
         }
         if ($result && ($controller = TZ_Portfolio_Plus_AddOnControllerLegacy::getInstance('PlgTZ_Portfolio_Plus' . ucfirst($this->_type) . ucfirst($this->_name), array('base_path' => COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . $this->_type . DIRECTORY_SEPARATOR . $this->_name)))) {
             tzportfolioplusimport('plugin.modelitem');
             $controller->set('addon', $addon);
             $controller->set('article', $article);
             $controller->set('trigger_params', $params);
             $task = $input->get('addon_task');
             if (!$task && !$addon_id) {
                 $input->set('addon_view', $vName);
                 $input->set('addon_layout', 'default');
                 if ($layout) {
                     $input->set('addon_layout', $layout);
                 }
             }
             $html = null;
             try {
                 ob_start();
                 $controller->execute($task);
                 $controller->redirect();
                 $html = ob_get_contents();
                 ob_end_clean();
             } catch (Exception $e) {
                 if ($e->getMessage()) {
                     JFactory::getApplication()->enqueueMessage('Addon ' . $this->_name . ': ' . $e->getMessage(), 'warning');
                 }
             }
             if ($html) {
                 $html = trim($html);
             }
             $input->set('addon_task', null);
             return $html;
         }
     }
 }