view index.php @ 44:79f708a48a7c

Added a constants include. Refactored out functions from sitemap.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Mon, 08 Oct 2012 02:01:04 +0200
parents 2a3ff56697db
children 66382989353f
line wrap: on
line source

<?php
include_once 'constants.inc';

$cacheable = true;

include_once 'CacheTimeCheck.inc';

$cache = CacheTimeCheck::instance(__FILE__);
$cache->includeOnce('Options.inc', dirname(__FILE__));
$cache->includeOnce('accept-language.inc', dirname(__FILE__));
$cache->includeOnce('common-functions.inc', dirname(__FILE__));
$cache->includeOnce('filters.inc', dirname(__FILE__));
$cache->includeOnce('inputParser.inc', dirname(__FILE__));

if (DEBUG_LEVEL >= VERBOSITY_DEBUG) {
  var_dump($_SERVER);
}

$master = new DOMDocument();
$masterName = basePath() . "/master.xml";
$master->load($masterName);

$options = new Options($master);
$options->setCache($cache);
$options->setBasePath(basePath());

$options->setUrlParams(array('name', 'lang'));

if(array_key_exists('lang', $_GET) && $_GET['lang']) {
  $options->setLang($_GET['lang']);
}
else {
  $options->setLang($options->getDefaultLang());
}

if(array_key_exists('name', $_GET) && $_GET['name']) {
  $options->setName($_GET['name']);
}

$params = $master->getElementsByTagName("param");

foreach ($params as $param) {
  if ($param->getAttribute("type") == "input") {
    $doc = getInput($master, $param, $options);

    $parent = $param->parentNode;
    foreach ($doc->firstChild->childNodes as $child) {
      $clonedChild = $master->importNode($child, true);
      $parent->insertBefore($clonedChild, $param);
    }
    $parent->removeChild($param);
  }
}

if (CACHING && $cacheable)
  $options->getCache()->CheckHttpModified();

print $master->saveXml($master);

?>