Changeset 4460

User picture

Author: Johan Janssens

(2012/02/02 22:54) 4 months ago

re #207 : Added ModDefaultHtml::_parseParams() function. Params are parsed either from json or ini format (dependant on the Joomla version) to a KConfig object. JParameter is no longer used.

Affected files

Updated trunk/code/site/modules/mod_default/html.php Download diff

44594460
89
        if($property == 'module') 
89
        if($property == 'module') 
90
        {
90
        {
91
            if(is_string($value->params)) {
91
            if(is_string($value->params)) {
92
                $value->params = new JParameter($value->params);
92
                $value->params = $this->_parseParams($value->params);
93
            }
93
            }
94
        }
94
        }
95
        
95
        
96
        parent::__set($property, $value);
96
        parent::__set($property, $value);
97
    }
97
    }
98
    
99
	/**
100
     * Method to extract key/value pairs out of a string
101
     *
102
     * @param   string  String containing the parameters
103
     * @return  array   Key/Value pairs for the attributes
104
     */
105
    protected function _parseParams( $string )
106
    {
107
        $params = array();
108
        
109
        if(!version_compare(JVERSION,'1.6.0','ge')) 
110
        {
111
            $string = trim($string);
112
        
113
            if(!empty($string))
114
            {
115
                foreach(explode("\n", $string) as $line) 
116
                {
117
                    $param = explode("=", $line, 2);
118
                    $params[$param[0]] = $param[1];
119
                }
120
            }
121
        } 
122
        else $params = json_decode($value->params);
123
       
124
        $params = new KConfig($params);     
125
        return $params;
126
    }
98
}
127
}