示例#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
 /**
  * Constructor.
  *
  * @param   array  $config  An optional associative array of configuration settings.
  *
  * @see     JControllerLegacy
  * @since   12.2
  * @throws  Exception
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // 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 context as the suffix, eg: OptionControllerContent.
     if (empty($this->context)) {
         $r = null;
         if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) {
             throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
         }
         $this->context = strtolower($r[2]);
     }
     // Guess the item view as the context.
     if (empty($this->view_item)) {
         $this->view_item = $this->context;
     }
     // Guess the list view as the plural of the item view.
     if (empty($this->view_list)) {
         // @TODO Probably worth moving to an inflector class based on
         // http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
         // Simple pluralisation based on public domain snippet by Paul Osman
         // For more complex types, just manually set the variable in your class.
         $plural = array(array('/(x|ch|ss|sh)$/i', "\$1es"), array('/([^aeiouy]|qu)y$/i', "\$1ies"), array('/([^aeiouy]|qu)ies$/i', "\$1y"), array('/(bu)s$/i', "\$1ses"), array('/s$/i', "s"), array('/$/', "s"));
         // Check for matches using regular expressions
         foreach ($plural as $pattern) {
             if (preg_match($pattern[0], $this->view_item)) {
                 $this->view_list = preg_replace($pattern[0], $pattern[1], $this->view_item);
                 break;
             }
         }
     }
     // Apply, Save & New, and Save As copy should be standard on forms.
     $this->registerTask('apply', 'save');
     $this->registerTask('save2new', 'save');
     $this->registerTask('save2copy', 'save');
 }