<commit_before><?php
/**
 * @version		$Id$
 * @category	Koowa
 * @package		Koowa_Dispatcher
 * @copyright	Copyright (C) 2007 - 2009 <NAME> and <NAME>. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.koowa.org
 */

/**
 * Abstract controller dispatcher
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Dispatcher
 * @uses		KMixinClass
 * @uses        KObject
 * @uses        KFactory
 */
abstract class KDispatcherAbstract extends KObject
{
	/**
	 * Options
	 *
	 * @var array
	 */
	protected $_options;
	
	/**
	 * Constructor.
	 *
	 * @param	array An optional associative array of configuration settings.
	 * Recognized key values include 'name', 'default_view'
	 */
	public function __construct(array $options = array())
	{
        // Initialize the options
        $this->_options  = $this->_initialize($options);
         
        // Mixin the KClass
        $this->mixin(new KMixinClass(array('mixer' => $this, 'name_base' => 'Dispatcher')));

        // Assign the classname with values from the config
        $this->setClassName($options['name']);
        
        // Figure out default view if none is set
        $this->_options['default_view'] = empty($this->_options['default_view']) ? $this->getClassName('suffix') : $this->_options['default_view'];
	}

    /**
     * Initializes the options for the object
     * 
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param	array	Options
     * @return 	array	Options
     */
    protected function _initialize(array $options)
    {
        $defaults = array(
        	'default_view'  => '',
            'name'          => array(
                        'prefix'    => 'k',
                        'base'      => 'dispatcher',
                        'suffix'    => 'default'
                        )
        );

        return array_merge($defaults, $options);
    }

	/**
	 * Dispatch the controller and redirect
	 * 
	 * @return	this
	 */
	public function dispatch()
	{
		// Require specific controller if requested
		$view		= KRequest::get('get.view', 'cmd', $this->_options['default_view']);
        
        // Push the view back in the request in case a default view is used
        KRequest::set('get.view', $view);

        //Get/Create the controller
        $controller = $this->getController();
        
        // Perform the Request action
        $default = KRequest::get('get.action', 'cmd', 'read');
        $action  = KRequest::get('post.action', 'cmd', $default);
        
        //Execute the controller, handle exeception if thrown.
        try 
        {
        	$controller->execute($action);<commit_msg>Removed default action, using $_REQUEST<commit_after><?php
/**
 * @version		$Id$
 * @category	Koowa
 * @package		Koowa_Dispatcher
 * @copyright	Copyright (C) 2007 - 2009 <NAME> and <NAME>. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.koowa.org
 */

/**
 * Abstract controller dispatcher
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Dispatcher
 * @uses		KMixinClass
 * @uses        KObject
 * @uses        KFactory
 */
abstract class KDispatcherAbstract extends KObject
{
	/**
	 * Options
	 *
	 * @var array
	 */
	protected $_options;
	
	/**
	 * Constructor.
	 *
	 * @param	array An optional associative array of configuration settings.
	 * Recognized key values include 'name', 'default_view'
	 */
	public function __construct(array $options = array())
	{
        // Initialize the options
        $this->_options  = $this->_initialize($options);
         
        // Mixin the KClass
        $this->mixin(new KMixinClass(array('mixer' => $this, 'name_base' => 'Dispatcher')));

        // Assign the classname with values from the config
        $this->setClassName($options['name']);
        
        // Figure out default view if none is set
        $this->_options['default_view'] = empty($this->_options['default_view']) ? $this->getClassName('suffix') : $this->_options['default_view'];
	}

    /**
     * Initializes the options for the object
     * 
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param	array	Options
     * @return 	array	Options
     */
    protected function _initialize(array $options)
    {
        $defaults = array(
        	'default_view'  => '',
            'name'          => array(
                        'prefix'    => 'k',
                        'base'      => 'dispatcher',
                        'suffix'    => 'default'
                        )
        );

        return array_merge($defaults, $options);
    }

	/**
	 * Dispatch the controller and redirect
	 * 
	 * @return	this
	 */
	public function dispatch()
	{
		// Require specific controller if requested
		$view		= KRequest::get('get.view', 'cmd', $this->_options['default_view']);
        
        // Push the view back in the request in case a default view is used
        KRequest::set('get.view', $view);

        //Get/Create the controller
        $controller = $this->getController();
        
        // Perform the Request action
        $action  = KRequest::get('request.action', 'cmd', null);
        
        //Execute the controller, handle exeception if thrown.
        try 
        {
        	$controller->execute($action);
{'fraction_non_alphanumeric': 0.1336888561971313, 'fraction_numerical': 0.004045605001838912, 'mean_word_length': 2.1751313485113837, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 51, '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': '2361238', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1524, 'n_words': 413}