/** * The constructor of a class * * @param array $config An optional associative array of configuration settings. * * @return void * @since 1.0 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array('sublist_id', 'subscriber_id', 'list_id', 'subscriber_name', 'list_name'); } parent::__construct($config); }
/** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. * @since 1.0 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.state'); return parent::getStoreId($id); }
/** * Method to auto-populate the model state. * Note. Calling getState in this method will result in recursion. * * @return void * @since 1.0 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $session = JFactory::getSession(); // Adjust the context to support modal layouts. if ($layout = JRequest::getVar('layout')) { $this->context .= '.' . $layout; } $form = JRequest::getVar('form'); $name = $this->getName(); if ($form != $name) { $search = $app->getUserState($this->context . '.filter.search'); $published = $app->getUserState($this->context . '.filter.published'); $published = $published ? $published : ''; } else { $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); if ($search == "Search...") { $search = ""; } $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); } $this->setState('filter.published', $published); $this->setState('filter.search', $search); // List state information. parent::populateState('a.title', 'asc'); }