public function __construct($config = array())
 {
     parent::__construct($config);
     if (empty($this->option)) {
         $this->option = 'com_' . strtolower($this->getName());
     }
     if (empty($this->text_prefix)) {
         $this->text_prefix = strtoupper($this->option);
     }
     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]);
     }
     if (empty($this->view_item)) {
         $this->view_item = $this->context;
     }
     if (empty($this->view_list)) {
         // 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"));
         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;
             }
         }
     }
     $this->registerTask('apply', 'save');
     $this->registerTask('save2new', 'save');
     $this->registerTask('save2copy', 'save');
 }
 public function __construct($config = array())
 {
     parent::__construct($config);
     if (empty($this->option)) {
         $this->option = 'com_' . strtolower($this->getName());
     }
     if (empty($this->text_prefix)) {
         $this->text_prefix = strtoupper($this->option);
     }
     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]);
     }
     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]);
     }
 }