diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
commit | 9e217d87c095170460a8580d5215ddf7cbe639f4 (patch) | |
tree | 3b426fe52e70ef0f1395edcb354f1be4788ca329 /includes | |
parent | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff) |
Template refactoring to use twig
Diffstat (limited to 'includes')
-rw-r--r-- | includes/sys_menu.php | 111 | ||||
-rw-r--r-- | includes/sys_template.php | 12 | ||||
-rw-r--r-- | includes/view/EventConfig_view.php | 51 |
3 files changed, 20 insertions, 154 deletions
diff --git a/includes/sys_menu.php b/includes/sys_menu.php index bb6965ea..ca2ab411 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -41,69 +41,6 @@ function header_render_hints() } /** - * Renders the header toolbar containing search, login/logout, user and settings links. - * - * @return string - */ -function header_toolbar() -{ - global $page, $privileges, $user; - - $toolbar_items = []; - - if (isset($user)) { - $toolbar_items[] = toolbar_item_link( - page_link_to('shifts', ['action' => 'next']), - 'time', - User_shift_state_render($user) - ); - } - - if (!isset($user) && in_array('register', $privileges) && config('registration_enabled')) { - $toolbar_items[] = toolbar_item_link( - page_link_to('register'), - 'plus', - register_title(), - $page == 'register' - ); - } - - if (in_array('login', $privileges)) { - $toolbar_items[] = toolbar_item_link( - page_link_to('login'), - 'log-in', - login_title(), - $page == 'login' - ); - } - - if (isset($user) && in_array('user_messages', $privileges)) { - $toolbar_items[] = toolbar_item_link( - page_link_to('user_messages'), - 'envelope', - user_unread_messages() - ); - } - - $toolbar_items[] = header_render_hints(); - if (in_array('user_myshifts', $privileges)) { - $toolbar_items[] = toolbar_item_link( - page_link_to('users', ['action' => 'view']), - ' icon-icon_angel', - $user['Nick'], - $page == 'users' - ); - } - - $user_submenu = make_user_submenu(); - if (count($user_submenu) > 0) { - $toolbar_items[] = toolbar_dropdown('', '', $user_submenu); - } - - return toolbar($toolbar_items, true); -} - -/** * @return array */ function make_user_submenu() @@ -120,7 +57,7 @@ function make_user_submenu() $user_submenu[] = toolbar_item_link( page_link_to('user_settings'), 'list-alt', - settings_title(), + __('Settings'), $page == 'user_settings' ); } @@ -129,7 +66,7 @@ function make_user_submenu() $user_submenu[] = toolbar_item_link( page_link_to('logout'), 'log-out', - logout_title(), + __('Logout'), $page == 'logout' ); } @@ -146,11 +83,11 @@ function make_navigation() $menu = []; $pages = [ - 'news' => news_title(), - 'user_meetings' => meetings_title(), - 'user_shifts' => shifts_title(), - 'angeltypes' => angeltypes_title(), - 'user_questions' => questions_title() + 'news' => __('News'), + 'user_meetings' => __('Meetings'), + 'user_shifts' => __('Shifts'), + 'angeltypes' => __('Angeltypes'), + 'user_questions' => __('Ask the Heaven'), ]; foreach ($pages as $menu_page => $title) { @@ -163,18 +100,18 @@ function make_navigation() $admin_menu = []; $admin_pages = [ - 'admin_arrive' => admin_arrive_title(), - 'admin_active' => admin_active_title(), - 'admin_user' => admin_user_title(), - 'admin_free' => admin_free_title(), - 'admin_questions' => admin_questions_title(), - 'shifttypes' => shifttypes_title(), - 'admin_shifts' => admin_shifts_title(), - 'admin_rooms' => admin_rooms_title(), - 'admin_groups' => admin_groups_title(), - 'admin_import' => admin_import_title(), - 'admin_log' => admin_log_title(), - 'admin_event_config' => event_config_title() + 'admin_arrive' => __('Arrived angels'), + 'admin_active' => __('Active angels'), + 'admin_user' => __('All Angels'), + 'admin_free' => __('Free angels'), + 'admin_questions' => __('Answer questions'), + 'shifttypes' => __('Shifttypes'), + 'admin_shifts' => __('Create shifts'), + 'admin_rooms' => __('Rooms'), + 'admin_groups' => __('Grouprights'), + 'admin_import' => __('Frab import'), + 'admin_log' => __('Log'), + 'admin_event_config' => __('Event config'), ]; foreach ($admin_pages as $menu_page => $title) { @@ -192,7 +129,7 @@ function make_navigation() $menu[] = toolbar_dropdown('', __('Admin'), $admin_menu); } - return toolbar($menu); + return '<ul class="nav navbar-nav">' . join("\n", $menu) . '</ul>'; } /** @@ -250,11 +187,3 @@ function make_language_select() } return $items; } - -/** - * @return string - */ -function make_menu() -{ - return make_navigation(); -} diff --git a/includes/sys_template.php b/includes/sys_template.php index 8c260140..52578f18 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -148,18 +148,6 @@ function heading($content, $number = 1) } /** - * Render a toolbar. - * - * @param array $items - * @param bool $right - * @return string - */ -function toolbar($items = [], $right = false) -{ - return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>'; -} - -/** * @param string[] $items * @return string */ diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index 2525182a..4290ab0a 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -61,57 +61,6 @@ function EventConfig_countdown_page($event_config) } /** - * Converts event name and start+end date into a line of text. - * - * @param array $event_config - * @return string - */ -function EventConfig_info($event_config) -{ - if (empty($event_config)) { - return ''; - } - - // Event name, start+end date are set - if ( - !is_null($event_config['event_name']) - && !is_null($event_config['event_start_date']) - && !is_null($event_config['event_end_date']) - ) { - return sprintf( - __('%s, from %s to %s'), - $event_config['event_name'], - date(__('Y-m-d'), $event_config['event_start_date']), - date(__('Y-m-d'), $event_config['event_end_date']) - ); - } - - // Event name, start date are set - if (!is_null($event_config['event_name']) && !is_null($event_config['event_start_date'])) { - return sprintf( - __('%s, starting %s'), $event_config['event_name'], - date(__('Y-m-d'), $event_config['event_start_date']) - ); - } - - // Event start+end date are set - if (!is_null($event_config['event_start_date']) && !is_null($event_config['event_end_date'])) { - return sprintf( - __('Event from %s to %s'), - date(__('Y-m-d'), $event_config['event_start_date']), - date(__('Y-m-d'), $event_config['event_end_date']) - ); - } - - // Only event name is set - if (!is_null($event_config['event_name'])) { - return sprintf($event_config['event_name']); - } - - return ''; -} - -/** * Render edit page for event config. * * @param string $event_name The event name |