Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merging changes from sandboxes

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@856 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 1dce095546b117f0d36f9c20a3d27341ea10af6f 1 parent 37da997
@phpnut phpnut authored
Showing with 559 additions and 438 deletions.
  1. +6 −6 app/views/layouts/default.thtml
  2. +4 −4 app/views/layouts/flash.thtml
  3. +9 −9 app/views/pages/home.thtml
  4. +3 −0  config/core.php
  5. +1 −1  config/tags.ini.php
  6. +1 −1  index.php
  7. +1 −1  libs/bake.php
  8. +73 −9 libs/basics.php
  9. +108 −107 libs/cache.php
  10. +18 −19 libs/class_registry.php
  11. +18 −12 libs/controller.php
  12. +4 −3 libs/controllers/templates/scaffolds/edit.thtml
  13. +9 −7 libs/controllers/templates/scaffolds/list.thtml
  14. +1 −1  libs/controllers/templates/scaffolds/new.thtml
  15. +8 −7 libs/controllers/templates/scaffolds/show.thtml
  16. +12 −2 libs/dbo/dbo_mysql.php
  17. +45 −40 libs/dispatcher.php
  18. +15 −17 libs/file.php
  19. +57 −38 libs/flay.php
  20. +1 −2  libs/folder.php
  21. +8 −5 libs/helpers/ajax.php
  22. +9 −8 libs/helpers/html.php
  23. +13 −10 libs/helpers/javascript.php
  24. +9 −13 libs/model.php
  25. +21 −19 libs/neat_array.php
  26. +55 −55 libs/sanitize.php
  27. +35 −37 libs/scaffold.php
  28. +2 −3 libs/view.php
  29. BIN  public/img/bg_fade.gif
  30. BIN  public/img/bg_header.gif
  31. BIN  public/img/logo.png
  32. BIN  public/img/red_box.gif
  33. +1 −1  public/index.php
  34. +2 −1  tests/core/cases/libs/inflector.test.php
  35. +10 −0 vendors/simpletest/simple_test.php
View
12 app/views/layouts/default.thtml
@@ -1,18 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><?=$title_for_layout?></title>
- <?=$html->charsetTag('UTF-8')?>
- <?=$html->cssTag('default')?>
- <?=$html->cssTag('forms')?>
+ <title><?php echo $title_for_layout?></title>
+ <?php echo $html->charsetTag('UTF-8')?>
+ <?php echo $html->cssTag('default')?>
+ <?php echo $html->cssTag('forms')?>
</head>
<body>
<div id="main">
-<?=$content_for_layout?>
+<?php echo $content_for_layout?>
<p>
-<a id="logo" href="http://www.cakephp.org/" target="_new"><img src="/img/pbcake.gif" width="120" height="28" alt="CakePHP : Rapid Development Framework" /></a>
+<a id="logo" href="http://www.cakephp.org/" target="_new"><img src="<?php echo $html->url("/img/pbcake.gif"); ?>" width="120" height="28" alt="CakePHP : Rapid Development Framework" /></a>
</p>
</div>
</body>
View
8 app/views/layouts/flash.thtml
@@ -1,10 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<head>
-<title><?=$page_title?></title>
+<title><?php echo $page_title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php if(DEBUG == 0) { ?>
-<meta http-equiv="Refresh" content="<?=$time?>;url=<?=$url?>" />
+<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>" />
<?php } ?>
<style><!--
P { text-align:center; font:bold 1.1em sans-serif }
@@ -15,7 +15,7 @@ A:HOVER { text-decoration: underline; color:#44E }
<body>
-<p><a href="<?=$url?>"><?=$message?></a></p>
+<p><a href="<?php echo $url?>"><?php echo $message?></a></p>
</body>
-</html>
+</html>
View
18 app/views/pages/home.thtml
@@ -1,10 +1,10 @@
<h1>CakePHP <em>Works!</em></h1><br/>
<hr/>
-Your database configuration file is <?= file_exists(CONFIGS.'database.php') ? 'present.'. $filePresent = ' ' : 'not present.';?><br/>
-<? $db = DboFactory::getInstance(); ?>
-<? if (!empty($filePresent)):?>
-Cake <?=$db->connected ? "is able to" : "is not able to" ?> connect to the database.
-<?endif?>
+Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ? 'present.'. $filePresent = ' ' : 'not present.';?><br/>
+<?php $db = DboFactory::getInstance(); ?>
+<?php if (!empty($filePresent)):?>
+Cake <?php echo $db->connected ? "is able to" : "is not able to" ?> connect to the database.
+<?php endif; ?>
<hr/>
<br/>
<h2>Editing <em>this Page</em></h2>
@@ -19,10 +19,10 @@ To change the content of this page, edit <code>/app/views/pages/home.thtml</code
<h2>Get <em>Involved</em></h2>
<p>Cake PHP needs you! We have an active user base and are always open to new bug reports or feature ideas!</p><br/>
-<?=$html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> &ndash; for public discussions about everything Cake.<br/>
-<?=$html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> &ndash; fastest way of getting newest information on Cake PHP.<br/>
-<?=$html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.<br/>
-<?=$html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> &ndash; check our plans for the bright future.<br/>
+<?php echo $html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> &ndash; for public discussions about everything Cake.<br/>
+<?php echo $html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> &ndash; fastest way of getting newest information on Cake PHP.<br/>
+<?php echo $html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.<br/>
+<?php echo $html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> &ndash; check our plans for the bright future.<br/>
#cakephp on irc.euirc.net for quick help<br/>
</p>
<br/>
View
3  config/core.php
@@ -36,6 +36,9 @@
* - 0: production
* - 1: development
* - 2: full debug with sql
+ *
+ * In production, the "flash messages" redirect after a time interval.
+ * With the other debug levels you get to click the "flash message" to continue.
*/
define('DEBUG', 1);
View
2  config/tags.ini.php
@@ -99,7 +99,7 @@
tableRow = "<tr%s>%s</tr>"
; Tag template for a CSS link tag.
-css = "<link rel="%s" type="text/css" href="%s" />"
+css = "<link rel="%s" type="text/css" href="%s" %s/>"
; Tag template for a charset meta-tag.
charset = "<meta http-equiv="Content-Type" content="text/html; charset=%s" />"
View
2  index.php
@@ -1,5 +1,5 @@
<?php
-/* SVN FILE: $Id:$ */
+/* SVN FILE: $Id$ */
/**
* Short description for file.
View
2  libs/bake.php
@@ -444,7 +444,7 @@ function getModelFn ($name)
}
/**
- * Creates a test for a given model.
+ * Creates a test for given model.
*
* @param string $name
* @return boolean
View
82 libs/basics.php
@@ -32,7 +32,7 @@
*/
/**
- * Basic defines
+ * Basic defines for timing functions.
*/
define('SECOND', 1);
define('MINUTE', 60 * SECOND);
@@ -103,8 +103,8 @@ function loadController ($name)
/**
* Lists PHP files in given directory.
*
- * @param string $path Path to scan for files
- * @return array List of files in directory
+ * @param string $path Path to scan for files
+ * @return array List of files in directory
*/
function listClasses($path)
{
@@ -115,7 +115,7 @@ function listClasses($path)
/**
* Loads configuration files
*
- * @return boolean True on success.
+ * @return boolean Success
*/
function config ()
{
@@ -160,7 +160,7 @@ function uses ()
}
/**
- * Require given files in the VENDORS directory. Function takes optional number of parameters.
+ * Require given files in the VENDORS directory. Takes optional number of parameters.
*
* @param string $name Filename without the .php part.
*
@@ -175,10 +175,12 @@ function vendor($name)
}
/**
- * Setup a debug point.
+ * Print out debug information about given variable.
+ *
+ * Only runs if DEBUG level is non-zero.
*
- * @param boolean $var
- * @param boolean $show_html
+ * @param boolean $var Variable to show debug information for.
+ * @param boolean $show_html If set to true, the method prints the debug data in a screen-friendly way.
*/
function debug($var = false, $show_html = false)
{
@@ -271,4 +273,66 @@ function array_combine($a1, $a2)
}
}
-?>
+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++)
+ {
+ $a[$args[$l]] = $l+1<count($args) ? $args[$l+1] : null;
+ $l++;
+ }
+ return $a;
+}
+
+
+function e($text)
+{
+ echo $text;
+}
+
+function pr($var)
+{
+ if(DEBUG > 0)
+ {
+ echo "<pre>";
+ print_r($var);
+ echo "</pre>";
+ }
+}
+
+function params($p)
+{
+
+ if(!is_array($p) || count($p) == 0)
+ {
+ return null;
+ }
+ else
+ {
+ if(is_array($p[0]) && count($p) == 1)
+ {
+ return $p[0];
+ }
+ else
+ {
+ return $p;
+ }
+ }
+
+}
+
+?>
View
215 libs/cache.php
@@ -49,113 +49,114 @@
*/
class Cache extends Model {
-/**
- * Identifier. Either an MD5 string or NULL.
- *
- * @var unknown_type
- */
- var $id = null;
-
-/**
- * Content container for cache data.
- *
- * @var unknown_type
- */
- var $data = null;
-
-/**
- * Content to be cached.
- *
- * @var unknown_type
- */
- var $for_caching = null;
-
-/**
- * Name of the database table used for caching.
- *
- * @var unknown_type
- */
- var $use_table = 'cache';
-
-/**
- * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
- *
- * @param unknown_type $id
- */
- function __construct ($id)
- {
- $this->id = (md5($id));
- parent::__construct($this->id);
- }
-
-/**
- * Returns this object's id after setting it. If no $id is given then $this->id is returned.
- *
- * @param unknown_type $id
- * @return unknown
- */
- function id ($id=null)
- {
- if (!$id) return $this->id;
- return ($this->id = $id);
- }
-
-/**
- * Save $content in cache for $keep_for seconds.
- *
- * @param string $content Content to keep in cache.
- * @param int $keep_for Number of seconds to keep data in cache.
- * @return unknown
- */
- function remember ($content, $keep_for=CACHE_PAGES_FOR)
- {
- $data = addslashes($this->for_caching.$content);
- $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999));
- return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
- }
-
-/**
- * Returns content from the Cache object itself, if the Cache object has a non-empty data property. Else from the database cache.
- *
- * @return unknown
- */
- function restore()
- {
- if (empty($this->data['data']))
- return $this->find("id='{$this->id}' AND expire>NOW()");
-
- return $this->data['data'];
- }
-
-/**
- * Returns true if the cache data property has current (non-stale) content for given id.
- *
- * @return boolean
- */
- function has()
- {
- return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
- }
-
-/**
- * Appends $string to the for_caching property of the Cache object.
- *
- * @param string $string
- */
- function append($string)
- {
- $this->for_caching .= $string;
- }
-
-/**
- * Clears the cache database table.
- *
- * @return unknown
- */
- function clear()
- {
- return $this->query("DELETE FROM {$this->use_table}");
- }
+ /**
+ * Identifier. Either an MD5 string or NULL.
+ *
+ * @var string
+ */
+ var $id = null;
+
+ /**
+ * Content container for cache data.
+ *
+ * @var unknown_type
+ */
+ var $data = null;
+
+ /**
+ * Content to be cached.
+ *
+ * @var unknown_type
+ */
+ var $for_caching = null;
+
+ /**
+ * Name of the database table used for caching.
+ *
+ * @var string
+ */
+ var $use_table = 'cache';
+
+ /**
+ * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
+ *
+ * @param unknown_type $id
+ */
+ function __construct ($id)
+ {
+ $this->id = (md5($id));
+ parent::__construct($this->id);
+ }
+
+ /**
+ * Returns this object's id after setting it. If called without parameters the current object's id is returned.
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+ function id ($id=null)
+ {
+ if (!$id) return $this->id;
+ return ($this->id = $id);
+ }
+
+ /**
+ * Store given content in cache database.
+ *
+ * @param string $content Content to keep in cache.
+ * @param int $keep_for Number of seconds to keep data in cache.
+ * @return boolean Success
+ */
+ function remember ($content, $keep_for=CACHE_PAGES_FOR)
+ {
+ $data = addslashes($this->for_caching.$content);
+ $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999));
+ return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
+ }
+
+ /**
+ * Returns content from the Cache object itself, if the Cache object has a non-empty data property.
+ * Else from the database cache.
+ *
+ * @return unknown
+ */
+ function restore()
+ {
+ if (empty($this->data['data']))
+ return $this->find("id='{$this->id}' AND expire>NOW()");
+
+ return $this->data['data'];
+ }
+
+ /**
+ * Returns true if the cache data property has current (non-stale) content for given id.
+ *
+ * @return boolean
+ */
+ function has()
+ {
+ return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
+ }
+
+ /**
+ * Appends $string to the for_caching property of the Cache object.
+ *
+ * @param string $string
+ */
+ function append($string)
+ {
+ $this->for_caching .= $string;
+ }
+
+ /**
+ * Clears the cache database table.
+ *
+ * @return unknown
+ */
+ function clear()
+ {
+ return $this->query("DELETE FROM {$this->use_table}");
+ }
}
?>
View
37 libs/class_registry.php
@@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Class collections.
*
- * Long description for file
+ * A repository for class objects, each registered with a key.
*
* PHP versions 4 and 5
*
@@ -34,7 +34,9 @@
/**
* Class Collections.
*
- * Long description for class
+ * A repository for class objects, each registered with a key.
+ * If you try to add an object with the same key twice, nothing will come of it.
+ * If you need a second instance of an object, give it another key.
*
* @package cake
* @subpackage cake.libs
@@ -44,15 +46,15 @@ class ClassRegistry
{
/**
- * Enter description here...
+ * Names of classes with their objects.
*
- * @var unknown_type
+ * @var array
* @access private
*/
var $_objects = array();
/**
- * Enter description here...
+ * Return a singleton instance of the ClassRegistry.
*
* @return ClassRegistry instance
*/
@@ -67,10 +69,10 @@ function &getInstance() {
}
/**
- * Enter description here...
+ * Add $object to the registry, associating it with the name $key.
*
- * @param unknown_type $key
- * @param unknown_type $object
+ * @param string $key
+ * @param mixed $object
*/
function addObject($key, &$object)
{
@@ -83,10 +85,10 @@ function addObject($key, &$object)
}
/**
- * Enter description here...
+ * Returns true if given key is present in the ClassRegistry.
*
- * @param unknown_type $key
- * @return unknown
+ * @param string $key Key to look for
+ * @return boolean Success
*/
function isKeySet($key)
{
@@ -95,18 +97,15 @@ function isKeySet($key)
}
/**
- * Enter description here...
+ * Return object which corresponds to given key.
*
- * @param unknown_type $key
- * @return unknown
+ * @param string $key
+ * @return mixed
*/
function &getObject($key)
{
$key = strtolower($key);
return $this->_objects[$key];
}
-
-
- }
-
+}
?>
View
30 libs/controller.php
@@ -181,7 +181,7 @@ class Controller extends Object
* Constructor.
*
*/
- function __construct ($params=null)
+ function __construct ()
{
// parent::__construct();
$r = null;
@@ -190,7 +190,7 @@ function __construct ($params=null)
die("Controller::__construct() : Can't get or parse my own class name, exiting.");
}
- $this->name = strtolower($r[1]);
+ $this->name = $r[1];
$this->viewPath = Inflector::underscore($r[1]);
//Adding Before Filter check
@@ -227,11 +227,15 @@ function contructClasses(){
$dboFactory = DboFactory::getInstance($this->useDbConfig);
$this->db =& $dboFactory;
- $model_class = Inflector::singularize($this->name);
+ $match = array();
+ preg_match('/(.*)Controller/i', get_class($this), $match);
+
+ $model_class = Inflector::singularize($match[1]);
+ $modelKey = strtolower(Inflector::underscore($model_class));
if (class_exists($model_class) && ($this->uses === false))
{
- $this->models[$model_class] = new $model_class($id);
+ $this->models[$modelKey] = new $model_class($id);
}
elseif ($this->uses)
{
@@ -245,10 +249,11 @@ function contructClasses(){
foreach ($uses as $model_name)
{
$model_class = ucfirst(strtolower($model_name));
+ $modelKey = strtolower(Inflector::underscore($model_class));
if (class_exists($model_class))
{
- $this->models[$model_name] = new $model_class($id);
+ $this->models[$modelKey] = new $model_class($id);
}
else
{
@@ -357,8 +362,9 @@ function render($action=null, $layout=null, $file=null)
if(!empty($this->models))
{
- foreach ($this->models as $key => $value)
+ foreach ($this->models as $key)
{
+ $key = Inflector::underscore(get_class($key));
if(!empty($this->models[$key]->validationErrors))
{
$view->validationErrors[$key] =& $this->models[$key]->validationErrors;
@@ -448,14 +454,15 @@ function _setTitle($pageTitle)
* @param string $url Relative URL to redirect to after the time expires
* @param int $time Time to show the message
*/
- function flash($message, $url, $time=1)
+ function flash($message, $url, $pause=1)
{
$this->autoRender = false;
$this->autoLayout = false;
$this->set('url', $this->base.$url);
$this->set('message', $message);
- $this->set('time', $time);
+ $this->set('pause', $pause);
+ $this->set('page_title', $message);
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
}
@@ -497,11 +504,11 @@ function generateFieldNames( $data = null, $doCreateOptions = true )
// figure out what model and table we are working with
$model = Inflector::pluralize($this->name);
- $table = Inflector::singularize($this->name);
+ $table = Inflector::underscore(Inflector::singularize($this->name));
// get all of the column names.
$classRegistry =& ClassRegistry::getInstance();
- $objRegistryModel = $classRegistry->getObject($table);
+ $objRegistryModel = $classRegistry->getObject(Inflector::singularize($model));
foreach ($objRegistryModel->_table_info as $tables)
{
@@ -676,7 +683,6 @@ function generateFieldNames( $data = null, $doCreateOptions = true )
$fieldNames[ $tabl['name']]['options'] = array();
$enumValues = split(',', $fieldLength );
- $iCount = 1;
foreach ($enumValues as $enum )
{
$enum = trim( $enum, "'" );
@@ -704,7 +710,7 @@ function generateFieldNames( $data = null, $doCreateOptions = true )
// loop through the many to many relations to make a list box.
foreach( $objRegistryModel->_manyToMany as $relation )
{
- list($tableName, $field, $value, $joinTable, $key1, $key2) = $relation;
+ list($tableName) = $relation;
$otherModelName = Inflector::singularize($tableName);
$otherModel = new $otherModelName();
View
7 libs/controllers/templates/scaffolds/edit.thtml
@@ -3,7 +3,7 @@ uses('helpers/form');
$form = new FormHelper();
- echo $html->formTag('/'.$this->name.'/update');
+ echo $html->formTag('/'.Inflector::underscore($this->name).'/update');
echo $form->generateFields( $html, $fieldNames );
@@ -13,9 +13,10 @@ uses('helpers/form');
<ul class='actions'>
<?php
$modelName = Inflector::singularize($this->name);
- echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelName]['id'])."</li>";
+ $modelKey = Inflector::underscore($modelName);
+ echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelKey]['id'])."</li>";
- foreach( $fieldNames as $field=>$value ) {
+ foreach( $fieldNames as $field => $value ) {
if( isset( $value['foreignKey'] ) )
{
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[Inflector::singularize($params['controller'])][$field] )."</li>";
View
16 libs/controllers/templates/scaffolds/list.thtml
@@ -1,6 +1,8 @@
<?php
$model = Inflector::pluralize($this->name);
- $table = Inflector::singularize($this->name);
+ //$table = Inflector::underscore(get_class($this->models[strtolower(Inflector::singularize(Inflector::underscore($this->name)))]));
+
+ $modelKey = Inflector::underscore(Inflector::singularize($this->name));
$humanName = Inflector::humanize($this->name);
$humanSingularName = Inflector::singularize( $humanName );
// var_dump( $data );
@@ -40,18 +42,18 @@
{
$displayText = $row[$otherModelName][ $otherModelObject->getDisplayField() ];
} else{
- $displayText = $row[$table][$field];
+ $displayText = $row[$modelKey][$field];
}
- echo $html->linkTo( $displayText, "/".Inflector::underscore($otherControllerName)."/show/".$row[$table][$field] );
+ echo $html->linkTo( $displayText, "/".Inflector::underscore($otherControllerName)."/show/".$row[$modelKey][$field] );
} else {
- echo $row[$table ][$field];
+ echo $row[$modelKey][$field];
} ?>
</td>
<?php } // end for each $fieldNames as $field=>value ?>
- <td class="listactions"><?php echo $html->linkTo('View',"/".$this->viewPath."/show/{$row[$table]['id']}/")?>
- <?php echo $html->linkTo('Edit',"/".$this->viewPath."/edit/{$row[$table]['id']}/")?>
- <?php echo $html->linkTo('Delete',"/".$this->viewPath."/destroy/{$row[$table]['id']}/")?>
+ <td class="listactions"><?php echo $html->linkTo('View',"/".$this->viewPath."/show/{$row[$modelKey]['id']}/")?>
+ <?php echo $html->linkTo('Edit',"/".$this->viewPath."/edit/{$row[$modelKey]['id']}/")?>
+ <?php echo $html->linkTo('Delete',"/".$this->viewPath."/destroy/{$row[$modelKey]['id']}/")?>
</td>
</tr>
View
2  libs/controllers/templates/scaffolds/new.thtml
@@ -3,7 +3,7 @@ uses('helpers/form');
$form = new FormHelper();
- echo $html->formTag('/'.$this->name.'/create');
+ echo $html->formTag('/'.Inflector::underscore($this->name).'/create');
echo $form->generateFields( $html, $fieldNames );
View
15 libs/controllers/templates/scaffolds/show.thtml
@@ -1,5 +1,6 @@
<?php
$modelName = Inflector::singularize($this->name);
+ $modelKey = Inflector::underscore($modelName);
$registry = ClassRegistry::getInstance();
?>
@@ -11,9 +12,9 @@
$displayField = $otherModelObject->getDisplayField();
$displayText = $data[$value['model']][ $displayField ];
- if( !empty($data[$modelName][$field]))
+ if( !empty($data[$modelKey][$field]))
{
- echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelName][ $field ] )."</dd>";
+ echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelKey][ $field ] )."</dd>";
}
else
{
@@ -23,9 +24,9 @@
else
{
// this is just a plain old field.
- if( !empty($data[$modelName][$field]))
+ if( !empty($data[$modelKey][$field]))
{
- echo "<dd>".$data[$modelName][$field]."</dd>";
+ echo "<dd>".$data[$modelKey][$field]."</dd>";
}
else
{
@@ -38,8 +39,8 @@
</dl>
<ul class='actions'>
<?php
- echo "<li>".$html->linkTo('Edit '.Inflector::humanize($modelName), '/'.$this->viewPath.'/edit/'.$data[$modelName]['id'])."</li>";
- echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelName]['id'])."</li>";
+ echo "<li>".$html->linkTo('Edit '.Inflector::humanize($modelKey), '/'.$this->viewPath.'/edit/'.$data[$modelKey]['id'])."</li>";
+ echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelKey), '/'.$this->viewPath.'/destroy/'.$data[$modelKey]['id'])."</li>";
foreach( $fieldNames as $field=>$value ) {
if( isset( $value['foreignKey'] ) )
@@ -146,4 +147,4 @@
</ul></div>
<?php } // end loop through relations
-?>
+?>
View
14 libs/dbo/dbo_mysql.php
@@ -144,8 +144,18 @@ function fields ($table_name)
$cols = $this->all("DESC {$table_name}");
foreach ($cols as $column)
+ {
// $fields[] = array('name'=>$column['Field'], 'type'=>$column['Type']);
- $fields[] = array('name'=>$column[0]['Field'], 'type'=>$column[0]['Type']);
+ if(isset($column['COLUMNS']) && !isset($column[0]))
+ {
+ $column[0] = $column['COLUMNS'];
+ }
+
+ if(isset($column[0]))
+ {
+ $fields[] = array('name' => $column[0]['Field'], 'type' => $column[0]['Type']);
+ }
+ }
return $fields;
}
@@ -211,7 +221,7 @@ function lastInsertId ()
*/
function selectLimit ($limit, $offset=null)
{
- return $limit? " LIMIT {$limit}".($offset? "{$offset}": null): null;
+ return $limit? " LIMIT".($offset? " {$offset},": null)." {$limit}": null;
}
/**
View
85 libs/dispatcher.php
@@ -2,9 +2,10 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Dispatcher takes the URL information, parses it for paramters and
+ * tells the involved controllers what to do.
*
- * Long description for file
+ * This is the heart of Cake's operation.
*
* PHP versions 4 and 5
*
@@ -65,7 +66,7 @@ class Dispatcher extends Object
var $base = false;
/**
- * Fetches base url.
+ * Constructor.
*/
function __construct()
{
@@ -73,30 +74,19 @@ function __construct()
parent::__construct();
}
-/**
- * Dispatches the request (action).
- *
- * @param string $url
- * @return array
- */
- function dispatch($url)
- {
- $params = $this->parseParams($url);
- $result = $this->invoke($url);
-
- return $result === true? $params: array();
- }
/**
- * Enter description here...
+ * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
+ *
+ * If no controller of given name can be found, invoke() shows error messages in
+ * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called
+ * Actions).
*
- * @param string $url
- * @return unknown
+ * @param string $url URL information to work on.
+ * @return boolean Success
*/
- function invoke($url)
+ function dispatch($url)
{
- global $_POST, $_GET, $_FILES, $_SESSION;
-
$params = $this->parseParams($url);
$missingController = false;
$missingAction = false;
@@ -217,13 +207,11 @@ function invoke($url)
/**
* Returns array of GET and POST parameters. GET parameters are taken from given URL.
*
- * @param string $from_url
+ * @param string $from_url URL to mine for parameter information.
* @return array Parameters found in POST and GET.
*/
function parseParams($from_url)
{
- global $_POST, $_FILES;
-
// load routes config
$Route = new Router();
include CONFIGS.'routes.php';
@@ -233,7 +221,14 @@ function parseParams($from_url)
$params['form'] = $_POST;
if (isset($_POST['data']))
{
- $params['data'] = (ini_get('magic_quotes_gpc') == 1) ? $this->stripslashes_deep($_POST['data']) : $_POST['data'];
+ $params['data'] = (ini_get('magic_quotes_gpc') == 1)?
+ $this->stripslashes_deep($_POST['data']) : $_POST['data'];
+ }
+ if (isset($_GET))
+ {
+ $params['url'] = $this->urldecode_deep($_GET);
+ $params['url'] = (ini_get('magic_quotes_gpc') == 1)?
+ $this->stripslashes_deep($params['url']) : $params['url'];
}
foreach ($_FILES as $name => $data)
@@ -255,13 +250,22 @@ function stripslashes_deep($val)
}
/**
+ * Recursively performs urldecode.
+ *
+ */
+ function urldecode_deep($val)
+ {
+ return (is_array($val)) ?
+ array_map(array('Dispatcher','urldecode_deep'), $val) : urldecode($val);
+ }
+
+/**
* Returns a base URL.
*
- * @return string
+ * @return string Base URL
*/
function baseUrl()
{
- global $_SERVER;
//non mod_rewrite use:
if (defined('BASE_URL')) return BASE_URL;
@@ -281,8 +285,8 @@ function baseUrl()
/**
* Displays an error page (e.g. 404 Not found).
*
- * @param int $code Error code (e.g. 404)
- * @param string $name Name of the error message (e.g. Not found)
+ * @param int $code Error code (e.g. 404)
+ * @param string $name Name of the error message (e.g. Not found)
* @param string $message
*/
function error ($code, $name, $message)
@@ -295,8 +299,8 @@ function error ($code, $name, $message)
/**
* Convenience method to display a 404 page.
*
- * @param unknown_type $url
- * @param unknown_type $message
+ * @param string $url URL that spawned this message, to be included in the output.
+ * @param string $message Message text for the 404 page.
*/
function error404 ($url, $message)
{
@@ -304,9 +308,10 @@ function error404 ($url, $message)
}
/**
- * If DEBUG is set, this displays a 404 error with the message that no controller is set. If DEBUG is not set, nothing happens.
+ * If DEBUG is set, this displays a 404 error with the message that no controller is set.
+ * If DEBUG is not set, nothing happens.
*
- * @param string $url
+ * @param string $url URL that spawned this message, to be included in the output.
*/
function errorNoController ($url)
{
@@ -319,7 +324,7 @@ function errorNoController ($url)
/**
* If DEBUG is set, this displays a 404 error with the message that the asked-for controller does not exist. If DEBUG is not set, nothing happens.
*
- * @param string $url
+ * @param string $url URL that spawned this message, to be included in the output.
* @param string $controller_class
*/
function errorUnknownController ($url, $controller_class)
@@ -333,7 +338,7 @@ function errorUnknownController ($url, $controller_class)
/**
* If DEBUG is set, this displays a 404 error with the message that no action is set. If DEBUG is not set, nothing happens.
*
- * @param string $url
+ * @param string $url URL that spawned this message, to be included in the output.
*/
function errorNoAction ($url)
{
@@ -346,7 +351,7 @@ function errorNoAction ($url)
/**
* If DEBUG is set, this displays a 404 error with the message that no such action exists. If DEBUG is not set, nothing happens.
*
- * @param string $url
+ * @param string $url URL that spawned this message, to be included in the output.
* @param string $controller_class
* @param string $action
*/
@@ -359,17 +364,17 @@ function errorUnknownAction ($url,$controller_class, $action)
}
/**
- * When now methods are present in a controller
+ * When methods are now present in a controller
* scaffoldView is used to call default Scaffold methods if:
* <code>
* var $scaffold;
* </code>
- * is placed in the controller class definition
+ * is placed in the controller's class definition.
*
* @param string $url
* @param string $controller_class
* @param array $params
- * @since Cake v 1.0.0.172
+ * @since Cake v 0.10.0.172
*/
function scaffoldView ($url, $controller_class, $params)
{
View
32 libs/file.php
@@ -2,9 +2,8 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Convenience class for reading, writing and appending to files.
*
- * Long description for file
*
* PHP versions 4 and 5
*
@@ -33,9 +32,8 @@
/**
- * Short description for class
+ * Convenience class for reading, writing and appending to files.
*
- * Long description for class
*
* @package cake
* @subpackage cake.libs
@@ -44,16 +42,16 @@
class File
{
/**
- * Enter description here...
+ * Path to file
*
- * @var unknown_type
+ * @var string
*/
var $path = null;
/**
- * Enter description here...
+ * Constructor
*
- * @param unknown_type $path
+ * @param string $path
* @return File
*/
function File ($path)
@@ -62,9 +60,9 @@ function File ($path)
}
/**
- * Enter description here...
+ * Return the contents of this File as a string.
*
- * @return unknown
+ * @return string Contents
*/
function read ()
{
@@ -72,10 +70,10 @@ function read ()
}
/**
- * Enter description here...
+ * Append given data string to this File.
*
- * @param unknown_type $data
- * @return unknown
+ * @param string $data Data to write
+ * @return boolean Success
*/
function append ($data)
{
@@ -83,11 +81,11 @@ function append ($data)
}
/**
- * Enter description here...
+ * Write given data to this File.
*
- * @param unknown_type $data
- * @param unknown_type $mode
- * @return unknown
+ * @param string $data Data to write to this File.
+ * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
+ * @return boolean Success
*/
function write ($data, $mode = 'w')
{
View
95 libs/flay.php
@@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Text-to-HTML parser.
*
- * Long description for file
+ * Text-to-html parser, similar to {@link http://textism.com/tools/textile/ Textile} or {@link http://www.whytheluckystiff.net/ruby/redcloth/ RedCloth}.
*
* PHP versions 4 and 5
*
@@ -37,7 +37,7 @@
uses('object');
/**
- * Short description for class
+ * Text-to-HTML parser.
*
* Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.
*
@@ -49,14 +49,14 @@
class Flay extends Object
{
/**
- * Enter description here...
+ * Text to be parsed.
*
* @var string
*/
var $text = null;
/**
- * Enter description here...
+ * Set this to allow HTML in the markup.
*
* @var boolean
*/
@@ -65,7 +65,7 @@ class Flay extends Object
/**
* Constructor.
*
- * @param unknown_type $text
+ * @param string $text
*/
function __construct ($text=null)
{
@@ -74,10 +74,10 @@ function __construct ($text=null)
}
/**
- * Returns $text translated to HTML using the Flay syntax.
+ * Returns given text translated to HTML using the Flay syntax.
*
- * @param string $text Text to format
- * @param boolean $bare
+ * @param string $text String to format
+ * @param boolean $bare Set this to only do <p> transforms and > to &gt;, no typography additions.
* @param boolean $allowHtml Set this to trim whitespace and disable all HTML
* @return string Formatted text
*/
@@ -85,15 +85,21 @@ function toHtml ($text=null, $bare=false, $allowHtml=false)
{
if (empty($text) && empty($this->text))
+ {
return false;
+ }
$text = $text? $text: $this->text;
// trim whitespace and disable all HTML
if ($allowHtml)
+ {
$text = trim($text);
+ }
else
+ {
$text = str_replace('<', '&lt;', str_replace('>', '&gt;', trim($text)));
+ }
if (!$bare)
{
@@ -195,9 +201,13 @@ function toHtml ($text=null, $bare=false, $allowHtml=false)
if (isset($regs[2]))
{
if (preg_match('#\.(jpg|jpeg|gif|png)$#', $regs[2]))
+ {
$body = "<img src=\"{$prefix}{$regs[2]}\" alt=\"\" />";
+ }
else
+ {
$body = $regs[2];
+ }
}
else
@@ -235,10 +245,10 @@ function toHtml ($text=null, $bare=false, $allowHtml=false)
}
/**
- * Enter description here...
+ * Return the words of the string as an array.
*
- * @param unknown_type $string
- * @return unknown
+ * @param string $string
+ * @return array Array of words
*/
function extractWords ($string)
{
@@ -246,12 +256,13 @@ function extractWords ($string)
}
/**
- * Enter description here...
+ * Return given string with words in array colorMarked, up to a number of times (defaults to 5).
*
- * @param unknown_type $words
- * @param unknown_type $string
- * @param unknown_type $max_snippets
- * @return unknown
+ * @param array $words Words to look for and markup
+ * @param string $string String to look in
+ * @param integer $max_snippets Max number of snippets to extract
+ * @return string
+ * @see colorMark
*/
function markedSnippets ($words, $string, $max_snippets=5)
{
@@ -265,7 +276,9 @@ function markedSnippets ($words, $string, $max_snippets=5)
if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r))
{
foreach ($r as $result)
+ {
$rest = str_replace($result, '', $rest);
+ }
$snips = array_merge($snips, $r[0]);
}
}
@@ -275,17 +288,17 @@ function markedSnippets ($words, $string, $max_snippets=5)
$snips = array_slice($snips, 0, $max_snippets);
}
$joined = join(' <b>...</b> ', $snips);
- $snips = $joined? "<b>...</b> {$joined} <b>...</b>": substr($string, 0, 80).'<b>...</b>';
+ $snips = $joined? "<b>...</b> {$joined} <b>...</b>": substr($string, 0, 80) . '<b>...</b>';
return Flay::colorMark($words, $snips);
}
/**
- * Enter description here...
+ * Returns string with EM elements with color classes added.
*
- * @param unknown_type $words
- * @param unknown_type $string
- * @return unknown
+ * @param array $words Array of words to be colorized
+ * @param string $string Text in which the words might be found
+ * @return string
*/
function colorMark($words, $string)
{
@@ -294,52 +307,58 @@ function colorMark($words, $string)
$nextColorIndex = 0;
foreach ($words as $word)
{
- $string = preg_replace("/({$word})/i", '<em class="'.$colors[$nextColorIndex%count($colors)]."\">\\1</em>", $string);
+ $string = preg_replace("/({$word})/i", '<em class="' . $colors[$nextColorIndex%count($colors)] . "\">\\1</em>", $string);
$nextColorIndex++;
}
return $string;
}
-
+
/**
- * Enter description here...
+ * Returns given text with tags stripped out.
*
- * @param unknown_type $text
- * @return unknown
+ * @param string $text
+ * @return string
*/
function toClean ($text)
{
return strip_tags(html_entity_decode($text, ENT_QUOTES));
}
+/**
+ * Return parsed text with tags stripped out.
+ *
+ * @param string $text
+ * @return string
+ */
function toParsedAndClean ($text)
{
return Flay::toClean(Flay::toHtml($text));
}
/**
- * Enter description here...
+ * Return a fragment of a text, up to $length characters long, with an ellipsis after it.
*
- * @param unknown_type $text
- * @param unknown_type $length
- * @param unknown_type $elipsis
- * @return unknown
+ * @param string $text Text to be truncated.
+ * @param integer $length Max length of text.
+ * @param string $ellipsis Sign to print after truncated text.
+ * @return string
*/
- function fragment ($text, $length, $elipsis='...')
+ function fragment ($text, $length, $ellipsis='...')
{
- $soft=$length-5;
- $hard=$length+5;
- $rx = '/(.{'.$soft.','.$hard.'})[\s,\.:\/="!\(\)<>~\[\]]+.*/';
+ $soft = $length - 5;
+ $hard = $length + 5;
+ $rx = '/(.{' . $soft . ',' . $hard . '})[\s,\.:\/="!\(\)<>~\[\]]+.*/';
if (preg_match($rx, $text, $r))
{
$out = $r[1];
}
else
{
- $out = substr($text,0,$length);
+ $out = substr($text, 0, $length);
}
- $out = $out.(strlen($out)<strlen($text)? $elipsis: null);
+ $out = $out . (strlen($out)<strlen($text)? $ellipsis: null);
return $out;
}
}
View
3  libs/folder.php
@@ -2,9 +2,8 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Convenience class for handling directories.
*
- * Long description for file
*
* PHP versions 4 and 5
*
View
13 libs/helpers/ajax.php
@@ -116,9 +116,11 @@ function linkToRemote ($html, $title, $options = null, $html_options = null)
{
// mouse click should call our remote function
$html_options['onclick'] = $this->remoteFunction($html, $options);
+
+ $href = (!empty($options['fallback'])) ? $options['fallback'] : '#';
// generate actual link
- return $html->link($title, '#', $html_options);
+ return $html->link($title, $href, $html_options);
}
/**
@@ -142,19 +144,20 @@ function remoteFunction ($html, $options = null)
if (isset($options['before']))
{
- $func .= "{$options['before']}; $function";
+ $func = "{$options['before']}; $function";
}
if (isset($options['after']))
{
- $func .= "$func; {$options['before']};";
+ $func = "$func; {$options['before']};";
}
if (isset($options['condition']))
{
- $func .= "if ({$options['condition']}) { $func; }";
+ $func = "if ({$options['condition']}) { $func; }";
}
if (isset($options['confirm']))
{
- $func .= "if (confirm('" . $this->escapeScript($options['confirm']) . "')) { $func; }";
+ $js = new JavascriptHelper;
+ $func = "if (confirm('" . $js->escapeScript($options['confirm']) . "')) { $func; } else { return false; }";
}
return $func;
}
View
17 libs/helpers/html.php
@@ -420,12 +420,13 @@ function hidden($fieldName, $htmlAttributes = null, $return = false)
* @return mixed Either string or boolean value, depends on AUTO_OUTPUT
* and $return.
*/
- function image($path, $htmlAttributes = null, $return = false)
- {
- $url = $this->base.IMAGES_URL.$path;
- $alt = $htmlAttributes['alt'];
- return $this->output(sprintf($this->tags['image'], $url, $alt, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
- }
+
+ function image($path, $htmlAttributes = null, $return = false)
+ {
+ $url = $this->base.IMAGES_URL.$path;
+ $alt = isset($htmlAttributes['alt']) ? $htmlAttributes['alt'] : "";
+ return $this->output(sprintf($this->tags['image'], $url, $alt, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
+ }
/**
* Creates a text input widget.
@@ -531,11 +532,11 @@ function tableCells($data, $odd_tr_options=null, $even_tr_options=null)
$cells_out = array();
foreach ($line as $cell)
{
- $cells_out[] = sprintf($this->tags['tableCell'], null, $cell);
+ $cells_out[] = sprintf($this->tags['tablecell'], null, $cell);
}
$options = $this->parseHtmlOptions($count%2? $odd_tr_options: $even_tr_options);
- $out[] = sprintf($this->tags['tableRow'], $options, join(' ', $cells_out));
+ $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cells_out));
}
return join("\n", $out);
View
23 libs/helpers/javascript.php
@@ -30,14 +30,6 @@
*/
-if(!defined("TAG_JAVASCRIPT")) {
- define("TAG_JAVASCRIPT", '<script type="text/javascript">%s</script>');
-}
-
-if(!defined("TAG_JAVASCRIPT_INCLUDE")) {
- define("TAG_JAVASCRIPT_INCLUDE", '<script type="text/javascript" src="%s"></script>');
-}
-
/**
* Javascript Helper class for easy use of JavaScript.
*
@@ -57,7 +49,7 @@ class JavascriptHelper extends Helper
*/
function codeBlock($script)
{
- return sprintf(TAG_JAVASCRIPT, $script);
+ return sprintf($this->tags['javascriptBlock'], $script);
}
/**
@@ -68,7 +60,18 @@ function codeBlock($script)
*/
function link($url)
{
- return sprintf(TAG_JAVASCRIPT_INCLUDE, $this->base.$url);
+ return sprintf($this->tags['javascriptLink'], $this->base.$url);
+ }
+
+ /**
+ * Returns a JavaScript include tag for an externally-hosted script
+ *
+ * @param string $url URL to JavaScript file.
+ * @return string
+ */
+ function linkOut($url)
+ {
+ return sprintf($this->tags['javascriptLink'], $url);
}
/**
View
22 libs/model.php
@@ -780,7 +780,7 @@ function useTable ($table_name)
function set ($one, $two=null)
{
$this->validationErrors = null;
- $data = is_array($one)? $one: array($one=>$two);
+ $data = is_array($one)? array($this->table=>$one) : array($one=>$two);
foreach ($data as $n => $v)
{
@@ -792,21 +792,17 @@ function set ($one, $two=null)
trigger_error('Application error occured, trying to set a field name that doesn\'t exist.', E_USER_WARNING);
}
*/
- //$n == 'id'? $this->setId($v): $this->data[$n] = $v;
-
foreach ($v as $x => $y)
{
- //$x == 'id'? $this->id = $y: $this->data[$n][$x] = $y;
- if($x == 'id')
- {
- $this->id = $y;
- }
- $this->data[$n][$x] = $y;
-
+ if($x == 'id')
+ {
+ $this->id = $y;
+ }
+ $this->data[$n][$x] = $y;
}
}
return $data;
- }
+ }
/**
* Sets current Model id to given $id.
@@ -815,7 +811,7 @@ function set ($one, $two=null)
*/
function setId ($id)
{
- $this->id[0] = $id;
+ $this->id = $id;
if(!empty($this->_belongsToOther))
{
@@ -1329,7 +1325,7 @@ function findAll ($conditions = null, $fields = null, $order = null, $limit=50,
{
for ($i = 0; $i< count($original); $i++)
{
- $newValue2[$i] = $original[$i];
+ $newValue[$i] = $original[$i];
}
}
elseif(!empty($original))
View
40 libs/neat_array.php
@@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
+ * Library of array functions for Cake.
*
- * Long description for file
+ * Internal use only.
*
* PHP versions 4 and 5
*
@@ -32,7 +32,7 @@
*/
/**
- * Class used for internal manipulation of multiarrays (arrays of arrays).
+ * Class used for internal manipulation of multi-dimensional arrays (arrays of arrays).
*
* Long description for class
*
@@ -63,7 +63,7 @@ function NeatArray ($value=array())
}
/**
- * Finds and returns records with $fieldName equal $value from this NeatArray.
+ * Finds and returns records with $fieldName equal to $value from this NeatArray.
*
* @param string $fieldName
* @param string $value
@@ -91,7 +91,7 @@ function findIn ($fieldName, $value)
}
/**
- * Checks if $this->value is array, and removes all empty elements.
+ * Checks if $this->value is an array, and removes all empty elements.
*
* @access public
* @uses NeatArray::value
@@ -114,7 +114,7 @@ function cleanup ()
}
/**
- * Adds elements from the supplied array to itself.
+ * Adds elements from given array to itself.
*
* @param string $value
* @return bool
@@ -169,10 +169,10 @@ function totals ($sortedBy=1,$reverse=true)
}
/**
- * Performs an array_filter() on the contents.
+ * Performs an array_filter() on the contents of this NeatArray.
*
- * @param unknown_type $with
- * @return unknown
+ * @param string $with Name of callback function to perform on each element of this NeatArray.
+ * @return array
*/
function filter ($with)
{
@@ -180,9 +180,10 @@ function filter ($with)
}
/**
- * Passes each of its values through a specified function or method. Think of PHP's 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()}.
*
- * @return array
+ * @param string $with Name of callback function
+ * @return array Returns value of NeatArray::value
* @access public
* @uses NeatArray::value
*/
@@ -193,10 +194,10 @@ function walk ($with)
}
/**
- * Enter description here...
+ * Apply $template to all elements of this NeatArray, and return the array itself.
*
- * @param unknown_type $template
- * @return unknown
+ * @param string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray.
+ * @return array
*/
function sprintf($template)
{
@@ -306,12 +307,13 @@ function joinWith ($his, $onMine, $onHis=null)
/**
* Enter description here...
+ * @todo Explain this function. almost looks like it creates a tree
*
- * @param unknown_type $root
- * @param unknown_type $idKey
- * @param unknown_type $parentIdKey
- * @param unknown_type $childrenKey
- * @return unknown
+ * @param string $root
+ * @param string $idKey
+ * @param string $parentIdKey
+ * @param string $childrenKey
+ * @return array
*/
function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children')
{
View
110 libs/sanitize.php
@@ -1,47 +1,47 @@
-<?php
-/* SVN FILE: $Id: sanitize.php 491 2005-07-31 18:31:45Z phpnut $ */
-
-/**
- * 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.libs
- * @since CakePHP v 0.9.2
- * @version $Revision: 491 $
- * @modifiedby $LastChangedBy: phpnut $
- * @lastmodified $Date: 2005-07-31 13:31:45 -0500 (Sun, 31 Jul 2005) $
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
-
-/**
- * Data Sanitization.
- *
- * Long description for class
- *
- * @package cake
- * @subpackage cake.libs
- * @since CakePHP v 0.9.2
- *
- */
-class Sanitize
+<?php
+/* SVN FILE: $Id: sanitize.php 491 2005-07-31 18:31:45Z phpnut $ */
+
+/**
+ * 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.libs
+ * @since CakePHP v 0.9.2
+ * @version $Revision: 491 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2005-07-31 13:31:45 -0500 (Sun, 31 Jul 2005) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Data Sanitization.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.9.2
+ *
+ */
+class Sanitize
{
/**
@@ -62,21 +62,21 @@ function paranoid($string)
* @return string
*/
function sql($string)
- {
+ {
if (!ini_get('magic_quotes_gpc'))
{
$string = addslashes($string);
}
-
+
return $string;
}
-/**
+/**
* Makes the string safe for display as HTML. Renders entities and converts newlines to <br/>.
*
* @param string $string
* @param boolean $remove
- * @return string
+ * @return string
*/
function html($string, $remove = false)
{
@@ -96,10 +96,10 @@ function html($string, $remove = false)
/**
* Recursively sanitizes an array of data for safe input.
- *
+ *
* @param mixed $toClean
- * @return mixed
- */
+ * @return mixed
+ */
function cleanArray(&$toClean)
{
return $this->cleanArrayR($toClean);
@@ -136,12 +136,12 @@ function cleanArrayR(&$toClean)
/**
* Do we really need to sanitize array keys? If so, we can use this code...
- function cleanKey($key)
+ function cleanKey($key)
{
if ($key == "")
- {
+ {
return "";
- }
+ }
//URL decode and convert chars to HTML entities
$key = htmlspecialchars(urldecode($key));
@@ -153,7 +153,7 @@ function cleanKey($key)
$key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
return $key;
- }
+ }
*/
/**
View
72 libs/scaffold.php
@@ -69,7 +69,7 @@ class Scaffold extends Object {
*
* @var unknown_type
*/
- var $model = null;
+ var $modelKey = null;
/**
* Enter description here...
@@ -115,8 +115,8 @@ function __construct($controller_class, $params)
{
die("Scaffold::__construct() : Can't get or parse class name.");
}
- $this->model = strtolower(Inflector::singularize($r[1]));
- $this->scaffoldTitle = $r[1];
+ $this->modelKey = Inflector::underscore(Inflector::singularize($r[1]));
+ $this->scaffoldTitle = Inflector::humanize($this->modelKey);
}
/**
@@ -142,6 +142,7 @@ function constructClasses($params)
*/
function scaffoldIndex($params)
{
+ $this->controllerClass->pageTitle = Inflector::humanize(Inflector::pluralize($this->modelKey));
return $this->scaffoldList($params);
}
@@ -152,7 +153,7 @@ function scaffoldIndex($params)
*/
function scaffoldShow($params)
{
- $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read();
+ $this->controllerClass->params['data'] = $this->controllerClass->models[$this->modelKey]->read();
$this->controllerClass->set('data', $this->controllerClass->params['data'] );
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) );
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml');
@@ -165,9 +166,8 @@ function scaffoldShow($params)
*/
function scaffoldList($params)
{
- $model = $this->model;
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) );
- $this->controllerClass->set('data', $this->controllerClass->models[$model]->findAll());
+ $this->controllerClass->set('data', $this->controllerClass->models[$this->modelKey]->findAll());
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml');
}
@@ -189,7 +189,7 @@ function scaffoldNew($params)
*/
function scaffoldEdit($params)
{
- $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read();
+ $this->controllerClass->params['data'] = $this->controllerClass->models[$this->modelKey]->read();
// generate the field names.
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) );
$this->controllerClass->set('data', $this->controllerClass->params['data']);
@@ -207,14 +207,14 @@ function scaffoldCreate($params)
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
$this->cleanUpFields();
- if ($this->controllerClass->models[$this->model]->save($this->controllerClass->params['data']))
+ if ($this->controllerClass->models[$this->modelKey]->save($this->controllerClass->params['data']))
{
- $this->controllerClass->flash('Your '.$this->model.' has been saved.', '/'.$this->controllerClass->viewPath );
+ $this->controllerClass->flash('Your '.$this->modelKey.' has been saved.', '/'.Inflector::underscore($this->controllerClass->viewPath) );
}
else
{
$this->controllerClass->set('data', $this->controllerClass->params['data']);
- $this->controllerClass->validateErrors($this->controllerClass->models[$this->model]);
+ $this->controllerClass->validateErrors($this->controllerClass->models[$this->modelKey]);
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
}
}
@@ -229,14 +229,14 @@ function scaffoldUpdate($params=array())
// clean up the date fields
$this->cleanUpFields();
- $this->controllerClass->models[$this->model]->set($this->controllerClass->params['data']);
- if ( $this->controllerClass->models[$this->model]->save())
+ $this->controllerClass->models[$this->modelKey]->set($this->controllerClass->params['data']);
+ if ( $this->controllerClass->models[$this->modelKey]->save())
{
- $this->controllerClass->flash('The '.$this->model.' has been updated.','/'.$this->controllerClass->name);
+ $this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' has been updated.','/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
- $this->controllerClass->flash('There was an error updating the '.$this->model,'/'.$this->controllerClass->name);
+ $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'.Inflector::underscore($this->controllerClass->viewPath));
}
}