| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_redirect 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 // No direct access. 10 defined('_JEXEC') or die; 11 12 jimport('joomla.application.component.modellist'); 13 14 /** 15 * Methods supporting a list of redirect links. 16 * 17 * @package Joomla.Administrator 18 * @subpackage com_redirect 19 * @since 1.6 20 */ 21 class RedirectModelLinks extends JModelList 22 { 23 /** 24 * Constructor. 25 * 26 * @param array An optional associative array of configuration settings. 27 * @see JController 28 * @since 1.6 29 */ 30 public function __construct($config = array()) 31 { 32 if (empty($config['filter_fields'])) { 33 $config['filter_fields'] = array( 34 'id', 'a.id', 35 'old_url', 'a.old_url', 36 'new_url', 'a.new_url', 37 'referer', 'a.referer', 38 'created_date', 'a.created_date', 39 'published', 'a.published', 40 ); 41 } 42 43 parent::__construct($config); 44 } 45 46 /** 47 * Method to auto-populate the model state. 48 * 49 * Note. Calling getState in this method will result in recursion. 50 * 51 * @since 1.6 52 */ 53 protected function populateState($ordering = null, $direction = null) 54 { 55 // Initialise variables. 56 $app = JFactory::getApplication('administrator'); 57 58 // Load the filter state. 59 $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); 60 $this->setState('filter.search', $search); 61 62 $state = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string'); 63 $this->setState('filter.state', $state); 64 65 // Load the parameters. 66 $params = JComponentHelper::getParams('com_redirect'); 67 $this->setState('params', $params); 68 69 // List state information. 70 parent::populateState('a.old_url', 'asc'); 71 } 72 73 /** 74 * Method to get a store id based on model configuration state. 75 * 76 * This is necessary because the model is used by the component and 77 * different modules that might need different sets of data or different 78 * ordering requirements. 79 * 80 * @param string A prefix for the store id. 81 * 82 * @return string A store id. 83 * @since 1.6 84 */ 85 protected function getStoreId($id = '') 86 { 87 // Compile the store id. 88 $id .= ':'.$this->getState('filter.search'); 89 $id .= ':'.$this->getState('filter.state'); 90 91 return parent::getStoreId($id); 92 } 93 94 /** 95 * Build an SQL query to load the list data. 96 * 97 * @return JDatabaseQuery 98 * @since 1.6 99 */ 100 protected function getListQuery() 101 { 102 // Create a new query object. 103 $db = $this->getDbo(); 104 $query = $db->getQuery(true); 105 106 // Select the required fields from the table. 107 $query->select( 108 $this->getState( 109 'list.select', 110 'a.*' 111 ) 112 ); 113 $query->from($db->quoteName('#__redirect_links').' AS a'); 114 115 // Filter by published state 116 $state = $this->getState('filter.state'); 117 if (is_numeric($state)) { 118 $query->where('a.published = '.(int) $state); 119 } elseif ($state === '') { 120 $query->where('(a.published IN (0,1,2))'); 121 } 122 123 // Filter the items over the search string if set. 124 $search = $this->getState('filter.search'); 125 if (!empty($search)) { 126 if (stripos($search, 'id:') === 0) { 127 $query->where('a.id = '.(int) substr($search, 3)); 128 } else { 129 $search = $db->Quote('%'.$db->escape($search, true).'%'); 130 $query->where( 131 '('.$db->quoteName('old_url').' LIKE '.$search . 132 ' OR '.$db->quoteName('new_url').' LIKE '.$search . 133 ' OR '.$db->quoteName('comment').' LIKE '.$search . 134 ' OR '.$db->quoteName('referer').' LIKE '.$search.')' 135 ); 136 } 137 } 138 139 // Add the list ordering clause. 140 $query->order($db->escape($this->getState('list.ordering', 'a.old_url')).' '.$db->escape($this->getState('list.direction', 'ASC'))); 141 142 //echo nl2br(str_replace('#__','jos_',$query)); 143 return $query; 144 } 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |