Location: PHPKode > projects > Polaring > view/general.php
<?php 
// vim: sw=4:ts=4
/**
* @version 00.04.09
* @package polaring
* @license This component in released under the GNU/GPL License
*
* Fil: view/general.php
* Roll: Allmänna funktioner, relaterat till HTML/"uppvisning."
*
**/

/**************************\
 * Read necessary files
\**************************/

require('./view/css.php');
require('./view/frontpage.php');
require('./view/navigation.php');
require('./view/gmaps.php');
require('./view/errorReport.php');


/**************************\
 * Class 'visa' takes care of
 * inserting required html-code.
\**************************/

class visa {

  function tillbaka($steps) {
    echo "<p><a href=\"javascript:history.go(-".$steps.")\">".
      strings::expression("common", "back").
      "</a></p>\n";
    return(true);
  }


  function backLink($from) {
      unset($link);
      if ( $from['mission'] == "day" ) {
	  $day = $from['dateTime'];
	  $year = substr($day, 0, 4);
	  $month = substr($day, 4, 2);
	  $link = give::phpindex()."?section=polar&amp;".
	      "mission=monthen&amp;year=".$year.
	      "&amp;month=".$month;
      } elseif ( $from['mission'] == "monthen" ) {
	  $year = substr($from['year'], 2, 2);
	  $link = give::phpindex()."?section=polar&amp;".
	      "mission=months&amp;yearShow=".$year;
      }

      if ( $link ) {
	  echo "<p><a href=\"".$link."\">".strings::expression(
	      "common", "back")."</a></p>\n";
	  return(true);
      } else {
	  return(false);
      }

  } // end function backLink


  function graphLinkMedium($graph) {
      if ( $graph == "dayGmapRoute" ) {
	  gmaps::mapDiv("640", "480");
	  return(true);
      }

      $imgLink = give::phpindex()."?mission=graf&amp;".
	  "section=polar&amp;gtyp=".$graph;
      if ( $_REQUEST['mission'] == "monthen" ) {
	  $imgLink .= "&amp;y=".$_REQUEST['year']."&amp;".
	      "m=".$_REQUEST['month'];
      } elseif ( $_REQUEST['mission'] == "day" ) {
	  $imgLink .= "&amp;dateTime=".$_REQUEST['dateTime'];
      }
      echo "<img class=\"graf\" src=\"{$imgLink}\" />";
      return(true);
  } // end function graphLinkMedium


  function graphLinkSmall($graph, $title, $width, $height) {
      $_SESSION['nGraphs']++;
      $nGraphs = $_SESSION['nGraphs'];
      if ( $_REQUEST['selGraph'] == $graph ) {
	  $_SESSION['nGraphs'] = $nGraphs - 1;
	  return(false);
      }
      if ( $nGraphs == 1 ) {
	  echo "    <tr>\n";
      } elseif ( $nGraphs % 2 ) {
	  echo "    </tr>\n    <tr>\n";
      }
      echo "      <td class=\"center\">";
      $refLink = give::phpindex()."?section=polar";
      if ( !isset($_REQUEST['month']) && 
	  !isset($_REQUEST['dateTime']) ) {
	      $refLink .= "&amp;mission=months";
      } elseif ( $_REQUEST['mission'] == "monthen" ) {
	  $refLink .= "&amp;mission=monthen&amp;".
	      "year=".$_REQUEST['year']."&amp;month=".
	      $_REQUEST['month'];
      } elseif ( $_REQUEST['mission'] == "day" ) {
	  $refLink .= "&amp;mission=day&amp;".
	      "dateTime=".$_REQUEST['dateTime'];
      }

      $refLink .= "&amp;selGraph={$graph}";
      $imgLink = give::phpindex()."?mission=graf&amp;".
	  "section=polar&amp;gtyp=".$graph;
      if ( isset($_REQUEST['month']) ) {
	  $imgLink .= "&amp;m=".$_REQUEST['month']."&amp;".
	      "y=".$_REQUEST['year'];
      } elseif ( isset($_REQUEST['dateTime']) ) {
	  $imgLink .= "&amp;dateTime=".$_REQUEST['dateTime'];
      }
      if ( $graph == "dayGmapRoute" ) {
	  echo "<a href=\"{$refLink}\">{$title}</a><br />\n";
	  gmaps::mapDiv($width, $height);
      } else {
	  echo "<a href=\"{$refLink}\">{$title}</a><br />\n";
	  echo "<a href=\"${refLink}\">".
	      "<img class=\"graf\" src=\"${imgLink}\" ".
	      "width=\"${width}\" "."height=\"${height}\" ".
	      "alt=\"${title}\" /></a>";
      }
      echo "</td>\n";
      return(true);
  } // end function graphLink


  function htmlHead() {
      echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n".
	  "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
      echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" ";
      if ( $_REQUEST['mission'] == "day" ) {
	  echo "xmlns:v=\"urn:schemas-microsoft-com:vml\" ";
      }
      echo "lang=\"en-gb\" xml:lang=\"en-gb\">\n".
	  "\n<head>\n".
	  "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
      //echo "  <link href=\"view/normal.css\" rel=\"stylesheet\" type=\"text/css\">\n";

      return;
  } // end function htmlHead

  function startHtml() {
      visa::htmlHead();
      echo "  <title>Polaring</title>\n";
      if ( $_SESSION['showGmaps'] && $_REQUEST['mission'] === "day" ) {
	  echo "<style type=\"text/css\" >\n";
	  echo "  v\:* { behavior:url(#default#VML); }\n";
	  echo "</style>\n";
	  gmaps::htmlHead();

	  $dateTime = $_REQUEST['dateTime'];
	  $latData = $_SESSION['workouts'][$dateTime]['sampleLocationLat'];
	  $longData = $_SESSION['workouts'][$dateTime]['sampleLocationLong'];
	  gmaps::mapRoute($latData, $longData);
      }
      echo "<style type=\"text/css\" >\n";
      css::normal();
      css::menu();
      echo "</style>\n";
      echo "</head>\n";
      if ( $_SESSION['showGmaps'] ) {
	  echo "<body onload=\"loadPolaringGmap()\" onunload=\"GUnload()\">\n\n";
      } else {
	  echo "<body>\n\n";
      }

    // "Headline"
    echo "<h1>Polaring</h1>\n";

    // Main container
    echo "<table class=\"huvudkontainer\">\n".
      // header
            "  <thead>\n";

    // Don't show navigation if there isn't anything to choose
    // between.
    if ( $_SESSION['menumode'] == "0" && (
	user::validateIP($_SESSION['validIp']['tools']) ||
	user::validateIP($_SESSION['validIp']['settings']) ||
	user::validateIP($_SESSION['validIp']['diary']) ||
	user::validateIP($_SESSION['validIp']['upload']) ) ) {
	    echo "    <tr>\n".
		    "      <td colspan=\"3\" id=\"TabHeadContainer\">";
	    navigation::navTabHead();
	    echo "      </td>\n".
		    "    </tr>\n";
	}       
    echo "  </thead>\n";

    // footer
    echo "  <tfoot>\n";
    if ( isset($_SESSION['footer']) ) {
	echo "    <tr>\n      <td>".$_SESSION['footer']."</td>".
	    "    </tr>\n";
    }
    echo "  </tfoot>\n";

    // body -- where the main action takes place
    echo "  <tbody>\n".
      "    <tr>\n";
    if ( $_SESSION['menumode'] == "1" && (
	user::validateIP($_SESSION['validIp']['tools']) ||
	user::validateIP($_SESSION['validIp']['settings']) ||
	user::validateIP($_SESSION['validIp']['diary']) ||
	user::validateIP($_SESSION['validIp']['upload']) ) ) {
	    //Insert menu in left column
	    echo "      <td class=\"navLeft menu\" >\n";
	    navigation::navLeft();
	    echo "      </td>\n";
	}

    //Insert body
    echo "      <td class=\"kropp\">\n";
    echo "<div class=\"kropp\">\n";
  } // end function startHtml


  function endHtml() {
    // End div and td 'kropp'
    echo "</div>\n";
    echo "      </td>\n";
    // Insert menu in right column
    echo "      <td class=\"navRight menu\">";
    navigation::navRight();
    echo "      </td>\n";
    // End table 'huvudcontainer'    
    echo "    </tr>\n" .
      "  </tbody>\n".
      "</table>\n";

// INSERT GOOGLE ANALYTICS TRACKER
?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2803819-4");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<?php
    echo "</body>\n";
    echo "</html>";

    return(true);
  } // end function stopHtml

} // end class visa


?>
Return current item: Polaring