API16:JControllerForm/ construct
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Constructor.
Description:JControllerForm/ construct
Syntax
__construct($config=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $config | array() | An optional associative array of configuration settings. |
Defined in
libraries/joomla/application/component/controllerform.php
Importing
jimport( 'joomla.application.component.controllerform' );
Source Body
public function __construct($config = array()) { parent::__construct($config); // Guess the option as com_NameOfController if (empty($this->_option)) { $this->_option = 'com_'.strtolower($this->getName()); } // Guess the context as the suffix, eg: OptionControllerContent. if (empty($this->_context)) { $r = null; if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) { JError::raiseError(500, 'JController_Error_Cannot_parse_name'); } $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'); }
[Edit See Also] SeeAlso:JControllerForm/ construct
Examples
<CodeExamplesForm />
