<?php
/**
 * @version $Id: bfSubmenu.php 117 2009-07-14 20:29:10Z  $
 * @package Blue Flame Framework (bfFramework)
 * @copyright Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Blue Flame IT Ltd. All rights reserved.
 * @license GNU General Public License
 * @link http://www.blueflameit.ltd.uk
 * @author Phil Taylor / Blue Flame IT Ltd.
 *
 * bfFramework is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * bfFramework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this package.  If not, see http://www.gnu.org/licenses/
 */
defined ( '_JEXEC' ) or die ( 'Restricted access' );

class bfSubmenu {
	/**
	 * I draw the unordered list for the menu.
	 *
	 */
	function render($suffix = '') {
		global $mainframe;
		/* Do I want to hide the menu? */
		$noSubmenu = bfRequest::getVar ( 'no_html' );
		if ($noSubmenu)
			return;
			/* Tell the view renderer that I have used popups */
		$registry = & bfRegistry::getInstance ( $mainframe->get ( 'component' ), $mainframe->get ( 'component' ) );
		if ($registry->get ( 'config.quickicons', 0 ) == "1")
			return;
		$registry->setValue ( 'hasPopups', 1 );
		/* Get the submenu items frm the framework config */
		$items = $registry->getValue ( 'bfFramework_' . $mainframe->get ( 'component_shortname' ) . '.submenus' . ($suffix ? '_' . $suffix : '') );
		/* build the ul */
		echo '<ul class="bfsubmenu">';
		foreach ( $items as $item => $link ) {
			$item = bfText::_ ( $item );
			$parts = explode ( '|', $link );
			if ($parts [1] == 'preview') {
				$href = '" href="' . $parts [0] . '">';
			}
			if ($parts [1] == 'turbo') {
				$href = '" href="http://www.phil-taylor.com/Turbo-Gears-Speed-Up-Joomla-1.5-Admin-Console" target="_blank">';
			} else {
				//jQuery(\'div#bf-main-content\').fadeOut(\'fast\');
				$loading = bfText::_ ( 'Loading' ) . '...';
				$href = '" href="javascript:void(0);" onclick="bfFramework.menuClick(\'' . $loading . '\',\'' . $parts [0] . '\');">';
			}
			if (@! $parts [1])
				$parts [1] = $item;
			echo '<li class="submenuicon-' . strtolower ( $parts [1] ) . '">';
			echo '<a class="submenuicon-' . strtolower ( $parts [1] ) . (@$parts [2] ? ' hasTip"' : '"') . ' title="' . (@$parts [2] ? $item . ' :: ' . @$parts [2] : $item . ' :: ' . $parts [0]) . $href . $item . '</a></li>';
		}
		echo '</ul>';
	}
}