diff Options.inc @ 48:c6d0892f81ff

Documentation.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Tue, 09 Oct 2012 20:05:12 +0200
parents 66382989353f
children b7efe2ecbc11
line wrap: on
line diff
--- a/Options.inc	Mon Oct 08 17:35:08 2012 +0200
+++ b/Options.inc	Tue Oct 09 20:05:12 2012 +0200
@@ -1,4 +1,9 @@
 <?php
+/**
+ * Contains alle configurable parameters, and "globals"
+ *
+ * @author Tom Fredrik Blenning Klaussen
+ */
 class Options
 {
   private $defaultLang;
@@ -12,16 +17,31 @@
   private $flagUrl;
   private $baseUrl;
 
+  /**
+   * Gets the default language
+   *
+   * @return two letter code for the language
+   */
   function getDefaultLang()
   {
     return $this->defaultLang;
   }
 
+  /**
+   * Gets the selected language
+   *
+   * @return two letter code for the language
+   */
   function getLang()
   {
     return $this->lang;
   }
 
+  /**
+   * Get the base url, or if non set, extracts it from _SERVER
+   *
+   * @return the baseurl for the scripts
+   */
   function getBaseUrl()
   {
     if ($this->baseUrl)
@@ -34,24 +54,48 @@
     return "http://" . $_SERVER['HTTP_HOST'] . $base;
   }
 
+  /**
+   * Replaces placeholder variables, with actual values.
+   *
+   * Currently supported values:
+   * @li \%HOST\%
+   *
+   * @param $value string to replace values in
+   * @return the processed string
+   */
   function replacePlaceholders($value)
   {
     $value = preg_replace('/%HOST%/', $_SERVER['HTTP_HOST'], $value);
     return $value;
   }
 
+  /**
+   * Sets the base url where scripts are located
+   *
+   * @param $baseUrl the url where scripts are located
+   */
   function setBaseUrl($baseUrl)
   {
     $baseUrl = self::replacePlaceholders($baseUrl);
     $this->baseUrl = $baseUrl;
   }
 
+  /**
+   * Sets the url for the flag script
+   *
+   * @param $flagUrl for flag script
+   */
   function setFlagUrl($flagUrl)
   {
     $flagUrl = self::replacePlaceholders($flagUrl);
     $this->flagUrl = $flagUrl;
   }
 
+  /**
+   * Gets the url for the flag script, or autogenerate if not set
+   *
+   * @return url for flag script
+   */
   function getFlagUrl()
   {
     if ($this->flagUrl)
@@ -60,21 +104,41 @@
     return $this->getBaseUrl() . "/flag.php";
   }
 
+  /**
+   * Sets the selected language
+   *
+   * @param $lang two letter code for the language
+   */
   function setLang($lang)
   {
     $this->lang = $lang;
   }
 
+  /**
+   * Gets the path where the scripts are located
+   *
+   * @return path where scripts are located
+   */
   function getBasePath()
   {
     return $this->basePath;
   }
 
+  /**
+   * Sets the path where the scripts are located
+   *
+   * @param $basePath path where scripts are located
+   */
   function setBasePath($basePath)
   {
     $this->basePath = $basePath;
   }
 
+  /**
+   * Sets a set of urlparameters
+   *
+   * @param $urlParams list of parameters to get from the URL
+   */
   function setUrlParams($urlParams)
   {
     foreach($urlParams as $key) {
@@ -83,41 +147,87 @@
     }
   }
 
+  /**
+   * Gets the default language
+   *
+   * @return associative array of key and value for the url parameters
+   */
   function getUrlParams()
   {
     return $this->urlParams;
   }
 
+  /**
+   * Sets the name(identity) for this page
+   *
+   * @param $name name(identity)
+   */
   function setName($name)
   {
     $this->name = $name;
   }
 
+  /**
+   * Gets the name(identity) for this page
+   *
+   * @return name(identity)
+   */
   function getName()
   {
     return $this->name;
   }
 
+  /**
+   * Sets a cache object
+   *
+   * @param $cache CacheTimeCheck object
+   */
   function setCache($cache)
   {
     $this->cache = $cache;
   }
 
+  /**
+   * Gets the cache object
+   *
+   * @return cache object
+   */
   function getCache()
   {
     return $this->cache;
   }
 
+  /**
+   * A list of languages which this configuration supports.
+   *
+   * @return array of two letter language codes
+   */
   function getAcceptedLanguages()
   {
     return $this->acceptedLanguages;
   }
 
+  /**
+   * Gets the default value associated whith the key
+   *
+   * @param $key as specified in master xml file.
+   * @return associated default
+   */
   function getInputDefault($key)
   {
     return $this->inputDefaults[$key];
   }
 
+  /**
+   * Constructs an options object
+   *
+   * This contstructor will consume any tag with the type option, and
+   * extract values from any tag with type input
+   *
+   * @include master.xml
+   *
+   * @param $baseDocument An open xml file
+   */
   function __construct($baseDocument)
   {
     $params = $baseDocument->getElementsByTagName("param");