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

/**
 * Module Chrome Filter 
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Template
 * @subpackage	Filter
 */
class ModDefaultTemplateFilterChrome extends KTemplateFilterAbstract implements KTemplateFilterWrite
{
  	/**
     * Constructor.
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct( KConfig $config = null) 
    { 
        parent::__construct($config);
        
        //Load the theme chrome functions
        include_once JPATH_THEMES.'/system/html/modules.php';
		include_once JPATH_THEMES.'/'.$config->template.'/html/modules.php';
    }
	
	/**
     * Initializes the options 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(
            'priority'   => KCommand::PRIORITY_LOW,
            'template'   => JFactory::getApplication()->getTemplate()
        ));

        parent::_initialize($config);
    }
    
	/**
	 * Render the module chrome
	 *
	 * @param string Block of text to parse
	 * @return ModDefaultFilterChrome
	 */
	public function write(&$text)
	{
		$data = (object) $this->getTemplate()->getData();
		
	    foreach($data->styles as $style)
		{
		    $method = 'modChrome_'.$style;
		   
			// Apply chrome and render module
		    if (function_exists($method))
			{  
			    $data->module->style   = implode(' ', $data->styles);
		        $data->module->content = $text;
		       
				ob_start();
				    $method($data->module, $data->module->params, $data->attribs);
				    $data->module->content = ob_get_contents();
				ob_end_clean();
			}
              
            $text = $data->module->content;
	    }
	    
	    return $this;
    }
}<commit_msg>Only load the template modules.php file if it exists.<commit_after><?php
/**
* @version      $Id$
* @category		Koowa
* @package      Koowa_Template
* @subpackage	Filter
* @copyright    Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
* @license      GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link 		http://www.nooku.org
*/

/**
 * Module Chrome Filter 
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Template
 * @subpackage	Filter
 */
class ModDefaultTemplateFilterChrome extends KTemplateFilterAbstract implements KTemplateFilterWrite
{
  	/**
     * Constructor.
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct( KConfig $config = null) 
    { 
        parent::__construct($config);
        
        //Load the theme chrome functions
        include_once JPATH_THEMES.'/system/html/modules.php';
        
        if(file_exists(JPATH_THEMES.'/'.$config->template.'/html/modules.php')) {
		    include_once JPATH_THEMES.'/'.$config->template.'/html/modules.php';
        }
    }
	
	/**
     * Initializes the options 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(
            'priority'   => KCommand::PRIORITY_LOW,
            'template'   => JFactory::getApplication()->getTemplate()
        ));

        parent::_initialize($config);
    }
    
	/**
	 * Render the module chrome
	 *
	 * @param string Block of text to parse
	 * @return ModDefaultFilterChrome
	 */
	public function write(&$text)
	{
		$data = (object) $this->getTemplate()->getData();
		
	    foreach($data->styles as $style)
		{
		    $method = 'modChrome_'.$style;
		   
			// Apply chrome and render module
		    if (function_exists($method))
			{  
			    $data->module->style   = implode(' ', $data->styles);
		        $data->module->content = $text;
		       
				ob_start();
				    $method($data->module, $data->module->params, $data->attribs);
				    $data->module->content = ob_get_contents();
				ob_end_clean();
			}
              
            $text = $data->module->content;
	    }
	    
	    return $this;
    }
}
{'fraction_non_alphanumeric': 0.13295676732565717, 'fraction_numerical': 0.003910493156636976, 'mean_word_length': 2.4078460399703925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 56, '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': '4154231', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1366, 'n_words': 315}