| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: helper.php 14996 2010-02-22 23:15:13Z ian $ 4 * @package Joomla 5 * @subpackage Menus 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 /** 16 * @package Joomla 17 * @subpackage Menus 18 */ 19 class MenusHelper 20 { 21 /** 22 * Get a list of the menu_types records 23 * @return array An array of records as objects 24 */ 25 function getMenuTypeList() 26 { 27 $db = &JFactory::getDBO(); 28 $query = 'SELECT a.*, SUM(b.home) AS home' . 29 ' FROM #__menu_types AS a' . 30 ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' . 31 ' GROUP BY a.id'; 32 $db->setQuery( $query ); 33 return $db->loadObjectList(); 34 } 35 36 /** 37 * Get a list of the menutypes 38 * @return array An array of menu type names 39 */ 40 function getMenuTypes() 41 { 42 $db = &JFactory::getDBO(); 43 $query = 'SELECT menutype' . 44 ' FROM #__menu_types'; 45 $db->setQuery( $query ); 46 return $db->loadResultArray(); 47 } 48 49 /** 50 * Gets a list of components that can link to the menu 51 */ 52 function getComponentList() 53 { 54 $db = &JFactory::getDBO(); 55 $query = 'SELECT c.id, c.name, c.link, c.option' . 56 ' FROM #__components AS c' . 57 ' WHERE c.link <> "" AND parent = 0 AND enabled = 1' . 58 ' ORDER BY c.name'; 59 $db->setQuery( $query ); 60 $result = $db->loadObjectList( ); 61 return $result; 62 } 63 64 /** 65 * Build the select list for parent menu item 66 */ 67 function Parent( &$row ) 68 { 69 $db =& JFactory::getDBO(); 70 71 // If a not a new item, lets set the menu item id 72 if ( $row->id ) { 73 $id = ' AND id != '.(int) $row->id; 74 } else { 75 $id = null; 76 } 77 78 // In case the parent was null 79 if (!$row->parent) { 80 $row->parent = 0; 81 } 82 83 // get a list of the menu items 84 // excluding the current menu item and its child elements 85 $query = 'SELECT m.*' . 86 ' FROM #__menu m' . 87 ' WHERE menutype = '.$db->Quote($row->menutype) . 88 ' AND published != -2' . 89 $id . 90 ' ORDER BY parent, ordering'; 91 $db->setQuery( $query ); 92 $mitems = $db->loadObjectList(); 93 94 // establish the hierarchy of the menu 95 $children = array(); 96 97 if ( $mitems ) 98 { 99 // first pass - collect children 100 foreach ( $mitems as $v ) 101 { 102 $pt = $v->parent; 103 $list = @$children[$pt] ? $children[$pt] : array(); 104 array_push( $list, $v ); 105 $children[$pt] = $list; 106 } 107 } 108 109 // second pass - get an indent list of the items 110 $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 ); 111 112 // assemble menu items to the array 113 $mitems = array(); 114 $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) ); 115 116 foreach ( $list as $item ) { 117 $mitems[] = JHTML::_('select.option', $item->id, ' '. $item->treename ); 118 } 119 120 $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent ); 121 122 return $output; 123 } 124 125 /** 126 * build the select list for target window 127 */ 128 function Target( &$row ) 129 { 130 $click[] = JHTML::_('select.option', '0', JText::_( 'Parent Window With Browser Navigation' ) ); 131 $click[] = JHTML::_('select.option', '1', JText::_( 'New Window With Browser Navigation' ) ); 132 $click[] = JHTML::_('select.option', '2', JText::_( 'New Window Without Browser Navigation' ) ); 133 $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) ); 134 135 return $target; 136 } 137 138 /** 139 * build the select list for target window 140 */ 141 function Published( &$row ) 142 { 143 $put[] = JHTML::_('select.option', '0', JText::_( 'No' )); 144 $put[] = JHTML::_('select.option', '1', JText::_( 'Yes' )); 145 146 // If not a new item, trash is not an option 147 if ( !$row->id ) { 148 $row->published = 1; 149 } 150 $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published ); 151 return $published; 152 } 153 154 /** 155 * clean system cache 156 */ 157 function cleanCache() 158 { 159 global $mainframe; 160 161 if ($mainframe->getCfg('caching')) { 162 // clean system cache 163 $cache =& JFactory::getCache('_system'); 164 $cache->clean(); 165 166 // clean mod_mainmenu cache 167 $cache2 =& JFactory::getCache('mod_mainmenu'); 168 $cache2->clean(); 169 } 170 } 171 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |