[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Form\Field; 11 12 use Joomla\CMS\Language\Text; 13 14 // phpcs:disable PSR1.Files.SideEffects 15 \defined('JPATH_PLATFORM') or die; 16 // phpcs:enable PSR1.Files.SideEffects 17 18 /** 19 * Field to load a list of possible item count limits 20 * 21 * @since 3.2 22 */ 23 class LimitboxField extends ListField 24 { 25 /** 26 * The form field type. 27 * 28 * @var string 29 * @since 3.2 30 */ 31 public $type = 'Limitbox'; 32 33 /** 34 * Cached array of the category items. 35 * 36 * @var array 37 * @since 3.2 38 */ 39 protected static $options = array(); 40 41 /** 42 * Default options 43 * 44 * @var array 45 */ 46 protected $defaultLimits = array(5, 10, 15, 20, 25, 30, 50, 100, 200, 500); 47 48 /** 49 * Method to get the options to populate to populate list 50 * 51 * @return array The field option objects. 52 * 53 * @since 3.2 54 */ 55 protected function getOptions() 56 { 57 // Accepted modifiers 58 $hash = md5($this->element->asXML()); 59 60 if (!isset(static::$options[$hash])) { 61 static::$options[$hash] = parent::getOptions(); 62 63 $options = array(); 64 $limits = $this->defaultLimits; 65 66 // Limits manually specified 67 if (isset($this->element['limits'])) { 68 $limits = explode(',', $this->element['limits']); 69 } 70 71 // User wants to add custom limits 72 if (isset($this->element['append'])) { 73 $limits = array_unique(array_merge($limits, explode(',', $this->element['append']))); 74 } 75 76 // User wants to remove some default limits 77 if (isset($this->element['remove'])) { 78 $limits = array_diff($limits, explode(',', $this->element['remove'])); 79 } 80 81 // Order the options 82 asort($limits); 83 84 // Add an option to show all? 85 $showAll = isset($this->element['showall']) ? (string) $this->element['showall'] === 'true' : true; 86 87 if ($showAll) { 88 $limits[] = 0; 89 } 90 91 if (!empty($limits)) { 92 foreach ($limits as $value) { 93 $options[] = (object) array( 94 'value' => $value, 95 'text' => ($value != 0) ? Text::_('J' . $value) : Text::_('JALL'), 96 ); 97 } 98 99 static::$options[$hash] = array_merge(static::$options[$hash], $options); 100 } 101 } 102 103 return static::$options[$hash]; 104 } 105 }
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 |