'Login', 'insert_user.php' => 'Join', 'show_users.php' => 'Users'); $user_pages = array( 'user_profile.php' => 'Profile', 'update_user.php' => 'Edit', 'manage_courses.php' => 'Manage Courses', 'insert_course.php' => 'Insert Course', 'logout.php' => 'Logout'); $admin_pages = array( 'manage_users.php' => 'Manage users', 'manage_courses.php' => 'Manage courses', 'show_table_data.php?table_name=users' => 'Show users', 'show_table_data.php?table_name=courses' => 'Show courses', 'show_table_columns.php?table_name=users' => 'Columns users', 'show_table_columns.php?table_name=courses' => 'Columns courses', 'logout.php' => 'Logout'); /* ----------------------------------------------------------------------- Select menu ----------------------------------------------------------------------- */ function select_menu() { global $default_pages; global $user_pages; global $admin_pages; session_start(); if ($_SESSION['admin']) $pages = $admin_pages; elseif ($_SESSION['uid']) $pages = $user_pages; else $pages = $default_pages; return $pages; } /* ------------------------------------------------------------------------------------------------------ Echos a basic web page with a navbar in the header, a Bootstrap main container and a custom footer ------------------------------------------------------------------------------------------------------ */ function make_basic_page($page_name, $content, $style=null) { global $website_name; global $author; $pages = select_menu(); echo make_top($website_name, $page_name, $style).'
'.make_navbar($pages, $website_name, $page_name).'
'.$content.'
'. make_bottom(); } /* ----------------------------------------------------------------------- This creates the top of every web page and slices in the website name, page name and optional style, i.e., embedded CSS ----------------------------------------------------------------------- */ function make_top($website_name, $page_name, $style=null) { if ($style != null) $style = ''; return ' '.$website_name.' - '.$page_name.' '.$style.' '; } /* ----------------------------------------------------------------------- Creates the bottom of every web page to include the bootstrap javascript ----------------------------------------------------------------------- */ function make_bottom() { return ' '; } /* ----------------------------------------------------------------------- This creates the nav menu from the pages array and active page name Also, slices the website name into the navbar brand area ----------------------------------------------------------------------- */ function make_navbar($pages, $website_name, $active_page) { $menu = ''; foreach ( $pages as $link => $name ) { $active = ''; if ($active_page == $name) $active = 'active'; $menu .= ''.$name.''; } return ' '; } /* ----------------------------------------------------------------------- This creates the page footer with links at bottom ----------------------------------------------------------------------- */ function make_footer($pages, $author=null) { $menu = ''; foreach ( $pages as $link => $name ) { $menu .= '
  • '.$name.'
  • '; } return ' '; } /* -------------------------------------------------------------------------------- Creates a Bootstrap row with columns that can have four different configuration depending on whether or not side_menu or aside_content are present -------------------------------------------------------------------------------- */ function make_main_content($main_article, $side_menu=null, $aside_content=null) { // If both side_menu and aside are present if ($side_menu && $aside_content) { $main_content = '
    '.$main_article.'
    '; } else if ($side_menu) { // Side menu only $main_content = '
    '.$main_article.'
    '; } else if ($aside_content) { // Aside only $main_content = '
    '.$main_article.'
    '; } else { // No side menu and no aside $main_content = '
    '.$main_article.'
    '; } return $main_content; } /* ----------------------------------------------------------------------- This creates a bootstrap card with the given title, content and background style (primary, success, danger, etc.) ----------------------------------------------------------------------- */ function make_card($title, $content, $style='primary') { return '
    '.$title.'
    '.$content.'
    '; } /* ---------------------------------------------------------------------------- This creates a bootstrap list group from the given title, list and style ---------------------------------------------------------------------------- */ function make_listgroup($title, $list, $style='primary') { $content = ''; foreach ($list as $url => $name) { $content .= ''.$name.''; } return '
    '.$title.'
    '; } /* ---------------------------------------------------------------------------- Calls the header function to redirect to the specified file name ---------------------------------------------------------------------------- */ function redirect($file_name) { header("Location: $file_name"); } ?>