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