I do not want any uppercase letters in filenames. I want CamelCase actions that link to under_scored files.

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@273 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
brego 2005-06-23 08:32:04 +00:00
parent 77d259860c
commit 9206b074d3
4 changed files with 324 additions and 321 deletions

View file

@ -1,38 +1,38 @@
<?PHP
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
//////////////////////////////////////////////////////////////////////////
/**
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @package cake
* @subpackage cake.config
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.thtml)...
*/
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
$Route->connect ('/pages/*', array('controller'=>'Pages', 'action'=>'display'));
/**
* Then we connect url '/test' to our test controller. This is helpfull in
* developement.
*/
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
?>
<?php
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
//////////////////////////////////////////////////////////////////////////
/**
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @package cake
* @subpackage cake.config
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.thtml)...
*/
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
$Route->connect ('/pages/*', array('controller'=>'Pages', 'action'=>'display'));
/**
* Then we connect url '/test' to our test controller. This is helpfull in
* developement.
*/
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
?>

View file

@ -1,265 +1,265 @@
<?PHP
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + //
//////////////////////////////////////////////////////////////////////////
/**
* Basic Cake functionalities.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
/**
* Basic defines
*/
define('SECOND', 1);
define('MINUTE', 60 * SECOND);
define('HOUR', 60 * MINUTE);
define('DAY', 24 * HOUR);
define('WEEK', 7 * DAY);
define('MONTH', 30 * DAY);
define('YEAR', 365 * DAY);
/**
* Loads all models.
*
* @uses listModules()
* @uses APP
* @uses MODELS
*/
function loadModels ()
{
require (APP.'app_model.php');
foreach (listClasses(MODELS) as $model_fn)
{
require (MODELS.$model_fn);
}
}
/**
* Loads all controllers.
*
* @uses APP
* @uses listModules()
* @uses HELPERS
* @uses CONTROLLERS
*/
function loadControllers ()
{
require (APP.'app_controller.php');
foreach (listClasses(HELPERS) as $helper)
{
require (HELPERS.$helper.'.php');
}
foreach (listClasses(CONTROLLERS) as $controller)
{
require (CONTROLLERS.$controller.'.php');
}
}
/**
* Loads a controller and its helper libraries.
*
* @param string $name
* @return boolean
*/
function loadController ($name)
{
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
require(APP.'app_controller.php');
if (file_exists($helper_fn))
require($helper_fn);
return file_exists($controller_fn)? require($controller_fn): false;
}
/**
* Lists PHP files in given directory.
*
* @param string $path
* @return array
*/
function listClasses($path)
{
$modules = new Folder($path);
return $modules->find('(.+)\.php');
}
/**
* Loads configuration files
*/
function config ()
{
$args = func_get_args();
foreach ($args as $arg)
{
if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
{
include_once(CONFIGS.$arg.'.php');
}
elseif (file_exists(CONFIGS.$arg.'.php'))
{
include (CONFIGS.$arg.'.php');
if (count($args) == 1) return true;
}
else
{
if (count($args) == 1) return false;
}
}
return true;
}
/**
* Loads component/components from LIBS.
*
* Example:
* <code>
* uses('flay', 'time');
* </code>
*
* @uses LIBS
*/
function uses ()
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(LIBS.strtolower($arg).'.php');
}
}
function vendor($name)
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(VENDORS.$arg.'.php');
}
}
/**
* Setup a debug point.
*
* @param boolean $var
* @param boolean $show_html
*/
function debug($var = false, $show_html = false)
{
if (DEBUG)
{
print "\n<pre>\n";
if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
print_r($var);
print "\n</pre>\n";
}
}
if (!function_exists('getMicrotime'))
{
/**
* Returns microtime for execution time checking.
*
* @return integer
*/
function getMicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
}
if (!function_exists('sortByKey'))
{
/**
* Sorts given $array by key $sortby.
*
* @param array $array
* @param string $sortby
* @param string $order Sort order asc/desc (ascending or descending).
* @param integer $type
* @return mixed
*/
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
{
if (!is_array($array))
return null;
foreach ($array as $key => $val)
{
$sa[$key] = $val[$sortby];
}
$order == 'asc'
? asort($sa, $type)
: arsort($sa, $type);
foreach ($sa as $key=>$val)
{
$out[] = $array[$key];
}
return $out;
}
}
if (!function_exists('array_combine'))
{
/**
* Combines given identical arrays by using the first array's values as keys,
* and the second one's values as values. (Implemented for back-compatibility with PHP4.)
*
* @param array $a1
* @param array $a2
* @return mixed Outputs either combined array or false.
*/
function array_combine($a1, $a2)
{
$a1 = array_values($a1);
$a2 = array_values($a2);
$c1 = count($a1);
$c2 = count($a2);
if ($c1 != $c2) return false; // different lenghts
if ($c1 <= 0) return false; // arrays are the same and both are empty
$output = array();
for ($i = 0; $i < $c1; $i++)
{
$output[$a1[$i]] = $a2[$i];
}
return $output;
}
}
?>
<?php
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + //
//////////////////////////////////////////////////////////////////////////
/**
* Basic Cake functionalities.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
/**
* Basic defines
*/
define('SECOND', 1);
define('MINUTE', 60 * SECOND);
define('HOUR', 60 * MINUTE);
define('DAY', 24 * HOUR);
define('WEEK', 7 * DAY);
define('MONTH', 30 * DAY);
define('YEAR', 365 * DAY);
/**
* Loads all models.
*
* @uses listModules()
* @uses APP
* @uses MODELS
*/
function loadModels ()
{
require (APP.'app_model.php');
foreach (listClasses(MODELS) as $model_fn)
{
require (MODELS.$model_fn);
}
}
/**
* Loads all controllers.
*
* @uses APP
* @uses listModules()
* @uses HELPERS
* @uses CONTROLLERS
*/
function loadControllers ()
{
require (APP.'app_controller.php');
foreach (listClasses(HELPERS) as $helper)
{
require (HELPERS.$helper.'.php');
}
foreach (listClasses(CONTROLLERS) as $controller)
{
require (CONTROLLERS.$controller.'.php');
}
}
/**
* Loads a controller and its helper libraries.
*
* @param string $name
* @return boolean
*/
function loadController ($name)
{
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
require(APP.'app_controller.php');
if (file_exists($helper_fn))
require($helper_fn);
return file_exists($controller_fn)? require($controller_fn): false;
}
/**
* Lists PHP files in given directory.
*
* @param string $path
* @return array
*/
function listClasses($path)
{
$modules = new Folder($path);
return $modules->find('(.+)\.php');
}
/**
* Loads configuration files
*/
function config ()
{
$args = func_get_args();
foreach ($args as $arg)
{
if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
{
include_once(CONFIGS.$arg.'.php');
}
elseif (file_exists(CONFIGS.$arg.'.php'))
{
include (CONFIGS.$arg.'.php');
if (count($args) == 1) return true;
}
else
{
if (count($args) == 1) return false;
}
}
return true;
}
/**
* Loads component/components from LIBS.
*
* Example:
* <code>
* uses('flay', 'time');
* </code>
*
* @uses LIBS
*/
function uses ()
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(LIBS.strtolower($arg).'.php');
}
}
function vendor($name)
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(VENDORS.$arg.'.php');
}
}
/**
* Setup a debug point.
*
* @param boolean $var
* @param boolean $show_html
*/
function debug($var = false, $show_html = false)
{
if (DEBUG)
{
print "\n<pre>\n";
if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
print_r($var);
print "\n</pre>\n";
}
}
if (!function_exists('getMicrotime'))
{
/**
* Returns microtime for execution time checking.
*
* @return integer
*/
function getMicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
}
if (!function_exists('sortByKey'))
{
/**
* Sorts given $array by key $sortby.
*
* @param array $array
* @param string $sortby
* @param string $order Sort order asc/desc (ascending or descending).
* @param integer $type
* @return mixed
*/
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
{
if (!is_array($array))
return null;
foreach ($array as $key => $val)
{
$sa[$key] = $val[$sortby];
}
$order == 'asc'
? asort($sa, $type)
: arsort($sa, $type);
foreach ($sa as $key=>$val)
{
$out[] = $array[$key];
}
return $out;
}
}
if (!function_exists('array_combine'))
{
/**
* Combines given identical arrays by using the first array's values as keys,
* and the second one's values as values. (Implemented for back-compatibility with PHP4.)
*
* @param array $a1
* @param array $a2
* @return mixed Outputs either combined array or false.
*/
function array_combine($a1, $a2)
{
$a1 = array_values($a1);
$a2 = array_values($a2);
$c1 = count($a1);
$c2 = count($a2);
if ($c1 != $c2) return false; // different lenghts
if ($c1 <= 0) return false; // arrays are the same and both are empty
$output = array();
for ($i = 0; $i < $c1; $i++)
{
$output[$a1[$i]] = $a2[$i];
}
return $output;
}
}
?>

View file

@ -147,19 +147,22 @@ class Controller extends Template
function missingController()
{
$this->autoRender = false;
$this->render('../errors/missing_controller');
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingController');
}
function missingAction()
{
$this->autoRender = false;
$this->render('../errors/missing_action');
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingAction');
}
function missingView()
{
$this->autoRender = false;
$this->render('../errors/missing_view');
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingView');
}
/**

View file

@ -329,7 +329,7 @@ class Template extends Object
}
/**
* Returns filename of given action's template file (.thtml) as a string.
* Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views.
*
* @param string $action Controller action to find template filename for
* @return string Template filename
@ -339,12 +339,12 @@ class Template extends Object
$action = Inflector::underscore($action);
$viewFn = VIEWS.$this->viewpath.DS."{$action}.thtml";
$viewPath = explode(DS, $viewFn);
$i = array_search('..', $viewPath);
unset($viewPath[$i-1]);
unset($viewPath[$i]);
return '/'.implode('/', $viewPath);
}
@ -370,7 +370,7 @@ class Template extends Object
$helperCn = ucfirst($helper).'Helper';
if (is_file($helperFn))
{
require_once $helperFn;
require_once $helperFn;
if(class_exists($helperCn)===true);
{
${$helper} = new $helperCn;
@ -383,7 +383,7 @@ class Template extends Object
}
}
}
extract($___data_for_view, EXTR_SKIP); # load all view variables
/**
* Local template variables.
@ -391,11 +391,11 @@ class Template extends Object
$BASE = $this->base;
$params = &$this->params;
$page_title = $this->pageTitle;
/**
* Start caching output (eval outputs directly so we need to cache).
*/
ob_start();
ob_start();
/**
* Include the template.
@ -407,7 +407,7 @@ class Template extends Object
return $out;
}
///////////////////////////////////////////////////////////////////////////
/**
@ -737,7 +737,7 @@ class Template extends Object
if (empty($email)) $email = $title;
$match = array();
// does the address contain extra attributes?
preg_match('!^(.*)(\?.*)$!', $email, $match);
@ -934,10 +934,10 @@ class Template extends Object
}
}
///////////////////////////////////////////////////////////////////////////
/**
* Returns link to javascript function
*
@ -1043,8 +1043,8 @@ class Template extends Object
{
$javascript_options = $this->__optionsForAjax($options);
$func = isset($options['update'])
? "new Ajax.Updater('{$options['update']}', "
: "new Ajax.Request(";
? "new Ajax.Updater('{$options['update']}', "
: "new Ajax.Request(";
$func .= "'" . $this->urlFor($options['url']) . "'";
$func .= ", $javascript_options)";