.
/**
* Layout API
*
* UI functions to render layout elements in every page. The layout api layer sits above the html api and abstract
* the lower level html markup into web components
*
* Here is the call order for the layout functions
*
* layout_page_header
* layout_page_header_begin
* layout_page_header_end
* layout_page_begin
* ...Page content here...
* layout_page_end
*
*
*
* @package CoreAPI
* @subpackage LayoutAPI
* @copyright Copyright 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses access_api.php
* @uses utility_api.php
*/
require_api( 'access_api.php' );
require_api( 'utility_api.php' );
/**
* Print the page header section
* @param string $p_page_title Html page title.
* @param string $p_redirect_url URL to redirect to if necessary.
* @param string $p_page_id The page id.
* @return void
*/
function layout_page_header( $p_page_title = null, $p_redirect_url = null, $p_page_id = null ) {
layout_page_header_begin( $p_page_title );
if( $p_redirect_url !== null ) {
html_meta_redirect( $p_redirect_url );
}
layout_page_header_end( $p_page_id );
}
/**
* Print the part of the page that comes before meta redirect tags should be inserted
* @param string $p_page_title Page title.
* @return void
*/
function layout_page_header_begin( $p_page_title = null ) {
html_begin();
html_head_begin();
html_content_type();
global $g_robots_meta;
if( !is_blank( $g_robots_meta ) ) {
echo "\t", '', "\n";
}
html_title( $p_page_title );
layout_head_meta();
html_css();
layout_head_css();
html_rss_link();
$t_favicon_image = config_get( 'favicon_image' );
if( !is_blank( $t_favicon_image ) ) {
echo "\t", '', "\n";
}
# Advertise the availability of the browser search plug-ins.
$t_title = config_get( 'search_title' );
$t_searches = array( 'text', 'id' );
foreach( $t_searches as $t_type ) {
echo "\t",
'',
"\n";
}
html_head_javascript();
}
/**
* Print the part of the page that comes after meta tags and before the
* actual page content, but without login info or menus. This is used
* directly during the login process and other times when the user may
* not be authenticated
*
* @param string $p_page_id The id of the page.
*
* @return void
*/
function layout_page_header_end( $p_page_id = null) {
global $g_error_send_page_header;
event_signal( 'EVENT_LAYOUT_RESOURCES' );
html_head_end();
if ( $p_page_id === null ) {
$t_body_id = '';
} else {
$t_body_id = 'id="' . $p_page_id . '" ';
}
# Add right-to-left css if needed
if( layout_is_rtl() ) {
echo '
', "\n";
} else {
echo '', "\n";
}
event_signal( 'EVENT_LAYOUT_BODY_BEGIN' );
$g_error_send_page_header = false;
}
/**
* Print page common elements including navbar, sidebar, info bar
* @param string $p_active_sidebar_page sidebar page where the current page lives under
* @return void
*/
function layout_page_begin( $p_active_sidebar_page = null ) {
layout_navbar();
if( !db_is_connected() ) {
return;
}
layout_main_container_begin();
layout_print_sidebar( $p_active_sidebar_page );
layout_main_content_begin();
layout_breadcrumbs();
layout_page_content_begin();
if( auth_is_user_authenticated() ) {
if( ON == config_get( 'show_project_menu_bar' ) ) {
echo '
' , "\n";
print_project_menu_bar();
echo '
' , "\n";
}
}
echo '
' , "\n";
event_signal( 'EVENT_LAYOUT_CONTENT_BEGIN' );
}
/**
* Print elements at the end of each page
* @return void
*/
function layout_page_end() {
if( !db_is_connected() ) {
return;
}
event_signal( 'EVENT_LAYOUT_CONTENT_END' );
echo '
' , "\n";
layout_page_content_end();
layout_main_content_end();
layout_footer();
layout_scroll_up_button();
layout_main_container_end();
layout_body_javascript();
html_body_end();
html_end();
}
/**
* Print common elements for admin pages
* @return void
*/
function layout_admin_page_begin() {
layout_navbar();
layout_main_container_begin();
}
/**
* Print elements at the end of each admin page
* @return void
*/
function layout_admin_page_end() {
layout_footer();
layout_scroll_up_button();
layout_main_container_end();
layout_body_javascript();
html_body_end();
html_end();
}
/**
* Check if the layout is setup for right to left languages
* @return bool
*/
function layout_is_rtl() {
if( lang_get( 'directionality' ) == 'rtl' ) {
return true;
}
return false;
}
/**
* Print meta tags for the page head
* @return null
*/
function layout_head_meta() {
# use the following meta to force IE use its most up to date rendering engine
echo '' . "\n";
echo '' . "\n";
}
/**
* Print css link directives for the head section of the page
* @return null
*/
function layout_head_css() {
# bootstrap & fontawesome
if ( config_get_global( 'cdn_enabled' ) == ON ) {
html_css_cdn_link( 'https://maxcdn.bootstrapcdn.com/bootstrap/' . BOOTSTRAP_VERSION . '/css/bootstrap.min.css' );
html_css_cdn_link( 'https://maxcdn.bootstrapcdn.com/font-awesome/' . FONT_AWESOME_VERSION . '/css/font-awesome.min.css' );
# theme text fonts
html_css_cdn_link( 'https://fonts.googleapis.com/css?family=Open+Sans:300,400' );
# datetimepicker
html_css_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/' . DATETIME_PICKER_VERSION . '/css/bootstrap-datetimepicker.min.css' );
} else {
html_css_link( 'bootstrap-' . BOOTSTRAP_VERSION . '.min.css' );
html_css_link( 'font-awesome-' . FONT_AWESOME_VERSION . '.min.css' );
# theme text fonts
html_css_link( 'open-sans.css' );
# datetimepicker
html_css_link( 'bootstrap-datetimepicker-' . DATETIME_PICKER_VERSION . '.min.css' );
}
# page specific plugin styles
# theme styles
html_css_link( 'ace.min.css' );
html_css_link( 'ace-mantis.css' );
# handle IE separately
echo '';
html_css_link( 'ace-skins.min.css' );
if( layout_is_rtl() ) {
html_css_link( 'ace-rtl.min.css' );
}
echo '';
echo "\n";
}
/**
* Print javascript directives for the head section of the page
* @return null
*/
function layout_head_javascript() {
# HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries
echo '';
echo "\n";
}
/**
* Print javascript directives before the closing of the page body element
* @return null
*/
function layout_body_javascript() {
if ( config_get_global( 'cdn_enabled' ) == ON ) {
# bootstrap
html_javascript_cdn_link( 'https://maxcdn.bootstrapcdn.com/bootstrap/' . BOOTSTRAP_VERSION . '/js/bootstrap.min.js', BOOTSTRAP_HASH );
# moment & datetimepicker
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/' . MOMENT_VERSION . '/moment-with-locales.min.js', MOMENT_HASH );
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/' . DATETIME_PICKER_VERSION . '/js/bootstrap-datetimepicker.min.js', DATETIME_PICKER_HASH );
# typeahead.js
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/corejs-typeahead/' . TYPEAHEAD_VERSION . '/typeahead.jquery.min.js', TYPEAHEAD_HASH );
# listjs
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/list.js/' . LISTJS_VERSION . '/list.min.js', LISTJS_HASH );
} else {
# bootstrap
html_javascript_link( 'bootstrap-' . BOOTSTRAP_VERSION . '.min.js' );
# moment & datetimepicker
html_javascript_link( 'moment-with-locales-' . MOMENT_VERSION . '.min.js' );
html_javascript_link( 'bootstrap-datetimepicker-' . DATETIME_PICKER_VERSION . '.min.js' );
# typeahead.js
html_javascript_link( 'typeahead.jquery-' . TYPEAHEAD_VERSION . '.min.js' );
# listjs
html_javascript_link( 'list-' . LISTJS_VERSION . '.min.js' );
}
# ace theme scripts
html_javascript_link( 'ace.min.js' );
}
/**
* Print opening markup for login/signup/register pages
* @return null
*/
function layout_login_page_begin() {
html_begin();
html_head_begin();
html_content_type();
global $g_robots_meta;
if( !is_blank( $g_robots_meta ) ) {
echo "\t", '', "\n";
}
html_title();
layout_head_meta();
html_css();
layout_head_css();
html_rss_link();
$t_favicon_image = config_get( 'favicon_image' );
if( !is_blank( $t_favicon_image ) ) {
echo "\t", '', "\n";
}
# Advertise the availability of the browser search plug-ins.
echo "\t", '' . "\n";
echo "\t", '' . "\n";
html_head_javascript();
event_signal( 'EVENT_LAYOUT_RESOURCES' );
html_head_end();
echo '';
layout_main_container_begin();
layout_main_content_begin();
echo '
';
}
/**
* Print closing markup for login/signup/register pages
* @return null
*/
function layout_login_page_end() {
echo '
';
layout_main_content_end();
layout_main_container_end();
layout_body_javascript();
echo '', "\n";
}
/**
* Render navbar at the top of the page
* @return null
*/
function layout_navbar() {
$t_logo_url = config_get('logo_url');
echo '
';
if (auth_is_user_authenticated()) {
# shortcuts button bar
layout_navbar_button_bar();
# projects dropdown menu
layout_navbar_projects_menu();
# user buttons such as messages, notifications and user menu
layout_navbar_user_menu();
}
echo '
';
echo '
';
echo '
';
echo '
';
}
/**
* Print navbar menu item
* @param string $p_url destination url of the menu item
* @param string $p_title menu item title
* @param string $p_icon icon to use for this menu
* @return null
*/
function layout_navbar_menu_item( $p_url, $p_title, $p_icon ) {
echo '
';
}
/**
* Print navbar user menu at the top right of the page
* @param bool $p_show_avatar decide whether to show logged in user avatar
* @return null
*/
function layout_navbar_user_menu( $p_show_avatar = true ) {
if( !auth_is_user_authenticated() ) {
return;
}
$t_username = current_user_get_field( 'username' );
echo '
';
}
/**
* Print projects that the current user has access to.
*
* @param int $p_project_id The current project id or null to use cookie.
* @param bool $p_include_all_projects true: include "All Projects", otherwise false.
* @param int|null $p_filter_project_id The id of a project to exclude or null.
* @param string|bool $p_trace The current project trace, identifies the sub-project via a path from top to bottom.
* @param bool $p_can_report_only If true, disables projects in which user can't report issues; defaults to false (all projects enabled)
*/
function layout_navbar_projects_list( $p_project_id = null, $p_include_all_projects = true, $p_filter_project_id = null, $p_trace = false, $p_can_report_only = false ) {
$t_user_id = auth_get_current_user_id();
$t_project_ids = user_get_accessible_projects( $t_user_id );
$t_can_report = true;
project_cache_array_rows( $t_project_ids );
if( $p_include_all_projects && $p_filter_project_id !== ALL_PROJECTS ) {
echo ALL_PROJECTS == $p_project_id ? '
';
}
/**
* Print sidebar menu item
* @param string $p_page page name
* @param string $p_title menu title in english
* @param string $p_icon icon to use for this menu
* @param string $p_active_sidebar_page page name to set as active
* @return null
*/
function layout_sidebar_menu( $p_page, $p_title, $p_icon, $p_active_sidebar_page = null ) {
if( $p_page == $p_active_sidebar_page ||
$p_page == basename( $_SERVER['SCRIPT_NAME'] ) ) {
echo '
';
}
}
# Bug Jump form
# CSRF protection not required here - form does not result in modifications
echo '
';
echo '';
echo '
';
echo PHP_EOL;
echo '
';
echo PHP_EOL;
}
/**
* Print the page footer information
* @return void
*/
function layout_footer() {
global $g_queries_array, $g_request_time;
# If a user is logged in, update their last visit time.
# We do this at the end of the page so that:
# 1) we can display the user's last visit time on a page before updating it
# 2) we don't invalidate the user cache immediately after fetching it
# 3) don't do this on the password verification or update page, as it causes the
# verification comparison to fail
if( auth_is_user_authenticated() && !current_user_is_anonymous() && !( is_page_name( 'verify.php' ) || is_page_name( 'account_update.php' ) ) ) {
$t_user_id = auth_get_current_user_id();
user_update_last_visit( $t_user_id );
}
layout_footer_begin();
# Show MantisBT version and copyright statement
$t_version_suffix = '';
$t_copyright_years = ' 2000 - ' . date( 'Y' );
if( config_get( 'show_version' ) == ON ) {
$t_version_suffix = ' ' . htmlentities( MANTIS_VERSION . config_get_global( 'version_suffix' ) );
}
// SAVO edit =========================================================================================================================\
if( is_page_name( 'view_all_bug_page.php' ) || is_page_name( 'view.php' ) ) {
$SC = config_get( 'status_colors');
$t = count($SC);
echo '
';
foreach($SC as $K => $V) echo '
'.$K.'
';
echo '
';
}
// SAVO edit =========================================================================================================================/
echo '
' . "\n";
# We don't have a button anymore, so for now we will only show the resized
# version of the logo when not on login page.
if( !is_page_name( 'login_page' ) ) {
echo '