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

View file

@ -14,7 +14,6 @@
//////////////////////////////////////////////////////////////////////////
/**
* Purpose: Basics
* Basic Cake functionalities.
*
* @filesource
@ -32,11 +31,13 @@
*/
/**
* Enter description here...
* Loads all libs from LIBS directory.
*
* @uses listModules()
* @uses LIBS
*/
function load_libs () {
foreach (list_modules(LIBS) as $lib) {
function loadLibs () {
foreach (listModules(LIBS) as $lib) {
if ($lib != 'basics') {
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');
foreach (list_modules(MODELS) as $model) {
foreach (listModules(MODELS) as $model) {
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');
foreach (list_modules(HELPERS) as $helper) {
foreach (listModules(HELPERS) as $helper) {
require (HELPERS.$helper.'.php');
}
foreach (list_modules(CONTROLLERS) as $controller) {
foreach (listModules(CONTROLLERS) as $controller) {
require (CONTROLLERS.$controller.'.php');
}
}
/**
* Enter description here...
* Lists all .php files from a given path.
*
* @param unknown_type $path
* @param unknown_type $sort
* @return unknown
* @param string $path
* @param boolean $sort
* @return array
*/
function list_modules($path, $sort=true) {
function listModules($path, $sort=true) {
if ($d = opendir($path)) {
$out = array();
$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;
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;
$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') {
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');
}
/**
* Enter description here...
* Loads component/components from LIBS.
*
* Example:
* <code>
* uses('inflector', 'object');
* </code>
*
* @uses LIBS
*/
function uses () {
$args = func_get_args();
@ -158,12 +180,12 @@ function uses () {
}
/**
* Enter description here...
* Setup a debug point.
*
* @param unknown_type $var
* @param unknown_type $show_html
* @param boolean $var
* @param boolean $show_html
*/
function debug($var = FALSE, $show_html = false) {
function debug($var = false, $show_html = false) {
if (DEBUG) {
print "\n<pre>\n";
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')) {
/**
* Enter description here...
* Returns microtime for execution time checking.
*
* @return unknown
* @return integer
*/
function getMicrotime() {
list($usec, $sec) = explode(" ", microtime());
@ -187,13 +209,13 @@ if (!function_exists('getMicrotime')) {
}
if (!function_exists('sortByKey')) {
/**
* Enter description here...
* Sorts given $array by key $sortby.
*
* @param unknown_type $array
* @param unknown_type $sortby
* @param unknown_type $order
* @param unknown_type $type
* @return unknown
* @param array $array
* @param string $sortby
* @param string $order
* @param integer $type
* @return mixed
*/
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
@ -210,21 +232,22 @@ if (!function_exists('sortByKey')) {
foreach( $sa as $key=>$val )
$out[] = $array[$key];
Return $out;
return $out;
}
else
Return null;
return null;
}
}
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 unknown_type $a2
* @return unknown
* @param array $a1
* @param array $a2
* @return mixed Outputs either combined array or false.
*/
function array_combine($a1, $a2) {
$a1 = array_values($a1);
@ -235,7 +258,7 @@ if (!function_exists('array_combine')) {
$output = array();
for ($i = 0; $i < count($a1); $i++) {
for ($i = 0, $c = count($a1); $i < $c; $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
* @subpackage cake.libs
* @since Cake v 0.2.9
*
*/
class NeatArray {
/**
* Enter description here...
/**
* Value of NeatArray.
*
* @param unknown_type $value
* @return NeatArray
* @var array
* @access public
*/
var $value;
/**
* Constructor.
*
* @param array $value
* @access public
* @uses NeatArray::value
*/
function NeatArray ($value) {
$this->value = $value;
}
/**
* Enter description here...
/**
* Checks wheter $fieldName with $value exists in this NeatArray object.
*
* @param unknown_type $field_name
* @param unknown_type $value
* @return unknown
* @param string $fieldName
* @param string $value
* @return mixed
* @access public
* @uses NeatArray::value
*/
function findIn ($field_name, $value) {
function findIn ($fieldName, $value) {
$out = false;
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;
}
}
@ -282,14 +313,19 @@ class NeatArray {
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;
foreach ($this->value as $k=>$v) {
if ($v) {
foreach ($this->value as $k=>$v)
{
if ($v)
{
$out[$k] = $v;
}
}

View file

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