mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
www: introduce automatic breadcrumbs
This way, every time we touch our Menu.xml the page's breadcrumbs are automatically switched. :) While there, clean the old $pgtitle setup so all of them translate properly. They are still used for the menu bar title, that will require more effort to unfold. Stay tuned. @adschellevis if this is not the correct way to do it feel free to refactor the MVC parts.
This commit is contained in:
parent
e955045cc8
commit
4788e5616c
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
*
|
||||
@ -114,4 +115,29 @@ class MenuSystem
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the currently selected page's breadcrumbs
|
||||
* @return array
|
||||
*/
|
||||
public function getBreadcrumbs()
|
||||
{
|
||||
$nodes = $this->root->getChildren();
|
||||
$breadcrumbs = array();
|
||||
|
||||
while ($nodes != null) {
|
||||
$next = null;
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->Selected) {
|
||||
$breadcrumbs[] = array('name' => $node->VisibleName);
|
||||
/* only go as far as the first reachable URL */
|
||||
$next = empty($node->Url) ? $node->Children : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$nodes = $next;
|
||||
}
|
||||
|
||||
return $breadcrumbs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<packagegui>
|
||||
<title>Services: Universal Plug and Play: Settings</title>
|
||||
<name>miniupnpd</name>
|
||||
<version>20100712</version>
|
||||
<service>
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
|
||||
$pgtitle = gettext("Diagnostics: Limiter Info");
|
||||
$pgtitle = array(gettext('Diagnostics'), gettext('Limiter Info'));
|
||||
$shortcut_section = "trafficshaper-limiters";
|
||||
|
||||
if(isset($_POST['getactivity'])) {
|
||||
|
||||
@ -48,7 +48,6 @@ if (isset($_POST['filtertext'])) {
|
||||
$filtertext = htmlspecialchars($_POST['filtertext']);
|
||||
}
|
||||
|
||||
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("PPP"));
|
||||
include("head.inc");
|
||||
|
||||
?>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 Deciso B.V.
|
||||
Copyright (C) 2010 Scott Ullrich
|
||||
@ -28,7 +29,7 @@
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
|
||||
$pgtitle = gettext("Diagnostics: pfInfo");
|
||||
$pgtitle = array(gettext('Diagnostics'), gettext('pfInfo'));
|
||||
$data_tabs = array("info", "memory", "timeouts", "interfaces", "rules");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
|
||||
$pgtitle = gettext("Diagnostics: System Activity");
|
||||
$pgtitle = array(gettext('Diagnostics'), gettext('System Activity'));
|
||||
|
||||
if($_REQUEST['getactivity']) {
|
||||
$text = `/usr/bin/top -aHS | /usr/bin/cut -c1-105`;
|
||||
|
||||
@ -52,7 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
exit;
|
||||
}
|
||||
|
||||
$pgtitle = gettext("Diagnostics: pfTop");
|
||||
$pgtitle = array(gettext('Diagnostics'), gettext('pfTop'));
|
||||
include("head.inc");
|
||||
?>
|
||||
<body>
|
||||
|
||||
@ -87,6 +87,7 @@ foreach ($ifarr as $key => $descr) {
|
||||
}
|
||||
unset($ifarr);
|
||||
$menuSystem = $menu->getItems($_SERVER['REQUEST_URI']);
|
||||
$menuBreadcrumbs = $menu->getBreadcrumbs();
|
||||
|
||||
$aclObj = new \OPNsense\Core\ACL();
|
||||
|
||||
@ -223,7 +224,7 @@ if($need_alert_display == true) {
|
||||
<div class="container-fluid">
|
||||
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
|
||||
<ul class="list-inline">
|
||||
<li class="__mb"><h1><?=gentitle($pgtitle);?></h1></li>
|
||||
<li class="__mb"><h1><?= gentitle(count($menuBreadcrumbs) ? $menuBreadcrumbs : $pgtitle) ?></h1></li>
|
||||
|
||||
<li class="btn-group-container">
|
||||
|
||||
|
||||
@ -297,12 +297,19 @@ function pprint_port($port) {
|
||||
return $pport;
|
||||
}
|
||||
|
||||
function gentitle($title) {
|
||||
$navlevelsep = ": "; /* navigation level separator string */
|
||||
if(!is_array($title))
|
||||
return $title;
|
||||
else
|
||||
return join($navlevelsep, $title);
|
||||
function gentitle($breadcrumbs)
|
||||
{
|
||||
$navlevelsep = ': ';
|
||||
$output = $breadcrumbs;
|
||||
|
||||
if (isset($breadcrumbs[0]['name'])) {
|
||||
$output = array();
|
||||
foreach ($breadcrumbs as $crumb) {
|
||||
$output[] = gettext($crumb['name']);
|
||||
}
|
||||
}
|
||||
|
||||
return join($navlevelsep, $output);
|
||||
}
|
||||
|
||||
function clear_log($logfile, $restart_syslogd = true)
|
||||
|
||||
@ -16,7 +16,7 @@ function system_get_language_code() {
|
||||
|
||||
$g['theme'] = get_current_theme();
|
||||
|
||||
$pagetitle = gentitle( $pgtitle );
|
||||
$pagetitle = gentitle( $pgtitle ); /* XXX zap me */
|
||||
|
||||
?><!doctype html>
|
||||
<!--[if IE 8 ]><html lang="<?=system_get_language_code();?>" class="ie ie8 lte9 lte8 no-js"><![endif]-->
|
||||
|
||||
@ -137,9 +137,7 @@ global $listtags;
|
||||
$listtags = array_flip(array('build_port_path', 'onetoone', 'queue', 'rule', 'servernat', 'alias', 'additional_files_needed', 'tab', 'menu', 'rowhelperfield', 'service', 'step', 'package', 'columnitem', 'option', 'item', 'field', 'package', 'file'));
|
||||
$pkg = parse_xml_config_raw('/usr/local/pkg/miniupnpd.xml', 'packagegui', false);
|
||||
|
||||
$name = $pkg['name'];
|
||||
$title = $pkg['title'];
|
||||
$pgtitle = $title;
|
||||
$pgtitle = array(gettext('Services'), gettext('Universal Plug and Play'), gettext('Settings'));
|
||||
|
||||
if($config['installedpackages'] && !is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']))
|
||||
$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'] = array();
|
||||
@ -513,73 +511,6 @@ include("head.inc");
|
||||
<?php include("foot.inc"); ?>
|
||||
|
||||
<?php
|
||||
/*
|
||||
* ROW Helpers function
|
||||
*/
|
||||
function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) {
|
||||
global $text, $config;
|
||||
echo "<td>\n";
|
||||
switch($type){
|
||||
case "input":
|
||||
echo "<input size='{$size}' name='{$fieldname}{$trc}' id='{$fieldname}{$trc}' class='formfld unknown' type='text' value=\"" . htmlspecialchars($value) . "\" />\n";
|
||||
break;
|
||||
case "checkbox":
|
||||
echo "<input size='{$size}' type='checkbox' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' value='ON' ".($value?"CHECKED":"")." />\n";
|
||||
break;
|
||||
case "password":
|
||||
echo "<input size='{$size}' type='password' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' class='formfld pwd' value=\"" . htmlspecialchars($value) . "\" />\n";
|
||||
break;
|
||||
case "textarea":
|
||||
echo "<textarea rows='2' cols='12' id='{$fieldname}{$trc}' class='formfld unknown' name='{$fieldname}{$trc}'>{$value}</textarea>\n";
|
||||
case "select":
|
||||
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$title}>\n";
|
||||
foreach($rowhelper['options']['option'] as $rowopt) {
|
||||
$text .= "<option value='{$rowopt['value']}'>{$rowopt['name']}</option>";
|
||||
echo "<option value='{$rowopt['value']}'".($rowopt['value'] == $value?" selected=\"selected\"":"").">{$rowopt['name']}</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
break;
|
||||
case "interfaces_selection":
|
||||
$size = ($size ? "size=\"{$size}\"" : '');
|
||||
$multiple = '';
|
||||
if (isset($rowhelper['multiple'])) {
|
||||
$fieldname .= '[]';
|
||||
$multiple = "multiple=\"multiple\"";
|
||||
}
|
||||
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$size} {$multiple}>\n";
|
||||
$ifaces = get_configured_interface_with_descr();
|
||||
$additional_ifaces = $rowhelper['add_to_interfaces_selection'];
|
||||
if (!empty($additional_ifaces))
|
||||
$ifaces = array_merge($ifaces, explode(',', $additional_ifaces));
|
||||
if(is_array($value))
|
||||
$values = $value;
|
||||
else
|
||||
$values = explode(',', $value);
|
||||
$ifaces["lo0"] = "loopback";
|
||||
echo "<option><name></name><value></value></option>/n";
|
||||
foreach($ifaces as $ifname => $iface) {
|
||||
$text .="<option value=\"{$ifname}\">$iface</option>";
|
||||
echo "<option value=\"{$ifname}\" ".(in_array($ifname, $values) ? 'selected="selected"' : '').">{$iface}</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
break;
|
||||
case "select_source":
|
||||
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}'>\n";
|
||||
if(isset($rowhelper['show_disable_value']))
|
||||
echo "<option value='{$rowhelper['show_disable_value']}'>{$rowhelper['show_disable_value']}</option>\n";
|
||||
$source_url = $rowhelper['source'];
|
||||
eval("\$pkg_source_txt = &$source_url;");
|
||||
foreach($pkg_source_txt as $opt) {
|
||||
$source_name = ($rowhelper['source_name'] ? $opt[$rowhelper['source_name']] : $opt[$rowhelper['name']]);
|
||||
$source_value = ($rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']]);
|
||||
$text .= "<option value='{$source_value}'>{$source_name}</option>";
|
||||
echo "<option value='{$source_value}'".($source_value == $value?" selected=\"selected\"":"").">{$source_name}</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
break;
|
||||
}
|
||||
echo "</td>\n";
|
||||
}
|
||||
|
||||
function fixup_string($string) {
|
||||
global $config;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user