[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_finder 6 * 7 * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Finder\Administrator\Model; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\Form; 15 use Joomla\CMS\MVC\Model\AdminModel; 16 use Joomla\Component\Finder\Administrator\Table\FilterTable; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Filter model class for Finder. 24 * 25 * @since 2.5 26 */ 27 class FilterModel extends AdminModel 28 { 29 /** 30 * The prefix to use with controller messages. 31 * 32 * @var string 33 * @since 2.5 34 */ 35 protected $text_prefix = 'COM_FINDER'; 36 37 /** 38 * Model context string. 39 * 40 * @var string 41 * @since 2.5 42 */ 43 protected $context = 'com_finder.filter'; 44 45 /** 46 * Custom clean cache method. 47 * 48 * @param string $group The component name. [optional] 49 * @param integer $clientId @deprecated 5.0 No longer used. 50 * 51 * @return void 52 * 53 * @since 2.5 54 */ 55 protected function cleanCache($group = 'com_finder', $clientId = 0) 56 { 57 parent::cleanCache($group); 58 } 59 60 /** 61 * Method to get the filter data. 62 * 63 * @return FilterTable|boolean The filter data or false on a failure. 64 * 65 * @since 2.5 66 */ 67 public function getFilter() 68 { 69 $filter_id = (int) $this->getState('filter.id'); 70 71 // Get a FinderTableFilter instance. 72 $filter = $this->getTable(); 73 74 // Attempt to load the row. 75 $return = $filter->load($filter_id); 76 77 // Check for a database error. 78 if ($return === false && $filter->getError()) { 79 $this->setError($filter->getError()); 80 81 return false; 82 } 83 84 // Process the filter data. 85 if (!empty($filter->data)) { 86 $filter->data = explode(',', $filter->data); 87 } elseif (empty($filter->data)) { 88 $filter->data = array(); 89 } 90 91 return $filter; 92 } 93 94 /** 95 * Method to get the record form. 96 * 97 * @param array $data Data for the form. [optional] 98 * @param boolean $loadData True if the form is to load its own data (default case), false if not. [optional] 99 * 100 * @return Form|boolean A Form object on success, false on failure 101 * 102 * @since 2.5 103 */ 104 public function getForm($data = array(), $loadData = true) 105 { 106 // Get the form. 107 $form = $this->loadForm('com_finder.filter', 'filter', array('control' => 'jform', 'load_data' => $loadData)); 108 109 if (empty($form)) { 110 return false; 111 } 112 113 return $form; 114 } 115 116 /** 117 * Method to get the data that should be injected in the form. 118 * 119 * @return mixed The data for the form. 120 * 121 * @since 2.5 122 */ 123 protected function loadFormData() 124 { 125 // Check the session for previously entered form data. 126 $data = Factory::getApplication()->getUserState('com_finder.edit.filter.data', array()); 127 128 if (empty($data)) { 129 $data = $this->getItem(); 130 } 131 132 $this->preprocessData('com_finder.filter', $data); 133 134 return $data; 135 } 136 137 /** 138 * Method to get the total indexed items 139 * 140 * @return number the number of indexed items 141 * 142 * @since 3.5 143 */ 144 public function getTotal() 145 { 146 $db = $this->getDatabase(); 147 $query = $db->getQuery(true) 148 ->select('MAX(link_id)') 149 ->from('#__finder_links'); 150 151 return $db->setQuery($query)->loadResult(); 152 } 153 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |