Commenting is slow. I noticed some under_scored methods in db stuf... Goodnight.

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@141 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
brego 2005-05-18 22:29:02 +00:00
parent ec0abbaac0
commit 3f7450435a
3 changed files with 420 additions and 384 deletions

View file

@ -45,7 +45,7 @@ uses('object', 'inflector');
*/ */
class Bake extends Object { class Bake extends Object {
/** /**
* Standard input stream (php://stdin). * Standard input stream (php://stdin).
* *
* @var resource * @var resource
@ -53,7 +53,7 @@ class Bake extends Object {
*/ */
var $stdin = null; var $stdin = null;
/** /**
* Standard output stream (php://stdout). * Standard output stream (php://stdout).
* *
* @var resource * @var resource
@ -61,7 +61,7 @@ class Bake extends Object {
*/ */
var $stdout = null; var $stdout = null;
/** /**
* Standard error stream (php://stderr). * Standard error stream (php://stderr).
* *
* @var resource * @var resource
@ -69,7 +69,7 @@ class Bake extends Object {
*/ */
var $stderr = null; var $stderr = null;
/** /**
* Counts taken actions. * Counts taken actions.
* *
* @var integer * @var integer
@ -77,7 +77,7 @@ class Bake extends Object {
*/ */
var $actions = null; var $actions = null;
/** /**
* Decides wether to overwrite existing files without asking. * Decides wether to overwrite existing files without asking.
* *
* @var boolean * @var boolean
@ -85,7 +85,7 @@ class Bake extends Object {
*/ */
var $dontAsk = false; var $dontAsk = false;
/** /**
* Returns template for file generator. * Returns template for file generator.
* *
* @param string $type * @param string $type
@ -130,7 +130,7 @@ class %sTest extends TestCase {
} }
/** /**
* Baker's constructor method. Initialises bakery, and starts production. * Baker's constructor method. Initialises bakery, and starts production.
* *
* @param string $type * @param string $type
@ -186,7 +186,7 @@ class %sTest extends TestCase {
} }
/** /**
* Creates new view in VIEWS/$controller/ directory. * Creates new view in VIEWS/$controller/ directory.
* *
* @param string $controller * @param string $controller
@ -208,7 +208,7 @@ class %sTest extends TestCase {
$this->actions++; $this->actions++;
} }
/** /**
* Creates new controller with defined actions, controller's test and helper * Creates new controller with defined actions, controller's test and helper
* with helper's test. * with helper's test.
* *
@ -229,7 +229,7 @@ class %sTest extends TestCase {
$this->actions++; $this->actions++;
} }
/** /**
* Creates new controller file with defined actions. * Creates new controller file with defined actions.
* *
* @param string $name * @param string $name
@ -250,7 +250,7 @@ class %sTest extends TestCase {
return $this->createFile($this->makeControllerFn($name), $body); return $this->createFile($this->makeControllerFn($name), $body);
} }
/** /**
* Returns controller's name in CamelCase. * Returns controller's name in CamelCase.
* *
* @param string $name * @param string $name
@ -262,7 +262,7 @@ class %sTest extends TestCase {
return Inflector::camelize($name).'Controller'; return Inflector::camelize($name).'Controller';
} }
/** /**
* Returns a name for controller's file, underscored. * Returns a name for controller's file, underscored.
* *
* @param string $name * @param string $name
@ -274,7 +274,7 @@ class %sTest extends TestCase {
return CONTROLLERS.Inflector::underscore($name).'_controller.php'; return CONTROLLERS.Inflector::underscore($name).'_controller.php';
} }
/** /**
* Creates new test for a controller. * Creates new test for a controller.
* *
* @param string $name * @param string $name
@ -292,7 +292,7 @@ class %sTest extends TestCase {
return $this->createFile($fn, $body); return $this->createFile($fn, $body);
} }
/** /**
* Creates new helper. * Creates new helper.
* *
* @param string $name * @param string $name
@ -308,7 +308,7 @@ class %sTest extends TestCase {
return $this->createFile($this->makeHelperFn($name), $body); return $this->createFile($this->makeHelperFn($name), $body);
} }
/** /**
* Returns CamelCase name for a helper. * Returns CamelCase name for a helper.
* *
* @param string $name * @param string $name
@ -320,7 +320,7 @@ class %sTest extends TestCase {
return Inflector::camelize($name).'Helper'; return Inflector::camelize($name).'Helper';
} }
/** /**
* Underscores file name for a helper. * Underscores file name for a helper.
* *
* @param string $name * @param string $name
@ -333,7 +333,7 @@ class %sTest extends TestCase {
return HELPERS.Inflector::underscore($name).'_helper.php'; return HELPERS.Inflector::underscore($name).'_helper.php';
} }
/** /**
* Creates new test for a helper. * Creates new test for a helper.
* *
* @param string $name * @param string $name
@ -351,7 +351,7 @@ class %sTest extends TestCase {
return $this->createFile($fn, $body); return $this->createFile($fn, $body);
} }
/** /**
* Returns array of actions' templates. * Returns array of actions' templates.
* *
* @param array $as * @param array $as
@ -366,7 +366,7 @@ class %sTest extends TestCase {
return $out; return $out;
} }
/** /**
* Returns test template for defined class. * Returns test template for defined class.
* *
* @param string $class * @param string $class
@ -378,7 +378,7 @@ class %sTest extends TestCase {
return sprintf($this->template('test'), $class, $class); return sprintf($this->template('test'), $class, $class);
} }
/** /**
* Creates new model. * Creates new model.
* *
* @param string $name * @param string $name
@ -396,7 +396,7 @@ class %sTest extends TestCase {
$this->actions++; $this->actions++;
} }
/** /**
* Returns underscored name for model's file. * Returns underscored name for model's file.
* *
* @param string $name * @param string $name
@ -409,7 +409,7 @@ class %sTest extends TestCase {
return MODELS.Inflector::underscore($name).'.php'; return MODELS.Inflector::underscore($name).'.php';
} }
/** /**
* Creates a test for a given model. * Creates a test for a given model.
* *
* @param string $name * @param string $name
@ -427,7 +427,7 @@ class %sTest extends TestCase {
return $this->createFile($fn, $body); return $this->createFile($fn, $body);
} }
/** /**
* Returns CamelCased name of a model. * Returns CamelCased name of a model.
* *
* @param string $name * @param string $name
@ -439,7 +439,7 @@ class %sTest extends TestCase {
return Inflector::camelize($name); return Inflector::camelize($name);
} }
/** /**
* Creates a file with given path and contents. * Creates a file with given path and contents.
* *
* @param string $path * @param string $path
@ -486,7 +486,7 @@ class %sTest extends TestCase {
} }
} }
/** /**
* Creates a directory with given path. * Creates a directory with given path.
* *
* @param string $path * @param string $path

View file

@ -14,7 +14,6 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Basics
* Basic Cake functionalities. * Basic Cake functionalities.
* *
* @filesource * @filesource
@ -32,11 +31,13 @@
*/ */
/** /**
* Enter description here... * Loads all libs from LIBS directory.
* *
* @uses listModules()
* @uses LIBS
*/ */
function load_libs () { function loadLibs () {
foreach (list_modules(LIBS) as $lib) { foreach (listModules(LIBS) as $lib) {
if ($lib != 'basics') { if ($lib != 'basics') {
include_once (LIBS.$lib.'.php'); include_once (LIBS.$lib.'.php');
} }
@ -44,40 +45,47 @@ function load_libs () {
} }
/** /**
* Enter description here... * Loads all models.
* *
* @uses listModules()
* @uses APP
* @uses MODELS
*/ */
function load_models () { function loadModels () {
require (APP.'app_model.php'); require (APP.'app_model.php');
foreach (list_modules(MODELS) as $model) { foreach (listModules(MODELS) as $model) {
require (MODELS.$model.'.php'); require (MODELS.$model.'.php');
} }
} }
/** /**
* Enter description here... * Loads all controllers.
* *
* @uses APP
* @uses listModules()
* @uses HELPERS
* @uses CONTROLLERS
*/ */
function load_controllers () { function loadControllers () {
require (APP.'app_controller.php'); require (APP.'app_controller.php');
foreach (list_modules(HELPERS) as $helper) { foreach (listModules(HELPERS) as $helper) {
require (HELPERS.$helper.'.php'); require (HELPERS.$helper.'.php');
} }
foreach (list_modules(CONTROLLERS) as $controller) { foreach (listModules(CONTROLLERS) as $controller) {
require (CONTROLLERS.$controller.'.php'); require (CONTROLLERS.$controller.'.php');
} }
} }
/** /**
* Enter description here... * Lists all .php files from a given path.
* *
* @param unknown_type $path * @param string $path
* @param unknown_type $sort * @param boolean $sort
* @return unknown * @return array
*/ */
function list_modules($path, $sort=true) { function listModules($path, $sort=true) {
if ($d = opendir($path)) { if ($d = opendir($path)) {
$out = array(); $out = array();
$r = null; $r = null;
@ -98,29 +106,36 @@ function list_modules($path, $sort=true) {
} }
/** /**
* Enter description here... * Loads core config.
* *
* @uses $TIME_START
* @uses CONFIGS
*/ */
function uses_config () { function usesConfig () {
global $TIME_START; global $TIME_START;
require (CONFIGS.'core.php'); require (CONFIGS.'core.php');
} }
/** /**
* Enter description here... * Loads database connection identified by $level.
* *
* @param string $level
* @uses $DB
* @uses DbFactory::make()
* @uses loadDatabaseConfig()
*/ */
function uses_database ($level='devel') { function usesDatabase ($level='devel') {
global $DB; global $DB;
$DB = DbFactory::make(loadDatabaseConfig($level)); $DB = DbFactory::make(loadDatabaseConfig($level));
} }
/** /**
* Enter description here... * Loads database configuration identified by $level from CONFIGS/database.php.
* *
* @return unknown * @param string $level
* @return mixed
*/ */
function loadDatabaseConfig ($level='devel') { function loadDatabaseConfig ($level='devel') {
if (file_exists(CONFIGS.'database.php')) if (file_exists(CONFIGS.'database.php'))
@ -139,16 +154,23 @@ function loadDatabaseConfig ($level='devel') {
} }
/** /**
* Enter description here... * Loads tags configuration from CONFIGS/tags.php.
* *
* @uses CONFIGS
*/ */
function uses_tag_generator () { function usesTagGenerator () {
require (CONFIGS.'tags.php'); require (CONFIGS.'tags.php');
} }
/** /**
* Enter description here... * Loads component/components from LIBS.
* *
* Example:
* <code>
* uses('inflector', 'object');
* </code>
*
* @uses LIBS
*/ */
function uses () { function uses () {
$args = func_get_args(); $args = func_get_args();
@ -158,12 +180,12 @@ function uses () {
} }
/** /**
* Enter description here... * Setup a debug point.
* *
* @param unknown_type $var * @param boolean $var
* @param unknown_type $show_html * @param boolean $show_html
*/ */
function debug($var = FALSE, $show_html = false) { function debug($var = false, $show_html = false) {
if (DEBUG) { if (DEBUG) {
print "\n<pre>\n"; 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));
@ -176,9 +198,9 @@ function debug($var = FALSE, $show_html = false) {
if (!function_exists('getMicrotime')) { if (!function_exists('getMicrotime')) {
/** /**
* Enter description here... * Returns microtime for execution time checking.
* *
* @return unknown * @return integer
*/ */
function getMicrotime() { function getMicrotime() {
list($usec, $sec) = explode(" ", microtime()); list($usec, $sec) = explode(" ", microtime());
@ -187,13 +209,13 @@ if (!function_exists('getMicrotime')) {
} }
if (!function_exists('sortByKey')) { if (!function_exists('sortByKey')) {
/** /**
* Enter description here... * Sorts given $array by key $sortby.
* *
* @param unknown_type $array * @param array $array
* @param unknown_type $sortby * @param string $sortby
* @param unknown_type $order * @param string $order
* @param unknown_type $type * @param integer $type
* @return unknown * @return mixed
*/ */
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) { function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
@ -210,21 +232,22 @@ if (!function_exists('sortByKey')) {
foreach( $sa as $key=>$val ) foreach( $sa as $key=>$val )
$out[] = $array[$key]; $out[] = $array[$key];
Return $out; return $out;
} }
else else
Return null; return null;
} }
} }
if (!function_exists('array_combine')) { if (!function_exists('array_combine')) {
/** /**
* Enter description here... * Combines given identical arrays by using the first array's values as keys,
* and second one's values as values.
* *
* @param unknown_type $a1 * @param array $a1
* @param unknown_type $a2 * @param array $a2
* @return unknown * @return mixed Outputs either combined array or false.
*/ */
function array_combine($a1, $a2) { function array_combine($a1, $a2) {
$a1 = array_values($a1); $a1 = array_values($a1);
@ -235,7 +258,7 @@ if (!function_exists('array_combine')) {
$output = array(); $output = array();
for ($i = 0; $i < count($a1); $i++) { for ($i = 0, $c = count($a1); $i < $c; $i++) {
$output[$a1[$i]] = $a2[$i]; $output[$a1[$i]] = $a2[$i];
} }
@ -244,37 +267,45 @@ if (!function_exists('array_combine')) {
} }
/** /**
* Enter description here... * Class used for internal manipulation with recordsets (?).
*
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
*
*/ */
class NeatArray { class NeatArray {
/**
/** * Value of NeatArray.
* Enter description here...
* *
* @param unknown_type $value * @var array
* @return NeatArray * @access public
*/
var $value;
/**
* Constructor.
*
* @param array $value
* @access public
* @uses NeatArray::value
*/ */
function NeatArray ($value) { function NeatArray ($value) {
$this->value = $value; $this->value = $value;
} }
/** /**
* Enter description here... * Checks wheter $fieldName with $value exists in this NeatArray object.
* *
* @param unknown_type $field_name * @param string $fieldName
* @param unknown_type $value * @param string $value
* @return unknown * @return mixed
* @access public
* @uses NeatArray::value
*/ */
function findIn ($field_name, $value) { function findIn ($fieldName, $value) {
$out = false; $out = false;
foreach ($this->value as $k=>$v) { foreach ($this->value as $k=>$v) {
if (isset($v[$field_name]) && ($v[$field_name] == $value)) { if (isset($v[$fieldName]) && ($v[$fieldName] == $value)) {
$out[$k] = $v; $out[$k] = $v;
} }
} }
@ -282,14 +313,19 @@ class NeatArray {
return $out; return $out;
} }
/** /**
* Enter description here... * Checks if $this->value is array, and removes all empty elements.
* *
* @access public
* @uses NeatArray::value
*/ */
function cleanup () { function cleanup ()
{
$out = is_array($this->value)? array(): null; $out = is_array($this->value)? array(): null;
foreach ($this->value as $k=>$v) { foreach ($this->value as $k=>$v)
if ($v) { {
if ($v)
{
$out[$k] = $v; $out[$k] = $v;
} }
} }

View file

@ -41,12 +41,12 @@ require ('../config/paths.php');
require (LIBS.'basics.php'); require (LIBS.'basics.php');
uses ('dispatcher', 'db_factory'); uses ('dispatcher', 'db_factory');
uses_config(); usesConfig();
uses_database(); usesDatabase();
uses_tag_generator(); usesTagGenerator();
load_models (); loadModels ();
load_controllers (); loadControllers ();
session_start(); session_start();