<commit_before><?php
/**
 * @version     $Id$
 * @category	Nooku
 * @package     Nooku_Modules
 * @subpackage  Default
 * @copyright   Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Default Module View
.*
 * @author      <NAME> <<EMAIL>>
 * @category    Nooku
 * @package     Nooku_Modules
 * @subpackage  Default
 */
class ModDefaultHtml extends KViewHtml
{
	/**
     * Initializes the default configuration for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   object  An optional KConfig object with configuration options
     * @return  void
     */
    protected function _initialize(KConfig $config)
    {      
        $config->append(array(
        	'template_filters' => array('chrome'),
            'data'			   => array(
                'styles' => array() 
            )
        ));
        
        parent::_initialize($config);
    }
      
	/**
	 * Get the name
	 *
	 * @return 	string 	The name of the object
	 */
	public function getName()
	{
		return $this->getIdentifier()->package;
	}
	
	/**
     * Renders and echo's the views output
     *
     * @return ModDefaultHtml
     */
    public function display()
    { 
		//Load the language files.
		//Type only exists if the module is loaded through ComExtensionsModelsModules
		if(isset($this->module->type)) {
            JFactory::getLanguage()->load($this->module->type);
		}
        
		if(empty($this->module->content)) 
		{
            $this->output = $this->getTemplate()
                ->loadIdentifier($this->_layout, $this->_data)
                ->render();
		}
		else 
		{
		     $this->output = $this->getTemplate()
                ->loadString($this->module->content, $this->_data, false)
                ->render();
		}
	
        return $this->output;
    }
    
    /**
     * Set a view properties
     *
     * @param   string  The property name.
     * @param   mixed   The property value.
     */
    public function __set($property, $value)
    {
        if($property == 'module') 
        {
            if(is_string($value->params)) {
                $value->params = $this->_parseParams($value->params);
            }
        }
        
        parent::__set($property, $value);
    }
    
    /**
     * Method to extract key/value pairs out of a string
     *
     * @param   string  String containing the parameters
     * @return  array   Key/Value pairs for the attributes
     */
    protected function _parseParams( $string )
    {
        $params = array();
        
        if(!version_compare(JVERSION,'1.6.0','ge')) 
        {
            $string = trim($string);
        
            if(!empty($string))
            {
                foreach(explode("\n", $string) as $line) 
                {
                    $param = explode("=", $line, 2);
                    $params[$param[0]] = $param[1];
                }
            }
        } 
        else $params = json_decode($value->params);
       
        $params = new KConfig($params);     
        return $params;
    }
}<commit_msg>re #207 : Fixed typo<commit_after><?php
/**
 * @version     $Id$
 * @category	Nooku
 * @package     Nooku_Modules
 * @subpackage  Default
 * @copyright   Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Default Module View
.*
 * @author      <NAME> <<EMAIL>>
 * @category    Nooku
 * @package     Nooku_Modules
 * @subpackage  Default
 */
class ModDefaultHtml extends KViewHtml
{
	/**
     * Initializes the default configuration for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   object  An optional KConfig object with configuration options
     * @return  void
     */
    protected function _initialize(KConfig $config)
    {      
        $config->append(array(
        	'template_filters' => array('chrome'),
            'data'			   => array(
                'styles' => array() 
            )
        ));
        
        parent::_initialize($config);
    }
      
	/**
	 * Get the name
	 *
	 * @return 	string 	The name of the object
	 */
	public function getName()
	{
		return $this->getIdentifier()->package;
	}
	
	/**
     * Renders and echo's the views output
     *
     * @return ModDefaultHtml
     */
    public function display()
    { 
		//Load the language files.
		//Type only exists if the module is loaded through ComExtensionsModelsModules
		if(isset($this->module->type)) {
            JFactory::getLanguage()->load($this->module->type);
		}
        
		if(empty($this->module->content)) 
		{
            $this->output = $this->getTemplate()
                ->loadIdentifier($this->_layout, $this->_data)
                ->render();
		}
		else 
		{
		     $this->output = $this->getTemplate()
                ->loadString($this->module->content, $this->_data, false)
                ->render();
		}
	
        return $this->output;
    }
    
    /**
     * Set a view properties
     *
     * @param   string  The property name.
     * @param   mixed   The property value.
     */
    public function __set($property, $value)
    {
        if($property == 'module') 
        {
            if(is_string($value->params)) {
                $value->params = $this->_parseParams($value->params);
            }
        }
        
        parent::__set($property, $value);
    }
    
    /**
     * Method to extract key/value pairs out of a string
     *
     * @param   string  String containing the parameters
     * @return  array   Key/Value pairs for the attributes
     */
    protected function _parseParams( $string )
    {
        $params = array();
        
        if(!version_compare(JVERSION,'1.6.0','ge')) 
        {
            $string = trim($string);
        
            if(!empty($string))
            {
                foreach(explode("\n", $string) as $line) 
                {
                    $param = explode("=", $line, 2);
                    $params[$param[0]] = $param[1];
                }
            }
        } 
        else $params = json_decode($string);
       
        $params = new KConfig($params);     
        return $params;
    }
}
{'fraction_non_alphanumeric': 0.1338977735967388, 'fraction_numerical': 0.0051740357478833494, 'mean_word_length': 1.7006773920406435, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6337512', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1811, 'n_words': 429}