summaryrefslogtreecommitdiffstats
path: root/app/classes/PlanetConfig.php
diff options
context:
space:
mode:
authorMaurice Svay <maurice@svay.com>2012-03-06 18:16:00 +0100
committerMaurice Svay <maurice@svay.com>2012-03-07 22:18:57 +0100
commit5d21ae32ac5141cc824946b149f50a461db09597 (patch)
tree8918d6f9c424f87335d0b5243d1f288f1f7011e4 /app/classes/PlanetConfig.php
parent95c72062ca5cfed6bea4cd17cb69003d5b651e62 (diff)
downloadplanet-5d21ae32ac5141cc824946b149f50a461db09597.tar
planet-5d21ae32ac5141cc824946b149f50a461db09597.tar.gz
planet-5d21ae32ac5141cc824946b149f50a461db09597.tar.bz2
planet-5d21ae32ac5141cc824946b149f50a461db09597.tar.xz
planet-5d21ae32ac5141cc824946b149f50a461db09597.zip
One file per class
Diffstat (limited to 'app/classes/PlanetConfig.php')
-rw-r--r--app/classes/PlanetConfig.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/app/classes/PlanetConfig.php b/app/classes/PlanetConfig.php
new file mode 100644
index 0000000..2509e00
--- /dev/null
+++ b/app/classes/PlanetConfig.php
@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * Planet configuration class
+ */
+class PlanetConfig{
+ var $conf;
+
+ function __construct($array){
+ $defaultConfig = Array(
+ 'url' => 'http://www.example.com/',
+ 'name' => '',
+ 'items' => 10,
+ 'shuffle' => 0,
+ 'refresh' => 240,
+ 'cache' => 10,
+ 'nohtml' => 0,
+ 'postmaxlength' => 0,
+ 'cachedir' => './cache'
+ );
+
+ //User config
+ $this->conf = $array;
+
+ //Complete config with default config
+ foreach ($defaultConfig as $key => $value){
+ if (!isset($this->conf[$key])){
+ $this->conf[$key] = $value;
+ }
+ }
+ }
+
+ function getUrl(){
+ return $this->conf['url'];
+ }
+
+ function getName(){
+ return $this->conf['name'];
+ }
+
+ function setName($name){
+ $this->conf['name'] = $name;
+ }
+
+ function getCacheTimeout(){
+ return $this->conf['refresh'];
+ }
+
+ function getOutputTimeout(){
+ return $this->conf['cache'];
+ }
+
+ //@TODO: drop this pref
+ function getShuffle(){
+ return $this->conf['shuffle'];
+ }
+
+ function getMaxDisplay(){
+ return $this->conf['items'];
+ }
+
+ //@TODO: drop this pref
+ function getNoHTML(){
+ return $this->conf['nohtml'];
+ }
+
+ //@TODO: drop this pref
+ function getPostMaxLength(){
+ return $this->conf['postmaxlength'];
+ }
+
+ function toYaml(){
+ return Spyc::YAMLDump($this->conf,4);
+ }
+} \ No newline at end of file