source view: _pagewrapper.php


<?php






  require_once( sprintf( '%s/classes/Admin.php', dirname( __FILE__ ) ) );






  /*
   *
   * Optional argument: filename, page title; really this is ugly and needs to be refactored with named arguments
   *
   */
  function wrapPageTop ()
  {
    require 'headers.php';
?>
<!doctype html>
<?php

    global $nav_parent, $page_color, $post_title;
    require 'navigation.php';
    
    $extra_headings = array();
    $show_title     = false;
    
    if ( func_num_args() > 0 )
    {
      if ( func_get_arg( 0 ) != null )
      {
        $show_title = true;

        $nav_parent = Navigation::getItemByURL( func_get_arg( 0 ) );
        $page_color = $nav_parent->getColor()->toHex();
        $text_color = $nav_parent->getFontColor()->toHex();
      }
      else if ( $nav_parent )
      {
        $page_title = $nav_parent->getName();
        $page_color = $nav_parent->getColor()->toHex();
        $text_color = $nav_parent->getFontColor()->toHex();
      }
      
      if ( func_num_args() > 2 )
      {
        if ( is_string( func_get_arg( 2 ) ) )
        {
          $nav_parent = null;
          $page_color = func_get_arg( 2 );
          $text_color = '#fff';
        }
        else if ( is_array( func_get_arg( 2 ) ) )
        {
          $extra_headings = func_get_arg( 2 );
        }
      }
      
      $page_title = func_get_arg( 1 );
      if ( ( $page_title == null && isset( $post_title ) ) || ( !is_null( $nav_parent ) && $page_title == $nav_parent->getName() ) )
      {
        $show_title = false;
        $page_title = $nav_parent->getName();
      }
    }
    else
    {
      $page_title = $nav_parent->getName();
      $page_color = $nav_parent->getColor()->toHex();
      $text_color = $nav_parent->getFontColor()->toHex();
    }
    
?>
<html>
  <head>
    <link href="/blog.css"  rel="stylesheet" type="text/css" />
    <link href="/style.css" rel="stylesheet" type="text/css" />
    <link rel="apple-touch-icon" sizes="57x57" href="/favicons/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/favicons/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/favicons/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/favicons/apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/favicons/apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/favicons/apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/favicons/apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/favicons/apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon-180x180.png">
    <link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/favicons/android-chrome-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="/favicons/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="/favicons/manifest.json">
    <link rel="shortcut icon" href="/favicons/favicon.ico">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="msapplication-TileImage" content="/favicons/mstile-144x144.png">
    <meta name="msapplication-config" content="/favicons/browserconfig.xml">
    <meta name="theme-color" content="#ffffff">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta http-equiv="last-modified" content="<?php print date( 'r', filemtime( $_SERVER['SCRIPT_FILENAME'] ) ); ?>" />
    <meta name="viewport" content="width=device-width, user-scalable=no" />
<?php include 'title-reset.php';?>
    <script src="/v2/logo/jslogo.js" type="text/javascript"></script>
    <script src="/js/banner.js" type="text/javascript"></script>
    <title>kyle woodward :: <?php print isset( $post_title ) ? $post_title : $page_title; ?></title>
    <style type="text/css">
      div#linkbar-upper a
      {
        color: <?php print $text_color; ?>;
      }
    </style>
<?php

  foreach ( $extra_headings as $id => $heading )
  {
    print "\t\t$heading\n";
  }

?>
  </head>
  <body>
    <!-- main page content -->
    <div id="content_div">
      <!-- page header -->
      <div id="header_div" style="background-color:<?php print $page_color; ?>;color:<?php print $text_color; ?>;">
        <canvas id="logologo" style="height:50px;width:600px;position:relative;" height="50" width="600"></canvas>
<div id="linkbar-upper" style="background-color:<?php print $page_color; ?>;"><?php

  for ( $i = 0; $i < Navigation::getItemCount(); ++$i )
  {
    $nav_item = Navigation::getItem( $i );
    $class_name = ( !$show_title && !is_null( $nav_parent ) && $nav_item->getURL() == $nav_parent->getURL() ) ? 'active' : 'standard';
    printf( '<div class="%s"><a href="/%s" target="_top" data:bgcolor="%s">%s</a></div>', $class_name, $nav_item->getURL(), $nav_item->getColor()->toHex(), $nav_item->getName() );
  }

  if ( $show_title )
  {
    printf( '<div class="active"><a href="%s" target="_top" data:bgcolor="%s">%s</a></div>', $_SERVER['PHP_SELF'], $nav_parent->getColor()->toHex(), $page_title );
  }

?>
<div id="spacer"></div></div></div><div id="content_actual">
<?php
  }



  function wrapPageBottom ()
  {
    global $page_color;
    
?>
        <!-- footer -->
        <div id="footer_div">
<?php
    for ( $i = 0; $i < Navigation::getItemCount(); ++$i )
    {
      $nav_item = Navigation::getItem( $i );
?><div style="border-color:<?php print $nav_item->getColor()->toHex();?>;"><a href="/<?php print $nav_item->getURL();?>" target="_top"><?php print $nav_item->getName();?></a></div><?php
    }
?>
          <br />
          <br />
          <span class="copyright">
            <?php include('copyright.php');?> | 
            <a href="/source.view.php?page=<?php print $_SERVER['PHP_SELF']; ?>" target="new">source</a>
<?php

    if ( Admin::isLoggedIn() )
    {
?>
 | <a href="/blog-login.php?action=logout">logout</a>
<?php
    }

?>
          </span>
          <a href="http://profiles.google.com/108677732441037950707" rel="author" style="display:none;">Kyle Woodward</a>
        </div>
      </div>
    </div>
<?php
    


    include 'urchin.tracking.php';
    $carr = toRGB( $page_color );



?>
    <script type="text/javascript">
      installBanner( <?php print join( ',', $carr ); ?> );
    </script>
  </body>
<?php

    if ( func_num_args() > 0 && func_get_arg( 0 ) != null )
    {
      $post_scripts = func_get_arg( 0 );
      foreach ( $post_scripts as $id => $script )
      {
        print "\t$script\n";
      }
    }

?>
</html>
<?php
  }



  function isDevServer ()
  {
    return Admin::isDevServer();
  }



  function makeCopyright ()
  {
    return sprintf( '&copy; %s kyle woodward', strtolower( date( 'Y' ) ) );
  }
  
  
  
  function toRGB ( $hex )
  {
    $hexarr = array();
    preg_match( '/([\da-f]{2})([\da-f]{2})([\da-f]{2})/i', $hex, $hexarr );
    return array( hexdec( $hexarr[1] ), hexdec( $hexarr[2] ), hexdec( $hexarr[3] ) );
  }



  function toRomanNumeral ( $n )
  {
    $R = array(  'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' );
    $T = array( 1000,  900, 500,  400, 100,   90,  50,   40,  10,    9,   5,    4,   1 );

    $i = 0;
    $s = '';
    while ( $n > 0 )
    {
      if ( $n >= $T[$i] )
      {
        $s .= $R[$i];
        $n -= $T[$i];
      }
      else
      {
        ++$i;
      }
    }

    return $s;
  }



?>