diff Options.inc @ 26:d8c7b328899e

Removed globals, and introduced Options object for passing values around. Introduced <accepted_values> tag into master.xml
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Sun, 30 Sep 2012 00:16:58 +0200
parents
children 394b5df43d1a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Options.inc	Sun Sep 30 00:16:58 2012 +0200
@@ -0,0 +1,58 @@
+<?php
+class Options
+{
+  private $defaultLang;
+  private $lang;
+  private $name;
+  private $acceptedLanguages = array();
+
+  function getDefaultLang()
+  {
+    return $this->defaultLang;
+  }
+
+  function getLang()
+  {
+    return $this->lang;
+  }
+
+  function setLang($lang)
+  {
+    $this->lang = $lang;
+  }
+
+  function setName($name)
+  {
+    $this->name = $name;
+  }
+
+  function getName()
+  {
+    return $this->name;
+  }
+
+  function __construct($baseDocument)
+  {
+    $params = $baseDocument->getElementsByTagName("param");
+    foreach ($params as $param) {
+      if ($param->getAttribute("type") == "option") {
+	$id = $param->getAttribute("id");
+	if ($id == "lang") {
+	  $this->defaultLang = $param->getAttribute("default");
+	  $accepts = $param->getElementsByTagName("accept_value");
+	  foreach($accepts as $accept) {
+	    foreach($accept->childNodes as $child) {
+	      array_push($this->acceptedLanguages, $child->nodeValue);
+	    }
+	  }
+	}
+	else {
+	  die("Invalid option : $id");
+	}
+	$parent = $param->parentNode;
+	$parent->removeChild($param);
+      }
+    }
+  }
+}
+?>
\ No newline at end of file