summaryrefslogtreecommitdiff
path: root/includes/sys_menu.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-28 16:21:10 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-28 17:34:00 +0200
commit73175e2b64c85c7a8c528c76452cd82ffa99f925 (patch)
tree7464fe30c04fe245424646a98cfd6247d060e517 /includes/sys_menu.php
parente1762e7764d4ee4f37757ecd2630f62a440dbf0e (diff)
#337: Added routing
Diffstat (limited to 'includes/sys_menu.php')
-rw-r--r--includes/sys_menu.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index f160441c..f809be0b 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -1,28 +1,32 @@
<?php
+
use Engelsystem\UserHintsRenderer;
/**
* @param string $page
+ * @param array $parameters get parameters
* @return string
*/
-function page_link_to($page = '')
+function page_link_to($page = '', $parameters = [])
{
- if ($page == '') {
- return '?';
- }
- return '?p=' . $page;
+ $parameters = http_build_query($parameters);
+ $page = ltrim($page, '/');
+ $page = str_replace('_', '-', $page);
+ return '/' . $page . (!empty($parameters) ? '?' . $parameters : '');
}
/**
+ * @TODO: remove?
* @param string $page
+ * @param array $parameters get parameters
* @return string
*/
-function page_link_to_absolute($page)
+function page_link_to_absolute($page, $parameters = [])
{
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
. $_SERVER['HTTP_HOST']
. preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI'])
- . page_link_to($page);
+ . page_link_to($page, $parameters);
}
/**
@@ -65,7 +69,7 @@ function header_toolbar()
if (isset($user)) {
$toolbar_items[] = toolbar_item_link(
- page_link_to('shifts') . '&amp;action=next',
+ page_link_to('shifts', ['action' => 'next']),
'time',
User_shift_state_render($user)
);
@@ -86,7 +90,7 @@ function header_toolbar()
$toolbar_items[] = header_render_hints();
if (in_array('user_myshifts', $privileges)) {
$toolbar_items[] = toolbar_item_link(
- page_link_to('users') . '&amp;action=view',
+ page_link_to('users', ['action' => 'view']),
' icon-icon_angel',
$user['Nick'],
$page == 'users'