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

/**
 * Abstract View Controller Class
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Controller
 * @uses        KInflector
 */
abstract class KControllerResource extends KControllerAbstract
{
	/**
	 * URL for redirection.
	 *
	 * @var	string
	 */
	protected $_redirect = null;

	/**
	 * Redirect message.
	 *
	 * @var	string
	 */
	protected $_redirect_message = null;

	/**
	 * Redirect message type.
	 *
	 * @var	string
	 */
	protected $_redirect_type = 'message';
	
	/**
	 * View object or identifier (com://APP/COMPONENT.view.NAME.FORMAT)
	 *
	 * @var	string|object
	 */
	protected $_view;
	
	/**
	 * Model object or identifier (com://APP/COMPONENT.model.NAME)
	 *
	 * @var	string|object
	 */
	protected $_model;
	
	/**
	 * Constructor
	 *
	 * @param 	object 	An optional KConfig object with configuration options.
	 */
	public function __construct(KConfig $config)
	{
		parent::__construct($config);

	    // Set the model identifier
	    $this->_model = $config->model;
		
		// Set the view identifier
		$this->_view = $config->view;
		
		//Register display as alias for get
		$this->registerActionAlias('display', 'get');
		
		//Made the executable behavior read-only
		if($this->isExecutable()) {
		    $this->getBehavior('executable')->setReadOnly($config->readonly);
		}
	}

	/**
     * 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(
    	    'model'	     => $this->getIdentifier()->name,
        	'view'	     => $this->getIdentifier()->name,
    	    'behaviors'  => array('executable', 'commandable'),
    	    'readonly'   => true, 
    		'request' 	 => array('format' => 'html')
        ));
        
        parent::_initialize($config);
        
        //Force the view to the information found in the request
        if(isset($config->request->view)) {
            $config->view = $config->request->view;
        }
    }
    
	/**<commit_msg>Fixed : KControllerResource overwrites view in config<commit_after><?php
/**
 * @version		$Id$
 * @category	Koowa
 * @package     Koowa_Controller
 * @copyright	Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link     	http://www.nooku.org
 */

/**
 * Abstract View Controller Class
 *
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Controller
 * @uses        KInflector
 */
abstract class KControllerResource extends KControllerAbstract
{
	/**
	 * URL for redirection.
	 *
	 * @var	string
	 */
	protected $_redirect = null;

	/**
	 * Redirect message.
	 *
	 * @var	string
	 */
	protected $_redirect_message = null;

	/**
	 * Redirect message type.
	 *
	 * @var	string
	 */
	protected $_redirect_type = 'message';
	
	/**
	 * View object or identifier (com://APP/COMPONENT.view.NAME.FORMAT)
	 *
	 * @var	string|object
	 */
	protected $_view;
	
	/**
	 * Model object or identifier (com://APP/COMPONENT.model.NAME)
	 *
	 * @var	string|object
	 */
	protected $_model;
	
	/**
	 * Constructor
	 *
	 * @param 	object 	An optional KConfig object with configuration options.
	 */
	public function __construct(KConfig $config)
	{
		parent::__construct($config);

	    // Set the model identifier
	    $this->_model = $config->model;
		
		// Set the view identifier
		$this->_view = $config->view;
		
		//Register display as alias for get
		$this->registerActionAlias('display', 'get');
		
		//Made the executable behavior read-only
		if($this->isExecutable()) {
		    $this->getBehavior('executable')->setReadOnly($config->readonly);
		}
	}

	/**
     * 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(
    	    'model'	     => $this->getIdentifier()->name,
        	'view'	     => $this->getIdentifier()->name,
    	    'behaviors'  => array('executable', 'commandable'),
    	    'readonly'   => true, 
    		'request' 	 => array('format' => 'html')
        ));
        
        parent::_initialize($config);
    }
    
	/**
{'fraction_non_alphanumeric': 0.14237573715248525, 'fraction_numerical': 0.0037910699241786015, 'mean_word_length': 2.633511859219587, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 58, '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': '3390535', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1437, 'n_words': 358}