merging changes from sandboxes

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@856 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-09-17 02:22:07 +00:00
parent 37da997748
commit 1dce095546
35 changed files with 549 additions and 428 deletions

View file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -99,7 +99,7 @@ tableCell = "<td%s>%s</td>"
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 file

@ -1,5 +1,5 @@
<?php
/* SVN FILE: $Id:$ */
/* SVN FILE: $Id$ */
/**
* Short description for file.

View file

@ -444,7 +444,7 @@ class %sTest extends TestCase {
}
/**
* Creates a test for a given model.
* Creates a test for given model.
*
* @param string $name
* @return boolean

View file

@ -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.
*
* @param boolean $var
* @param boolean $show_html
* Only runs if DEBUG level is non-zero.
*
* @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 @@ if (!function_exists('array_combine'))
}
}
?>
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 file

@ -49,113 +49,114 @@ uses('model');
*/
class Cache extends Model {
/**
* Identifier. Either an MD5 string or NULL.
*
* @var unknown_type
*/
var $id = null;
/**
* Identifier. Either an MD5 string or NULL.
*
* @var string
*/
var $id = null;
/**
* Content container for cache data.
*
* @var unknown_type
*/
var $data = null;
/**
* Content container for cache data.
*
* @var unknown_type
*/
var $data = null;
/**
* Content to be cached.
*
* @var unknown_type
*/
var $for_caching = 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';
/**
* 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);
}
/**
* 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);
}
/**
* 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);
}
/**
* 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}')");
}
/**
* 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 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()");
/**
* 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()"));
}
return $this->data['data'];
}
/**
* Appends $string to the for_caching property of the Cache object.
*
* @param string $string
*/
function append($string)
{
$this->for_caching .= $string;
}
/**
* 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()"));
}
/**
* Clears the cache database table.
*
* @return unknown
*/
function clear()
{
return $this->query("DELETE FROM {$this->use_table}");
}
/**
* 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 file

@ -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 @@
{
/**
* 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 @@
}
/**
* 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 @@
}
/**
* 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 @@
}
/**
* 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 file

@ -181,7 +181,7 @@ class Controller extends Object
* Constructor.
*
*/
function __construct ($params=null)
function __construct ()
{
// parent::__construct();
$r = null;
@ -190,7 +190,7 @@ class Controller extends Object
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 @@ class Controller extends Object
$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 @@ class Controller extends Object
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 @@ class Controller extends Object
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 @@ class Controller extends Object
* @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 @@ class Controller extends Object
// 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 @@ class Controller extends Object
$fieldNames[ $tabl['name']]['options'] = array();
$enumValues = split(',', $fieldLength );
$iCount = 1;
foreach ($enumValues as $enum )
{
$enum = trim( $enum, "'" );
@ -704,7 +710,7 @@ class Controller extends Object
// 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 file

@ -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 file

@ -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 file

@ -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 file

@ -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 file

@ -144,8 +144,18 @@ class DBO_MySQL extends DBO
$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 @@ class DBO_MySQL extends DBO
*/
function selectLimit ($limit, $offset=null)
{
return $limit? " LIMIT {$limit}".($offset? "{$offset}": null): null;
return $limit? " LIMIT".($offset? " {$offset},": null)." {$limit}": null;
}
/**

View file

@ -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 @@ class Dispatcher extends Object
parent::__construct();
}
/**
* Dispatches the request (action).
* Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
*
* @param string $url
* @return array
* 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 URL information to work on.
* @return boolean Success
*/
function dispatch($url)
{
$params = $this->parseParams($url);
$result = $this->invoke($url);
return $result === true? $params: array();
}
/**
* Enter description here...
*
* @param string $url
* @return unknown
*/
function invoke($url)
{
global $_POST, $_GET, $_FILES, $_SESSION;
$params = $this->parseParams($url);
$missingController = false;
$missingAction = false;
@ -217,13 +207,11 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
$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)
@ -254,14 +249,23 @@ class Dispatcher extends Object
array_map(array('Dispatcher','stripslashes_deep'), $val) : stripslashes($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 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
}
/**
* 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 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
/**
* 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 @@ class Dispatcher extends Object
}
/**
* 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 file

@ -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 @@ class File
}
/**
* Enter description here...
* Return the contents of this File as a string.
*
* @return unknown
* @return string Contents
*/
function read ()
{
@ -72,10 +70,10 @@ class File
}
/**
* 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 @@ class File
}
/**
* 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 file

@ -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 @@ uses('object');
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 @@ class Flay extends Object
}
/**
* 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 @@ class Flay extends Object
{
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 @@ class Flay extends Object
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 @@ class Flay extends Object
}
/**
* 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 @@ class Flay extends Object
}
/**
* 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 @@ class Flay extends Object
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 @@ class Flay extends Object
$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 @@ class Flay extends Object
$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 file

@ -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 file

@ -116,9 +116,11 @@ class AjaxHelper extends Helper
{
// 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 @@ class AjaxHelper extends Helper
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 file

@ -420,12 +420,13 @@ class HtmlHelper extends Helper
* @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 @@ class HtmlHelper extends Helper
$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 file

@ -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 @@ class JavascriptHelper extends Helper
*/
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 file

@ -780,7 +780,7 @@ class Model extends Object
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 @@ class Model extends Object
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 @@ class Model extends Object
*/
function setId ($id)
{
$this->id[0] = $id;
$this->id = $id;
if(!empty($this->_belongsToOther))
{
@ -1329,7 +1325,7 @@ class Model extends Object
{
for ($i = 0; $i< count($original); $i++)
{
$newValue2[$i] = $original[$i];
$newValue[$i] = $original[$i];
}
}
elseif(!empty($original))

View file

@ -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 @@ class NeatArray
}
/**
* 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 @@ class NeatArray
}
/**
* 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 @@ class NeatArray
}
/**
* Adds elements from the supplied array to itself.
* Adds elements from given array to itself.
*
* @param string $value
* @return bool
@ -169,10 +169,10 @@ class NeatArray
}
/**
* 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 @@ class NeatArray
}
/**
* 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 @@ class NeatArray
}
/**
* 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 @@ class NeatArray
/**
* 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 file

@ -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 @@ class Sanitize
* @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 @@ class Sanitize
/**
* 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 @@ class Sanitize
/**
* 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 @@ class Sanitize
$key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
return $key;
}
}
*/
/**

View file

@ -69,7 +69,7 @@ class Scaffold extends Object {
*
* @var unknown_type
*/
var $model = null;
var $modelKey = null;
/**
* Enter description here...
@ -115,8 +115,8 @@ class Scaffold extends Object {
{
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 @@ class Scaffold extends Object {
*/
function scaffoldIndex($params)
{
$this->controllerClass->pageTitle = Inflector::humanize(Inflector::pluralize($this->modelKey));
return $this->scaffoldList($params);
}
@ -152,7 +153,7 @@ class Scaffold extends Object {
*/
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 @@ class Scaffold extends Object {
*/
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 @@ class Scaffold extends Object {
*/
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 @@ class Scaffold extends Object {
$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 @@ class Scaffold extends Object {
// 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));
}
}
@ -249,15 +249,13 @@ class Scaffold extends Object {
{
$id = $params['pass'][0];
// figure out what model and table we are working with
$controllerName = $this->controllerClass->name;
$table = Inflector::singularize($controllerName);
if ($this->controllerClass->models[$table]->del($id))
if ($this->controllerClass->models[$this->modelKey]->del($id))
{
$this->controllerClass->flash('The '.$table.' with id: '.$id.' has been deleted.', '/'.$controllerName);
$this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' with id: '.$id.' has been deleted.', '/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
$this->controllerClass->flash('There was an error deleting the '.$table.' with the id '.$id, '/'.$controllerName);
$this->controllerClass->flash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.$id, '/'.Inflector::underscore($this->controllerClass->viewPath));
}
}
/**
@ -268,46 +266,46 @@ class Scaffold extends Object {
function cleanUpFields()
{
// clean up the date fields
$objModel = $this->controllerClass->models[$this->model];
$objModel = $this->controllerClass->models[$this->modelKey];
foreach( $objModel->_table_info as $table )
{
foreach ($table as $field)
{
if( 'date' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) )
if( 'date' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ) )
{
$newDate = mktime( 0,0,0,
$this->controllerClass->params['data'][$this->model][$field['name'].'_month'],
$this->controllerClass->params['data'][$this->model][$field['name'].'_day'],
$this->controllerClass->params['data'][$this->model][$field['name'].'_year'] );
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'],
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'],
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] );
$newDate = date( 'Y-m-d', $newDate );
$this->controllerClass->params['data'][$this->model][$field['name']] = $newDate;
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
}
else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) )
else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ) )
{
$hour = $this->controllerClass->params['data'][$this->model][$field['name'].'_hour'];
if( $hour != 12 && 'pm' == $this->controllerClass->params['data'][$this->model][$field['name'].'_meridian'] )
$hour = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_hour'];
if( $hour != 12 && 'pm' == $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_meridian'] )
{
$hour = $hour + 12;
}
$newDate = mktime( $hour,
$this->controllerClass->params['data'][$this->model][$field['name'].'_min'],
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'],
0,
$this->controllerClass->params['data'][$this->model][$field['name'].'_month'],
$this->controllerClass->params['data'][$this->model][$field['name'].'_day'],
$this->controllerClass->params['data'][$this->model][$field['name'].'_year'] );
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'],
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'],
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] );
$newDate = date( 'Y-m-d', $newDate );
$this->controllerClass->params['data'][$this->model][$field['name']] = $newDate;
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
}
else if( 'tinyint(1)' == $field['type'] )
{
if( isset( $this->controllerClass->params['data'][$this->model][$field['name']]) &&
"on" == $this->controllerClass->params['data'][$this->model][$field['name']] )
if( isset( $this->controllerClass->params['data'][$this->modelKey][$field['name']]) &&
"on" == $this->controllerClass->params['data'][$this->modelKey][$field['name']] )
{
$this->controllerClass->params['data'][$this->model][$field['name']] = true;
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = true;
}
else
{
$this->controllerClass->params['data'][$this->model][$field['name']] = false;
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = false;
}
}
}

View file

@ -2,9 +2,8 @@
/* SVN FILE: $Id$ */
/**
* Short description for file.
* Methods for displaying presentation data
*
* Long description for file
*
* PHP versions 4 and 5
*
@ -63,7 +62,7 @@ class View extends Object
var $here = null;
/**
* Enter description here...
* Not used. 2005-09
*
* @var unknown_type
* @access public

BIN
public/img/bg_fade.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/img/bg_header.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

BIN
public/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
public/img/red_box.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 B

View file

@ -99,4 +99,4 @@ if (class_exists('DATABASE_CONFIG'))
//CLEANUP
if (DEBUG) echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
?>
?>

View file

@ -29,7 +29,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once LIBS.'inflectornew.php';
/**
* Short description for class.
*
@ -39,6 +39,7 @@
*/
class InflectorTest extends UnitTestCase
{
}
?>

View file

@ -30,7 +30,15 @@
* @subpackage UnitTester
*/
class SimpleTestCase {
/**
* @var string Name of the test.
* @access private
*/
var $_label = false;
/**
* @var SimpleRunner Test runner.
* @access private
*/
var $_runner = false;
/**
@ -536,6 +544,8 @@
* Sets the name of the test suite and error message.
* @param string $label Name sent at the start and end
* of the test.
* @param string $error
*
* @access public
*/
function BadGroupTest($label, $error) {