<commit_before><?php
/* SVN FILE: $Id$ */

/**
 * Dispatcher takes the URL information, parses it for paramters and 
 * tells the involved controllers what to do.
 * 
 * This is the heart of Cake's operation. 
 *
 * PHP versions 4 and 5
 *
 * CakePHP :  Rapid Development Framework <http://www.cakephp.org/>
 * Copyright (c) 2005, CakePHP Authors/Developers
 *
 * Author(s): <NAME> aka Pies <<EMAIL>>
 *            <NAME> aka PhpNut <<EMAIL>>
 *            <NAME> aka Brego <<EMAIL>>
 *
 *  Licensed under The MIT License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource 
 * @author       CakePHP Authors/Developers
 * @copyright    Copyright (c) 2005, CakePHP Authors/Developers
 * @link         https://trac.cakephp.org/wiki/Authors Authors/Developers
 * @package      cake
 * @subpackage   cake.libs
 * @since        CakePHP v 0.2.9
 * @version      $Revision$
 * @modifiedby   $LastChangedBy$
 * @lastmodified $Date$
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Add Description
 */
uses('error_messages', 'object', 'router', '/controller/controller', '/controller/scaffold');

/**
 * Short description for class.
 * 
 * Dispatches the request, creating appropriate models and controllers.
 *
 * @package    cake
 * @subpackage cake.libs
 * @since      CakePHP v 0.2.9
 */
class Dispatcher extends Object
{
/**
 * Base URL
 * @var string
 */
   var $base = false;

/**
 * Constructor.
 */
   function __construct()
   {
      $this->base = $this->baseUrl();
      parent::__construct();
   }

/**
 * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
 *
 * If no controller of given name can be found, invoke() shows error messages in 
 * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called 
 * Actions).
 *
 * @param string $url	URL information to work on.
 * @return boolean		Success
 */
   function dispatch($url, $additionalParams=array())
   {
      $params = array_merge($this->parseParams($url), $additionalParams);
      $missingController = false;
      $missingAction     = false;
      $missingView       = false;
      
      if(!in_array('render', array_keys($params)))
      {
          $params['render'] = 0;
      }
          
      if (empty($params['controller']))
      {
         $missingController = true;
      }
      else
      {
         $ctrlName  = Inflector::camelize($params['controller']);
         $ctrlClass = $ctrlName.'Controller';

         if (!loadController($ctrlName) || !class_exists($ctrlClass))
         {
            $missingController = true;
         }
      }

      if ($missingController)
      {
         $controller       =& new AppController();
         $params['action'] = 'missingController';
         $params['controller'] = Inflector::camelize($params['controller']."Controller");
         $controller->missingController = $params['controller'];
         return $this->_invoke($controller, $params );
      }
      else
      {
         $controller =& new $ctrlClass($this);
      }
      
      $classMethods = get_class_methods($controller);
      $classVars = get_object_vars($controller);
      
      if (empty($params['action']))
      {
          $params['action'] = 'index';
      }
      
      if(!in_array($params['action'], $classMethods))
      {
          $missingAction = true;
      }
      
      $controller->base        = $this->base;
      $controller->here        = $this->base.'/'.$url;
      $controller->webroot     = $this->webroot;
      $controller->params      = $params;
      $controller->action      = $params['action'];
      $controller->data        = empty($params['data'])? null: $params['data'];
      $controller->passed_args = empty($params['pass'])? null: $params['pass'];
      $controller->viewpath = Inflector::underscore($ctrlName);
      $controller->autoLayout = !$params['bare'];
      $controller->autoRender = !$params['render'];
<commit_msg>fixed missing paths in missing controller error page<commit_after><?php
/* SVN FILE: $Id$ */

/**
 * Dispatcher takes the URL information, parses it for paramters and 
 * tells the involved controllers what to do.
 * 
 * This is the heart of Cake's operation. 
 *
 * PHP versions 4 and 5
 *
 * CakePHP :  Rapid Development Framework <http://www.cakephp.org/>
 * Copyright (c) 2005, CakePHP Authors/Developers
 *
 * Author(s): <NAME>ka Pies <<EMAIL>>
 *            <NAME> aka PhpNut <<EMAIL>>
 *            <NAME> aka Brego <<EMAIL>>
 *
 *  Licensed under The MIT License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource 
 * @author       CakePHP Authors/Developers
 * @copyright    Copyright (c) 2005, CakePHP Authors/Developers
 * @link         https://trac.cakephp.org/wiki/Authors Authors/Developers
 * @package      cake
 * @subpackage   cake.libs
 * @since        CakePHP v 0.2.9
 * @version      $Revision$
 * @modifiedby   $LastChangedBy$
 * @lastmodified $Date$
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Add Description
 */
uses('error_messages', 'object', 'router', '/controller/controller', '/controller/scaffold');

/**
 * Short description for class.
 * 
 * Dispatches the request, creating appropriate models and controllers.
 *
 * @package    cake
 * @subpackage cake.libs
 * @since      CakePHP v 0.2.9
 */
class Dispatcher extends Object
{
/**
 * Base URL
 * @var string
 */
   var $base = false;

/**
 * Constructor.
 */
   function __construct()
   {
      $this->base = $this->baseUrl();
      parent::__construct();
   }

/**
 * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
 *
 * If no controller of given name can be found, invoke() shows error messages in 
 * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called 
 * Actions).
 *
 * @param string $url	URL information to work on.
 * @return boolean		Success
 */
   function dispatch($url, $additionalParams=array())
   {
      $params = array_merge($this->parseParams($url), $additionalParams);
      $missingController = false;
      $missingAction     = false;
      $missingView       = false;
      
      if(!in_array('render', array_keys($params)))
      {
          $params['render'] = 0;
      }
          
      if (empty($params['controller']))
      {
         $missingController = true;
      }
      else
      {
         $ctrlName  = Inflector::camelize($params['controller']);
         $ctrlClass = $ctrlName.'Controller';

         if (!loadController($ctrlName) || !class_exists($ctrlClass))
         {
            $missingController = true;
         }
      }

      if ($missingController)
      {
         $controller       =& new AppController();
         $params['action'] = 'missingController';
         $params['controller'] = Inflector::camelize($params['controller']."Controller");
         $controller->missingController = $params['controller'];
         $controller->webroot     = $this->webroot;
         return $this->_invoke($controller, $params );
      }
      else
      {
         $controller =& new $ctrlClass($this);
      }
      
      $classMethods = get_class_methods($controller);
      $classVars = get_object_vars($controller);
      
      if (empty($params['action']))
      {
          $params['action'] = 'index';
      }
      
      if(!in_array($params['action'], $classMethods))
      {
          $missingAction = true;
      }
      
      $controller->base        = $this->base;
      $controller->here        = $this->base.'/'.$url;
      $controller->webroot     = $this->webroot;
      $controller->params      = $params;
      $controller->action      = $params['action'];
      $controller->data        = empty($params['data'])? null: $params['data'];
      $controller->passed_args = empty($params['pass'])? null: $params['pass'];
      $controller->viewpath = Inflector::underscore($ctrlName);
      $controller->autoLayout = !$params['bare'];
      $controller->autoRender = !$params['render'];

{'fraction_non_alphanumeric': 0.14083141437401528, 'fraction_numerical': 0.004120712640892013, 'mean_word_length': 2.6050677151594583, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 61, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '601276', 'n_tokens_mistral': 2422, 'n_tokens_neox': 2318, 'n_words': 596}