<?php
/**
 * @version $Id: submenu.php 139 2010-01-03 20:45:41Z  $
 * @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' );

/**
 * I return the submenu as defined in the framework.config.php
 *
 * @return string HTML
 */
function getSubmenu() {
	global $mainframe;
	$registry = bfRegistry::getInstance($mainframe->get('component'), $mainframe->get('component'));
	$submenus = $registry->getValue('bfFramework_'.$mainframe->get('component_shortname').'.submenus');

	$html  = '<div class="submenu-pad">';
	$html .= '	<div class="submenu-box">';
	$html .= '		<div class="submenu-pad">';
	$html .= '			<ul id="submenu">';

	$i=1;
	foreach ($submenus as $menutext => $submenu) {
		if ($submenu=='xconfiguration'){
			if ( bfSecurity::checkPermissions('Admin.EditConfiguration','',false) === false){
				continue;
			}
		}
		$i == 1 ? $class = ' class="active"' :	$class = 'class =""';

		if (preg_match('/index.php/i',$submenu)){
			$url = bfURI::resolve($submenu);
			$html .= "<li class=\"item-smenu\"><a href=\"$url\" id=\"$submenu\"$class target=\"_blank\">".bfText::_($menutext)."</a></li>\n";
		} else {
			$html .= "<li class=\"item-smenu\"><a onClick=\"selectSubmenuItem(this, '$submenu');\" id=\"$submenu\"$class>".bfText::_($menutext)."</a></li>\n";
		}
		$i++;

	}
	$html .= '			</ul>';
	$html .= '			<div class="clr"></div>';
	$html .= '		</div>';
	$html .= '  </div>';
	$html .= '</div>';
	$html .= '<div class="clr"></div>';
	return $html;
}
?>
