AAAAhome/academiac/www/administrator/components/com_virtuemart/helpers/paramhelper.php000060400000005140151372154320024766 0ustar00value */ private $_data; /** @var char seperator */ private $_sep; /* * @deprecated */ public function __construct($p = null, $s = '\n') { // initialise $this->_sep = $s; if ($p === null) { $this->_data = array(); } else { $this->parseParam($p); } } /** * Set the field seperator * @param char $s */ public function setSeper($s) { $this->_sep = $s; } /** * Return a single parameter value * @param $p parameter name * @param $d default value * @return mixed parameter value or default value if non existing */ public function get($p, $d = null) { if (array_key_exists($p, $this->_data)) { return $this->_data[$p]; } else { return $d; } } /** * Return a single parameter value * @param $p parameter name * @param $v value */ public function set($p, $v = null) { $this->_data[$p] = $v; } /** * Parse a parameter string and fill the _data array with key/value pairs * @param string $p * @deprecated */ public function parseParam ($p) { if (!$p) { return; } $_arr = explode($this->_sep, $p); if (count($_arr) == 0) { $this->_data = array(); return; } foreach ($_arr as $_p) { $_p = trim($_p); list($k, $v) = explode('=', $_p, 2); $this->_data[$k] = $v; } } /** * Format the _data array for database storage * @return string or null when no parameters exist */ public function paramString() { $s = array(); foreach ($this->_data as $k => $v) { $s[]=$k.'='.$v; } return (count($s) == 0 ) ? null : implode($this->_sep, $s); } } // No closing tag