[ 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_menus 6 * 7 * @copyright (C) 2017 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\Menus\Administrator\Helper; 12 13 use Joomla\CMS\Association\AssociationExtensionHelper; 14 use Joomla\CMS\Language\Associations; 15 use Joomla\CMS\Table\Table; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Menu associations helper. 23 * 24 * @since 3.7.0 25 */ 26 class AssociationsHelper extends AssociationExtensionHelper 27 { 28 /** 29 * The extension name 30 * 31 * @var array $extension 32 * 33 * @since 3.7.0 34 */ 35 protected $extension = 'com_menus'; 36 37 /** 38 * Array of item types 39 * 40 * @var array $itemTypes 41 * 42 * @since 3.7.0 43 */ 44 protected $itemTypes = array('item'); 45 46 /** 47 * Has the extension association support 48 * 49 * @var boolean $associationsSupport 50 * 51 * @since 3.7.0 52 */ 53 protected $associationsSupport = true; 54 55 /** 56 * Method to get the associations for a given item. 57 * 58 * @param integer $id Id of the item 59 * @param string $view Name of the view 60 * 61 * @return array Array of associations for the item 62 * 63 * @since 4.0.0 64 */ 65 public function getAssociationsForItem($id = 0, $view = null) 66 { 67 return []; 68 } 69 70 /** 71 * Get the associated items for an item 72 * 73 * @param string $typeName The item type 74 * @param int $id The id of item for which we need the associated items 75 * 76 * @return array 77 * 78 * @since 3.7.0 79 */ 80 public function getAssociations($typeName, $id) 81 { 82 $type = $this->getType($typeName); 83 84 $context = $this->extension . '.item'; 85 86 // Get the associations. 87 $associations = Associations::getAssociations( 88 $this->extension, 89 $type['tables']['a'], 90 $context, 91 $id, 92 'id', 93 'alias', 94 '' 95 ); 96 97 return $associations; 98 } 99 100 /** 101 * Get item information 102 * 103 * @param string $typeName The item type 104 * @param int $id The id of item for which we need the associated items 105 * 106 * @return Table|null 107 * 108 * @since 3.7.0 109 */ 110 public function getItem($typeName, $id) 111 { 112 if (empty($id)) { 113 return null; 114 } 115 116 $table = null; 117 118 switch ($typeName) { 119 case 'item': 120 $table = Table::getInstance('menu'); 121 break; 122 } 123 124 if (is_null($table)) { 125 return null; 126 } 127 128 $table->load($id); 129 130 return $table; 131 } 132 133 /** 134 * Get information about the type 135 * 136 * @param string $typeName The item type 137 * 138 * @return array Array of item types 139 * 140 * @since 3.7.0 141 */ 142 public function getType($typeName = '') 143 { 144 $fields = $this->getFieldsTemplate(); 145 $tables = array(); 146 $joins = array(); 147 $support = $this->getSupportTemplate(); 148 $title = ''; 149 150 if (in_array($typeName, $this->itemTypes)) { 151 switch ($typeName) { 152 case 'item': 153 $fields['ordering'] = 'a.lft'; 154 $fields['level'] = 'a.level'; 155 $fields['catid'] = ''; 156 $fields['state'] = 'a.published'; 157 $fields['created_user_id'] = ''; 158 $fields['menutype'] = 'a.menutype'; 159 160 $support['state'] = true; 161 $support['acl'] = true; 162 $support['checkout'] = true; 163 $support['level'] = true; 164 165 $tables = array( 166 'a' => '#__menu' 167 ); 168 169 $title = 'menu'; 170 break; 171 } 172 } 173 174 return array( 175 'fields' => $fields, 176 'support' => $support, 177 'tables' => $tables, 178 'joins' => $joins, 179 'title' => $title 180 ); 181 } 182 }
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 |