view index.php @ 25:da86ec2814e2

Whitespace cleanup.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Wed, 19 Sep 2012 21:50:20 +0200
parents 5c4d7c758fda
children d8c7b328899e
line wrap: on
line source

<?php
define(DEBUG,0);
define(MAX_RECURSE,50);
define(CACHING,1);

/*
var_dump($_SERVER);
exit;
*/

if (DEBUG) {
  error_reporting(E_ALL);
  ini_set("display_errors", 1);
}

$SCRIPT_FILENAME=$_SERVER['SCRIPT_FILENAME'];
$newest = filemtime($SCRIPT_FILENAME);
$cacheable = true;

include 'php/cache_check.inc';
include_with_mtime('php/accept-language.inc');
include_with_mtime('php/filters.inc');
include_with_mtime('php/common-functions.inc');
include_with_mtime('php/inputParser.inc');

$URL_PARAMS=array('name','lang');

#Globals
$name = $_GET['name'];
$lang = $_GET['lang'];

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

$params = $master->getElementsByTagName("param");
foreach ($params as $param) {
  if ($param->getAttribute("type") == "option") {
    if ($param->getAttribute("id") == "lang") {
      $defaultLang = $param->getAttribute("default");
    }
  }
}

if (!$lang) {
  $lang = preferLanguage($defaultLang);
}


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

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

  }
}

if (CACHING && $cacheable)
  print cache_check($newest);

print $master->saveXml($master);

?>