File manager - Edit - /home/verseaumee/empowernetkenyajuly2026/Model.zip
Back
PK �q.]�'��6 6 ContactModel.phpnu &1i� <?php /** * @package Joomla.Site * @subpackage com_contact * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Contact\Site\Model; \defined('_JEXEC') or die; use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Form\Form; use Joomla\CMS\Helper\TagsHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\FormModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Database\ParameterType; use Joomla\Database\QueryInterface; use Joomla\Registry\Registry; /** * Single item model for a contact * * @package Joomla.Site * @subpackage com_contact * @since 1.5 */ class ContactModel extends FormModel { /** * The name of the view for a single item * * @var string * @since 1.6 */ protected $view_item = 'contact'; /** * A loaded item * * @var \stdClass * @since 1.6 */ protected $_item = null; /** * Model context string. * * @var string */ protected $_context = 'com_contact.contact'; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 1.6 */ protected function populateState() { /** @var SiteApplication $app */ $app = Factory::getContainer()->get(SiteApplication::class); if (Factory::getApplication()->isClient('api')) { // TODO: remove this $app->loadLanguage(); $this->setState('contact.id', Factory::getApplication()->input->post->getInt('id')); } else { $this->setState('contact.id', $app->input->getInt('id')); } $this->setState('params', $app->getParams()); $user = Factory::getUser(); if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) { $this->setState('filter.published', 1); $this->setState('filter.archived', 2); } } /** * Method to get the contact form. * The base form is loaded from XML and then an event is fired * * @param array $data An optional array of data for the form to interrogate. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return Form A Form object on success, false on failure * * @since 1.6 */ public function getForm($data = array(), $loadData = true) { $form = $this->loadForm('com_contact.contact', 'contact', array('control' => 'jform', 'load_data' => true)); if (empty($form)) { return false; } $temp = clone $this->getState('params'); $contact = $this->_item[$this->getState('contact.id')]; $active = Factory::getContainer()->get(SiteApplication::class)->getMenu()->getActive(); if ($active) { // If the current view is the active item and a contact view for this contact, then the menu item params take priority if (strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id)) { // $contact->params are the contact params, $temp are the menu item params // Merge so that the menu item params take priority $contact->params->merge($temp); } else { // Current view is not a single contact, so the contact params take priority here // Merge the menu item params with the contact params so that the contact params take priority $temp->merge($contact->params); $contact->params = $temp; } } else { // Merge so that contact params take priority $temp->merge($contact->params); $contact->params = $temp; } if (!$contact->params->get('show_email_copy', 0)) { $form->removeField('contact_email_copy'); } return $form; } /** * Method to get the data that should be injected in the form. * * @return array The default data is an empty array. * * @since 1.6.2 */ protected function loadFormData() { $data = (array) Factory::getApplication()->getUserState('com_contact.contact.data', array()); if (empty($data['language']) && Multilanguage::isEnabled()) { $data['language'] = Factory::getLanguage()->getTag(); } // Add contact id to contact form data, so fields plugin can work properly if (empty($data['catid'])) { $data['catid'] = $this->getItem()->catid; } $this->preprocessData('com_contact.contact', $data); return $data; } /** * Gets a contact * * @param integer $pk Id for the contact * * @return mixed Object or null * * @since 1.6.0 */ public function getItem($pk = null) { $pk = $pk ?: (int) $this->getState('contact.id'); if ($this->_item === null) { $this->_item = array(); } if (!isset($this->_item[$pk])) { try { $db = $this->getDbo(); $query = $db->getQuery(true); $query->select($this->getState('item.select', 'a.*')) ->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug') ->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug') ->from($db->quoteName('#__contact_details', 'a')) // Join on category table. ->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access') ->leftJoin($db->quoteName('#__categories', 'c'), 'c.id = a.catid') // Join over the categories to get parent category titles ->select('parent.title AS parent_title, parent.id AS parent_id, parent.path AS parent_route, parent.alias AS parent_alias') ->leftJoin($db->quoteName('#__categories', 'parent'), 'parent.id = c.parent_id') ->where($db->quoteName('a.id') . ' = :id') ->bind(':id', $pk, ParameterType::INTEGER); // Filter by start and end dates. $nowDate = Factory::getDate()->toSql(); // Filter by published state. $published = $this->getState('filter.published'); $archived = $this->getState('filter.archived'); if (is_numeric($published)) { $queryString = $db->quoteName('a.published') . ' = :published'; if ($archived !== null) { $queryString = '(' . $queryString . ' OR ' . $db->quoteName('a.published') . ' = :archived)'; $query->bind(':archived', $archived, ParameterType::INTEGER); } $query->where($queryString) ->where('(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)') ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)') ->bind(':published', $published, ParameterType::INTEGER) ->bind(':publish_up', $nowDate) ->bind(':publish_down', $nowDate); } $db->setQuery($query); $data = $db->loadObject(); if (empty($data)) { throw new \Exception(Text::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404); } // Check for published state if filter set. if ((is_numeric($published) || is_numeric($archived)) && (($data->published != $published) && ($data->published != $archived))) { throw new \Exception(Text::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404); } /** * In case some entity params have been set to "use global", those are * represented as an empty string and must be "overridden" by merging * the component and / or menu params here. */ $registry = new Registry($data->params); $data->params = clone $this->getState('params'); $data->params->merge($registry); $registry = new Registry($data->metadata); $data->metadata = $registry; // Some contexts may not use tags data at all, so we allow callers to disable loading tag data if ($this->getState('load_tags', true)) { $data->tags = new TagsHelper; $data->tags->getItemTags('com_contact.contact', $data->id); } // Compute access permissions. if (($access = $this->getState('filter.access'))) { // If the access filter has been set, we already know this user can view. $data->params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. $user = Factory::getUser(); $groups = $user->getAuthorisedViewLevels(); if ($data->catid == 0 || $data->category_access === null) { $data->params->set('access-view', in_array($data->access, $groups)); } else { $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups)); } } $this->_item[$pk] = $data; } catch (\Exception $e) { if ($e->getCode() == 404) { // Need to go through the error handler to allow Redirect to work. throw $e; } else { $this->setError($e); $this->_item[$pk] = false; } } } if ($this->_item[$pk]) { $this->buildContactExtendedData($this->_item[$pk]); } return $this->_item[$pk]; } /** * Load extended data (profile, articles) for a contact * * @param object $contact The contact object * * @return void */ protected function buildContactExtendedData($contact) { $db = $this->getDbo(); $nowDate = Factory::getDate()->toSql(); $user = Factory::getUser(); $groups = $user->getAuthorisedViewLevels(); $published = $this->getState('filter.published'); $query = $db->getQuery(true); // If we are showing a contact list, then the contact parameters take priority // So merge the contact parameters with the merged parameters if ($this->getState('params')->get('show_contact_list')) { $this->getState('params')->merge($contact->params); } // Get the com_content articles by the linked user if ((int) $contact->user_id && $this->getState('params')->get('show_articles')) { $query->select('a.id') ->select('a.title') ->select('a.state') ->select('a.access') ->select('a.catid') ->select('a.created') ->select('a.language') ->select('a.publish_up') ->select('a.introtext') ->select('a.images') ->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug') ->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug') ->from($db->quoteName('#__content', 'a')) ->leftJoin($db->quoteName('#__categories', 'c') . ' ON a.catid = c.id') ->where($db->quoteName('a.created_by') . ' = :created_by') ->whereIn($db->quoteName('a.access'), $groups) ->bind(':created_by', $contact->user_id, ParameterType::INTEGER) ->order('a.publish_up DESC'); // Filter per language if plugin published if (Multilanguage::isEnabled()) { $language = [Factory::getLanguage()->getTag(), $db->quote('*')]; $query->whereIn($db->quoteName('a.language'), $language, ParameterType::STRING); } if (is_numeric($published)) { $query->where('a.state IN (1,2)') ->where('(' . $db->quoteName('a.publish_up') . ' IS NULL' . ' OR ' . $db->quoteName('a.publish_up') . ' <= :now1)' ) ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL' . ' OR ' . $db->quoteName('a.publish_down') . ' >= :now2)' ) ->bind([':now1', ':now2'], $nowDate); } // Number of articles to display from config/menu params $articles_display_num = $this->getState('params')->get('articles_display_num', 10); // Use contact setting? if ($articles_display_num === 'use_contact') { $articles_display_num = $contact->params->get('articles_display_num', 10); // Use global? if ((string) $articles_display_num === '') { $articles_display_num = ComponentHelper::getParams('com_contact')->get('articles_display_num', 10); } } $query->setLimit((int) $articles_display_num); $db->setQuery($query); $contact->articles = $db->loadObjectList(); } else { $contact->articles = null; } // Get the profile information for the linked user $userModel = $this->bootComponent('com_users')->getMVCFactory() ->createModel('User', 'Administrator', ['ignore_request' => true]); $data = $userModel->getItem((int) $contact->user_id); PluginHelper::importPlugin('user'); // Get the form. Form::addFormPath(JPATH_SITE . '/components/com_users/forms'); $form = Form::getInstance('com_users.profile', 'profile'); // Trigger the form preparation event. Factory::getApplication()->triggerEvent('onContentPrepareForm', array($form, $data)); // Trigger the data preparation event. Factory::getApplication()->triggerEvent('onContentPrepareData', array('com_users.profile', $data)); // Load the data into the form after the plugins have operated. $form->bind($data); $contact->profile = $form; } /** * Generate column expression for slug or catslug. * * @param QueryInterface $query Current query instance. * @param string $id Column id name. * @param string $alias Column alias name. * * @return string * * @since 4.0.0 */ private function getSlugColumn($query, $id, $alias) { return 'CASE WHEN ' . $query->charLength($alias, '!=', '0') . ' THEN ' . $query->concatenate(array($query->castAsChar($id), $alias), ':') . ' ELSE ' . $query->castAsChar($id) . ' END'; } /** * Increment the hit counter for the contact. * * @param integer $pk Optional primary key of the contact to increment. * * @return boolean True if successful; false otherwise and internal error set. * * @since 3.0 */ public function hit($pk = 0) { $input = Factory::getApplication()->input; $hitcount = $input->getInt('hitcount', 1); if ($hitcount) { $pk = $pk ?: (int) $this->getState('contact.id'); $table = $this->getTable('Contact'); $table->hit($pk); } return true; } } PK �q.]���Y Y CategoriesModel.phpnu &1i� <?php /** * @package Joomla.Site * @subpackage com_contact * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Contact\Site\Model; \defined('_JEXEC') or die; use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; use Joomla\Registry\Registry; /** * This models supports retrieving lists of contact categories. * * @since 1.6 */ class CategoriesModel extends ListModel { /** * Model context string. * * @var string */ public $_context = 'com_contact.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_contact'; /** * Parent category of the current one * * @var CategoryNode|null */ private $_parent = null; /** * Array of child-categories * * @var CategoryNode[]|null */ private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = Factory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = $app->input->getInt('id'); $this->setState('filter.parentId', $parentId); $params = $app->getParams(); $this->setState('params', $params); $this->setState('filter.published', 1); $this->setState('filter.access', true); } /** * 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. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.extension'); $id .= ':' . $this->getState('filter.published'); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.parentId'); return parent::getStoreId($id); } /** * Redefine the function and add some properties to make the styling easier * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if ($this->_items === null) { $app = Factory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); if ($active) { $params = $active->getParams(); } else { $params = new Registry; } $options = array(); $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = Categories::getInstance('Contact', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } /** * Gets the id of the parent category for the selected list of categories * * @return integer The id of the parent category * * @since 1.6.0 */ public function getParent() { if (!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } PK �q.]���� FormModel.phpnu &1i� <?php /** * @package Joomla.Site * @subpackage com_contact * * @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Contact\Site\Model; \defined('_JEXEC') or die; use Exception; use Joomla\CMS\Factory; use Joomla\CMS\Form\Form; use Joomla\CMS\Helper\TagsHelper; use Joomla\CMS\Language\Associations; use Joomla\CMS\Language\Multilanguage; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; /** * Contact Component Contact Model * * @since 4.0.0 */ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactModel { /** * Model typeAlias string. Used for version history. * * @var string * @since 4.0.0 */ public $typeAlias = 'com_contact.contact'; /** * Name of the form * * @var string * @since 4.0.0 */ protected $formName = 'form'; /** * Method to get the row form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return \JForm|boolean A \JForm object on success, false on failure * * @since 4.0.0 */ public function getForm($data = array(), $loadData = true) { $form = parent::getForm($data, $loadData); // Prevent messing with article language and category when editing existing contact with associations if ($id = $this->getState('contact.id') && Associations::isEnabled()) { $associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id); // Make fields read only if (!empty($associations)) { $form->setFieldAttribute('language', 'readonly', 'true'); $form->setFieldAttribute('language', 'filter', 'unset'); } } return $form; } /** * Method to get contact data. * * @param integer $itemId The id of the contact. * * @return mixed Contact item data object on success, false on failure. * * @throws Exception * * @since 4.0.0 */ public function getItem($itemId = null) { $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('contact.id'); // Get a row instance. $table = $this->getTable(); // Attempt to load the row. try { if (!$table->load($itemId)) { return false; } } catch (Exception $e) { Factory::getApplication()->enqueueMessage($e->getMessage()); return false; } $properties = $table->getProperties(); $value = ArrayHelper::toObject($properties, 'JObject'); // Convert field to Registry. $value->params = new Registry($value->params); // Convert the metadata field to an array. $registry = new Registry($value->metadata); $value->metadata = $registry->toArray(); if ($itemId) { $value->tags = new TagsHelper; $value->tags->getTagIds($value->id, 'com_contact.contact'); $value->metadata['tags'] = $value->tags; } return $value; } /** * Get the return URL. * * @return string The return URL. * * @since 4.0.0 */ public function getReturnPage() { return base64_encode($this->getState('return_page')); } /** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @throws Exception * @since 4.0.0 */ public function save($data) { // Associations are not edited in frontend ATM so we have to inherit them if (Associations::isEnabled() && !empty($data['id']) && $associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $data['id'])) { foreach ($associations as $tag => $associated) { $associations[$tag] = (int) $associated->id; } $data['associations'] = $associations; } return parent::save($data); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @throws Exception * * @since 4.0.0 */ protected function populateState() { $app = Factory::getApplication(); // Load state from the request. $pk = $app->input->getInt('id'); $this->setState('contact.id', $pk); $this->setState('contact.catid', $app->input->getInt('catid')); $return = $app->input->get('return', null, 'base64'); $this->setState('return_page', base64_decode($return)); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); $this->setState('layout', $app->input->getString('layout')); } /** * Allows preprocessing of the JForm object. * * @param Form $form The form object * @param array $data The data to be merged into the form object * @param string $group The plugin group to be executed * * @return void * * @since 4.0.0 */ protected function preprocessForm(Form $form, $data, $group = 'contact') { if (!Multilanguage::isEnabled()) { $form->setFieldAttribute('language', 'type', 'hidden'); $form->setFieldAttribute('language', 'default', '*'); } return parent::preprocessForm($form, $data, $group); } /** * Method to get a table object, load it if necessary. * * @param string $name The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $options Configuration array for model. Optional. * * @return Table A Table object * * @since 4.0.0 * @throws \Exception */ public function getTable($name = 'Contact', $prefix = 'Administrator', $options = array()) { return parent::getTable($name, $prefix, $options); } } PK �q.]��%6P0 P0 CategoryModel.phpnu &1i� <?php /** * @package Joomla.Site * @subpackage com_contact * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Contact\Site\Model; \defined('_JEXEC') or die; use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Table\Table; use Joomla\Database\ParameterType; use Joomla\Registry\Registry; /** * Single item model for a contact * * @package Joomla.Site * @subpackage com_contact * @since 1.5 */ class CategoryModel extends ListModel { /** * Category item data * * @var CategoryNode */ protected $_item = null; /** * Array of contacts in the category * * @var \stdClass[] */ protected $_articles = null; /** * Category left and right of this one * * @var CategoryNode[]|null */ protected $_siblings = null; /** * Array of child-categories * * @var CategoryNode[]|null */ protected $_children = null; /** * Parent category of the current one * * @var CategoryNode|null */ protected $_parent = null; /** * The category that applies. * * @var object */ protected $_category = null; /** * The list of other contact categories. * * @var array */ protected $_categories = null; /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'name', 'a.name', 'con_position', 'a.con_position', 'suburb', 'a.suburb', 'state', 'a.state', 'country', 'a.country', 'ordering', 'a.ordering', 'sortname', 'sortname1', 'a.sortname1', 'sortname2', 'a.sortname2', 'sortname3', 'a.sortname3', 'featuredordering', 'a.featured' ); } parent::__construct($config); } /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ public function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); if ($items === false) { return false; } // Convert the params field into an object, saving original in _params for ($i = 0, $n = count($items); $i < $n; $i++) { $item = &$items[$i]; if (!isset($this->_params)) { $item->params = new Registry($item->params); } // Some contexts may not use tags data at all, so we allow callers to disable loading tag data if ($this->getState('load_tags', true)) { $this->tags = new TagsHelper; $this->tags->getItemTags('com_contact.contact', $item->id); } } return $items; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * * @since 1.6 */ protected function getListQuery() { $user = Factory::getUser(); $groups = $user->getAuthorisedViewLevels(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $query->select($this->getState('list.select', 'a.*')) ->select($this->getSlugColumn($query, 'a.id', 'a.alias') . ' AS slug') ->select($this->getSlugColumn($query, 'c.id', 'c.alias') . ' AS catslug') /** * TODO: we actually should be doing it but it's wrong this way * . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' * . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug '); */ ->from($db->quoteName('#__contact_details', 'a')) ->leftJoin($db->quoteName('#__categories', 'c') . ' ON c.id = a.catid') ->whereIn($db->quoteName('a.access'), $groups); // Filter by category. if ($categoryId = $this->getState('category.id')) { $query->where($db->quoteName('a.catid') . ' = :acatid') ->whereIn($db->quoteName('c.access'), $groups); $query->bind(':acatid', $categoryId, ParameterType::INTEGER); } // Join over the users for the author and modified_by names. $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author") ->select('ua.email AS author_email') ->leftJoin($db->quoteName('#__users', 'ua') . ' ON ua.id = a.created_by') ->leftJoin($db->quoteName('#__users', 'uam') . ' ON uam.id = a.modified_by'); // Filter by state $state = $this->getState('filter.published'); if (is_numeric($state)) { $query->where($db->quoteName('a.published') . ' = :published'); $query->bind(':published', $state, ParameterType::INTEGER); } else { $query->whereIn($db->quoteName('c.published'), [0,1,2]); } // Filter by start and end dates. $nowDate = Factory::getDate()->toSql(); if ($this->getState('filter.publish_date')) { $query->where('(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)' ) ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)' ) ->bind(':publish_up', $nowDate) ->bind(':publish_down', $nowDate); } // Filter by search in title $search = $this->getState('list.filter'); if (!empty($search)) { $search = '%' . trim($search) . '%'; $query->where($db->quoteName('a.name') . ' LIKE :name '); $query->bind(':name', $search); } // Filter on the language. if ($this->getState('filter.language')) { $query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING); } // Set sortname ordering if selected if ($this->getState('list.ordering') === 'sortname') { $query->order($db->escape('a.sortname1') . ' ' . $db->escape($this->getState('list.direction', 'ASC'))) ->order($db->escape('a.sortname2') . ' ' . $db->escape($this->getState('list.direction', 'ASC'))) ->order($db->escape('a.sortname3') . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); } elseif ($this->getState('list.ordering') === 'featuredordering') { $query->order($db->escape('a.featured') . ' DESC') ->order($db->escape('a.ordering') . ' ASC'); } else { $query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); } return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = Factory::getApplication(); $params = ComponentHelper::getParams('com_contact'); // Get list ordering default from the parameters if ($menu = $app->getMenu()->getActive()) { $menuParams = $menu->getParams(); } else { $menuParams = new Registry; } $mergedParams = clone $params; $mergedParams->merge($menuParams); // List state information $format = $app->input->getWord('format'); if ($format === 'feed') { $limit = $app->get('feed_limit'); } else { $limit = $app->getUserStateFromRequest( 'com_contact.category.list', 'limit', $mergedParams->get('contacts_display_num', $app->get('list_limit')), 'uint' ); } $this->setState('list.limit', $limit); $limitstart = $app->input->get('limitstart', 0, 'uint'); $this->setState('list.start', $limitstart); // Optional filter text $itemid = $app->input->get('Itemid', 0, 'int'); $search = $app->getUserStateFromRequest('com_contact.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string'); $this->setState('list.filter', $search); $orderCol = $app->input->get('filter_order', $mergedParams->get('initial_sort', 'ordering')); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->input->get('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $id = $app->input->get('id', 0, 'int'); $this->setState('category.id', $id); $user = Factory::getUser(); if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) { // Limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', Multilanguage::isEnabled()); // Load the parameters. $this->setState('params', $params); } /** * Method to get category data for the current category * * @return object The category object * * @since 1.5 */ public function getCategory() { if (!is_object($this->_item)) { $app = Factory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); if ($active) { $params = $active->getParams(); } else { $params = new Registry; } $options = array(); $options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0); $categories = Categories::getInstance('Contact', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); if (is_object($this->_item)) { $this->_children = $this->_item->getChildren(); $this->_parent = false; if ($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; } /** * Get the parent category. * * @return mixed An array of categories or false if an error occurs. */ public function getParent() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_parent; } /** * Get the sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getLeftSibling() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_leftsibling; } /** * Get the sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getRightSibling() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_rightsibling; } /** * Get the child categories. * * @return mixed An array of categories or false if an error occurs. */ public function &getChildren() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_children; } /** * Generate column expression for slug or catslug. * * @param \JDatabaseQuery $query Current query instance. * @param string $id Column id name. * @param string $alias Column alias name. * * @return string * * @since 4.0.0 */ private function getSlugColumn($query, $id, $alias) { return 'CASE WHEN ' . $query->charLength($alias, '!=', '0') . ' THEN ' . $query->concatenate(array($query->castAsChar($id), $alias), ':') . ' ELSE ' . $query->castAsChar($id) . ' END'; } /** * Increment the hit counter for the category. * * @param integer $pk Optional primary key of the category to increment. * * @return boolean True if successful; false otherwise and internal error set. * * @since 3.2 */ public function hit($pk = 0) { $input = Factory::getApplication()->input; $hitcount = $input->getInt('hitcount', 1); if ($hitcount) { $pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id'); $table = Table::getInstance('Category'); $table->hit($pk); } return true; } } PK �q.]+�y?f f FeaturedModel.phpnu &1i� <?php /** * @package Joomla.Site * @subpackage com_contact * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Contact\Site\Model; \defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\MVC\Model\ListModel; use Joomla\Database\ParameterType; use Joomla\Registry\Registry; /** * Featured contact model class. * * @since 1.6.0 */ class FeaturedModel extends ListModel { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'name', 'a.name', 'con_position', 'a.con_position', 'suburb', 'a.suburb', 'state', 'a.state', 'country', 'a.country', 'ordering', 'a.ordering', ); } parent::__construct($config); } /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ public function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); // Convert the params field into an object, saving original in _params for ($i = 0, $n = count($items); $i < $n; $i++) { $item = &$items[$i]; if (!isset($this->_params)) { $item->params = new Registry($item->params); } } return $items; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * * @since 1.6 */ protected function getListQuery() { $user = Factory::getUser(); $groups = $user->getAuthorisedViewLevels(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')) ->from($db->quoteName('#__contact_details', 'a')) ->where($db->quoteName('a.featured') . ' = 1') ->whereIn($db->quoteName('a.access'), $groups) ->innerJoin($db->quoteName('#__categories', 'c') . ' ON c.id = a.catid') ->whereIn($db->quoteName('c.access'), $groups); // Filter by category. if ($categoryId = $this->getState('category.id')) { $query->where($db->quoteName('a.catid') . ' = :catid'); $query->bind(':catid', $categoryId, ParameterType::INTEGER); } $query->select('c.published as cat_published, c.published AS parents_published') ->where('c.published = 1'); // Filter by state $state = $this->getState('filter.published'); if (is_numeric($state)) { $query->where($db->quoteName('a.published') . ' = :published'); $query->bind(':published', $state, ParameterType::INTEGER); // Filter by start and end dates. $nowDate = Factory::getDate()->toSql(); $query->where('(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publish_up)' ) ->where('(' . $db->quoteName('a.publish_down') . ' IS NULL OR ' . $db->quoteName('a.publish_down') . ' >= :publish_down)' ) ->bind(':publish_up', $nowDate) ->bind(':publish_down', $nowDate); } // Filter by search in title $search = $this->getState('list.filter'); // Filter by search in title if (!empty($search)) { $search = '%' . trim($search) . '%'; $query->where($db->quoteName('a.name') . ' LIKE :name '); $query->bind(':name', $search); } // Filter by language if ($this->getState('filter.language')) { $query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING); } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = Factory::getApplication(); $params = ComponentHelper::getParams('com_contact'); // List state information $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint'); $this->setState('list.limit', $limit); $limitstart = $app->input->get('limitstart', 0, 'uint'); $this->setState('list.start', $limitstart); // Optional filter text $this->setState('list.filter', $app->input->getString('filter-search')); $orderCol = $app->input->get('filter_order', 'ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->input->get('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $user = Factory::getUser(); if ((!$user->authorise('core.edit.state', 'com_contact')) && (!$user->authorise('core.edit', 'com_contact'))) { // Limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', Multilanguage::isEnabled()); // Load the parameters. $this->setState('params', $params); } } PK �q.]�'��6 6 ContactModel.phpnu &1i� PK �q.]���Y Y B6 CategoriesModel.phpnu &1i� PK �q.]���� �D FormModel.phpnu &1i� PK �q.]��%6P0 P0 9[ CategoryModel.phpnu &1i� PK �q.]+�y?f f ʋ FeaturedModel.phpnu &1i� PK � q�
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings