source-function-F_menu_link

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

 1: <?php
 2: //============================================================+
 3: // File name   : tce_functions_menu.php
 4: // Begin       : 2001-09-08
 5: // Last Update : 2010-09-16
 6: //
 7: // Description : Functions for Web menu.
 8: //
 9: // Author: Nicola Asuni
10: //
11: // (c) Copyright:
12: //               Nicola Asuni
13: //               Tecnick.com LTD
14: //               www.tecnick.com
15: //               info@tecnick.com
16: //
17: // License:
18: //    Copyright (C) 2004-2010 Nicola Asuni - Tecnick.com LTD
19: //    See LICENSE.TXT file for more information.
20: //============================================================+
21: 
22: /**
23:  * @file
24:  * Functions for Web menu.
25:  * @package com.tecnick.tcexam.shared
26:  * @author Nicola Asuni
27:  * @since 2010-09-16
28:  */
29: 
30: /**
31:  * Returns a menu element link wit subitems.
32:  * If the link refers to the current page, only the name will be returned.
33:  * @param $link (string) URL
34:  * @param $data (array) link data
35:  * @param $level (int) item level
36:  */
37: function F_menu_link($link, $data, $level = 0)
38: {
39:     global $l, $db;
40:     require_once('../config/tce_config.php');
41:     if (!$data['enabled'] or ($_SESSION['session_user_level'] < $data['level'])) {
42:         // this item is disabled
43:         return;
44:     }
45:     $str = '<li>';
46:     if ($link != basename($_SERVER['SCRIPT_NAME'])) {
47:         $str .= '<a href="'.$data['link'].'" title="'.$data['title'].'"';
48:         if (!empty($data['key'])) {
49:             $str .= ' accesskey="'.$data['key'].'"';
50:         }
51:         if (F_menu_isChildActive($data)) {
52:             $str .= ' class="active"';
53:         }
54:         $str .= '>'.$data['name'].'</a>';
55:     } else {
56:         // active link
57:         $str .= '<span class="active">'.$data['name'].'</span>';
58:     }
59:     if (isset($data['sub']) and !empty($data['sub'])) {
60:         // print sub-items
61:         $sublevel = ($level + 1);
62:         $str .= K_NEWLINE.'<!--[if lte IE 6]><iframe class="menu"></iframe><![endif]-->'.K_NEWLINE;
63:         $str .= '<ul>'.K_NEWLINE;
64:         foreach ($data['sub'] as $sublink => $subdata) {
65:             $str .= F_menu_link($sublink, $subdata, $sublevel);
66:         }
67:         $str .= '</ul>'.K_NEWLINE;
68:     }
69:     $str .= '</li>'.K_NEWLINE;
70:     return $str;
71: }
72: 
73: /**
74:  * Returns true if the menu item has an active child, false otherwise.
75:  * @param $data (array) link data
76:  */
77: function F_menu_isChildActive($data)
78: {
79:     if (isset($data['sub']) and !empty($data['sub'])) {
80:         if (array_key_exists(basename($_SERVER['SCRIPT_NAME']), $data['sub'])) {
81:             // key found
82:             return true;
83:         } else {
84:             // try sub-trees
85:             foreach ($data['sub'] as $submenu) {
86:                 if (F_menu_isChildActive($submenu)) {
87:                     return true;
88:                 }
89:             }
90:         }
91:     }
92:     return false;
93: }
94: 
95: //============================================================+
96: // END OF FILE
97: //============================================================+
98: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy