00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class aliroParameters {
00046 protected $params = array();
00047 protected $raw = null;
00048 protected $xml = null;
00049
00050 public function __construct ($text='', $xml='') {
00051 $this->raw = is_null($text) ? '' : $text;
00052 if (!is_string($this->raw)) trigger_error (T_('Raw data for aliroParameters not a string'));
00053
00054 $this->params = @unserialize($this->raw);
00055 if (!is_array($this->params)) $this->params = array();
00056 if ($this->raw AND count($this->params) == 0) trigger_error (T_('Raw data for aliroParameters was not null, but did not yield any values'));
00057
00058 foreach ($this->params as &$param) $param = base64_decode($param);
00059 $this->xml = $xml;
00060 }
00061
00062 public function getParams () {
00063 die ('Aliro handles parameters differently, please review what you need');
00064 }
00065
00066 public function set( $key, $value='' ) {
00067 $this->params[$key] = $value;
00068 return $value;
00069 }
00070
00071 public function setAll ($keyedValues) {
00072 $this->params = $keyedValues;
00073 }
00074
00075 public function def( $key, $value='' ) {
00076 return $this->set ($key, $this->get($key, $value));
00077 }
00078
00079 public function get( $key, $default='' ) {
00080 if (isset($this->params[$key])) return $this->params[$key] === '' ? $default : $this->params[$key];
00081 else return $default;
00082 }
00083
00084 public function __get ($property) {
00085 return $this->get ($property);
00086 }
00087
00088 public function processInput ($params) {
00089 $inarray = (array) $params;
00090 foreach ($inarray as &$param) if (ini_get('magic_quotes-gpc')) $param = stripslashes($param);
00091 $this->params = $inarray;
00092 return $this->asString();
00093 }
00094
00095 public function asString () {
00096 $encoded = array();
00097 foreach ($this->params as $key=>$param) $encoded[$key] = base64_encode($param);
00098 return serialize($encoded);
00099 }
00100
00101 public function asPost () {
00102 return $this->params;
00103 }
00104
00105 public function render ($name='params') {
00106 if ($this->xml) {
00107 $params = new aliroXMLParams;
00108 if (is_file($this->xml)) return $params->paramsFromFile($this->xml, $this, $name);
00109 else return $params->paramsFromString($this->xml, T_('Data passed to aliroParameters'), $this, $name);
00110 }
00111 return "<textarea name='$name' cols='40' rows='10' class='text_area'>$this->raw</textarea>";
00112 }
00113
00114 }
00115
00116 class mosParameters extends aliroParameters {
00117
00118 }
00119
00120 class mosAdminParameters extends aliroParameters {
00121
00122
00123
00124 }
00125
00126
00127
00128 class mosSpecialAdminParameters extends aliroParameters {
00129
00130 function __construct ($name, $version='') {
00131 $database = aliroDatabase::getInstance();
00132 $sql = "SELECT * FROM #__parameters WHERE param_name='$name'";
00133 if ($version) $sql .= " AND param_version='$version'";
00134 $database->setQuery($sql);
00135 $parameters = $database->loadObjectList();
00136 if ($parameters) $parameters = $parameters[0];
00137 parent::__construct($parameters->params, aliroCore::get('mosConfig_absolute_path').'/parameters/'.$parameters->param_file);
00138 }
00139 }