Site Template (Last OK 17-04-2014) πŸ“„

This PHP file serves as the master layout for the Logistics front-end. It orchestrates the inclusion of configuration, meta tags, header, navigation, content, footer, and an optional profiler panel. Its modular structure allows swapping templates dynamically based on the current page.

Purpose 🎯

  • Assemble a consistent page structure across the Logistics portal.
  • Dynamically load template fragments (_top, _meta, _content) based on $current_template_name.
  • Offer built-in profiling for execution time and database query logging.

Dependencies & Includes βš™οΈ

File / Constant Role
inc/config.php Defines core constants (e.g., TEMPLATE_DIR, PROFILER, DB_NAME)
TEMPLATE_DIR . $current_template_name . "_top.php" Template-specific header override (if exists)
TEMPLATE_DIR . "inc/template_meta.php" Common <meta> tags and CSS/JS includes
inc/panels/meta.php Shared meta elements or scripts
TEMPLATE_DIR . $current_template_name . "_meta.php" Template-specific meta override (if exists)
inc/panels/header.php Main site header (logo, login status)
inc/panels/top_nav.php Primary navigation bar
inc/panels/small_banner.php Optional banner (shown unless template excluded)
TEMPLATE_DIR . $current_template_name . "_content.php" Main content area injected per page
inc/panels/footer.php Site footer (copyright, links)
PROFILER, $GLOBALS['BENCHMARKS'], $GLOBALS['QueryLog'] Runtime profiling and DB query logging

Page Assembly Flow πŸ—οΈ

  1. Configuration Load

    <?php
    include_once("inc/config.php");
    

    Establishes constants and starts timer if profiling is enabled .

  2. Template-Specific Top Include

    if (file_exists(TEMPLATE_DIR . $current_template_name . "_top.php")) {
      include_once(TEMPLATE_DIR . $current_template_name . "_top.php");
    }
    

    Allows per-template override of the initial HTML structure .

  3. HTML <head> Composition

    include_once(TEMPLATE_DIR . "inc/template_meta.php");
    include_once("inc/panels/meta.php");
    if (file_exists(TEMPLATE_DIR . $current_template_name . "_meta.php")) {
      include_once(TEMPLATE_DIR . $current_template_name . "_meta.php");
    }
    

    Aggregates shared and template-specific <meta> tags .

  4. Header & Navigation

    include_once("inc/panels/header.php");
    include_once("inc/panels/top_nav.php");
    

    Renders the top-of-page UI elements .

  5. Content Injection

    if (!in_array($currnt_template, $exclude_banner)) {
      include_once("inc/panels/small_banner.php");
    }
    include_once(TEMPLATE_DIR . $current_template_name . "_content.php");
    

    Optionally shows a small banner and then the page’s main content .

  6. Footer

    include_once("inc/panels/footer.php");
    

    Completes the page structure .

  7. Profiler Panel (Optional)

    if (PROFILER) {
      $pageLoadingTime = microtime(true) - $pageLoadingStartTime;
      $GLOBALS['BENCHMARKS']['total_execution_time'] = $pageLoadingTime;
    ?>
      <div class="profiler">
        <!-- BENCHMARKS & QUERIES tables -->
      </div>
    <?php } ?>
    

    When PROFILER is true, it displays execution time, individual benchmarks, and sorted DB query log .

Profiler Details πŸ“Š

  • Total Execution Time: Calculated from $pageLoadingStartTime to page render completion.
  • Benchmarks Table: Lists named timers (e.g., β€œDatabase”, β€œTemplate Load”) in a <fieldset> with red legend.
  • Query Log Table: Shows each SQL statement sorted by time, with a blue legend citing DB_NAME and total queries/time.

Key Snippet

foreach ($GLOBALS['QueryLog']['TimeTaken'] as $idx => $time) {
  echo "<tr><td>{$time}</td><td>{$GLOBALS['QueryLog']['Query'][$idx]}</td></tr>";
}

Configuration Variables πŸ“

  • TEMPLATE_DIR: Absolute path to the active template directory.
  • $current_template_name: Identifies which template variant to load.
  • $currnt_template: Used to determine if banners should be suppressed.
  • $exclude_banner: Array of templates excluding the small banner.
  • PROFILER: Boolean constant toggling the debug panel.
  • DB_NAME: Database name displayed in profiler legend.
linuxfront-v2-logistics/
β”œβ”€ inc/
β”‚  β”œβ”€ config.php           # Core settings & constants
β”‚  └─ panels/
β”‚     β”œβ”€ header.php
β”‚     β”œβ”€ top_nav.php
β”‚     β”œβ”€ small_banner.php
β”‚     β”œβ”€ footer.php
β”‚     └─ meta.php
β”œβ”€ site_template_lastok-17-04-2014.php  # ← This file
β”œβ”€ site_template.php       # Earlier generic template
β”œβ”€ popup_template.php      # Layout for modal/pop-up pages
β”œβ”€ route.php / route1.php  # Front-controller routing requests
└─ other assets (labels, js, manifests…)

Each include under inc/panels/ provides a single responsibility (header, nav, banner, footer) for clean separation of concerns.

Usage πŸ”„

  • Front-Controller (route.php) determines $currnt_file_name and $current_template_name.
  • It then includes this template file to render the full page.
  • Template fragments under TEMPLATE_DIR supply page-specific markup without altering the master layout.

Version Note πŸ•‘

This file is named with the suffix lastok-17-04-2014 to indicate the last known working revision on 17 April 2014. Legacy counterparts (e.g., 21-11-2012_site_template.php) share similar structure but lack the enhanced profiler logic.


By centralizing layout logic here, the application achieves a consistent look and feel, simplifies template swaps, and offers built-in performance insightsβ€”all in a compact, modular, and maintainable fashion.