Code formatting.

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1010 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
brego 2005-09-29 18:19:30 +00:00
parent b59672754b
commit a00a927cca
2 changed files with 206 additions and 184 deletions

View file

@ -565,7 +565,5 @@ class %sTest extends TestCase
return false;
}
}
}
?>

View file

@ -49,12 +49,12 @@ define('YEAR', 365 * DAY);
* @uses APP
* @uses MODELS
*/
function loadModels ()
function loadModels()
{
require (APP.'app_model.php');
require APP.'app_model.php';
foreach (listClasses(MODELS) as $model_fn)
{
require_once (MODELS.$model_fn);
require_once MODELS.$model_fn;
}
}
@ -66,18 +66,18 @@ function loadModels ()
* @uses HELPERS
* @uses CONTROLLERS
*/
function loadControllers ()
function loadControllers()
{
require (APP.'app_controller.php');
require APP.'app_controller.php';
foreach (listClasses(HELPERS) as $helper)
{
require_once (HELPERS.$helper.'.php');
require_once HELPERS.$helper.'.php';
}
foreach (listClasses(CONTROLLERS) as $controller)
{
require_once (CONTROLLERS.$controller.'.php');
require_once CONTROLLERS.$controller.'.php';
}
}
@ -87,17 +87,26 @@ function loadControllers ()
* @param string $name Name of controller
* @return boolean Success
*/
function loadController ($name)
function loadController($name)
{
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
$controllerFn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
$helperFn = HELPERS.Inflector::underscore($name).'_helper.php';
require_once(APP.'app_controller.php');
if (file_exists($helper_fn))
require_once($helper_fn);
if (file_exists($helperFn))
{
require_once $helperFn;
}
return file_exists($controller_fn)? require_once($controller_fn): false;
if (file_exists($controllerFn))
{
return require_once $controllerFn;
}
else
{
return false;
}
}
/**
@ -117,26 +126,29 @@ function listClasses($path)
*
* @return boolean Success
*/
function config ()
function config()
{
$args = func_get_args();
foreach ($args as $arg)
{
if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
{
include_once(CONFIGS.$arg.'.php');
require_once CONFIGS.$arg.'.php';
}
elseif (file_exists(CONFIGS.$arg.'.php'))
{
include_once (CONFIGS.$arg.'.php');
if (count($args) == 1) return true;
}
else
{
if (count($args) == 1) return false;
}
}
require_once CONFIGS.$arg.'.php';
if (count($args) == 1)
{
return true;
}
}
elseif (count($args) == 1)
{
return false;
}
}
return true;
}
@ -150,27 +162,24 @@ function config ()
*
* @uses LIBS
*/
function uses ()
function uses()
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(LIBS.strtolower($arg).'.php');
require_once LIBS.strtolower($arg).'.php';
}
}
/**
* Require given files in the VENDORS directory. Takes optional number of parameters.
*
* @param string $name Filename without the .php part.
*
*/
function vendor($name)
function vendor()
{
$args = func_get_args();
foreach ($args as $arg)
{
require_once(VENDORS.$arg.'.php');
require_once VENDORS.$arg.'.php';
}
}
@ -187,7 +196,10 @@ function debug($var = false, $show_html = false)
if (DEBUG)
{
print "\n<pre>\n";
if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
if ($show_html)
{
$var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
}
print_r($var);
print "\n</pre>\n";
}
@ -196,7 +208,7 @@ function debug($var = false, $show_html = false)
if (!function_exists('getMicrotime'))
{
/**
/**
* Returns microtime for execution time checking.
*
* @return integer
@ -210,7 +222,7 @@ if (!function_exists('getMicrotime'))
if (!function_exists('sortByKey'))
{
/**
/**
* Sorts given $array by key $sortby.
*
* @param array $array
@ -219,19 +231,26 @@ if (!function_exists('sortByKey'))
* @param integer $type
* @return mixed
*/
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
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);
if ($order == 'asc')
{
asort($sa, $type);
}
else
{
arsort($sa, $type);
}
foreach ($sa as $key=>$val)
{
@ -244,7 +263,7 @@ if (!function_exists('sortByKey'))
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.)
*
@ -259,8 +278,16 @@ if (!function_exists('array_combine'))
$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
if ($c1 != $c2)
{
// different lenghts
return false;
}
if ($c1 <= 0)
{
// arrays are the same and both are empty
return false;
}
$output = array();
@ -278,19 +305,17 @@ function h($text)
return htmlspecialchars($text);
}
function a()
{
$args = func_get_args();
return $args;
}
function ha()
{
$args = func_get_args();
for($l=0 ; $l<count($args) ; $l++)
for ($l=0 ; $l<count($args) ; $l++)
{
$a[$args[$l]] = $l+1<count($args) ? $args[$l+1] : null;
$l++;
@ -298,7 +323,6 @@ function ha()
return $a;
}
function e($text)
{
echo $text;
@ -306,7 +330,7 @@ function e($text)
function pr($var)
{
if(DEBUG > 0)
if (DEBUG > 0)
{
echo "<pre>";
print_r($var);
@ -317,13 +341,13 @@ function pr($var)
function params($p)
{
if(!is_array($p) || count($p) == 0)
if (!is_array($p) || count($p) == 0)
{
return null;
}
else
{
if(is_array($p[0]) && count($p) == 1)
if (is_array($p[0]) && count($p) == 1)
{
return $p[0];
}