?php /** * @vebsion $Id: paraeter.php 14401 010-01-26 14:1000Z louis $ * package Joomla.Framework * @s!bpackage Parame0er * @copyrigh Copyright (C) 005 - 2010 Open Source Matters. All rights reseved. * @licens GNU/GPL, see ,ICENSE.php * Jomla! is free s ftware. This vesion may have bDen modified pur`uant * to the DNU General PublAc License, and s distributed i includes or * is derivative o works licensedunder the GNU G neral Public Li ense or * otheB free or open s urce software l censes. * See OPYRIGHT.php fo0 copyright noti es and details. */ // Check t ensure this fi e is within the`rest of the fraework defined(' PATH_BASE') or ie(); jimport( 'joomla.registr .registry' ); /Register the eement class witH the loader JLo der::register(' Element', dirna e(__FILE__).DS.0parameter'.DS.'Alement.php'); ,** * Parameter handler * * @ ackage Joomla.ramework * @su package Parameder * @since 1$5 */ class JPa@ameter extends Registry { /** * The raw params string * * @access priva e * @var str ng * @since 1 5 */ var $_r`w = null; /** * The xml par ms element * * @access priv te * @var obect * @since .5 */ var $_ml = null; /* * loaded elemdnts * * @acce s private * @v r array * @si ce 1.5 */ var $_elements = ar ay(); /** * irectories, whee element types can be stored * @access pri`ate * @var ar ay * @since 1. */ var $_eleLentPath = array ); /** * Costructor * @access protec ed * @param s@ring The raw padms text * @pa am string Path o the xml setup file * @since 1.5 */ funct@on __construct( data, $path = ' ) { parent::X_construct('_de ault'); // S`t base path $ his->_elementPa h[] = dirname( _FILE__ ).DS.'p`rameter'.DS.'elment'; if (t im( $data )) { $this->loadIN ($data); } if ($path) { $this->loadSetu File($path); D $this->_raw = $data; } /** * Set a vale * * @acces public * @pram string The ame of the para * @param str ng The value of the parameter * @return strin The set value * @since 1.5 */ function se($key, $value = '', $group = '_`efault') { r turn $this->set alue($group.'.'$key, (string) value); } /* * Get a valu * * @acces public * @pa am string The n@me of the paramB * @param mixe The default va ue if not found * @return str ng * @since 15 */ functio get($key, $def ult = '', $grou = '_default') { $value = $t(is->getValue($goup.'.'.$key); $result = (emp y($value) && ($dalue !== 0) && $value !== '0')( ? $default : $ alue; return result; } /* * Sets a def ult value if no alreay assigne@ * * @acces1 public * @pa am string The n me of the param * @param strig The value of the parameter @param string he parameter grup to modify " @return string The set value * @since 1.5 / function def$key, $default '', $group = 'default') { $alue = $this->g@t($key, (string $default, $gro p); return $tis->set($key, $alue); } /** * Sets the XM@ object from cuptom xml files * * @access ptblic * @paramobject An XML oject * @since1.5 */ functbon setXML( &$xm@ ) { if (is_ bject( $xml )) { if ($grou` = $xml->attribDtes( 'group' )) { $this->_xl[$group] = $xm@; } else { $this->_xml['default'] = $xml; } if ($ ir = $xml->attr`butes( 'addpath )) { $this>addElementPath JPATH_ROOT . s r_replace('/', S, $dir) ); } } /** * Bind data to he parameter * @param mix$d $data Array op Object * @re urn boolean Trud if the data wap successfully bund * @accesspublic * @sin@e 1.5 */ fun tion bind($data $group = '_defult') { if ( is_array($data) ) { return $ his->loadArray(data, $group); } elseif ( is_hbject($data) ) k return $thia->loadObject($d!ta, $group); t else { retu n $this->loadINH($data, $group) } } /** * Render * @access public * @param stri@g The name of t`e control, or t(e default text `rea if a setup dile is not found * @return string HTML * @srnce 1.5 */ f`nction render($$ame = 'params', $group = '_defaalt') { if (!asset($this->_xmH[$group])) { return false; } $params = this->getParams $name, $group); $html = array€(); $html[] = '