[ 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\Service\HTML; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\HTML\HTMLHelper; 15 use Joomla\CMS\Language\Text; 16 use Joomla\Component\Finder\Administrator\Helper\LanguageHelper; 17 use Joomla\Database\DatabaseAwareTrait; 18 use Joomla\Utilities\ArrayHelper; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * HTML behavior class for Finder. 26 * 27 * @since 2.5 28 */ 29 class Finder 30 { 31 use DatabaseAwareTrait; 32 33 /** 34 * Creates a list of types to filter on. 35 * 36 * @return array An array containing the types that can be selected. 37 * 38 * @since 2.5 39 */ 40 public function typeslist() 41 { 42 // Load the finder types. 43 $db = $this->getDatabase(); 44 $query = $db->getQuery(true) 45 ->select('DISTINCT t.title AS text, t.id AS value') 46 ->from($db->quoteName('#__finder_types') . ' AS t') 47 ->join('LEFT', $db->quoteName('#__finder_links') . ' AS l ON l.type_id = t.id') 48 ->order('t.title ASC'); 49 $db->setQuery($query); 50 51 try { 52 $rows = $db->loadObjectList(); 53 } catch (\RuntimeException $e) { 54 return array(); 55 } 56 57 // Compile the options. 58 $options = array(); 59 60 $lang = Factory::getLanguage(); 61 62 foreach ($rows as $row) { 63 $key = $lang->hasKey(LanguageHelper::branchPlural($row->text)) ? LanguageHelper::branchPlural($row->text) : $row->text; 64 $options[] = HTMLHelper::_('select.option', $row->value, Text::sprintf('COM_FINDER_ITEM_X_ONLY', Text::_($key))); 65 } 66 67 return $options; 68 } 69 70 /** 71 * Creates a list of maps. 72 * 73 * @return array An array containing the maps that can be selected. 74 * 75 * @since 2.5 76 */ 77 public function mapslist() 78 { 79 // Load the finder types. 80 $db = $this->getDatabase(); 81 $query = $db->getQuery(true) 82 ->select($db->quoteName('title', 'text')) 83 ->select($db->quoteName('id', 'value')) 84 ->from($db->quoteName('#__finder_taxonomy')) 85 ->where($db->quoteName('parent_id') . ' = 1'); 86 $db->setQuery($query); 87 88 try { 89 $branches = $db->loadObjectList(); 90 } catch (\RuntimeException $e) { 91 Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); 92 } 93 94 // Translate. 95 $lang = Factory::getLanguage(); 96 97 foreach ($branches as $branch) { 98 $key = LanguageHelper::branchPlural($branch->text); 99 $branch->translatedText = $lang->hasKey($key) ? Text::_($key) : $branch->text; 100 } 101 102 // Order by title. 103 $branches = ArrayHelper::sortObjects($branches, 'translatedText', 1, true, true); 104 105 // Compile the options. 106 $options = array(); 107 $options[] = HTMLHelper::_('select.option', '', Text::_('COM_FINDER_MAPS_SELECT_BRANCH')); 108 109 // Convert the values to options. 110 foreach ($branches as $branch) { 111 $options[] = HTMLHelper::_('select.option', $branch->value, $branch->translatedText); 112 } 113 114 return $options; 115 } 116 117 /** 118 * Creates a list of published states. 119 * 120 * @return array An array containing the states that can be selected. 121 * 122 * @since 2.5 123 */ 124 public static function statelist() 125 { 126 return array( 127 HTMLHelper::_('select.option', '1', Text::sprintf('COM_FINDER_ITEM_X_ONLY', Text::_('JPUBLISHED'))), 128 HTMLHelper::_('select.option', '0', Text::sprintf('COM_FINDER_ITEM_X_ONLY', Text::_('JUNPUBLISHED'))) 129 ); 130 } 131 }
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 |