diff InputParser.inc @ 66:74f7b64bdb78

Lots of documentation fixes, and removal of unused function getXmlContent
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Thu, 11 Oct 2012 22:11:33 +0200
parents 92c3e52c12d4
children 4dfa3f6a2dc1
line wrap: on
line diff
--- a/InputParser.inc	Thu Oct 11 20:36:24 2012 +0200
+++ b/InputParser.inc	Thu Oct 11 22:11:33 2012 +0200
@@ -1,12 +1,20 @@
 <?php
 /**
- * @file
- * Functionality for translating an XML document into a webpage
+ * Functionality for translating an XML configuration document into a webpage
  */
 class InputParser {
   private $options;
   private $master;
 
+  /**
+   * Constructs a new InputParser object
+   *
+   * @param $name name of file to read configuration from
+   * @param $masterCache CacheTimeCheck cache object to use as parent for this inputParsercache
+   *
+   * @todo masterCache is currently used as is, fix so linked caches
+   * may be used.
+   */
   function __construct($name, $masterCache) {
     $this->master = new DOMDocument();
     $cache = $masterCache;
@@ -49,6 +57,10 @@
 
   }
 
+  /**
+   * Generate an appropriate response for this page, eg. 302 NOT
+   * MODIFIED or the actual page
+   */
   function genPage()
   {
     if (CACHING && $this->options->getCacheable())
@@ -58,17 +70,24 @@
     //print_r($cache->cacheSet(1));
   }
 
-
+  /**
+   * Extracts data from a @<param@> tag.
+   *
+   * @param $param the param tag
+   *
+   * @return if the type is array, return an array, otherwise return a
+   * scalar
+   */
   function getParam($param)
   {
-    $param_type=$param->getAttribute("type");
+    $param_type = $param->getAttribute("type");
     $param_value;
-    if (!$param_type)
-      $param_type="scalar";
+    if (! $param_type)
+      $param_type = "scalar";
 
     if($param_type == "scalar") {
-      $param_subst=$param->getAttribute("subst");
-      $param_value=$param->getAttribute("value");
+      $param_subst = $param->getAttribute("subst");
+      $param_value = $param->getAttribute("value");
       if ($param_subst) {
 	/*
 	  $param_value=preg_replace("/name/", $name, $param_subst);
@@ -77,19 +96,26 @@
       }
     }
     elseif($param_type == "array") {
-      $params=$param->getElementsByTagName("param");
-      $param_value=array();
+      $params = $param->getElementsByTagName("param");
+      $param_value = array();
       foreach ($param->childNodes as $param) {
-	if ($param->nodeType == XML_ELEMENT_NODE)
-	  {
-	    array_push($param_value, self::getParam($param));
-	  }
+	if ($param->nodeType == XML_ELEMENT_NODE) {
+	  array_push($param_value, self::getParam($param));
+	}
       }
     }
     return $param_value;
   }
 
-  function getFiles($doc, $options) {
+  /**
+   * This is the last processing stage for generating a file.
+   *
+   * @param $doc the document to be worked upon
+   * @param $options an Options object for this file.
+   *
+   * @return This is the same as the input document, fully processed
+   */
+  static function getFiles($doc, $options) {
     $lang = $options->getLang();
     $conf = $options->getName();
 
@@ -228,6 +254,17 @@
     return $doc;
   }
 
+  /**
+   * Follows all include directives recursively for the specified
+   * $param an generates an xml file.
+   *
+   * This function may be used to generate a file which has all the
+   * necessary information to determine wether or not we may cache.
+   *
+   * @param $master The master document to be processed
+   * @param $param the input tag to resolve
+   * @param $options the options object for this file
+   */
   function getInput($master, $param, $options)
   {
     $lang = $options->getLang();