CORE-POS/IS4C

View on GitHub
fannie/src/header.bootstrap.html

Summary

Maintainability
Test Coverage
<?php
$FANNIE_PRODUCTION = true;
if ($headerConfig instanceof FannieConfig) {
    $FANNIE_DYNAMIC_MENU = $headerConfig->get('DYNAMIC_MENU');
    $FANNIE_NAV_POSITION = $headerConfig->get('NAV_POSITION');
    $FANNIE_CSS_LOGO = $headerConfig->get('CSS_LOGO');
    $FANNIE_CHARSET = $headerConfig->get('CHARSET');
    $FANNIE_CUSTOM_TITLE = $headerConfig->get('CUSTOM_TITLE');
    $FANNIE_MENU = $headerConfig->get('MENU');
    $FANNIE_PRODUCTION = $headerConfig->production();
}
if (preg_match('/^Fannie[^\w]+.*$/', $page_title)) {
    $page_title = preg_replace('/^Fannie(.*)$/', $BACKEND_NAME . '$1', $page_title);
}
if (preg_match('/^Fannie[^\w]+.*$/', $header)) {
    $header = preg_replace('/^Fannie(.*)$/', $BACKEND_NAME . '$1', $header);
}
/* try to deal with relative paths for includes */
$path = "";
$limit = 15;
$counter = 0;
while ($counter < $limit) {
    if (file_exists($path . 'classlib2.0/FannieAPI.php')) {
        break;
    }
    $path .= "../";
    $counter++;
}
if ($counter >= $limit && $headerConfig instanceof FannieConfig) {
    $path = $headerConfig->get('URL');
}
if (!isset($FANNIE_CHARSET) || empty($FANNIE_CHARSET)) {
    $FANNIE_CHARSET = 'ISO-8859-1';
}
?>
<!DOCTYPE html> 
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $FANNIE_CHARSET; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $page_title; ?></title>
<?php
$path1 = dirname(__FILE__) . '/javascript/composer-components/';
$path2 = dirname(__FILE__) . '/javascript/';
if (file_exists($path1 . 'bootstrap/js/bootstrap.min.js')) {
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/composer-components/bootstrap/css/bootstrap.min.css">', $path);
    echo "\n";
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/composer-components/bootstrap-default/css/bootstrap.min.css">', $path);
    echo "\n";
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/composer-components/bootstrap-default/css/bootstrap-theme.min.css">', $path);
    echo "\n";
} elseif (file_exists($path2 . 'bootstrap/js/bootstrap.min.js')) {
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/bootstrap/css/bootstrap.min.css">', $path);
    echo "\n";
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/bootstrap-default/css/bootstrap.min.css">', $path);
    echo "\n";
    printf('<link rel="stylesheet" type="text/css" href="%ssrc/javascript/bootstrap-default/css/bootstrap-theme.min.css">', $path);
    echo "\n";
}
?>
<?php if (!$FANNIE_PRODUCTION): ?>
<style type="text/css">
  body {
      background-image: url('<?php echo $headerConfig->get('URL'); ?>src/img/testing.png');
  }
</style>
<?php endif; ?>
<script type="text/javascript">
function smartToggle()
{
    /**
      Hack to combine bootstrap screensize hidden* classes and collapse classes
      Nav bar initially renders with .collapse.in (shown) and .hidden-xs
      On extra small device, the result is a hidden menu. On the first click, remove
      the hidden-xs class so all further toggling is handled by collapse but
      also remove the "in" class. This hides the nav from collapse's perspective
      so the first data-toggle shows it instead of hides it.
    */
    if ($('.device-xs').is(':visible') && $('.navbar-default').hasClass('hidden-xs')) {
        $('.navbar-default').removeClass('hidden-xs');
        $('.navbar-default').removeClass('in');
    }
}
</script>
</head>
<body>
<div id="fannie-outer-margin" style="margin-left:3em;margin-right:3em;">
    
    <div class="hidden-print">
        <table> <!-- yes. sick of fighting with floating divs... -->
        <tr><td class="hidden-xs">
            <?php if (isset($FANNIE_CSS_LOGO) && !empty($FANNIE_CSS_LOGO)) { ?>
            <img src="<?php echo $FANNIE_CSS_LOGO; ?>" alt="logo" />
            <?php } ?>
        </td>
        <td>
        <div class="hidden-xs" style="font-size:28px;margin-bottom:5px;" class="primaryColor">
        <a href="<?php echo $path; ?>">
        <?php echo $BACKEND_NAME; ?>
        <?php if (isset($FANNIE_CUSTOM_TITLE) && !empty($FANNIE_CUSTOM_TITLE)) {
            echo ' - ' . $FANNIE_CUSTOM_TITLE;
        } ?>
        </a>
        </div>
        <!-- this span is for detecting bootstrap screensize -->
        <span class="device-xs visible-xs"></span>
        <div style="font-size:20px;" class="secondaryColor" id="smallscreen-menu-toggle"
            data-toggle="collapse" data-target=".navbar-default"
            onclick="smartToggle();">
            <span class="hidden-xs">IT CORE</span> maintenance &amp; reporting
        </div>
        </td></tr>
        </table>
    </div>
    <div class="secondaryBorder container-fluid" id="fannie-main-content" style="border-width: 1px; border-style: solid;">

        <div class="navbar navbar-default collapse in hidden-xs hidden-print">
            <ul class="nav navbar-nav">
            <?php
            if (!is_array($FANNIE_MENU) || count($FANNIE_MENU) == 0) {
                include(dirname(__FILE__) . '/init_menu.php');
                $FANNIE_MENU = $INIT_MENU;
            } elseif (isset($FANNIE_MENU[0]['subheading'])) {
                // old-style menu configuration
                include(dirname(__FILE__) . '/init_menu.php');
                $FANNIE_MENU = $INIT_MENU;
            }
            foreach ($FANNIE_MENU as $menu => $contents) {
                if (count($contents) == 0) {
                    continue;
                }
                if ($menu == '__store__') {
                    $menu = 'Custom';
                }
                printf('<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" data-target="#" 
                        href="#">%s<span class="caret"></span></a>' . "\n", $menu);
                echo '<ul class="dropdown-menu" role="menu">' . "\n";
                foreach ($contents as $m_title => $m_url) {
                    if ($m_url == '__header__') {
                        printf('<li class="dropdown-header">%s</li>' . "\n", $m_title);
                    } elseif ($m_url == '__divider__') {
                        echo '<li class="divider"></li>' . "\n";
                    } else {
                        $prefix = $path;
                        if ($m_url[0] == '/' || substr($m_url, 0, 7) == 'http://' || substr($m_url, 0, 8) == 'https://') {
                            $prefix = '';
                        }
                        printf('<li><a href="%s%s">%s</a></li>' . "\n", $prefix, $m_url, $m_title);
                    }
                }
                echo '</ul>' . "\n";
                echo '</li>' . "\n";
            }
            ?>
            <li id="nav-help-link">
                <a href="#help-modal" data-toggle="modal" data-target="#help-modal">
                    Help
                    <span class="fas fa-question-circle"></span>
                </a>
            </li>
            </ul>
        </div>
        <div class="h3 primaryColor">
            <?php echo $header; ?>
        </div>
        <div id="primary-content" class="">