<commit_before><?php
/**
 * @package    DOCman
 * @copyright   Copyright (C) 2011 - 2013 Timble CVBA (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

class ComKoowaDispatcherBehaviorPageable extends KControllerBehaviorAbstract
{
    /**
     * Automatically set to true if the format query variable is page
     *
     * @var bool
     */
    protected $_enabled = false;

    /**
     * Render the page using HTML format and don't let Joomla touch it
     *
     * @param KDispatcherContextInterface $context
     * @throws RuntimeException
     */
    protected function _beforeDispatch(KDispatcherContextInterface $context)
    {
        if ($context->request->isGet() && $context->request->getFormat() === 'page') {
            $this->_enabled = true;

            $this->_resetDocument('html');

            $context->request->setFormat('html');
        }
    }

    /**
     * Reset the document object in Joomla after rendering it via JDocument
     *
     * @param KDispatcherContextInterface $context
     */
    protected function _afterDispatch(KDispatcherContextInterface $context)
    {
        if ($this->_enabled) {
            $params = array(
                'directory' => dirname(dirname(dirname(__FILE__))) . '/views/page',
                'template'  => 'tmpl',
                'file'      => 'index.html.php',
                'params'    => array()
            );

            $document = JFactory::getDocument();
            $document->parse($params);

            $document->setBuffer($context->result, 'component');

            $context->result = $document->render(false, $params);

            // Revert back to JDocumentRaw to complete the request
            $this->_resetDocument('raw');
        }
    }

    /**
     * Overrides the JDocument instance stored in JFactory to the passed format
     *
     * @param $format
     */
    protected function _resetDocument($format)
    {
        JFactory::getApplication()->input->set('format', $format);

        if (version_compare(JVERSION, '3.0', '<')) {
            JRequest::setVar('format', $format);
        }

        JFactory::$document = null;
        JFactory::getDocument();
    }
}<commit_msg>Formatting<commit_after><?php
/**
 * @package    DOCman
 * @copyright   Copyright (C) 2011 - 2013 Timble CVBA (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

class ComKoowaDispatcherBehaviorPageable extends KControllerBehaviorAbstract
{
    /**
     * Automatically set to true if the format query variable is page
     *
     * @var bool
     */
    protected $_enabled = false;

    /**
     * Render the page using HTML format and don't let Joomla touch it
     *
     * @param KDispatcherContextInterface $context
     * @throws RuntimeException
     */
    protected function _beforeDispatch(KDispatcherContextInterface $context)
    {
        if ($context->request->isGet() && $context->request->getFormat() === 'page') {
            $this->_enabled = true;

            $this->_resetDocument('html');

            $context->request->setFormat('html');
        }
    }

    /**
     * Reset the document object in Joomla after rendering it via JDocument
     *
     * @param KDispatcherContextInterface $context
     */
    protected function _afterDispatch(KDispatcherContextInterface $context)
    {
        if ($this->_enabled)
        {
            $params = array(
                'directory' => dirname(dirname(dirname(__FILE__))) . '/views/page',
                'template'  => 'tmpl',
                'file'      => 'index.html.php',
                'params'    => array()
            );

            $document = JFactory::getDocument();
            $document->parse($params);

            $document->setBuffer($context->result, 'component');

            $context->result = $document->render(false, $params);

            // Revert back to JDocumentRaw to complete the request
            $this->_resetDocument('raw');
        }
    }

    /**
     * Overrides the JDocument instance stored in JFactory to the passed format
     *
     * @param $format
     */
    protected function _resetDocument($format)
    {
        JFactory::getApplication()->input->set('format', $format);

        if (version_compare(JVERSION, '3.0', '<')) {
            JRequest::setVar('format', $format);
        }

        JFactory::$document = null;
        JFactory::getDocument();
    }
}
{'fraction_non_alphanumeric': 0.13157315731573158, 'fraction_numerical': 0.004840484048404841, 'mean_word_length': 2.176799440950384, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6649513', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1210, 'n_words': 280}