| Current Path : /home/sunflowe/www2/vacancesfloride/templates/ariolite/ |
| Current File : /home/sunflowe/www2/vacancesfloride/templates/ariolite/jj_suckerfish.php |
<?php
/**
* @version $Id: jj_suckerfish.php Carlos Guimaraes [http://www.open4g.com] $
* @package Joomla
* @copyright Copyright (C) 2006 Open4G Solutions.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
/**
* Draws a horizontal 'flat' style menu (very simple case)
*/
function mosShowSuckerFishMenu( $menu_name, $class_sfx='-nav') {
global $mainframe;
$database = $mainframe->getCfg('db');
$user =& JFactory::getUser();
$my = $user -> get('usertype');
$cur_template = $mainframe->getTemplate();
$Itemid = JRequest::getInt('Itemid');
$mosConfig_live_site = $mainframe->getCfg('live_site');
$contentConfig = &JComponentHelper::getParams( 'com_content' );
$mosConfig_shownoauth = !$contentConfig->get('shownoauth');
error_reporting(E_ALL ^ E_NOTICE);
$expand_menu = 1;
$indent_image = 0;
/* If a user has signed in, get their user type */
$intUserType = 0;
if($my->gid){
switch ($my->usertype) {
case 'Super Administrator':
$intUserType = 0;
break;
case 'Administrator':
$intUserType = 1;
break;
case 'Editor':
$intUserType = 2;
break;
case 'Registered':
$intUserType = 3;
break;
case 'Author':
$intUserType = 4;
break;
case 'Publisher':
$intUserType = 5;
break;
case 'Manager':
$intUserType = 6;
break;
}
} else {
/* user isn't logged in so make their usertype 0 */
$intUserType = 0;
}
$and = '';
if ( !$mosConfig_shownoauth ) {
$and = "\n AND access <= $my->gid";
}
$sql = &JFactory::getDBO();
$sql ->setQuery ( "SELECT m.*"
. "\n FROM #__menu AS m"
. "\n WHERE menutype = '". $menu_name."'"
. "\n AND published = 1"
. $and
. "\n ORDER BY parent, ordering");
$rows = $sql->loadObjectList( 'id' );
// miya
// indent icons
switch ( $indent_image ) {
case '1':
// Default images
$imgpath = $mosConfig_live_site .'/images/M_images';
for ( $i = 1; $i < 7; $i++ ) {
$img[$i] = '<img src="'. $imgpath .'/indent'. $i .'.png" alt="" />';
}
break;
case '2':
// Use Params
$imgpath = $mosConfig_live_site .'/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 = $mosConfig_live_site .'/templates/'. $cur_template .'/images';
for ( $i = 1; $i < 7; $i++ ) {
$img[$i] = '<img src="'. $imgpath .'/indent'. $i .'.png" alt="" />';
}
break;
}
$menuclass = 'mainmenu'. $class_sfx;
$indents = array(
// block prefix / item prefix / item suffix / block suffix
array( '<ul id="'.$menuclass.'">', '<li>' , '</li>', '</ul>' ),
array( '<ul>', '<li>', '</li>', '</ul>' )
);
// establish the hierarchy of the menu
$children = array();
// first pass - collect children
foreach ($rows as $v ) {
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
// second pass - collect 'open' menus
$open = array( $Itemid );
$count = 20; // maximum levels - to prevent runaway loop
$id = $Itemid;
while (--$count) {
if (isset($rows[$id]) && $rows[$id]->parent > 0) {
$id = $rows[$id]->parent;
$open[] = $id;
} else {
break;
}
}
mosJJRecurseVIMenu( 0, 0, $children, $open, $indents, $expand_menu, $class_sfx );
}
/**
* Utility function for writing a menu link
*/
function mosJJGetMenuLink( $mitem, $level=0, &$class_sfx, &$menuclass, $open=null ) {
global $Itemid, $mosConfig_live_site, $mainframe;
$activate_parent = 0;
$full_active_id = 1;
$menu_images = 0;
$menu_images_align = 0;
$txt = '';
switch ($mitem->type) {
case 'separator':
case 'component_item_link':
break;
case 'url':
if ( eregi( 'index.php\?', $mitem->link ) ) {
if ( !eregi( 'Itemid=', $mitem->link ) ) {
$mitem->link .= '&Itemid='. $mitem->id;
}
}
break;
case 'content_item_link':
case 'content_typed':
// load menu params
$menuparams = new mosParameters( $mitem->params, $mainframe->getPath( 'menu_xml', $mitem->type ), 'menu' );
$unique_itemid = $menuparams->get( 'unique_itemid', 1 );
if ( $unique_itemid ) {
$mitem->link .= '&Itemid='. $mitem->id;
} else {
$temp = split('&task=view&id=', $mitem->link);
if ( $mitem->type == 'content_typed' ) {
$mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1], 1, 0);
} else {
$mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1], 0, 1);
}
}
break;
default:
$mitem->link .= '&Itemid='. $mitem->id;
break;
}
// Active Menu highlighting
$current_itemid = $Itemid;
if ( !$current_itemid ) {
$id = '';
} else if ( $current_itemid == $mitem->id ) {
$id = 'id="active_menu'. $class_sfx .'"';
} else if( $activate_parent && isset( $open ) && in_array( $mitem->id, $open ) ) {
$id = 'id="active_menu'. $class_sfx .'"';
} else {
$id = '';
}
if ( $full_active_id ) {
// support for `active_menu` of 'Link - Component Item'
if ( $id == '' && $mitem->type == 'component_item_link' ) {
parse_str( $mitem->link, $url );
if ( $url['Itemid'] == $current_itemid ) {
$id = 'id="active_menu'. $class_sfx .'"';
}
}
// support for `active_menu` of 'Link - Url' if link is relative
if ( $id == '' && $mitem->type == 'url' && strpos( 'http', $mitem->link ) === false) {
parse_str( $mitem->link, $url );
if ( isset( $url['Itemid'] ) ) {
if ( $url['Itemid'] == $current_itemid ) {
$id = 'id="active_menu'. $class_sfx .'"';
}
}
}
}
// replace & with amp; for xhtml compliance
//$mitem->link = ampReplace( $mitem->link ); //miya
// run through SEF convertor
//$mitem->link = sefRelToAbs( $mitem->link ); //miya
//$menuclass = 'mainmenu'. $class_sfx;
//if ($level > 0) {
// $menuclass = 'sublevel'. $class_sfx;
//}
// replace & with amp; for xhtml compliance
// remove slashes from excaped characters
// $mitem->name = stripslashes( ampReplace($mitem->name) ); //miya
switch ($mitem->browserNav) {
// cases are slightly different
case 1:
// open in a new window
if ($menuclass) {
$txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';
} else {
$txt = '<a href="'. $mitem->link .'" target="_blank" '. $id .'>'. $mitem->name .'</a>';
}
break;
case 2:
// open in a popup window
if ($menuclass) {
$txt = "<a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '', '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";
} else {
$txt = "<a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\ >". $mitem->name ."</a>\n";
}
break;
case 3:
// don't link it
if ($menuclass) {
$txt = '<span class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</span>';
} else {
$txt = '<span '. $id .'>'. $mitem->name .'</span>';
}
break;
default:
// open in parent window
if ($menuclass) {
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';
} else {
$txt = '<a href="'. $mitem->link .'" '. $id .'>'. $mitem->name .'</a>';
}
break;
}
if ( $menu_images ) {
$menu_params = new stdClass();
$menu_params = new mosParameters( $mitem->params );
$menu_image = $menu_params->def( 'menu_image', -1 );
if ( ( $menu_image != '-1' ) && $menu_image ) {
$image = '<img src="'. $mosConfig_live_site .'/images/stories/'. $menu_image .'" border="0" alt="'. $mitem->name .'"/>';
if ( $menu_images_align ) {
$txt = $txt .' '. $image;
} else {
$txt = $image .' '. $txt;
}
}
}
return $txt;
}
function mosJJCheckHasChildren($childrens,$menuid){
$haschildren = false;
foreach ($childrens as $cix => $chindex) {
if ($cix == $menuid) {
$haschildren = true;
}
}
return $haschildren;
}
/**
* Utility function to recursively work through a vertically indented
* hierarchial menu
*/
function mosJJRecurseVIMenu( $id, $level, &$children, &$open, &$indents, &$expand_menu, &$class_sfx) {
if (@$children[$id]) {
$n = min( $level, count( $indents )-1 );
echo "\n".$indents[$n][0];
foreach ($children[$id] as $row) {
if (mosJJCheckHasChildren($children,$row->id)) {
if ($level == 0) {
$menuclass = "haschild";
} else {
$menuclass = "hassubchild";
}
} else {
$menuclass = null;
}
echo "\n".$indents[$n][1];
echo mosJJGetMenuLink( $row, $level, $class_sfx, $menuclass, $open );
// show menu with menu expanded - submenus visible
if ( !$expand_menu ) {
if ( in_array( $row->id, $open )) {
mosJJRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $expand_menu, $class_sfx );
}
} else {
mosJJRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $expand_menu, $class_sfx );
}
echo $indents[$n][2];
}
echo "\n".$indents[$n][3];
}
}
?>