- md5
- b977c90bebaccaaa01a43e63d5cec26e
- sha1
- 10959888891115fd7b41bf1bc2fe20afbdf9e135
- sha256
- 7e1fcac9561c2ebdea44e5ece2bbb9708692145f4b4a95d555fc36c287c6293c
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
<?php
/**
* @version $Id: legacy.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @copyright Copyright (C) 2005 - 2010 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.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Utility function for writing a menu link
*/
function mosGetMenuLink($mitem, $level = 0, & $params, $open = null)
{
global $Itemid;
$txt = '';
//needed to break reference to prevent altering the actual menu item
$mitem = clone($mitem);
// Menu Link is a special type that is a link to another item
if ($mitem->type == 'menulink')
{
$menu = &JSite::getMenu();
if ($tmp = $menu->getItem($mitem->query['Itemid'])) {
$name = $mitem->name;
$mid = $mitem->id;
$parent = $mitem->parent;
$mitem = clone($tmp);
$mitem->name = $name;
$mitem->mid = $mid;
$mitem->parent = $parent;
} else {
return;
}
}
switch ($mitem->type)
{
case 'separator' :
$mitem->browserNav = 3;
break;
case 'url' :
if (preg_match('#index.php\?#i', $mitem->link)) {
if (!preg_match('#Itemid=#i', $mitem->link)) {
$mitem->link .= '&Itemid='.$mitem->id;
}
}
break;
default :
$mitem->link = 'index.php?Itemid='.$mitem->id;
break;
}
// Active Menu highlighting
$current_itemid = intval( $Itemid );
if (!$current_itemid) {
$id = '';
} else {
if ($current_itemid == $mitem->id) {
$id = 'id="active_menu' . $params->get('class_sfx') . '"';
} else {
if ($params->get('activate_parent') && isset ($open) && in_array($mitem->id, $open)) {
$id = 'id="active_menu' . $params->get('class_sfx') . '"';
} else {
if ($mitem->type == 'url' && ItemidContained($mitem->link, $current_itemid)) {
$id = 'id="active_menu' . $params->get('class_sfx') . '"';
} else {
$id = '';
}
}
}
}
if ($params->get('full_active_id'))
{
// support for `active_menu` of 'Link - Url' if link is relative
if ($id == '' && $mitem->type == 'url' && strpos($mitem->link, 'http') === false) {
$url = array();
if(strpos($mitem->link, '&') !== false)
{
$mitem->link = str_replace('&','&',$mitem->link);
}
parse_str($mitem->link, $url);
if (isset ($url['Itemid'])) {
if ($url['Itemid'] == $current_itemid) {
$id = 'id="active_menu' . $params->get('class_sfx') . '"';
}
}
}
}
// replace & with amp; for xhtml compliance
$menu_params = new stdClass();
$menu_params = new JParameter($mitem->params);
$menu_secure = $menu_params->def('secure', 0);
if (strcasecmp(substr($mitem->link, 0, 4), 'http')) {
$mitem->url = JRoute::_($mitem->link, true, $menu_secure);
} else {
$mitem->url = $mitem->link;
}
$menuclass = 'mainlevel' . $params->get('class_sfx');
if ($level > 0) {
$menuclass = 'sublevel' . $params->get('class_sfx');
}
// replace & with amp; for xhtml compliance
// remove slashes from excaped characters
$mitem->name = stripslashes(htmlspecialchars($mitem->name));
switch ($mitem->browserNav)
{
// cases are slightly different
case 1 :
// open in a new window
$txt = '<a href="' . $mitem->url . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
break;
case 2 :
// open in a popup window
$txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->url . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"$menuclass\" " . $id . ">" . $mitem->name . "</a>\n";
break;
case 3 :
// don't link it
$txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
break;
default : // formerly case 2
// open in parent window
$txt = '<a href="' . $mitem->url . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
break;
}
if ($params->get('menu_images'))
{
$menu_params = new stdClass();
$menu_params = new JParameter($mitem->params);
$menu_image = $menu_params->def('menu_image', -1);
if (($menu_image <> '-1') && $menu_image) {
$image = '<img src="'.JURI::base(true).'/images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
if ($params->get('menu_images_align')) {
$txt = $txt . ' ' . $image;
} else {
$txt = $image . ' ' . $txt;
}
}
}
return $txt;
}
/**
* Vertically Indented Menu
*/
function mosShowVIMenu(& $params)
{
global $mainframe, $Itemid;
$template = $mainframe->getTemplate();
$menu =& JSite::getMenu();
$user =& JFactory::getUser();
// indent icons
switch ($params->get('indent_image')) {
case '1' :
{
// Default images
$imgpath = JURI::base(true).'/images/M_images';
for ($i = 1; $i < 7; $i++) {
$img[$i] = '<img src="' . $imgpath . '/indent' . $i . '.png" alt="" />';
}
}
break;
case '2' :
{
// Use Params
$imgpath = JURI::base(true).'/images/M_images';
for ($i = 1; $i < 7; $i++) {
if ($params->get('indent_image' . $i) == '-1') {
$img[$i] = NULL;
} else {
$img[$i] = '<img src="' . $imgpath . '/' . $params->get('indent_image' . $i) . '" alt="" />';
}
}
}
break;
case '3' :
{
// None
for ($i = 1; $i < 7; $i++) {
$img[$i] = NULL;
}
}
break;
default :
{
// Template
$imgpath = JURI::base(true).'/templates/' . $template . '/images';
for ($i = 1; $i < 7; $i++) {
$img[$i] = '<img src="' . $imgpath . '/indent' . $i . '.png" alt="" />';
}
}
}
$indents = array (
// block prefix / item prefix / item suffix / block suffix
array (
'<table width="100%" border="0" cellpadding="0" cellspacing="0">',
'<tr ><td>',
'</td></tr>',
'</table>'
),
array (
'',
'<div style="padding-left: 4px">' . $img[1],
'</div>',
''
),
array (
'',
'<div style="padding-left: 8px">' . $img[2],
'</div>',
''
),
array (
'',
'<div style="padding-left: 12px">' . $img[3],
'</div>',
''
),
array (
'',
'<div style="padding-left: 16px">' . $img[4],
'</div>',
''
),
array (
'',
'<div style="padding-left: 20px">' . $img[5],
'</div>',
''
),
array (
'',
'<div style="padding-left: 24px">' . $img[6],
'</div>',
''
),
);
// establish the hierarchy of the menu
$children = array ();
//get menu items
$rows = $menu->getItems('menutype', $params->get('menutype'));
// first pass - collect children
$cacheIndex = array();
if(is_array($rows) && count($rows)) {
foreach ($rows as $index => $v) {
if ($v->access <= $user->get('aid')) {
$pt = $v->parent;
$list = @ $children[$pt] ? $children[$pt] : array ();
array_push($list, $v);
$children[$pt] = $list;
}
$cacheIndex[$v->id] = $index;
}
}
// second pass - collect 'open' menus
$open = array (
$Itemid
);
$count = 20; // maximum levels - to prevent runaway loop
$id = $Itemid;
while (-- $count)
{
if (isset($cacheIndex[$id])) {
$index = $cacheIndex[$id];
if (isset ($rows[$index]) && $rows[$index]->parent > 0) {
$id = $rows[$index]->parent;
$open[] = $id;
} else {
break;
}
}
}
mosRecurseVIMenu(0, 0, $children, $open, $indents, $params);
}
/**
* Utility function to recursively work through a vertically indented
* hierarchial menu
*/
function mosRecurseVIMenu($id, $level, & $children, & $open, & $indents, & $params)
{
if (@ $children[$id]) {
$n = min($level, count($indents) - 1);
echo "\n" . $indents[$n][0];
foreach ($children[$id] as $row) {
echo "\n" . $indents[$n][1];
echo mosGetMenuLink($row, $level, $params, $open);
// show menu with menu expanded - submenus visible
if (!$params->get('expand_menu')) {
if (in_array($row->id, $open)) {
mosRecurseVIMenu($row->id, $level +1, $children, $open, $indents, $params);
}
} else {
mosRecurseVIMenu($row->id, $level +1, $children, $open, $indents, $params);
}
echo $indents[$n][2];
}
echo "\n" . $indents[$n][3];
}
}
/**
* Draws a horizontal 'flat' style menu (very simple case)
*/
function mosShowHFMenu(& $params, $style = 0)
{
$menu = & JSite::getMenu();
$user = & JFactory::getUser();
//get menu items
$rows = $menu->getItems('menutype', $params->get('menutype'));
$links = array ();
if(is_array($rows) && count($rows)) {
foreach ($rows as $row)
{
if ($row->access <= $user->get('aid', 0)) {
$links[] = mosGetMenuLink($row, 0, $params);
}
}
}
$menuclass = 'mainlevel' . $params->get('class_sfx');
$lang =& JFactory::getLanguage();
if (count($links))
{
switch ($style)
{
case 1 :
echo '<ul id="' . $menuclass . '">';
foreach ($links as $link) {
echo '<li>' . $link . '</li>';
}
echo '</ul>';
break;
default :
$spacer_start = $params->get('spacer');
$spacer_end = $params->get('end_spacer');
echo '<table width="100%" border="0" cellpadding="0" cellspacing="1">';
echo '<tr>';
echo '<td nowrap="nowrap">';
if ($spacer_end) {
echo '<span class="' . $menuclass . '"> ' . $spacer_end . ' </span>';
}
if ($spacer_start) {
$html = '<span class="' . $menuclass . '"> ' . $spacer_start . ' </span>';
echo implode($html, $links);
} else {
echo implode('', $links);
}
if ($spacer_end) {
echo '<span class="' . $menuclass . '"> ' . $spacer_end . ' </span>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
break;
}
}
}
/**
* Search for Itemid in link
*/
function ItemidContained($link, $Itemid)
{
$link = str_replace('&', '&', $link);
$temp = explode("&", $link);
$linkItemid = "";
foreach ($temp as $value) {
$temp2 = explode("=", $value);
if ($temp2[0] == "Itemid") {
$linkItemid = $temp2[1];
break;
}
}
if ($linkItemid != "" && $linkItemid == $Itemid) {
return true;
} else {
return false;
}
}
The same content is in 11 releases, Joomla 1.5.16 to 1.5.26. See them all, or every version of this file.