Exemple #1
0
function llena_sesion($usuario = array())
{
    $_SESSION[user]['id_usuario'] = $usuario[id_usuario];
    $_SESSION[user]['usuario'] = $usuario[usuario];
    $_SESSION[user]['activo'] = $usuario[activo];
    $_SESSION[user]['id_perfil'] = $usuario[id_perfil];
    $_SESSION[user]['id_grupo'] = $usuario[id_grupo];
    $_SESSION[user]['grupo'] = $usuario[grupo];
    $_SESSION[user]['id_personal'] = $usuario[id_personal];
    $_SESSION[user]['nombre'] = $usuario[nombreCompleto];
    $_SESSION[user]['empleado_num'] = $usuario[empleado_num];
    $_SESSION[user]['email'] = $usuario[email];
    $_SESSION[user]['id_empresa'] = $usuario[id_empresa];
    $_SESSION[user]['id_empresa_nomina'] = $usuario[id_empresa_nomina];
    $_SESSION[user]['empresa'] = $usuario[empresa];
    $_SESSION[user]['pais'] = $usuario[pais];
    $_SESSION[user]['id_pais'] = $usuario[id_pais];
    $_SESSION[user]['id_region'] = $usuario[id_region];
    $_SESSION[user]['nombre_usuario'] = $usuario[nombre];
    $_SESSION[user]['grupo'] = $usuario[grupo];
    #Accesos en menú GROUP
    $visible_group = array_filter(preg_split("/[\\s,;|*]+/", $usuario[visible_group]));
    $invisible_group = array_filter(preg_split("/[\\s,;|*]+/", $usuario[invisible_group]));
    $invisible_group = array_diff($invisible_group, $visible_group);
    #Accesos en menú USER
    $visible_user = array_filter(preg_split("/[\\s,;|*]+/", $usuario[visible_user]));
    $invisible_user = array_filter(preg_split("/[\\s,;|*]+/", $usuario[invisible_user]));
    #Accesos en menú FINAL
    #USER tiene preferencia a GROUP
    $visible_final = array_diff(array_unique(array_merge($visible_group, $visible_user)), $invisible_user);
    $invisible_final = array_unique(array_merge($invisible_group, $invisible_user));
    $invisible_final = array_diff($invisible_final, $visible_final);
    $_SESSION[user]['accesos']['visible'] = implode(',', $visible_final);
    $_SESSION[user]['accesos']['invisible'] = implode(',', $invisible_final);
    #Menú
    $_SESSION[user]['menu'] = buildMenu($_SESSION[user]['accesos']['visible'], $_SESSION[user]['accesos']['invisible']);
    #Accesos en submenú GROUP
    $visible_group_submenu = array_filter(preg_split("/[\\s,;|*]+/", $usuario[visible_submenu_group]));
    $invisible_group_submenu = array_filter(preg_split("/[\\s,;|*]+/", $usuario[invisible_submenu_group]));
    $invisible_group_submenu = array_diff($invisible_group_submenu, $visible_group_submenu);
    #Accesos en submenú USER
    $visible_user_submenu = array_filter(preg_split("/[\\s,;|*]+/", $usuario[visible_submenu_user]));
    $invisible_user_submenu = array_filter(preg_split("/[\\s,;|*]+/", $usuario[invisible_submenu_user]));
    #Accesos en submenú FINAL
    #USER tiene preferencia a GROUP
    $visible_final_submenu = array_diff(array_unique(array_merge($visible_group_submenu, $visible_user_submenu)), $invisible_user_submenu);
    $invisible_final_submenu = array_unique(array_merge($invisible_group_submenu, $invisible_user_submenu));
    $invisible_final_submenu = array_diff($invisible_final_submenu, $visible_final_submenu);
    $_SESSION[user]['accesos']['visible_submenu'] = implode(',', $visible_final_submenu);
    $_SESSION[user]['accesos']['invisible_submenu'] = implode(',', $invisible_final_submenu);
    #Submenú
    // $_SESSION[user]['submenu'] 			= buildMenu($_SESSION[user]['accesos']['visible_submenu'],$_SESSION[user]['accesos']['invisible_submenu']);
    // dump_var($_SESSION[user]);
    return true;
}
 /**
  * 执行行为 run方法是Behavior唯一的接口
  * @access public
  * @param mixed $params 行为参数
  * @return void
  */
 public function run(&$params)
 {
     // 进行权限认证逻辑 如果认证通过 $return = true;
     if (UID == C('ADMINISTRATOR')) {
         buildMenu();
         $params = true;
     } else {
         $controllerName = CONTROLLER_NAME;
         $auth = new Auth();
         if (!$auth->check($controllerName, UID) && !in_array($controllerName, C('NO_AUTH_CHECK'))) {
             A('Public')->noauth();
         } else {
             $params = true;
         }
     }
 }
Exemple #3
0
 function buildMenu($parent, $menu)
 {
     $html = "";
     if (isset($menu['parent_menus'][$parent])) {
         $html .= "<ul>";
         foreach ($menu['parent_menus'][$parent] as $menu_id) {
             if (!isset($menu['parent_menus'][$menu_id])) {
                 $html .= "<li>Child Menu - <a href='" . $menu['menus'][$menu_id]['slug'] . "'>" . $menu['menus'][$menu_id]['name'] . "</a> " . $menu['menus'][$menu_id]['count'] . " </li>";
             }
             if (isset($menu['parent_menus'][$menu_id])) {
                 $html .= "<li>Parent Menu - <a href='" . $menu['menus'][$menu_id]['slug'] . "'>" . $menu['menus'][$menu_id]['name'] . "</a> " . $menu['menus'][$menu_id]['count'] . " ";
                 $html .= buildMenu($menu_id, $menu);
                 $html .= "</li>";
             }
         }
         $html .= "</ul>";
     }
     return $html;
 }
function buildMenu($parent_id, $menuData)
{
    $html = '';
    if (isset($menuData['parents'][$parent_id])) {
        $html = '<ul>';
        foreach ($menuData['parents'][$parent_id] as $itemId) {
            if ($menuData['items'][$itemId]['page_id'] != 0) {
                $link_page_id = $menuData['items'][$itemId]['page_id'];
                $html .= '<a href="index.php?pid=' . $link_page_id;
                $html .= '">';
                $html .= '<li>' . $menuData['items'][$itemId]['name'];
                $html .= '</a>';
                $html .= '';
                // find childitems recursively
                $html .= buildMenu($itemId, $menuData);
                $html .= '</li>';
            } else {
                if ($menuData['items'][$itemId]['post_id'] != 0) {
                    $html .= '<a href="#=' . $menuData['items'][$itemId]['post_id'];
                    $html .= '">';
                    $html .= '<li>' . $menuData['items'][$itemId]['name'];
                    $html .= '</a>';
                    $html .= '';
                    // find childitems recursively
                    $html .= buildMenu($itemId, $menuData);
                    $html .= '</li>';
                } else {
                    $html .= '<a href="' . $menuData['items'][$itemId]['link'];
                    $html .= '">';
                    $html .= '<li>' . $menuData['items'][$itemId]['name'];
                    $html .= '</a>';
                    $html .= '';
                    // find childitems recursively
                    $html .= buildMenu($itemId, $menuData);
                    $html .= '</li>';
                }
            }
        }
        $html .= '</ul>';
    }
    return $html;
}
function renderChromeMenu($paramstring, $params = array())
{
    global $wgParser, $wgScriptPath, $wgOut;
    $wgParser->disableCache();
    if (isset($params['name'])) {
        $name = $params['name'];
    }
    if (isset($params['align'])) {
        $align = $params['align'];
    }
    // clean update newlines and extra whitespace
    $paramstring = preg_replace('@\\s+@', " ", $paramstring);
    $path = $wgScriptPath . '/extensions/ChromeMenu/';
    $wgOut->addStyle($path . 'chrometheme/chromestyle.css', 'screen');
    $wgOut->addScriptFile($path . 'chromejs/chrome.js');
    $menuHead = "\n<div class='chromestyle' id='{$name}'><ul style='text-align:{$align}'>";
    $menuFoot = "</ul></div>";
    buildMenu($paramstring, $menu, $menuItems);
    $html = $menuHead . $menu . $menuFoot . $menuItems;
    $execScript = "<script type='text/javascript'>cssdropdown.startchrome('{$name}')</script>";
    return $html . $execScript;
}
Exemple #6
0
<!DOCTYPE html>
<html>
<head>
	<title>Hospital Management System  - <?php 
echo $_SERVER['QUERY_STRING'];
?>
</title>
	<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>

<div id="wrap">
	<h1>Hospital Management System</h1>
	<div id="menu">
		<ul>
<?php 
buildMenu();
?>
		</ul>
	</div>
	<hr>
	<div id="body">
Exemple #7
0
 /**
  * 获得权限列表
  * @param integer $uid 用户id
  * @param integer $type
  */
 protected function getAuthList($uid, $type)
 {
     static $_authList = array();
     //保存用户验证通过的权限列表
     $t = implode(',', (array) $type);
     if (isset($_authList[$uid . $t])) {
         return $_authList[$uid . $t];
     }
     if ($this->_config['AUTH_TYPE'] == 2 && isset($_SESSION['_AUTH_LIST_' . $uid . $t])) {
         return $_SESSION['_AUTH_LIST_' . $uid . $t];
     }
     //读取用户所属用户组
     $groups = $this->getGroups($uid);
     $ids = array();
     //保存用户所属用户组设置的所有权限规则id
     foreach ($groups as $g) {
         $ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
     }
     $ids = array_unique($ids);
     if (empty($ids)) {
         $_authList[$uid . $t] = array();
         return array();
     }
     $map = array('id' => array('in', $ids), 'type' => $type, 'status' => 1);
     //读取用户组所有权限规则
     $rules = M()->table($this->_config['AUTH_RULE'])->where($map)->field('condition,name,title,pid,id,icon')->order('id')->select();
     //循环规则,判断结果。
     $authList = array();
     //
     foreach ($rules as $rule) {
         if (!empty($rule['condition'])) {
             //根据condition进行验证
             $user = $this->getUserInfo($uid);
             //获取用户信息,一维数组
             $command = preg_replace('/\\{(\\w*?)\\}/', '$user[\'\\1\']', $rule['condition']);
             //dump($command);//debug
             @eval('$condition=(' . $command . ');');
             if ($condition) {
                 $authList[] = strtolower($rule['name']);
             }
         } else {
             //只要存在就记录
             $authList[] = strtolower($rule['name']);
         }
     }
     $_authList[$uid . $t] = $authList;
     if ($this->_config['AUTH_TYPE'] == 2) {
         //规则列表结果保存到session
         $_SESSION['_AUTH_LIST_' . $uid . $t] = $authList;
     }
     //缓存菜单到session中
     buildMenu($rules);
     return array_unique($authList);
 }
Exemple #8
0
        $html .= '<div class="row">';
        $html .= '<div class="col-lg-3 col-md-3">';
        $html .= '<ul class="mega-links">';
        foreach ($array as $value) {
            $html .= '<li><a href="">' . $value['category_name'] . '</a></li>';
        }
        $html .= '</ul>';
        $html .= '</div>';
        $html .= '</div>';
        $html .= '</div>';
        $html .= '</li>';
        $html .= '</ul>';
        return $html;
    }
    function buildMenu(array $array)
    {
        $html = '<li class="dropdown yamm-fw">';
        foreach ($array as $value) {
            $html .= '<li class="dropdown yamm-fw">';
            $html .= '<a class="dropdown-link" href="">' . $value['category_name'] . '</a>';
            $html .= '<a class="dropdown-caret dropdown-toggle" data-hover="dropdown" ><b class="caret hidden-xs"></b></a>';
            if (!empty($value['children'])) {
                $html .= buildParent($value['children']);
            }
        }
        $html .= '</li>';
        return $html;
    }
    $this->view->getEnvironment()->addGlobal('front_category', buildMenu($list));
    return $next($request, $response);
});
                     closedir($sublink);
                 } else {
                     $currentSubdirSize = "XXX";
                 }
                 $subdirssizelist[$file] = $currentSubdirSize;
             } else {
                 $filelist[] = $file;
                 $datelist[$file] = $currentFileTime;
                 $sizelist[$file] = $currentFileSize;
             }
         }
     }
     closedir($dirlink);
 }
 $filenum = sizeof($filelist) + sizeof($subdirs);
 buildMenu($self, $uplink, $reloadlink, $helplink);
 if (count($filelist) != 0 || is_array($subdirs)) {
     printTableHeader();
     if ($_SESSION["sort"] == "date") {
         $filelist = array();
         arsort($datelist);
         foreach ($datelist as $file => $currentFileTime) {
             $filelist[] = $file;
         }
         if (is_array($subdirs)) {
             asort($subdirsdatelist);
             foreach ($subdirsdatelist as $currentSubdir => $currentFileTime) {
                 array_unshift($filelist, $currentSubdir);
             }
         }
     } elseif ($_SESSION["sort"] == "size") {
Exemple #10
0
$item['view_sysinfo'] = item($_lang['view_sysinfo'], 53, $modx->hasPermission('logs'));
// system-info
// User Profile Menu
$item['change_user_pf'] = item($_lang['profile'], 119, $modx->hasPermission('change_password'));
// change password
$item['change_password'] = item($_lang['change_password'], 28, $modx->hasPermission('change_password'));
// change password
$item['messages'] = item($_lang['messages'], 10, $modx->hasPermission('messages'));
// messages
$sitemenu = buildMenu('site', $item);
$elementmenu = buildMenu('element', $item);
//$modulemenu   = buildMenu('module',$item);//$item['modules']
$securitymenu = buildMenu('security', $item);
$toolsmenu = buildMenu('tools', $item);
$reportsmenu = buildMenu('reports', $item);
$usermenu = buildMenu('user', $item);
// Output Menus where there are items to show
if (!empty($sitemenu)) {
    echo '<li id="limenu1" class="active"><a href="#menu1" onclick="new NavToggle(this); return false;">' . $_lang['site'] . '</a><ul class="subnav" id="menu1">' . "\n" . "{$sitemenu}\n</ul></li>\n";
}
if (!empty($elementmenu)) {
    echo '<li id="limenu2"><a href="#menu2" onclick="new NavToggle(this); return false;">' . $_lang['elements'] . '</a><ul class="subnav" id="menu2">' . "\n" . "{$elementmenu}\n</ul></li>\n";
}
if (!empty($modulemenu)) {
    echo '<li id="limenu3"><a href="#menu3" onclick="new NavToggle(this); return false;">' . $_lang['modules'] . '</a><ul class="subnav" id="menu3">' . "\n" . "{$modulemenu}\n</ul></li>\n";
}
if (!empty($securitymenu)) {
    echo '<li id="limenu4"><a href="#menu4" onclick="new NavToggle(this); return false;">' . $_lang['users'] . '</a><ul class="subnav" id="menu4">' . "\n" . "{$securitymenu}\n</ul></li>\n";
}
if (!empty($usermenu)) {
    echo '<li id="limenu7"><a href="#menu7" onclick="new NavToggle(this); return false;">' . $_lang['user'] . '</a><ul class="subnav" id="menu7">' . "\n" . "{$usermenu}\n</ul></li>\n";
Exemple #11
0
	<dl>
		<dt>About</dt>
		<dd><?php 
buildMenu($about, $view);
?>
</dd>

		<dt>Filters</dt>
		<dd><?php 
buildMenu($filters, $view);
?>
</dd>

		<dt>Hooks</dt>
		<dd><?php 
buildMenu($hooks, $view);
?>
</dd>
	</dl>

	<span class="clear"></span>

	<?php 
if (file_exists($view . '.php') && $view !== 'index') {
    include $view . '.php';
} else {
    include 'features.php';
}
?>
</body>
</html>
Exemple #12
0
function dynamicMenu($id, $pid)
{
    $menusSession = buildMenu();
    if ($id != null && $pid != null) {
        $menusSession[$pid]['condition'] = 'active open';
        $menusSession[$pid]['child'][$id]['condition'] = 'active';
    }
    return $menusSession;
}
Exemple #13
0
	<div class="container">
		<div class="header">
			<ul>
			<?php 
buildMenu($assist);
?>
</ul>
			<div class="issn">ISSN (print) xxxx-xxxx, (online) xxxx-xxxx</div>
			<div class="title"><img src="/img/logo.gif" alt="logo"><span><?php 
echo J_NAME;
?>
</span></div>
		</div>
		<ul class="nav">
			<?php 
buildMenu($page, $current);
?>
</ul>
		<div class="page <?php 
echo $path;
?>
">
			<?php 
echo $output;
?>
		</div>
		<div class="footer">
			<span>&copy; 2015 <?php 
echo J_NAME;
?>
</span>
Exemple #14
0
function buildMenu($array)
{
    echo '<ul>';
    foreach ($array as $item) {
        echo '<li>';
        echo $item['name'];
        $test = array();
        if (!empty($item['children'])) {
            buildMenu($item['children']);
        }
        echo '</li>';
    }
    echo '</ul>';
}
include_once 'dictionary.php';
$url = $_SERVER['PHP_SELF'];
//aktuelle Page reinlesen
//Falls man während der Produktauswahl die Sprache wechseln will - bei der Confirmation habe ich das nachher nicht mehr gemacht
if (isset($_GET["productID"])) {
    $productID = "&productID=" . $_GET["productID"];
} else {
    $productID = "";
}
//Navigationsmenu
echo '<p id="NavHeader">' . translate('navigationList', $lanID);
echo "</p><br>";
//Je nach Auswahl wird der Parameter des aktuellen Scripts verändert, wenn das gemacht wird, wird die gleiche Seite eben mit den neuen Parametern aufgerufen.
//menu wird bei jedem Seitenaufruf neu gebaut.
include_once "menu.php";
buildMenu($lanID);
//DE-EN Auswahl: Bei Klick wird die Seite neu gebaut, aber mit dem richtigen 'lan' Parameter.
echo "<br><br><br>Sprache/Language:<br><br>";
//buildURL mit: aktueller View +
//include ('utility.php');
$currentView = getCurrentView();
//Bei erstem Besuch ist Sprachenwechsel noch nicht machbar, egal.
$urlDE = "index.php?view=" . urlencode($currentView) . $productID . "&lan=de";
$urlEN = "index.php?view=" . urlencode($currentView) . $productID . "&lan=en";
echo '<div class="langLink">';
echo "<a href = {$urlDE}>DE</a>";
echo " / ";
echo "<a href = {$urlEN}>EN</a>";
echo "</div>";
?>
Exemple #16
0
function buildDocOutput($comments_or_text,$index_array,$is_index=false) {
	$final_doc_contents = '';
	if (file_exists(dirname(__FILE__) . '/page_header.inc')) {
		$page_header = file_get_contents(dirname(__FILE__) . '/page_header.inc');
		if ($is_index) {
			$page_header = str_replace('../','',$page_header);
		}
		$final_doc_contents .= $page_header;
	}
	$final_doc_contents .= '<div id="pagemenu">' . buildMenu($index_array,$is_index) . '</div>';
	
	if (is_array($comments_or_text)) {
		$final_doc_contents .= formatParsedArray($comments_or_text);
	} else {
		$final_doc_contents .= $comments_or_text;
	}
	if (file_exists(dirname(__FILE__) . '/page_footer.inc')) {
		$final_doc_contents .= file_get_contents(dirname(__FILE__) . '/page_footer.inc');
	}
	$replace_these = array('@param','@return');
	$replace_these_with = array('<span class="param">@param</span>','<span class="return">@return</span>');
	return str_replace($replace_these,$replace_these_with,$final_doc_contents);
}
Exemple #17
0
function buildMenu($parent)
{
    global $CI;
    if (!isset($build)) {
        $build = '';
    }
    $menu = $CI->category_model->getSubCategories($parent);
    if (count($menu) > 0) {
        foreach ($menu as $row) {
            $url = $row['cat_parent'] == 0 ? site_url('category/index/' . $row['cat_id']) : site_url('product/cat/' . $row['cat_id'] . '/0/0');
            $build .= '<li><a href="' . $url . '">' . $row['cat_title'] . '-' . $row['cat_id'] . '</a>';
            $submenu = $CI->category_model->getSubCategories($row['cat_id']);
            //getSubcategory($row['cat_id']);
            if (!empty($submenu)) {
                $build .= '<ul>';
                $build .= buildMenu($row['cat_id']);
                $build .= '</ul>';
            }
            $build .= getProduct($row['cat_id']);
            $build .= '</li>';
        }
    }
    return $build;
}
Exemple #18
0
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" onresize="setFooterWidth()"
      onload="setFooterWidth()">
<div class="page index">

    <header>
        RaspiControl
    </header>

    <section class="mainMenu mainSection">

        <?php 
if (isset($error)) {
    echo "<p class='error'>" . $error . "</p>";
} else {
    try {
        buildMenu($user);
    } catch (Exception $e) {
        echo "<p class='error'>" . $e->getMessage() . "</p>";
    }
}
?>

    </section>
    <section class="toolsMenu">
        <ul class="scripts">
            <!-- TODO define Tools Menu -->
            <li><a href="widgets.php">Widgets</a></li>
            <li><a href="passwd.php">Change Password</a></li>
            <?php 
if ($user->IsAdmin()) {
    ?>
function buildMenu($node)
{
    $out = '';
    $n = 0;
    global $popups;
    if (!empty($node) && is_array($node)) {
        foreach ($node as $key => $value) {
            if (empty($value['url']) || empty($value['title']) || empty($value['id'])) {
                continue;
            }
            $value['prefix'] = !empty($value['prefix']) ? trim($value['prefix']) : '';
            $value['sufix'] = !empty($value['sufix']) ? trim($value['sufix']) : '';
            $value['newwin'] = !empty($value['newwin']) ? 1 : 0;
            $out .= '<li>' . "\n";
            $out .= '<div class="item">' . h($value['title']) . '<input type="hidden" name="id" value="' . $value['id'] . '" />' . "\n" . '<input type="hidden" name="url" value="' . h($value['url']) . '" />' . "\n" . '<input type="hidden" name="ankor" value="' . h($value['title']) . '" />' . "\n" . '<input type="hidden" name="prefix" value="' . h($value['prefix']) . '" />' . "\n" . '<input type="hidden" name="sufix" value="' . h($value['sufix']) . '" />' . "\n" . '<input type="hidden" name="newwin" value="' . h($value['newwin']) . '" />' . "\n" . '<div style="float:right;"><a class="edit" ' . 'title="Edit" onClick="openPopup(\'edit' . $value['id'] . '\');"></a>' . "\n" . '<a class="delete" title="Delete" ' . 'onClick="if(confirm(\'' . __('Are you sure?') . '\'))deletePoint(this);"></a><div style="clear:both;"></div></div>' . "\n" . '</div>' . "\n";
            $checked = !empty($value['newwin']) ? 'selected="selected"' : '';
            $popups .= '<div id="edit' . $value['id'] . '" class="popup">
				<div class="top">
					<div class="title">' . __('Add an item') . '</div>
					<div onClick="closePopup(\'edit' . $value['id'] . '\')" class="close"></div>
				</div>
				<form action="menu_editor.php?ac=edit&id=' . $value['id'] . '" method="POST">
				<div class="items">
					<div class="item">
						<div class="left">
							' . __('Visible text') . ':
						</div>
						<div class="right">
							<input type="text" name="ankor" value="' . h($value['title']) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="item">
						<div class="left">
							URL:
						</div>
						<div class="right">
							<input type="text" name="url" value="' . h($value['url']) . '" />
						</div>
						<div class="clear"></div>
					</div>
					<div class="item">
						<div class="left">
							' . __('Prefix') . ':
						</div>
						<div class="right">
							<textarea name="prefix">' . h($value['prefix']) . '</textarea>
						</div>
						<div class="clear"></div>
					</div>
					<div class="item">
						<div class="left">
							' . __('Sufix') . ':
						</div>
						<div class="right">
							<textarea name="sufix">' . h($value['sufix']) . '</textarea>
						</div>
						<div class="clear"></div>
					</div>
					<div class="item">
						<div class="left">
							' . __('In new window') . ':
						</div>
						<div class="right">
							<input id="newwin' . $value['id'] . '" type="checkbox" value="1" name="newwin" ' . $checked . ' />
							<label for="newwin' . $value['id'] . '"></lael>
						</div>
						<div class="clear"></div>
					</div>
					
					<div class="item submit">
						<div class="left"></div>
						<div class="right" style="float:left;">
							<input type="submit" value="' . __('Save') . '" name="send" class="save-button" />
						</div>
						<div class="clear"></div>
					</div>
				</div>
				</form>
			</div>';
            $out .= '<ul>' . "\n";
            if (!empty($value['sub']) && is_array($value['sub'])) {
                $out .= buildMenu($value['sub']) . "\n";
            }
            $out .= '<li></li></ul>' . "\n";
            $out .= '</li>';
            $n++;
        }
    }
    return $out;
}
Exemple #20
0
function buildMenu($menu_array, $is_sub = false)
{
    global $id_cnt;
    /*
     * If the supplied array is part of a sub-menu, add the
     * sub-menu class instead of the menu ID for CSS styling
     */
    $attr = $is_sub ? ' class="dd-item"' : ' class="dd-list"';
    $attr = ' class="dd-list"';
    $menu = '<ol ' . $attr . ' >' . "\n";
    // Open the menu container
    /*
     * Loop through the array to extract element values
     */
    foreach ($menu_array as $id => $properties) {
        /*
         * Because each page element is another array, we
         * need to loop again. This time, we save individual
         * array elements as variables, using the array key
         * as the variable name.
         */
        foreach ($properties as $key => $val) {
            /*
             * If the array element contains another array,
             * call the buildMenu() function recursively to
             * build the sub-menu and store it in $sub
             */
            if (is_array($val)) {
                $sub = buildMenu($val, TRUE);
            } else {
                $sub = NULL;
                ${$key} = $val;
            }
        }
        /*
         * If no array element had the key 'url', set the
         * $url variable equal to the containing element's ID
         */
        if (!isset($url)) {
            $url = $id;
        }
        /*
         * Use the created variables to output HTML
         */
        $id_cnt++;
        $menu .= '<li class="dd-item" data-url="' . $url . '" data-id="' . $id_cnt . '" ><div class="dd-handle">' . $display . '</div>' . $sub . '</li>' . "\n";
        /*
         * Destroy the variables to ensure they're reset
         * on each iteration
         */
        unset($url, $display, $sub);
    }
    /*
     * Close the menu container and return the markup for output
     */
    return $menu . '</ul>' . "\n";
}
Exemple #21
0
function buildMenu($items, $currentId = 0, $parent = 0, $level = 2)
{
    $hasChildren = false;
    $childrenHtml = '';
    $outputHtml = '<ul class="level' . $level . '">%s</ul>';
    if ($parent == 0) {
        $outputHtml = '%s';
    }
    foreach ($items as $item) {
        $s = $item['id'] == $currentId ? 'selected' : '';
        if ($item['parent_id'] == $parent) {
            $hasChildren = true;
            $temp = buildMenu($items, $currentId, $item['id'], $item['level'] + 1);
            $c_left = $item['level'] == 1 ? 'left' : '';
            $dropdown = $temp ? 'class="parent ' . $c_left . '"' : '';
            $lv3_li_class = $item['level'] == 3 ? 'class="cat-menu-sub-show"' : '';
            $spanclass = $item['level'] == 1 ? '<span class="menucenter">' : '';
            $endspanclass = $item['level'] == 1 ? '</span>' : '';
            $childrenHtml .= '<li id="cat-menu-' . $item['id'] . '" ' . $dropdown . ' ' . $lv3_li_class . '>' . $spanclass . '<a class="' . $s . '" tabindex="-1" href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id']) . '.html">' . $item['title'] . '</a>' . $endspanclass;
            if ($item['level'] == 2) {
                $childrenHtml .= '<div class="nav-layerSpec">
                                            <div class="nav-menu-col nav-menu-col1"><h3>Danh mục</h3>';
            }
            $childrenHtml .= $temp;
            if ($item['level'] == 2) {
                $childrenHtml .= '
                                            <h3>Sắp xếp</h3>
                                            <ul class="level3">
                                                <li class="cat-menu-sub-show"><a href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id'] . '.html') . '?sortlist=product_new_desc">Mới nhất</a></li>
                                                <li class="cat-menu-sub-show"><a href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id'] . '.html') . '?sortlist=product_sale_desc">Hot nhất</a></li>
                                                <li class="cat-menu-sub-show"><a href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id'] . '.html') . '?sortlist=product_saleoff_desc">Rẻ nhất</a></li>
                                                <li class="cat-menu-sub-show"><a href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id'] . '.html') . '?sortlist=product_sale_buy">Hàng đẹp</a></li>
                                                <li class="cat-menu-sub-show"><a href="' . base_url('p/cat/' . $item['slug'] . '-' . $item['id'] . '.html') . '?sortlist=product_view_desc">Yêu thích</a></li>
                                            </ul>';
                $childrenHtml .= '</div></div>';
            }
            $childrenHtml .= '</li>';
        }
    }
    // Without children, we do not need the <ul> tag.
    if (!$hasChildren) {
        $outputHtml = '';
    }
    // Returns the HTML
    return sprintf($outputHtml, $childrenHtml);
}
Exemple #22
0
});
// Prepare view
$app->view(new \Slim\Views\Twig());
$app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('../app/templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
$app->view->parserExtensions = array(new \Slim\Views\TwigExtension());
// Define routes
$app->get('/', function () use($app) {
    $systemDir = __DIR__ . '/../storage/data/system';
    $snippetsDir = __DIR__ . '/../storage/data/snippets';
    $packageDir = __DIR__ . '/../storage/data/packages';
    $systemFiles = glob($systemDir . '/*.txt');
    $snippetFiles = glob($snippetsDir . '/*.txt');
    $packageFiles = glob($packageDir . '/*.txt');
    $data['system_entries'] = buildMenu($systemFiles);
    $data['snippet_entries'] = buildMenu($snippetFiles);
    $data['package_entries'] = buildMenu($packageFiles);
    $app->render('home.twig', $data);
});
function buildMenu($files)
{
    $menu = array();
    if (!empty($files)) {
        foreach ($files as $file) {
            $dataArray = explode('---', file_get_contents($file));
            // remove spaces
            $dataArray = array_map('trim', $dataArray);
            // don't include items not containing "code" element
            if (empty($dataArray[1])) {
                continue;
            }
            $menu[] = array('name' => $dataArray[0], 'code' => $dataArray[1], 'autorun' => $dataArray[2]);
Exemple #23
0
function buildMenu($parent_id, $menuData)
{
    $html = '';
    if (isset($menuData['parents'][$parent_id])) {
        $html = '<ul>';
        foreach ($menuData['parents'][$parent_id] as $itemId) {
            if ($menuData['items'][$itemId]['page_id'] != 0) {
                $link_page_id = $menuData['items'][$itemId]['page_id'];
                $html .= '<li class="table-look"  id="p' . $menuData['items'][$itemId]['id'] . '">';
                $html .= '<a href="#tabs-' . $menuData['items'][$itemId]['id'] . '"></a>';
                $html .= $menuData['items'][$itemId]['name'];
                $html .= '</a>';
                $html .= "<script> \$(document).ready(function() { \$('.toggle" . $menuData['items'][$itemId]['id'] . "').click(function(){";
                $html .= " \$('div.showhide" . $menuData['items'][$itemId]['id'] . "').toggle(); }); }); </script>";
                $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Edit Navigation Item"><img src="../assets/gfx/sub-icon_black.png" width="15" height="15" style="vertical-align:middle; float:left; padding:3px 5px 5px 5px;"/></a>';
                $html .= '<a class="navDelete" style="right:22%;" href="?moveup_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Up">&#8743;</a>';
                $html .= '<a class="navDelete" style="right:20%;" href="?movedown_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Down">&#8744;</a>';
                $html .= '<span class="navDelete">Page</span>';
                $html .= '</li>';
                $html .= '<div id="edit-nav" class="showhide' . $menuData['items'][$itemId]['id'] . '">';
                $html .= '';
                $html .= '<form name="editNav" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
                $html .= '<label>Navigation Label &nbsp;</label><br />';
                $html .= '<input type="text" name="edit_name" class="inputdesigna" value="' . $menuData['items'][$itemId]['name'] . '"/><br /><br />';
                $html .= '<input type="text" name="edit_id" class="invisible" value="' . $menuData['items'][$itemId]['id'] . '"/>';
                $html .= '</br><i>Page Linked</i> - ';
                $searchid = $menuData['items'][$itemId]['page_id'];
                $query = "SELECT * FROM `page` where id='{$searchid}'";
                $result = mysql_query($query);
                $page_data = mysql_fetch_assoc($result);
                $html .= $page_data['title'];
                $html .= '<br /><br /><br /><input type="submit" name="editNav"  value="Save" class="BUTTONsubmit" accesskey="s" tabindex="15" style="right:2%; bottom:1%;" />';
                $html .= '</br></br> <a style="position:relative; color:#900;" href="?delete_nav_item=' . $menuData['items'][$itemId]['id'];
                $html .= '" title="Delete Navigation Item">Delete</a> | ';
                $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Close Edit">Cancel</a>';
                $html .= '</form>';
                $html .= '</div>';
                // find childitems recursively
                $html .= buildMenu($itemId, $menuData);
            } else {
                if ($menuData['items'][$itemId]['post_id'] != 0) {
                    $link_page_id = $menuData['items'][$itemId]['page_id'];
                    $html .= '<li class="table-look"  id="p' . $menuData['items'][$itemId]['id'] . '">';
                    $html .= '<a href="#tabs-' . $menuData['items'][$itemId]['id'] . '"></a>';
                    $html .= $menuData['items'][$itemId]['name'];
                    $html .= '</a>';
                    $html .= "<script> \$(document).ready(function() { \$('.toggle" . $menuData['items'][$itemId]['id'] . "').click(function(){";
                    $html .= " \$('div.showhide" . $menuData['items'][$itemId]['id'] . "').toggle(); }); }); </script>";
                    $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Edit Navigation Item"><img src="../assets/gfx/sub-icon_black.png" width="15" height="15" style="vertical-align:middle; float:left; padding:3px 5px 5px 5px;"/></a>';
                    $html .= '<a class="navDelete" style="right:22%;" href="?moveup_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Up">&#8743;</a>';
                    $html .= '<a class="navDelete" style="right:20%;" href="?movedown_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Down">&#8744;</a>';
                    $html .= '<span class="navDelete">Post</span>';
                    $html .= '</li>';
                    $html .= '<div id="edit-nav" class="showhide' . $menuData['items'][$itemId]['id'] . '">';
                    $html .= '';
                    $html .= '<form name="editNav" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
                    $html .= '<label>Navigation Label &nbsp;<br /></label>';
                    $html .= '<input type="text" name="edit_name" class="inputdesigna" value="' . $menuData['items'][$itemId]['name'] . '"/><br /><br />';
                    $html .= '<input type="text" name="edit_id" class="invisible" value="' . $menuData['items'][$itemId]['id'] . '"/>';
                    $html .= '</br><i>Page Linked</i> - ';
                    $searchid = $menuData['items'][$itemId]['page_id'];
                    $query = "SELECT * FROM `page` where id='{$searchid}'";
                    $result = mysql_query($query);
                    $page_data = mysql_fetch_assoc($result);
                    $html .= $page_data['title'];
                    $html .= '<br /><br /><br /><input type="submit" name="editNav"  value="Save" class="BUTTONsubmit" accesskey="s" tabindex="15" style="right:2%; bottom:1%;" />';
                    $html .= '</br></br> <a style="position:relative; color:#900;" href="?delete_nav_item=' . $menuData['items'][$itemId]['id'];
                    $html .= '" title="Delete Navigation Item">Delete</a> | ';
                    $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Close Edit">Cancel</a>';
                    $html .= '</form>';
                    $html .= '</div>';
                    // find childitems recursively
                    $html .= buildMenu($itemId, $menuData);
                } else {
                    $link_page_id = $menuData['items'][$itemId]['page_id'];
                    $html .= '<li class="table-look"  id="p' . $menuData['items'][$itemId]['id'] . '">';
                    $html .= '<a href="#tabs-' . $menuData['items'][$itemId]['id'] . '"></a>';
                    $html .= $menuData['items'][$itemId]['name'];
                    $html .= '</a>';
                    $html .= "<script> \$(document).ready(function() { \$('.toggle" . $menuData['items'][$itemId]['id'] . "').click(function(){";
                    $html .= " \$('div.showhide" . $menuData['items'][$itemId]['id'] . "').toggle(); }); }); </script>";
                    $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Edit Navigation Item"><img src="../assets/gfx/sub-icon_black.png" width="15" height="15" style="vertical-align:middle; float:left; padding:3px 5px 5px 5px;"/></a>';
                    $html .= '<a class="navDelete" style="right:22%;" href="?moveup_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Up">&#8743;</a>';
                    $html .= '<a class="navDelete" style="right:20%;" href="?movedown_id=' . $menuData['items'][$itemId]['id'] . '" 
							title="Move Down">&#8744;</a>';
                    $html .= '<span class="navDelete">Custom</span>';
                    $html .= '</li>';
                    $html .= '<div id="edit-nav" class="showhide' . $menuData['items'][$itemId]['id'] . '">';
                    $html .= '';
                    $html .= '<form name="editNav" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
                    $html .= '<label>Navigation Label &nbsp;<br /></label>';
                    $html .= '<input type="text" name="edit_name" class="inputdesigna" value="' . $menuData['items'][$itemId]['name'] . '"/><br /><br />';
                    $html .= '<input type="text" name="edit_id" class="invisible" value="' . $menuData['items'][$itemId]['id'] . '"/>';
                    $html .= '</br><label><i>URL</i></label> - ';
                    $html .= '<input type="text" name="edit_url" class="inputdesignb" style="color:#1d1d1d;" value="' . $menuData['items'][$itemId]['link'] . '"/>';
                    $html .= '<br /><br /><br /><input type="submit" name="editNav"  value="Save" class="BUTTONsubmit" accesskey="s" tabindex="15" style="right:2%; bottom:1%;" />';
                    $html .= '</br></br> <a style="position:relative; color:#900;" href="?delete_nav_item=' . $menuData['items'][$itemId]['id'];
                    $html .= '" title="Delete Navigation Item">Delete</a> | ';
                    $html .= '<a href="#" class="toggle' . $menuData['items'][$itemId]['id'] . '" 
							title="Close Edit">Cancel</a>';
                    $html .= '</form>';
                    $html .= '</div>';
                    // find childitems recursively
                    $html .= buildMenu($itemId, $menuData);
                }
            }
        }
        $html .= '</ul>';
    }
    return $html;
}