<commit_before><?php
/**
 * @version     $Id: link.php -1 1970-01-01 00:00:00Z  $
 * @package     Nooku_Server
 * @subpackage  Pages
 * @copyright   Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Module Template Filter Class
 *
 * Filter will parse elements of the form <html:modules position="[position]" /> and render the modules that are
 * available for this position.
 *
 * Filter will parse elements of the form <html:module position="[position]">[content]</module> and inject the
 * content into the module position.
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package     Nooku_Server
 * @subpackage  Pages
 */
class ComPagesTemplateFilterModule extends KTemplateFilterAbstract implements KTemplateFilterWrite
{
    /**
     * Modules
     *
     * @var ComPagesDatabaseRowsetModules
     */
    protected $_modules;

    /**
     * Parse <khtml:modules /> and <khtml:modules></khtml:modules> tags
     *
     * @param string Block of text to parse
     * @return ComPagesTemplateFilterModule
     */
    public function write(&$text)
    {
        $this->_parseModuleTags($text);
        $this->_parseModulesTags($text);

        return $this;
    }

    /**
     * Parse <ktml:module></ktml:module> tags
     *
     * @param string Block of text to parse
     * @@return ComPagesDatabaseRowsetModules The rowset object.
     */
    public function _parseModuleTags(&$text)
    {
        $matches = array();
        if(preg_match_all('#<ktml:module\s+([^>]*)>(.*)</ktml:module>#siU', $text, $matches))
        {
            foreach($matches[0] as $key => $match)
            {
                //Create attributes array
                $defaults = array(
                    'params'	=> '',
                    'title'		=> '',
                    'class'		=> '',
                    'position'  => ''
                );

                $attributes = array_merge($defaults, $this->_parseAttributes($matches[1][$key]));

                //Create module object
                $values = array(
                    'id'         => uniqid(),
                    'content'    => $matches[2][$key],
                    'position'   => $attributes['position'],
                    'params'     => $attributes['params'],
                    'title'      => $attributes['title'],
                    'name'       => 'mod_default',
                    'identifier' => $this->getIdentifier('com://admin/default.module.default.html'),
                    'attribs'    => array_diff_key($attributes, $defaults)
                );

                $this->_loadModules()->addData(array($values), false);
            }

            //Remove the <khtml:module></khtml:module> tags
            $text = str_replace($matches[0], '', $text);
        }
    }

    /**
     * Parse <khtml:modules /> and <khtml:modules></khtml:modules> tags
     *
     * @param string Block of text to parse
     * @return ComPagesTemplateFilterModule
     */
    public function _parseModulesTags(&$text)
    {
        $replace = array();
        $matches = array();
        // <ktml:modules position="[position]" />
        if(preg_match_all('#<ktml:modules\s+position="([^"]+)"(.*)\/>#iU', $text, $matches))
        {
            $count = count($matches[1]);<commit_msg>KDatabaseRowset::addData() has been renamed to KDatabaseRowset::addRow()<commit_after><?php
/**
 * @version     $Id: link.php -1 1970-01-01 00:00:00Z  $
 * @package     Nooku_Server
 * @subpackage  Pages
 * @copyright   Copyright (C) 2007 - 2012 <NAME>. All rights reserved.
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Module Template Filter Class
 *
 * Filter will parse elements of the form <html:modules position="[position]" /> and render the modules that are
 * available for this position.
 *
 * Filter will parse elements of the form <html:module position="[position]">[content]</module> and inject the
 * content into the module position.
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/johanjanssens>
 * @package     Nooku_Server
 * @subpackage  Pages
 */
class ComPagesTemplateFilterModule extends KTemplateFilterAbstract implements KTemplateFilterWrite
{
    /**
     * Modules
     *
     * @var ComPagesDatabaseRowsetModules
     */
    protected $_modules;

    /**
     * Parse <khtml:modules /> and <khtml:modules></khtml:modules> tags
     *
     * @param string Block of text to parse
     * @return ComPagesTemplateFilterModule
     */
    public function write(&$text)
    {
        $this->_parseModuleTags($text);
        $this->_parseModulesTags($text);

        return $this;
    }

    /**
     * Parse <ktml:module></ktml:module> tags
     *
     * @param string Block of text to parse
     * @@return ComPagesDatabaseRowsetModules The rowset object.
     */
    public function _parseModuleTags(&$text)
    {
        $matches = array();
        if(preg_match_all('#<ktml:module\s+([^>]*)>(.*)</ktml:module>#siU', $text, $matches))
        {
            foreach($matches[0] as $key => $match)
            {
                //Create attributes array
                $defaults = array(
                    'params'	=> '',
                    'title'		=> '',
                    'class'		=> '',
                    'position'  => ''
                );

                $attributes = array_merge($defaults, $this->_parseAttributes($matches[1][$key]));

                //Create module object
                $values = array(
                    'id'         => uniqid(),
                    'content'    => $matches[2][$key],
                    'position'   => $attributes['position'],
                    'params'     => $attributes['params'],
                    'title'      => $attributes['title'],
                    'name'       => 'mod_default',
                    'identifier' => $this->getIdentifier('com://admin/default.module.default.html'),
                    'attribs'    => array_diff_key($attributes, $defaults)
                );

                $this->_loadModules()->addRow(array($values), false);
            }

            //Remove the <khtml:module></khtml:module> tags
            $text = str_replace($matches[0], '', $text);
        }
    }

    /**
     * Parse <khtml:modules /> and <khtml:modules></khtml:modules> tags
     *
     * @param string Block of text to parse
     * @return ComPagesTemplateFilterModule
     */
    public function _parseModulesTags(&$text)
    {
        $replace = array();
        $matches = array();
        // <ktml:modules position="[position]" />
        if(preg_match_all('#<ktml:modules\s+position="([^"]+)"(.*)\/>#iU', $text, $matches))
        {
            $count = count($matches[1]);
{'fraction_non_alphanumeric': 0.14906651108518088, 'fraction_numerical': 0.008459743290548424, 'mean_word_length': 1.9891020052310375, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 85, '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': '3436802', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1923, 'n_words': 410}