/** * Parse navigation bar * * @param boolean $force * @ignore */ function parse_navbar($force = false) { $tpl = createobject('phpgwapi.Template', PHPGW_TEMPLATE_DIR); $tpl->set_unknowns('remove'); $tpl->set_file('navbar', 'navbar.tpl'); $tpl->set_block('navbar', 'app_row', 'app_rows'); $var['api_root'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/probusiness/'; /* * folder handling */ if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $mtree = createobject('folders.uifolders', ''); $var['switchlink'] = $mtree->get_switchlink(); $folderMode = $mtree->get_folderMode(); } if (false) { if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $var['navbarview'] = $mtree->get_iframe(); } } else { /* * application list */ $navbar = execMethod('phpgwapi.menu.get', 'navbar'); prepare_navbar($navbar); foreach ($navbar as $app => $app_data) { if ($app == 'logout') { if (isset($GLOBALS['phpgw_info']['user']['apps']['manual'])) { $tpl->set_var(array('url' => "javascript:openwindow('" . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'manual.uimanual.help', 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'], 'section' => isset($GLOBALS['phpgw_info']['apps']['manual']['section']) ? $GLOBALS['phpgw_info']['apps']['manual']['section'] : '', 'referer' => phpgw::get_var('menuaction'))) . "','700','600')", 'text' => lang('help'), 'image' => $GLOBALS['phpgw']->common->image('manual', 'navbar'))); } $tpl->parse('app_rows', 'app_row', true); } if ($app == $GLOBALS['phpgw_info']['flags']['currentapp']) { $app_data['class'] = ' class="selectedNavLink"'; } $app_data['image'] = $GLOBALS['phpgw']->common->image($app_data['image'][0], $app_data['image'][1]); $tpl->set_var($app_data); $tpl->parse('app_rows', 'app_row', true); } } // get sidebox content and parse it as a menu // it's just a hack. You need to enable the folders module to get an ouput if ($GLOBALS['phpgw_info']['user']['apps']['folders']['enabled'] == true) { $GLOBALS['phpgw']->hooks->single('sidebox_menu', $GLOBALS['phpgw_info']['flags']['currentapp']); $var['sideboxcontent'] = parseMenu(); } if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) { $var['current_users'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uicurrentsessions.list_sessions')) . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; } if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == 0) { $api_messages = lang('You are required to change your password during your first login') . '<br> Click this image on the navbar: <img src="' . $GLOBALS['phpgw']->common->image('preferences', 'navbar.gif') . '">'; } elseif ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - 86400 * 30) { $api_messages = lang('it has been more then %1 days since you changed your password', 30); } // This gonna change if (isset($cd)) { $var['messages'] = $api_messages . '<br>' . checkcode($cd); } if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) { $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; } $tpl->set_var($var); $tpl->pfp('out', 'navbar'); // If the application has a header include, we now include it if (!@$GLOBALS['phpgw_info']['flags']['noappheader'] && @isset($_GET['menuaction'])) { list($app, $class, $method) = explode('.', $_GET['menuaction']); if (is_array($GLOBALS[$class]->public_functions) && isset($GLOBALS[$class]->public_functions['header']) && $GLOBALS[$class]->public_functions['header']) { $GLOBALS[$class]->header(); } } $GLOBALS['phpgw']->hooks->process('after_navbar'); }
function parseMenu($level, $under) { global $db, $i, $login_access; ++$i; $resultname = "result{$i}"; $resultcheck = "resultcheck{$i}"; $rowcheck = "rowcheck{$i}"; $strSQL = "SELECT * from tbl_menu WHERE ((level={$level}) and (referensi={$under})) order by bobot asc"; ${$resultname} = $db->Execute($strSQL); if (!${$resultname}) { print $db > ErrorMsg(); } if ($level > 0) { echo "<ul>"; } // Display Query while ($row = ${$resultname}->FetchRow()) { $id = $row['id']; $nomorurut = $row['nomorurut']; $level = $row['level']; $referensi = $row['referensi']; $judul = $row['judul']; $url = $row['url']; $target = $row['target']; $keterangan = $row['keterangan']; $sql = "select read_priv from tbl_functionaccess where name='{$login_access}' and menu_id='{$nomorurut}'"; ${$resultcheck} = $db->Execute($sql); if (!${$resultcheck}) { print $db->ErrorMsg(); } $rowcheck = ${$resultcheck}->FetchRow(); $fua_read = $rowcheck['read_priv']; if ($fua_read == '1') { unset($_target, $_url_1, $_url_2); if ($target) { $_target = " target=\"{$target}\" "; } if ($url) { if ($judul == 'Log Out') { $type = 'iconCls="icon-no"'; } elseif ($judul == 'Ganti Password') { $type = 'iconCls="icon-pencil"'; } if ($judul == 'Log Out') { $_url_1 = "<span><a href=\"{$url}\" title=\"{$keterangan}\" target=\"_top\">"; $_url_2 = "</a></span>"; } else { $_url_1 = "<span><a href=# title=\"{$keterangan}\" onclick=\"addTab('{$judul}','{$url}')\">"; $_url_2 = "</a></span>"; } } else { $_url_1 = "<span>"; $_url_2 = "</span>"; } if ($level == 0) { $judul = "<b>{$judul}</b>"; } if (!$url) { echo "<li data-options=\"state:'closed'\">{$_url_1} {$judul} {$_url_2}"; } else { echo "<li {$type}>{$_url_1} {$judul} {$_url_2}"; } } ++$j; $resultname2 = "result2level{$j}"; $checklevel = $level + 1; $strSQL = "SELECT * from tbl_menu WHERE level={$checklevel} and referensi={$nomorurut}"; ${$resultname2} = $db->Execute($strSQL); if (!${$resultname2}) { print $db->ErrorMsg(); } if (${$resultname2}->RecordCount() > 0) { parseMenu($checklevel, $nomorurut); } if ($fua_read == '1') { echo "</li>\n"; } } if ($level > 0) { echo "</ul>\n"; } }
function parseMenu($level, $under) { global $db, $i, $login_access, $menu_output; ++$i; $resultname = "result{$i}"; $resultcheck = "resultcheck{$i}"; $rowcheck = "rowcheck{$i}"; $strSQL = "SELECT * from tbl_menu WHERE ((level={$level}) and (referensi={$under})) order by bobot asc"; ${$resultname} = $db->Execute($strSQL); if (!${$resultname}) { print $db > ErrorMsg(); } $menu_output .= "["; // Display Query while ($row = ${$resultname}->FetchRow()) { $id = $row['id']; $nomorurut = $row['nomorurut']; $level = $row['level']; $referensi = $row['referensi']; $judul = $row['judul']; $url = $row['url']; $target = $row['target']; $sql = "select read_priv from tbl_functionaccess where name='{$login_access}' and menu_id='{$nomorurut}'"; ${$resultcheck} = $db->Execute($sql); if (!${$resultcheck}) { print $db->ErrorMsg(); } $rowcheck = ${$resultcheck}->FetchRow(); $fua_read = $rowcheck['read_priv']; if ($fua_read == '1') { unset($_target, $_url_1, $_url_2); //if ($target) $_target = "\"target\": \"$target\", "; if ($url) { if ($judul == 'Log Out') { $type = 'logout'; } elseif ($judul == 'Ganti Password') { $type = 'password'; } else { $type = 'file'; } $_url = "\"attributes\":{\"url\": \"{$url}\"}, "; } else { $_url = ""; } $_judul = "\"text\": \"{$judul}\", "; $_state = "\"state\": \"close\", "; $menu_output .= substr("{" . $_judul . $_state . $_target . $_url, 0, -2); } ++$j; $resultname2 = "result2level{$j}"; $checklevel = $level + 1; $strSQL = "SELECT * from tbl_menu WHERE level={$checklevel} and referensi={$nomorurut}"; ${$resultname2} = $db->Execute($strSQL); if (!${$resultname2}) { print $db->ErrorMsg(); } if (${$resultname2}->RecordCount() > 0) { $menu_output .= ", \"children\": "; parseMenu($checklevel, $nomorurut); } if ($fua_read == '1') { $menu_output .= "}, "; } } $menu_output = substr($menu_output, 0, -2); $menu_output .= "]\n"; }
$strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parseSetting($intElmntId, $strCommand); break; case NAV_PCMS_LANGUAGES: require_once 'includes/inc.tplparse_language.php'; $strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parseLanguage($intElmntId, $strCommand); break; case NAV_PCMS_HELP: require_once 'includes/inc.tplparse_help.php'; $strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parseHelp($intElmntId, $strCommand); break; case NAV_PCMS_SEARCH: require_once 'includes/inc.tplparse_search.php'; $strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parseSearch($intElmntId, $strCommand); break; case NAV_PCMS_ELEMENTS: require_once 'includes/inc.tplparse_element.php'; $strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parsePages($intElmntId, $strCommand); break; default: $strOutput .= parseMenu($intCatId, $strCommand); $strOutput .= parseUndefined($intCatId, $strCommand); } //*** Parse the HTML Footer. $strOutput .= parseFooter(); echo $strOutput; //echo "<br /><br />Execution time: " . (microtime(true) - $start);