Adding empty directories where overrides for the core views can be placed.
Adding an empty directory for elements 

[1127]
Adding directory to hold core inflection files 

[1128]
More work on the new inflector.
This still is not completed but should be soon

[1130]
Documentation strings, du jour.

[1131]
Docstringed and ready. Inflector lacks one docstring. It is noted in its todo

[1132]
Incomplete documentation, and some corrections to previous documentation.
Gwoo noted that there'll be more changes in the Helpers soon, so I back off here.

[1134]
Adding before filters back to code.
Commented out a regex in Inflector::pluralize(); that os causing problems.
Removed a duplicate define in index.php.
Removed the bare array being set automatically when using requestAction().
With this change you must use requestAction(); like this.
$object->requestAction('/bare/controller/action/param');
Added GOTCHAS file with links to problems people may have with CakePHP.
Some more work done on new Inflector. 

[1135]
Added a check when trying to access a private method of a controller.
This will now display an error page informing user that this is not allowed. 

[1137]
Fixed a few undefined variable errors in the code
Corrected problem with double layout display when an error is returned and caught.

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1138 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-10-18 22:27:39 +00:00
parent ebdb8df957
commit 6baaa1120f
35 changed files with 642 additions and 496 deletions

View file

@ -99,6 +99,11 @@ define ('ELEMENTS', VIEWS.'elements'.DS);
*/ */
define ('CONFIGS', APP.'config'.DS); define ('CONFIGS', APP.'config'.DS);
/**
* Path to the libs directory.
*/
define ('INFLECTIONS', CAKE.'config'.DS.'inflections'.DS);
/** /**
* Path to the libs directory. * Path to the libs directory.
*/ */

View file

@ -2,7 +2,7 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Application model for Cake.
* *
* This file is application-wide model file. You can put all * This file is application-wide model file. You can put all
* application-wide model-related methods here. * application-wide model-related methods here.
@ -33,7 +33,7 @@
*/ */
/** /**
* Short description for class. * Application model for Cake.
* *
* Add your application-wide methods in the class below, your models * Add your application-wide methods in the class below, your models
* will inherit them. * will inherit them.

View file

@ -297,10 +297,10 @@ if (!function_exists('array_combine'))
} }
/** /**
* Enter description here... * Convenience method for htmlspecialchars.
* *
* @param unknown_type $text * @param string $text
* @return unknown * @return string
*/ */
function h($text) function h($text)
{ {
@ -309,9 +309,9 @@ function h($text)
/** /**
* Enter description here... * Returns an array of all the given parameters, making parameter lists shorter to write.
* *
* @return unknown * @return array
*/ */
function a() function a()
{ {
@ -321,9 +321,10 @@ function a()
/** /**
* Enter description here... * Hierarchical arrays.
* *
* @return unknown * @return array
* @todo Explain this method better.
*/ */
function ha() function ha()
{ {
@ -339,9 +340,9 @@ function ha()
/** /**
* Enter description here... * Convenience method for echo().
* *
* @param unknown_type $text * @param string $text String to echo
*/ */
function e($text) function e($text)
{ {
@ -349,9 +350,11 @@ function e($text)
} }
/** /**
* Enter description here... * Print_r convenience function, which prints out <PRE> tags around
* * the output of given array. Similar to debug().
* @param unknown_type $var *
* @see debug
* @param array $var
*/ */
function pr($var) function pr($var)
{ {
@ -364,10 +367,10 @@ function pr($var)
} }
/** /**
* Enter description here... * Display parameter
* *
* @param unknown_type $p * @param mixed $p Parameter as string or array
* @return unknown * @return string
*/ */
function params($p) function params($p)
{ {
@ -391,9 +394,10 @@ function params($p)
} }
/** /**
* Enter description here... * Returns the REQUEST_URI from the server environment, or, failing that, constructs
* a new one, using the PHP_SELF constant and other variables.
* *
* @return unknown * @return string
*/ */
function setUri() { function setUri() {
if (isset($_SERVER['REQUEST_URI'])) if (isset($_SERVER['REQUEST_URI']))

View file

@ -0,0 +1,101 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP 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.
*
* @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.cake.config.inflections
* @since CakePHP v .0.10.x.x
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
$pluralUninflectedHerd = array(
# DON'T INFLECT IN CLASSICAL MODE, OTHERWISE NORMAL INFLECTION
'wildebeest', 'swine', 'eland', 'bison', 'buffalo','elk', 'moose', 'rhinoceros',);
$pluralUninflecteds =array(
# PAIRS OR GROUPS SUBSUMED TO A SINGULAR...
'breeches', 'britches', 'clippers', 'gallows', 'hijinks',
'headquarters', 'pliers', 'scissors', 'testes', 'herpes',
'pincers', 'shears', 'proceedings', 'trousers',
# UNASSIMILATED LATIN 4th DECLENSION
'cantus', 'coitus', 'nexus',
# RECENT IMPORTS...
'contretemps', 'corps', 'debris',
'.*ois', 'siemens',
# DISEASES
'.*measles', 'mumps',
# MISCELLANEOUS OTHERS...
'diabetes', 'jackanapes', 'series', 'species', 'rabies',
'chassis', 'innings', 'news', 'mews',);
$pluralUninflected = array(
# SOME FISH AND HERD ANIMALS
'.*fish', 'tuna', 'salmon', 'mackerel', 'trout',
'bream', 'sea[- ]bass', 'carp', 'cod', 'flounder', 'whiting',
'.*deer', '.*sheep',
# ALL NATIONALS ENDING IN -ese
'Portuguese', 'Amoyese', 'Borghese', 'Congoese', 'Faroese',
'Foochowese', 'Genevese', 'Genoese', 'Gilbertese', 'Hottentotese',
'Kiplingese', 'Kongoese', 'Lucchese', 'Maltese', 'Nankingese',
'Niasese', 'Pekingese', 'Piedmontese', 'Pistoiese', 'Sarawakese',
'Shavese', 'Vermontese', 'Wenchowese', 'Yengeese',
'.*[nrlm]ese',
# DISEASES
'.*pox',
# OTHER ODDITIES
'graffiti', 'djinn');
$pluralIrregulars = array(
'corpus' => 'corpuses|corpora',
'opus' => 'opuses|opera',
'genus' => 'genera',
'mythos' => 'mythoi',
'penis' => 'penises|penes',
'testis' => 'testes',
'atlas' => 'atlases|atlantes',);
$pluralIrregular =array(
'child' => 'children',
'brother' => 'brothers|brethren',
'loaf' => 'loaves',
'hoof' => 'hoofs|hooves',
'beef' => 'beefs|beeves',
'money' => 'monies',
'mongoose' => 'mongooses|',
'ox' => 'oxen',
'cow' => 'cows|kine',
'soliloquy' => 'soliloquies|',
'graffito' => 'graffiti',
'prima donna' => 'prima donnas|prime donne',
'octopus' => 'octopuses|octopodes',
'genie' => 'genies|genii',
'ganglion' => 'ganglions|ganglia',
'trilby' => 'trilbys',
'turf' => 'turfs|turves',
'numen' => 'numina',
'occiput' => 'occiputs|occipita',);
?>

View file

@ -33,12 +33,12 @@
*/ */
/** /**
* Add Description * List of helpers to include
*/ */
uses('error_messages', 'object', 'router', DS.'controller'.DS.'controller', DS.'controller'.DS.'scaffold'); uses('error_messages', 'object', 'router', DS.'controller'.DS.'controller', DS.'controller'.DS.'scaffold');
/** /**
* Short description for class. * Dispatcher translates URLs to controller-action-paramter triads.
* *
* Dispatches the request, creating appropriate models and controllers. * Dispatches the request, creating appropriate models and controllers.
* *
@ -79,6 +79,7 @@ class Dispatcher extends Object
$missingController = false; $missingController = false;
$missingAction = false; $missingAction = false;
$missingView = false; $missingView = false;
$privateAction = false;
if(!in_array('render', array_keys($params))) if(!in_array('render', array_keys($params)))
{ {
@ -130,6 +131,11 @@ class Dispatcher extends Object
$params['action'] = 'index'; $params['action'] = 'index';
} }
if(in_array($params['action'], $classMethods) && strpos($params['action'], '_', 0) === 0)
{
$privateAction = true;
}
if(!in_array($params['action'], $classMethods)) if(!in_array($params['action'], $classMethods))
{ {
$missingAction = true; $missingAction = true;
@ -160,15 +166,21 @@ class Dispatcher extends Object
$params['action'] = 'missingAction'; $params['action'] = 'missingAction';
} }
if ($privateAction)
{
$controller->privateAction = $params['action'];
$params['action'] = 'privateAction';
}
return $this->_invoke($controller, $params ); return $this->_invoke($controller, $params );
} }
/** /**
* Enter description here... * Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string.
* *
* @param unknown_type $controller * @param object $controller
* @param unknown_type $params * @param array $params
* @return unknown * @return string
*/ */
function _invoke (&$controller, $params ) function _invoke (&$controller, $params )
{ {
@ -218,7 +230,7 @@ class Dispatcher extends Object
} }
/** /**
* Recursively strips slashes. * Recursively strips slashes from given array.
* *
*/ */
function stripslashes_deep($val) function stripslashes_deep($val)
@ -228,7 +240,7 @@ class Dispatcher extends Object
} }
/** /**
* Recursively performs urldecode. * Recursively performs urldecode on given array.
* *
*/ */
function urldecode_deep($val) function urldecode_deep($val)
@ -275,7 +287,6 @@ class Dispatcher extends Object
$webroot =setUri(); $webroot =setUri();
$htaccess = preg_replace('/(?:'.APP_DIR.'(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.WEBROOT_DIR.'/'; $htaccess = preg_replace('/(?:'.APP_DIR.'(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.WEBROOT_DIR.'/';
} }
// Document root is probably not set to Cake 'webroot' dir
if(APP_DIR === 'app') if(APP_DIR === 'app')
{ {
if (preg_match('/^(.*)\\/'.APP_DIR.'\\/'.WEBROOT_DIR.'\\/index\\.php$/', $scriptName, $regs)) if (preg_match('/^(.*)\\/'.APP_DIR.'\\/'.WEBROOT_DIR.'\\/index\\.php$/', $scriptName, $regs))
@ -302,17 +313,6 @@ class Dispatcher extends Object
return $base; return $base;
} }
} }
//Fallback if all others fail
if (preg_match('/^(.*)\\/index\\.php$/', $scriptName, $regs))
{
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].'/';
return $regs[1];
}
else
{
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
return $base;
}
} }
return $base; return $base;
} }

17
cake/docs/GOTCHAS.txt Normal file
View file

@ -0,0 +1,17 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// + $Id:$
// + Last Modified:$
// + Modified By:$
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
You can find some help with problems you may have installing CakePHP here:
http://wiki.cakephp.org/docs:0.10_dev_gotchas
Visit our IRC channel for help.
#cakephp on irc.freenode.net
The google group is also a good place to get support from other users of CakePHP.
http://groups.google.com/group/cake-php

View file

@ -8,11 +8,12 @@
This README will be updated This README will be updated
for now visit: For now visit:
https://trac.cakephp.org/
OR:
https://www.cakephp.org/ https://www.cakephp.org/
User related documentation
http://wiki.cakephp.org/
For information on development:
https://trac.cakephp.org/

View file

@ -33,7 +33,7 @@
/** /**
* Enter description here... * Included libraries.
* *
*/ */
uses(DS.'model'.DS.'model'); uses(DS.'model'.DS.'model');

View file

@ -229,12 +229,18 @@ class Controller extends Object
{ {
foreach($this->beforeFilter as $filter) foreach($this->beforeFilter as $filter)
{ {
if(is_callable(array($this,$filter)))
{
$this->$filter();
}
} }
} }
else else
{ {
if(is_callable(array($this,$this->beforeFilter)))
{
$this->{$this->beforeFilter}();
}
} }
} }
@ -388,6 +394,7 @@ class Controller extends Object
$this->autoLayout = true; $this->autoLayout = true;
$this->pageTitle = 'Missing Controller'; $this->pageTitle = 'Missing Controller';
$this->render('../errors/missingController'); $this->render('../errors/missingController');
exit();
} }
/** /**
@ -399,6 +406,19 @@ class Controller extends Object
$this->autoLayout = true; $this->autoLayout = true;
$this->pageTitle = 'Missing Method in Controller'; $this->pageTitle = 'Missing Method in Controller';
$this->render('../errors/missingAction'); $this->render('../errors/missingAction');
exit();
}
/**
* Renders the Private Action web page.
*
*/
function privateAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Trying to access private method in class';
$this->render('../errors/privateAction');
exit();
} }
/** /**
@ -409,8 +429,8 @@ class Controller extends Object
{ {
$this->autoLayout = true; $this->autoLayout = true;
$this->pageTitle = 'Scaffold Missing Database Connection'; $this->pageTitle = 'Scaffold Missing Database Connection';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingScaffolddb'); $this->render('../errors/missingScaffolddb');
exit();
} }
/** /**
@ -422,8 +442,8 @@ class Controller extends Object
$this->autoLayout = true; $this->autoLayout = true;
$this->missingTableName = $tableName; $this->missingTableName = $tableName;
$this->pageTitle = 'Missing Database Table'; $this->pageTitle = 'Missing Database Table';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingTable'); $this->render('../errors/missingTable');
exit();
} }
/** /**
@ -435,8 +455,8 @@ class Controller extends Object
$this->missingHelperFile = $file; $this->missingHelperFile = $file;
$this->missingHelperClass = Inflector::camelize($file) . "Helper"; $this->missingHelperClass = Inflector::camelize($file) . "Helper";
$this->pageTitle = 'Missing Helper File'; $this->pageTitle = 'Missing Helper File';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingHelperFile'); $this->render('../errors/missingHelperFile');
exit();
} }
@ -449,8 +469,8 @@ class Controller extends Object
$this->missingHelperClass = Inflector::camelize($class) . "Helper"; $this->missingHelperClass = Inflector::camelize($class) . "Helper";
$this->missingHelperFile = Inflector::underscore($class); $this->missingHelperFile = Inflector::underscore($class);
$this->pageTitle = 'Missing Helper Class'; $this->pageTitle = 'Missing Helper Class';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingHelperClass'); $this->render('../errors/missingHelperClass');
exit();
} }
/** /**
@ -461,8 +481,8 @@ class Controller extends Object
{ {
$this->autoLayout = true; $this->autoLayout = true;
$this->pageTitle = 'Missing Database Connection'; $this->pageTitle = 'Missing Database Connection';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingDatabase'); $this->render('../errors/missingDatabase');
exit();
} }
// /** // /**
// * Displays an error page to the user. Uses layouts/error.html to render the page. // * Displays an error page to the user. Uses layouts/error.html to render the page.

View file

@ -4,7 +4,8 @@
/** /**
* Error Messages Defines * Error Messages Defines
* *
* Long description for file * Longer, human-readable error messages for Cake operation errors to be displayed
* to end-users.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -31,7 +31,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
* *
*/ */
uses('object'); uses('object');
@ -153,10 +153,10 @@ class File extends Object
} }
/** /**
* Get the Filesize * Returns the Filesize, either in bytes or in human-readable format.
* *
* @param boolean $humanReadeble Data to write to this File. * @param boolean $humanReadeble Data to write to this File.
* @return string|int filesize as int or as humand readable string * @return string|int filesize as int or as a human-readable string
*/ */
function getSize () function getSize ()
{ {
@ -165,7 +165,7 @@ class File extends Object
} }
/** /**
* Get the Fileextension * Returns the File extension.
* *
* @return string The Fileextension * @return string The Fileextension
*/ */
@ -188,7 +188,7 @@ class File extends Object
} }
/** /**
* Get the Filename * Returns the filename.
* *
* @return string The Filename * @return string The Filename
*/ */
@ -198,7 +198,7 @@ class File extends Object
} }
/** /**
* get the File owner * Returns the File's owner.
* *
* @return int the Fileowner * @return int the Fileowner
*/ */
@ -208,7 +208,7 @@ class File extends Object
} }
/** /**
* get the File owner * Returns the File group.
* *
* @return int the Filegroup * @return int the Filegroup
*/ */
@ -218,9 +218,9 @@ class File extends Object
} }
/** /**
* creates the File * Creates the File.
* *
* @return boolean * @return boolean Success
*/ */
function create () function create ()
{ {
@ -245,7 +245,7 @@ class File extends Object
} }
/** /**
* deletes the File * Returns true if the File exists.
* *
* @return boolean * @return boolean
*/ */
@ -255,7 +255,7 @@ class File extends Object
} }
/** /**
* deletes the File * Deletes the File.
* *
* @return boolean * @return boolean
*/ */
@ -265,7 +265,7 @@ class File extends Object
} }
/** /**
* check if the File writable * Returns true if the File is writable.
* *
* @return boolean * @return boolean
*/ */
@ -275,7 +275,7 @@ class File extends Object
} }
/** /**
* check if the File executable * Returns true if the File is executable.
* *
* @return boolean * @return boolean
*/ */
@ -285,7 +285,7 @@ class File extends Object
} }
/** /**
* check if the File readable * Returns true if the File is readable.
* *
* @return boolean * @return boolean
*/ */
@ -295,7 +295,7 @@ class File extends Object
} }
/** /**
* get last access time * Returns last access time.
* *
* @return int timestamp * @return int timestamp
*/ */
@ -305,7 +305,7 @@ class File extends Object
} }
/** /**
* get last access time * Returns last modified time.
* *
* @return int timestamp * @return int timestamp
*/ */
@ -315,7 +315,7 @@ class File extends Object
} }
/** /**
* get the current folder * Returns the current folder.
* *
* @return Folder * @return Folder
*/ */
@ -325,7 +325,7 @@ class File extends Object
} }
/** /**
* get the chmod of the File * Returns the "chmod" (permissions) of the File.
* *
* @return string * @return string
*/ */
@ -335,7 +335,7 @@ class File extends Object
} }
/** /**
* get the chmod of the File * Returns the full path of the File.
* *
* @return string * @return string
*/ */

View file

@ -32,7 +32,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('object'); uses('object');

View file

@ -31,7 +31,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
* *
*/ */
uses('object'); uses('object');
@ -48,14 +48,14 @@ uses('object');
class Folder extends Object { class Folder extends Object {
/** /**
* Enter description here... * Path to Folder.
* *
* @var string * @var string
*/ */
var $path = null; var $path = null;
/** /**
* Enter description here... * Sortedness.
* *
* @var boolean * @var boolean
*/ */
@ -65,7 +65,7 @@ class Folder extends Object {
* Constructor. * Constructor.
* *
* @param string $path * @param string $path
* @param bollean $path * @param boolean $path
*/ */
function Folder ($path = false , $create = false, $mode = false) function Folder ($path = false , $create = false, $mode = false)
{ {
@ -156,7 +156,7 @@ class Folder extends Object {
/** /**
* Returns an array of all matching files in current directory * Returns an array of all matching files in current directory.
* *
* @param string $pattern Preg_match pattern (Defaults to: .*) * @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array * @return array
@ -186,7 +186,7 @@ class Folder extends Object {
/** /**
* Returns an array of all matching files in and below current directory * Returns an array of all matching files in and below current directory.
* *
* @param string $pattern Preg_match pattern (Defaults to: .*) * @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array Files matching $pattern * @return array Files matching $pattern
@ -303,7 +303,7 @@ class Folder extends Object {
} }
/** /**
* check if the File is in a given CakePath * Returns true if the File is in a given CakePath.
* *
* @return boolean * @return boolean
*/ */
@ -317,7 +317,7 @@ class Folder extends Object {
} }
/** /**
* check if the File is in a given Path * Returns true if the File is in given path.
* *
* @return boolean * @return boolean
*/ */
@ -338,7 +338,7 @@ class Folder extends Object {
} }
/** /**
* Create a directory structure recursively * Create a directory structure recursively.
* *
* @author Aidan Lister <aidan@php.net> * @author Aidan Lister <aidan@php.net>
* @version 1.0.0 * @version 1.0.0
@ -375,7 +375,7 @@ class Folder extends Object {
} }
/** /**
* Get the size of a directory. * Returns the size in bytes of this Folder.
* *
* @author Aidan Lister <aidan@php.net> * @author Aidan Lister <aidan@php.net>
* @version 1.0.0 * @version 1.0.0

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Pluralize and singularize English words.
* *
* Long description for file * Used by Cake's naming conventions throughout the framework.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -32,9 +32,10 @@
*/ */
/** /**
* Short description for class * Pluralize and singularize English words.
* *
* Inflector pluralizes and singularizes English nouns. * Inflector pluralizes and singularizes English nouns.
* Used by Cake's naming conventions throughout the framework.
* Test with $i = new Inflector(); $i->test(); * Test with $i = new Inflector(); $i->test();
* *
* @package cake * @package cake
@ -66,7 +67,7 @@ class Inflector extends Object
'/([m|l])ouse$/' => '\1ice', # mouse, louse '/([m|l])ouse$/' => '\1ice', # mouse, louse
'/(matr|vert|ind)ix|ex$/' => '\1ices', # matrix, vertex, index '/(matr|vert|ind)ix|ex$/' => '\1ices', # matrix, vertex, index
'/(x|ch|ss|sh)$/' => '\1es', # search, switch, fix, box, process, address '/(x|ch|ss|sh)$/' => '\1es', # search, switch, fix, box, process, address
'/([^aeiouy]|qu)ies$/' => '\1y', //'/([^aeiouy]|qu)ies$/' => '\1y',
'/([^aeiouy]|qu)y$/' => '\1ies', # query, ability, agency '/([^aeiouy]|qu)y$/' => '\1ies', # query, ability, agency
'/(hive)$/' => '\1s', # archive, hive '/(hive)$/' => '\1s', # archive, hive
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', # half, safe, wife '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', # half, safe, wife
@ -163,8 +164,8 @@ class Inflector extends Object
*/ */
function underscore($camel_cased_word) function underscore($camel_cased_word)
{ {
$camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2',$camel_cased_word); $camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2', $camel_cased_word);
return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2',$camel_cased_word)); return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2', $camel_cased_word));
} }
/** /**
@ -180,7 +181,7 @@ class Inflector extends Object
} }
/** /**
* Returns corresponding table name for given $class_name. * Returns corresponding table name for given $class_name. ("posts" for the model class "Post").
* *
* @param string $class_name Name of class to get database table name for * @param string $class_name Name of class to get database table name for
* @return string Name of the database table for given class * @return string Name of the database table for given class
@ -191,7 +192,7 @@ class Inflector extends Object
} }
/** /**
* Returns Cake class name ("Post" for the database table "posts".) for given database table. * Returns Cake model class name ("Post" for the database table "posts".) for given database table.
* *
* @param string $tableName Name of database table to get class name for * @param string $tableName Name of database table to get class name for
* @return string * @return string
@ -203,7 +204,7 @@ class Inflector extends Object
/** /**
* Returns $class_name in underscored form, with "_id" tacked on at the end. * Returns $class_name in underscored form, with "_id" tacked on at the end.
* This is for use in dealing with the database. * This is for use in dealing with foreign keys in the database.
* *
* @param string $class_name * @param string $class_name
* @return string * @return string
@ -214,10 +215,10 @@ class Inflector extends Object
} }
/** /**
* Enter description here... * Returns filename for given Cake controller name.
* *
* @param unknown_type $name * @param string $name
* @return unknown * @return string
*/ */
function toControllerFilename($name) function toControllerFilename($name)
{ {
@ -225,10 +226,10 @@ class Inflector extends Object
} }
/** /**
* Enter description here... * Returns filename for given Cake helper name.
* *
* @param unknown_type $name * @param string $name
* @return unknown * @return string
*/ */
function toHelperFilename($name) function toHelperFilename($name)
{ {
@ -236,11 +237,12 @@ class Inflector extends Object
} }
/** /**
* Enter description here... * Returns given name as camelized.
* *
* @param unknown_type $name * @param string $name
* @param unknown_type $correct * @param string $correct
* @return unknown * @return string
* @todo Explain this method
*/ */
function toFullName($name, $correct) function toFullName($name, $correct)
{ {
@ -267,10 +269,10 @@ class Inflector extends Object
} }
/** /**
* Enter description here... * Returns filename for given Cake library name.
* *
* @param unknown_type $name * @param string $name
* @return unknown * @return string
*/ */
function toLibraryFilename ($name) function toLibraryFilename ($name)
{ {

View file

@ -2,7 +2,7 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Backwards compatibility functions.
* *
* With this hack you can use clone() in PHP4 code * With this hack you can use clone() in PHP4 code
* use "clone($object)" not "clone $object"! the former works in both PHP4 and PHP5 * use "clone($object)" not "clone $object"! the former works in both PHP4 and PHP5

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Logging.
* *
* Long description for file * Log messages to text files.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -32,15 +32,13 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('file'); uses('file');
/** /**
* Logs messages to text files * Logs messages to text files
* *
* Long description for class
*
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
* @since CakePHP v 0.2.9 * @since CakePHP v 0.2.9
@ -48,11 +46,11 @@ uses('file');
class Log class Log
{ {
/** /**
* Enter description here... * Writes given message to a log file in the logs directory.
* *
* @param unknown_type $type * @param string $type Type of log, becomes part of the log's filename
* @param unknown_type $msg * @param string $msg Message to log
* @return unknown * @return boolean Success
*/ */
function write($type, $msg) function write($type, $msg)
{ {
@ -71,7 +69,7 @@ class Log
define ('LOG_ERROR', 2); define ('LOG_ERROR', 2);
/** /**
* Shortcut. * Shortcut to Log::write.
*/ */
function LogError ($message) function LogError ($message)
{ {

View file

@ -1582,7 +1582,7 @@ class Model extends Object
$data = ($data? $data: (isset($this->data)? $this->data: array())); $data = ($data? $data: (isset($this->data)? $this->data: array()));
$errors = array(); $errors = array();
foreach ($this->data as $table => $field) foreach ($data as $table => $field)
{ {
foreach ($this->validate as $field_name=>$validator) foreach ($this->validate as $field_name=>$validator)
{ {

View file

@ -180,7 +180,8 @@ class NeatArray
} }
/** /**
* Passes each of its values through a specified function or method. Think of PHP's {@link http://php.net/array_walk array_walk()}. * Passes each of its values through a specified function or method.
* Think of PHP's {@link http://php.net/array_walk array_walk()}.
* *
* @param string $with Name of callback function * @param string $with Name of callback function
* @return array Returns value of NeatArray::value * @return array Returns value of NeatArray::value

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * String handling methods.
* *
* Long description for file * Random passwords, splitting strings into arrays, removing Cyrillic characters, stripping whitespace.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -32,9 +32,9 @@
*/ */
/** /**
* Short description for class * String handling methods.
* *
* Long description for class * Random passwords, splitting strings into arrays, removing Cyrillic characters, stripping whitespace.
* *
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
@ -44,10 +44,10 @@
class NeatString class NeatString
{ {
/** /**
* Enter description here... * Returns an array with each of the non-empty characters in $string as an element.
* *
* @param unknown_type $string * @param string $string
* @return unknown * @return array
*/ */
function toArray ($string) function toArray ($string)
{ {
@ -55,10 +55,10 @@ class NeatString
} }
/** /**
* Enter description here... * Returns string with Cyrillic characters translated to Roman ones.
* *
* @param unknown_type $string * @param string $string
* @return unknown * @return string
*/ */
function toRoman ($string) function toRoman ($string)
{ {
@ -69,10 +69,10 @@ class NeatString
} }
/** /**
* Enter description here... * Returns string as lowercase with whitespace removed.
* *
* @param unknown_type $string * @param string $string
* @return unknown * @return string
*/ */
function toCompressed ($string) function toCompressed ($string)
{ {
@ -81,11 +81,11 @@ class NeatString
} }
/** /**
* Enter description here... * Returns a random password.
* *
* @param unknown_type $length * @param integer $length Length of generated password
* @param unknown_type $available_chars * @param string $available_chars List of characters to use in password
* @return unknown * @return string Generated password
*/ */
function randomPassword ($length, $available_chars = 'ABDEFHKMNPRTWXYABDEFHKMNPRTWXY23456789') function randomPassword ($length, $available_chars = 'ABDEFHKMNPRTWXYABDEFHKMNPRTWXY23456789')
{ {

View file

@ -40,33 +40,102 @@
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
* @since CakePHP v .0.10.x.x * @since CakePHP v .0.10.x.x
*/ */
class Inflector class Inflector
{ {
var $classical = array(); var $classical = array();
function __construct() var $pre = '';
{
} var $word = '';
var $post = '';
function &getInstance() {
static $instance = array();
if (!$instance)
{
$instance[0] =& new Inflector;
}
return $instance[0];
}
function pluralize($text, $type = 'Noun' , $classical = false) function pluralize($text, $type = 'Noun' , $classical = false)
{ {
$this->classical = $classical; $inflec =& Inflector::getInstance();
$this->count = count($text); $inflec->classical = $classical;
$inflec->count = strlen($text);
return $this->_plural.$type($text); if ($inflec->count == 1)
{
return $text;
}
if(empty($text))
{
return;
}
$inflec->_pre($text);
if (empty($inflec->word))
{
return $text;
}
$type = '_plural'.$type;
$inflected = $inflec->_postProcess($inflec->word,$inflec->$type());
return $inflected;
} }
function singularize($text, $type = 'Noun' , $classical = false) function singularize($text, $type = 'Noun' , $classical = false)
{ {
$this->classical = $classical; $inflec =& Inflector::getInstance();
$this->count = count($text); $inflec->classical = $classical;
$inflec->count = count($text);
return $this->_singular.$type($text); if ($inflec->count == 1)
{
return $text;
}
if(empty($text))
{
return;
}
return $inflec->_singular.$type($text);
} }
function _pluralNoun($text) function _pluralNoun()
{ {
return $pluralText; $inflec =& Inflector::getInstance();
require_once('config/nouns.php');
$regexPluralUninflected = $inflec->_enclose(join( '|', array_values(array_merge($pluralUninflected,$pluralUninflecteds))));
$regexPluralUninflectedHerd = $inflec->_enclose(join( '|', array_values($pluralUninflectedHerd)));
$pluralIrregular = array_merge($pluralIrregular,$pluralIrregulars);
$regexPluralIrregular = $inflec->_enclose(join( '|', array_keys($pluralIrregular)));
if (preg_match('/^('.$regexPluralUninflected.')$/i', $inflec->word, $regs))
{
return $inflec->word;
}
if (empty($inflec->classical))
{
preg_match('/^('.$regexPluralUninflectedHerd.')$/i', $inflec->word, $regs);
return $inflec->word;
}
if (preg_match('/(.*)\\b('.$regexPluralIrregular.')$/i', $inflec->word, $regs))
{
return $regs[1] . $pluralIrregular[strtolower($regs[2])];
}
return $inflec->word.'s';
} }
function _pluralVerb($text) function _pluralVerb($text)
@ -136,7 +205,40 @@ class Inflector
function _enclose($string) function _enclose($string)
{ {
return '"(?:'.$string.')"'; return '(?:'.$string.')';
} }
function _pre($text)
{
$inflec =& Inflector::getInstance();
if (preg_match('/\\A(\\s*)(.+?)(\\s*)\\Z/', $text, $regs))
{
if (!empty($regs[1]))
{
$inflec->pre = $regs[1];
}
if (!empty($regs[2]))
{
$inflec->word = $regs[2];
}
if (!empty($regs[3]))
{
$inflec->post = $regs[3];;
}
}
}
function _postProcess($orig, $inflected)
{
$inflec =& Inflector::getInstance();
$inflected = preg_replace('/([^|]+)\\|(.+)/', $inflec->classical ? '${2}' : '${1}', $inflected);
return $inflected;
}
} }
echo Inflector::pluralize('rhinoceros');
?> ?>

View file

@ -2,9 +2,10 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Object class, allowing __construct and __destruct in PHP4.
* *
* Long description for file * Also includes methods for logging and the special method RequestAction,
* to call other Controllers' Actions from anywhere.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -32,14 +33,15 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('log'); uses('log');
/** /**
* Object class, allowing __construct and __destruct in PHP4. * Object class, allowing __construct and __destruct in PHP4.
* *
* Long description for class * Also includes methods for logging and the special method RequestAction,
* to call other Controllers' Actions from anywhere.
* *
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
@ -86,9 +88,9 @@ class Object
/** /**
* Object-to-string conversion. * Object-to-string conversion.
* Each class can override it as necessary. * Each class can override this method as necessary.
* *
* @return string This name of this class * @return string The name of this class
*/ */
function toString() function toString()
{ {
@ -96,13 +98,11 @@ class Object
} }
/** /**
* * Calls a controller's method from any location.
* Allow calling a controllers method from any location
*
* *
* @param unknown_type $url * @param string $url URL in the form of Cake URL ("/controller/method/parameter")
* @param unknown_type $extra * @param array $extra If array includes the key "render" it sets the AutoRender to true.
* @return unknown * @return boolean Success
*/ */
function requestAction ($url, $extra = array()) function requestAction ($url, $extra = array())
{ {
@ -114,7 +114,7 @@ class Object
{ {
$extra['render'] = 1; $extra['render'] = 1;
} }
$extra = array_merge($extra, array('bare'=>1)); //$extra = array_merge($extra, array('bare'=>1));
$dispatcher =& new Dispatcher(); $dispatcher =& new Dispatcher();
return $dispatcher->dispatch($url, $extra); return $dispatcher->dispatch($url, $extra);
} }

View file

@ -2,7 +2,7 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Parses the request URL into controller, action, and parameters.
* *
* Long description for file * Long description for file
* *
@ -32,7 +32,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('object', 'neat_array'); uses('object', 'neat_array');
@ -56,10 +56,10 @@ class Router extends Object {
/** /**
* TODO: Better description. Returns this object's routes array. Returns false if there are no routes available. * TODO: Better description. Returns this object's routes array. Returns false if there are no routes available.
* *
* @param string $route An empty string, or a route string "/" * @param string $route An empty string, or a route string "/"
* @param array $default NULL or an array describing the default route * @param array $default NULL or an array describing the default route
* @see routes * @see routes
* @return array Array of routes * @return array Array of routes
*/ */
function connect ($route, $default=null) function connect ($route, $default=null)
{ {
@ -107,7 +107,8 @@ class Router extends Object {
} }
/** /**
* TODO: Better description. Returns an array of routes. * Parses given URL and returns an array of controllers, action and parameters
* taken from that URL.
* *
* @param string $url URL to be parsed * @param string $url URL to be parsed
* @return array * @return array

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Washes strings from unwanted noise.
* *
* Long description for file * Helpful methods to make unsafe strings usable.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -34,7 +34,8 @@
/** /**
* Data Sanitization. * Data Sanitization.
* *
* Long description for class * Removal of alpahnumeric characters, SQL-safe slash-added strings, HTML-friendly strings,
* and all of the above on arrays.
* *
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
@ -52,7 +53,7 @@ class Sanitize
*/ */
function paranoid($string) function paranoid($string)
{ {
return preg_replace("/[^a-zA-Z0-9]/", "", $string); return preg_replace( "/[^a-zA-Z0-9]/", "", $string );
} }
/** /**
@ -72,10 +73,10 @@ class Sanitize
} }
/** /**
* Makes the string safe for display as HTML. Renders entities and converts newlines to <br/>. * Returns given string safe for display as HTML. Renders entities and converts newlines to <br/>.
* *
* @param string $string * @param string $string
* @param boolean $remove * @param boolean $remove If true, the string is stripped of all HTML tags
* @return string * @return string
*/ */
function html($string, $remove = false) function html($string, $remove = false)
@ -95,7 +96,7 @@ class Sanitize
} }
/** /**
* Recursively sanitizes an array of data for safe input. * Recursively sanitizes given array of data for safe input.
* *
* @param mixed $toClean * @param mixed $toClean
* @return mixed * @return mixed
@ -110,6 +111,7 @@ class Sanitize
* *
* @param array $toClean * @param array $toClean
* @return array * @return array
* @see cleanArray
*/ */
function cleanArrayR(&$toClean) function cleanArrayR(&$toClean)
{ {
@ -157,7 +159,7 @@ class Sanitize
*/ */
/** /**
* Method used by cleanArray() to sanitized array nodes. * Method used by cleanArray() to sanitize array nodes.
* *
* @param string $val * @param string $val
* @return string * @return string

View file

@ -1,266 +0,0 @@
<?php
/* SVN FILE: $Id$ */
/**
* Time library for Cake.
*
* Methods for handling and formatting date and time information.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP 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.
*
* @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.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
*/
/**
* Enter description here...
*/
uses ('object');
/**
* Time-related functions, formatting for dates etc.
*
* The Time class handles and formats date and time information.
*
* @package cake
* @subpackage cake.cake.libs
* @since CakePHP v 0.2.9
*/
class Time extends Object
{
/**
* Returns a formatted date string for given Datetime string.
*
* @param string $date_string Datetime string
* @return string Formatted date string
*/
function nice ($date_string=null)
{
$date = $date_string? strtotime($date_string): time();
return date("D, M jS Y, H:i", $date);
}
/**
* Returns a formatted descriptive date string for given datetime string.
* If the given date is today, the returned string could be "Today, 16:54".
* If the given date was yesterday, the returned string could be "Yesterday, 16:54".
* If $date_string's year is the current year, the returned string does not
* include mention of the year.
*
* @param string $date_string Datetime string
* @return string Described, relative date string
*/
function niceShort ($date_string=null)
{
$date = $date_string? Time::fromString($date_string): time();
$y = Time::isThisYear($date)? '': ' Y';
if (Time::isToday($date))
{
return "Today, ".date("H:i", $date);
}
elseif (Time::wasYesterday($date))
{
return "Yesterday, ".date("H:i", $date);
}
else
{
return date("M jS{$y}, H:i", $date);
}
}
/**
* Returns true if given datetime string is today.
*
* @param string $date Datetime string
* @return boolean True if datetime string is today
*/
function isToday ($date)
{
return date('Y-m-d', $date) == date('Y-m-d', time());
}
/**
* Returns SQL for selecting a date range between the datetime pair $begin and $end.
*
* @param string $begin Start of date range as a Datetime string
* @param string $end End of date range as a Datetime string
* @param string $field_name Name of database date field
* @return string SQL code for selecting the date range
*/
function daysAsSql ($begin, $end, $field_name)
{
$begin = date('Y-m-d', $begin).' 00:00:00';
$end = date('Y-m-d', $end). ' 23:59:59';
return "($field_name >= '$begin') AND ($field_name <= '$end')";
}
/**
* Returns SQL for selecting a date range that includes the whole day of given datetime string.
*
* @param string $date Datetime string
* @param string $field_name Name of database date field
* @return SQL for selecting the date range of that full day
* @see Time::daysAsSql()
*/
function dayAsSql ($date, $field_name)
{
return Time::daysAsSql($date, $date, $field_name);
}
/**
* Returns true if given datetime string is within current year.
*
* @param string $date Datetime string
* @return boolean True if datetime string is within current year
*/
function isThisYear ($date)
{
return date('Y', $date) == date('Y', time());
}
/**
* Returns true if given datetime string was yesterday.
*
* @param string $date Datetime string
* @return boolean True if datetime string was yesterday
*/
function wasYesterday ($date)
{
return date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday'));
}
/**
* Returns a Unix timestamp from a textual datetime description. Wrapper for PHP function strtotime().
*
* @param string $date_string Datetime string to be represented as a Unix timestamp
* @return int Unix timestamp
*/
function fromString ($date_string)
{
return strtotime($date_string);
}
/**
* Returns a date formatted for Atom RSS feeds.
*
* @param string $date Datetime string
* @return string Formatted date string
*/
function toAtom ($date)
{
return date('Y-m-d\TH:i:s\Z', $date);
}
/**
* Formats date for RSS feeds
*
* @param datetime $date Datetime string
* @return string Formatted date string
* @todo Is this for RSS 0.9.2 or RSS 2.0?
*/
function toRSS ($date)
{
return date('D, d M Y H:i:s O', $date);
}
/**
* Returns either a relative date or a formatted date depending
* on the difference between the current time and given datetime.
* $datetime should be in a <i>strtotime</i>-parsable format like MySQL datetime.
*
* Relative dates look something like this:
* 3 weeks, 4 days ago
* 15 seconds ago
* Formatted dates look like this:
* on 02/18/2004
*
* The returned string includes 'ago' or 'on' and assumes you'll properly add a word
* like 'Posted ' before the function output.
*
* @param $datetime Time in strtotime-parsable format
* @return string Relative time string.
*/
function timeAgoInWords ($datetime)
{
$in_seconds=strtotime($datetime);
$diff = time()-$in_seconds;
$months = floor($diff/2419200);
$diff -= $months*2419200;
$weeks = floor($diff/604800);
$diff -= $weeks*604800;
$days = floor($diff/86400);
$diff -= $days*86400;
$hours = floor($diff/3600);
$diff -= $hours*3600;
$minutes = floor($diff/60);
$diff -= $minutes*60;
$seconds = $diff;
if ($months>0)
{
// over a month old, just show date (mm/dd/yyyy format)
return 'on '.date("j/n/Y", $in_seconds);
}
else
{
$relative_date='';
if ($weeks>0)
{
// weeks and days
$relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':'');
$relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):'';
}
elseif ($days>0)
{
// days and hours
$relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':'');
$relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):'';
}
elseif ($hours>0)
{
// hours and minutes
$relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':'');
$relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):'';
}
elseif ($minutes>0)
{
// minutes only
$relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':'');
}
else
{
// seconds only
$relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':'');
}
}
// show relative date and add proper verbiage
return $relative_date.' ago';
}
}
?>

View file

@ -4,7 +4,7 @@
/** /**
* Tort Validators * Tort Validators
* *
* Used to validate data in Models. * Used to validate data in Models.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Backend for helpers.
* *
* Long description for file * Internal methods for the Helpers.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -83,13 +83,13 @@ class Helper extends Object
} }
/** /**
* Decides wheter to output or return a string. * Decides whether to output or return a string.
* *
* Based on AUTO_OUTPUT and $return's value, this method decides wheter to * Based on AUTO_OUTPUT and $return's value, this method decides whether to
* output a string, or return it. * output a string, or return it.
* *
* @param string $str String to be outputed or returned. * @param string $str String to be output or returned.
* @param boolean $return Wheter this method should return a value or * @param boolean $return Whether this method should return a value or
* output it. This overrides AUTO_OUTPUT. * output it. This overrides AUTO_OUTPUT.
* @return mixed Either string or boolean value, depends on AUTO_OUTPUT * @return mixed Either string or boolean value, depends on AUTO_OUTPUT
* and $return. * and $return.
@ -130,10 +130,10 @@ class Helper extends Object
} }
/** /**
* Enter description here... * Returns an array of settings in given INI file.
* *
* @param unknown_type $fileName * @param string $fileName
* @return unknown * @return array
*/ */
function readConfigFile ($fileName) function readConfigFile ($fileName)
{ {

View file

@ -47,16 +47,46 @@
class AjaxHelper extends Helper class AjaxHelper extends Helper
{ {
/**
* Included helpers.
*
* @var array
*/
var $helpers = array('html', 'javascript'); var $helpers = array('html', 'javascript');
/**
* Enter description here...
*
* @var array
*/
var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete'); var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete');
/**
* Enter description here...
*
* @var array
*/
var $ajaxOptions = array('method','position','form','parameters','evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive'); var $ajaxOptions = array('method','position','form','parameters','evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive');
/**
* Enter description here...
*
* @var array
*/
var $dragOptions = array('handle', 'revert', 'constraint', 'change'); var $dragOptions = array('handle', 'revert', 'constraint', 'change');
/**
* Enter description here...
*
* @var array
*/
var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop'); var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop');
/**
* Enter description here...
*
* @var array
*/
var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverClass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange'); var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverClass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange');
@ -338,6 +368,12 @@ class AjaxHelper extends Helper
return $this->javascript->codeBlock("new Draggable('$id'$options);"); return $this->javascript->codeBlock("new Draggable('$id'$options);");
} }
/**
* Enter description here...
*
* @param array $options
* @return array
*/
function _optionsForDraggable ($options) function _optionsForDraggable ($options)
{ {
$options = $this->_optionsToString($options, array('handle','constraint')); $options = $this->_optionsToString($options, array('handle','constraint'));
@ -453,6 +489,14 @@ class AjaxHelper extends Helper
} }
} }
/**
* Enter description here... Return JavaScript text for ...
*
* @param string $klass Name of JavaScript class
* @param string $name
* @param array $options
* @return string Formatted JavaScript
*/
function _buildObserver ($klass, $name, $options=null) function _buildObserver ($klass, $name, $options=null)
{ {
if(!isset($options['with']) && isset($options['update'])) if(!isset($options['with']) && isset($options['update']))
@ -467,6 +511,12 @@ class AjaxHelper extends Helper
return $javascript; return $javascript;
} }
/**
* Enter description here... Return JavaScript text for ...
*
* @param array $options
* @return array
*/
function _buildCallbacks($options) function _buildCallbacks($options)
{ {
$callbacks = array(); $callbacks = array();

View file

@ -361,7 +361,7 @@ class FormHelper extends Helper
} }
/** /**
* Generates an form to go onto a HtmlHelper object. * Generates a form to go onto a HtmlHelper object.
* *
* @param array $fields An array of form field definitions * @param array $fields An array of form field definitions
* @param boolean $readOnly True if the form should be rendered as READONLY * @param boolean $readOnly True if the form should be rendered as READONLY

View file

@ -49,20 +49,20 @@ class HtmlHelper extends Helper
*/ */
/** /**
* Enter description here... * Base URL
* *
* @var unknown_type * @var string
*/ */
var $base = null; var $base = null;
/** /**
* Enter description here... * URL to current action.
* *
* @var unknown_type * @var string
*/ */
var $here = null; var $here = null;
/** /**
* Enter description here... * Parameter array.
* *
* @var array * @var array
*/ */
@ -1236,6 +1236,15 @@ class HtmlHelper extends Helper
return "<$name ". $this->parseHtmlOptions($options). ">$content</$name>"; return "<$name ". $this->parseHtmlOptions($options). ">$content</$name>";
} }
/**
* Returns a SELECT element for days.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{ {
$value = isset($value)? $value : $this->tagValue($tagName."_day"); $value = isset($value)? $value : $this->tagValue($tagName."_day");
@ -1254,6 +1263,17 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a SELECT element for years
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param integer $minYear First year in sequence
* @param integer $maxYear Last year in sequence
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function yearOptionTag( $tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null) function yearOptionTag( $tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null)
{ {
$value = isset($value)? $value : $this->tagValue($tagName."_year"); $value = isset($value)? $value : $this->tagValue($tagName."_year");
@ -1283,6 +1303,15 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a SELECT element for months.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{ {
$value = isset($value)? $value : $this->tagValue($tagName."_month"); $value = isset($value)? $value : $this->tagValue($tagName."_month");
@ -1295,6 +1324,16 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a SELECT element for hours.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param boolean $format24Hours True for 24 hours format
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function hourOptionTag( $tagName,$value=null, function hourOptionTag( $tagName,$value=null,
$format24Hours = false, $format24Hours = false,
$selected=null, $selected=null,
@ -1330,6 +1369,15 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a SELECT element for minutes.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{ {
$value = isset($value)? $value : $this->tagValue($tagName."_min"); $value = isset($value)? $value : $this->tagValue($tagName."_min");
@ -1344,6 +1392,15 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a SELECT element for AM or PM.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $value
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{ {
$value = isset($value)? $value : $this->tagValue($tagName."_meridian"); $value = isset($value)? $value : $this->tagValue($tagName."_meridian");
@ -1355,6 +1412,16 @@ class HtmlHelper extends Helper
return $option; return $option;
} }
/**
* Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
*
* @param string $tagName Prefix name for the SELECT element
* @param string $dateFormat DMY, MDY, YMD or NONE.
* @param string $timeFormat 12, 24, NONE
* @param string $selected Option which is selected.
* @param array $optionAttr Attribute array for the option elements.
* @return string The HTML formatted OPTION element
*/
function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $optionAttr=null) function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $optionAttr=null)
{ {
switch ( $dateFormat ) switch ( $dateFormat )

View file

@ -33,7 +33,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('flay', DS.'view'.DS.'helpers'.DS.'html'); uses('flay', DS.'view'.DS.'helpers'.DS.'html');
@ -94,9 +94,10 @@ class TextHelper extends Helper
} }
/** /**
* Adds links (<a href=....) to a given text. * Adds links (<a href=....) to a given text, by finding text that begins with
* strings like http:// and ftp://.
* *
* @param string $text Text * @param string $text Text to add links to
* @param array $htmlOptions Array of HTML options. * @param array $htmlOptions Array of HTML options.
* @return string The text with links * @return string The text with links
*/ */

View file

@ -0,0 +1,40 @@
<?php
/* SVN FILE: $Id:$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP 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.
*
* @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.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<?php $controller = Inflector::camelize($this->name)."Controller"; ?>
<h1>Private Method in <?php echo $controller;?></h1>
<p class="error">You are seeing this error because the action <em><?php echo $this->controller->privateAction;?></em>
should not be accessed directly
</p>

View file

@ -31,7 +31,7 @@
*/ */
/** /**
* Enter description here... * Included libraries.
*/ */
uses('object', DS.'view'.DS.'helper'); uses('object', DS.'view'.DS.'helper');
@ -163,14 +163,14 @@ class View extends Object
*/ */
var $params; var $params;
/** /**
* Enter description here... * True when the view has been rendered.
* *
* @var boolean * @var boolean
*/ */
var $hasRendered = null; var $hasRendered = null;
/** /**
* Enter description here... * True when the Model objects are all loaded.
* *
* @var boolean * @var boolean
*/ */
@ -231,7 +231,7 @@ class View extends Object
* for a view filename (e.g. customFunkyView.thtml). * for a view filename (e.g. customFunkyView.thtml).
* *
* @param string $action Name of action to render for * @param string $action Name of action to render for
* @param string $layout * @param string $layout Layout to use
* @param string $file Custom filename for view * @param string $file Custom filename for view
*/ */
function render($action=null, $layout=null, $file=null) function render($action=null, $layout=null, $file=null)
@ -390,7 +390,7 @@ class View extends Object
* Renders a layout. Returns output from _render(). Returns false on error. * Renders a layout. Returns output from _render(). Returns false on error.
* *
* @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout. * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout.
* @return string Rendered output, or false on error * @return mixed Rendered output, or false on error
*/ */
function renderLayout($content_for_layout) function renderLayout($content_for_layout)
{ {
@ -423,7 +423,7 @@ class View extends Object
} }
/** /**
* Set layout to be used when rendering. * Sets layout to be used when rendering.
* *
* @param string $layout * @param string $layout
*/ */
@ -473,7 +473,9 @@ class View extends Object
function _getViewFileName($action) function _getViewFileName($action)
{ {
$action = Inflector::underscore($action); $action = Inflector::underscore($action);
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
if(file_exists(VIEWS.$this->viewPath.DS.$action.'.thtml')) if(file_exists(VIEWS.$this->viewPath.DS.$action.'.thtml'))
{ {
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml'; $viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
@ -576,12 +578,12 @@ class View extends Object
return $out; return $out;
} }
/** /**
* Enter description here... * Loads helpers, with their dependencies.
* *
* @param unknown_type $loaded * @param array $loaded List of helpers that are already loaded.
* @param unknown_type $helpers * @param array $helpers List of helpers to load.
* @return unknown * @return array
*/ */
function &_loadHelpers(&$loaded, $helpers) { function &_loadHelpers(&$loaded, $helpers) {

View file

@ -3,9 +3,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Bake startup script
* *
* Long description for file * Invokes the Bake class with given parameters.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Test reporter for Cake
* *
* Long description for file * A test reporter that extends HtmlReporter.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -32,10 +32,11 @@
*/ */
/** /**
* Helper function for outputing data. Should be moved somevhere else. * Helper function for outputting data.
* *
* @param mixed $data Data to be dumped * @param mixed $data Data to be dumped
* @return string Dumped data * @return string Dumped data
* @todo Should be moved somevhere else.
*/ */
function dump($data) function dump($data)
{ {
@ -77,7 +78,7 @@ require_once SIMPLE_TEST.'reporter.php';
$groupTest = new GroupTest('Cake tests'); $groupTest = new GroupTest('Cake tests');
/** /**
* We need to loop thru tests folder. * We need to loop through the tests folder.
*/ */
uses('folder'); uses('folder');
$testsFolder = new Folder(TESTS); $testsFolder = new Folder(TESTS);
@ -94,18 +95,18 @@ foreach ($testsFolder->findRecursive('.*\.php') as $test)
class CakeHtmlReporter extends HtmlReporter class CakeHtmlReporter extends HtmlReporter
{ {
/** /**
* Enter description here... * Returns CSS formatting for the reporter.
* *
* @return unknown * @return string
*/ */
function _getCss() function _getCss()
{ {
return '.error { margin: 10px 0px; border: 1px solid #d7d4c7; padding: 4px; } .fail { color: red; font-weight: bold; } pre { background-color: lightgray; } .msg { margin-top: 5px; } body { font-family: Verdana; font-size: small; }'; return '.error { margin: 10px 0px; border: 1px solid #d7d4c7; padding: 4px; } .fail { color: red; font-weight: bold; } pre { background-color: lightgray; } .msg { margin-top: 5px; } body { font-family: Verdana; font-size: small; }';
} }
/** /**
* Enter description here... * Renders a test failure
* *
* @param unknown_type $message * @param string $message
*/ */
function paintFail($message) function paintFail($message)
{ {
@ -118,9 +119,9 @@ class CakeHtmlReporter extends HtmlReporter
print '</div>'; print '</div>';
} }
/** /**
* Enter description here... * Renders an exception
* *
* @param unknown_type $message * @param string $message Message to be rendered
*/ */
function paintException($message) function paintException($message)
{ {

View file

@ -2,7 +2,7 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Requests collector.
* *
* This file collects requests if: * This file collects requests if:
* - no mod_rewrite is avilable or .htaccess files are not supported * - no mod_rewrite is avilable or .htaccess files are not supported
@ -42,17 +42,13 @@ define ('ROOT', dirname(__FILE__).DS);
require_once ROOT.APP_DIR.DS.'config'.DS.'core.php'; require_once ROOT.APP_DIR.DS.'config'.DS.'core.php';
require_once ROOT.APP_DIR.DS.'config'.DS.'paths.php'; require_once ROOT.APP_DIR.DS.'config'.DS.'paths.php';
require_once CAKE.'basics.php'; require_once CAKE.'basics.php';
/**
* We need to redefine some constants and variables, so that Cake knows it is
* working without mod_rewrite.
*/
//define ('BASE_URL', $_SERVER['SCRIPT_NAME']);
$uri = setUri(); $uri = setUri();
/** /**
* As mod_rewrite (or .htaccess files) is not working, we need to take care * As mod_rewrite (or .htaccess files) is not working, we need to take care
* of what would normally be rewrited, i.e. the static files in /public * of what would normally be rewritten, i.e. the static files in /public
*/ */
if ($uri === '/' || $uri === '/index.php') if ($uri === '/' || $uri === '/index.php')
{ {