Revision: [1638]
removing php short tags

Revision: [1637]
Remove renderElememnts loading of helpers also, forgot it in the last commit

Revision: [1636]
Refactoring after profiling code.
Session was creating a new instance of Dispatcher removed the need for it.
Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time.

Changed View class so it would not load helpers when rending a layout, no need for that.
A great performance boost after the change.

Change the loadModels method call in app/webroot/index.php.
Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory.
Removed all unnecessary calls to basics uses(). Again another big performance increase.
Added fix to the Html::guiListTree() after discussing the output that is expected.
A ticket was closed on this already.

Revision: [1635]
Removing calls to basic uses()

Revision: [1634]
Removing calls to basics uses() that are not needed.

Revision: [1633]
Removing calls to basics uses() that are not needed.
Moved Object class further up in the loading order

Revision: [1632]
adding fix for Ticket #132

Revision: [1631]
Added fix from Ticket #122

Revision: [1630]
Scaffold views can now be placed in a view directory.
These will override the core.
Example (Must have the scaffold dot name):
app/views/posts/scaffold.list.thtml
app/views/posts/scaffold.new.thtml
app/views/posts/scaffold.edit.thtml
app/views/posts/scaffold.show.thtml

Revision: [1629]
Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00.

Revision: [1628]
Added a few more change to allow saving dates prior to January 1 1970 00:00:00.
Still a few issues with this, but will get them figured out soon.
Changed scaffold to use only one form view.

Revision: [1627]
Added fix for Ticket #189

Revision: [1626]
Added fix for Ticket #120.

Revision: [1625]
left justified doc blocks

Revision: [1624]
remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes

Revision: [1623]
adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory

Revision: [1622]
Adding fix to time helper that was lost in a previous merge
Removing all tabs from code

Revision: [1621]
Addtional model validation fixes

Revision: [1620]
fixed parse error

Revision: [1619]
Fixing ticket #102

Revision: [1618]
correcting mime types and keywords

Revision: [1617]
correcting mime types and keywords

Revision: [1616]
fixed link in footer

Revision: [1615]
Fixing ticket #207

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-12-27 03:33:44 +00:00
parent 134744b5d6
commit 9560f78884
54 changed files with 4331 additions and 4176 deletions

View file

@ -66,8 +66,8 @@ if (!defined('WEBROOT_DIR'))
require_once ROOT.'cake'.DS.'basics.php';
require_once ROOT.APP_DIR.DS.'config'.DS.'core.php';
require_once ROOT.'cake'.DS.'config'.DS.'paths.php';
require_once LIBS.'log.php';
require_once LIBS.'object.php';
require_once LIBS.'log.php';
require_once LIBS.'session.php';
require_once LIBS.'security.php';
require_once LIBS.'neat_array.php';
@ -127,13 +127,12 @@ require_once LIBS.'model'.DS.'dbo'.DS.'dbo_factory.php';
config('database');
if (class_exists('DATABASE_CONFIG'))
if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel'))
{
require_once LIBS.'model'.DS.'model.php';
loadModels();
}
//RUN THE SCRIPT
if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico')
{

View file

@ -60,6 +60,8 @@ define('YEAR', 365 * DAY);
* @uses MODELS
*/
function loadModels ()
{
if(!class_exists('AppModel', FALSE))
{
if(file_exists(APP.'app_model.php'))
{
@ -74,6 +76,7 @@ function loadModels ()
require_once (MODELS.$model_fn);
}
}
}
/**
* Loads all controllers.
@ -84,6 +87,8 @@ function loadModels ()
* @uses CONTROLLERS
*/
function loadControllers ()
{
if(!class_exists('AppController', FALSE))
{
if(file_exists(APP.'app_controller.php'))
{
@ -93,12 +98,15 @@ function loadControllers ()
{
require_once(CAKE.'app_controller.php');
}
}
foreach (listClasses(CONTROLLERS) as $controller)
{
if(!class_exists($controller, FALSE))
{
require_once (CONTROLLERS.$controller.'.php');
}
}
}
/**
* Loads a controller and its helper libraries.
@ -107,6 +115,19 @@ function loadControllers ()
* @return boolean Success
*/
function loadController ($name)
{
if(!class_exists('AppController', FALSE))
{
if(file_exists(APP.'app_controller.php'))
{
require_once(APP.'app_controller.php');
}
else
{
require_once(CAKE.'app_controller.php');
}
}
if(!class_exists($name, FALSE))
{
$name = Inflector::underscore($name);
if(file_exists(CONTROLLERS.$name.'_controller.php'))
@ -121,18 +142,9 @@ function loadController ($name)
{
$controller_fn = false;
}
if(file_exists(APP.'app_controller.php'))
{
require_once(APP.'app_controller.php');
}
else
{
require_once(CAKE.'app_controller.php');
}
return file_exists($controller_fn)? require_once($controller_fn): false;
}
}
/**
* Lists PHP files in given directory.
@ -154,6 +166,7 @@ function listClasses($path)
function config ()
{
$args = func_get_args();
$count = count($args);
foreach ($args as $arg)
{
if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
@ -163,11 +176,11 @@ function config ()
elseif (file_exists(CONFIGS.$arg.'.php'))
{
include_once (CONFIGS.$arg.'.php');
if (count($args) == 1) return true;
if ($count == 1) return true;
}
else
{
if (count($args) == 1) return false;
if ($count == 1) return false;
}
}
@ -256,22 +269,25 @@ if (!function_exists('sortByKey'))
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
{
if (!is_array($array))
{
return null;
}
foreach ($array as $key => $val)
{
$sa[$key] = $val[$sortby];
}
$order == 'asc'
? asort($sa, $type)
: arsort($sa, $type);
if($order == 'asc')
{
asort($sa, $type);
}
else
{
arsort($sa, $type);
}
foreach ($sa as $key=>$val)
{
$out[] = $array[$key];
}
return $out;
}
}
@ -293,16 +309,20 @@ if (!function_exists('array_combine'))
$c1 = count($a1);
$c2 = count($a2);
if ($c1 != $c2) return false; // different lenghts
if ($c1 <= 0) return false; // arrays are the same and both are empty
if ($c1 != $c2)
{
return false; // different lenghts
}
if ($c1 <= 0)
{
return false; // arrays are the same and both are empty
}
$output = array();
for ($i = 0; $i < $c1; $i++)
{
$output[$a1[$i]] = $a2[$i];
}
return $output;
}
}
@ -318,7 +338,6 @@ function h($text)
return htmlspecialchars($text);
}
/**
* Returns an array of all the given parameters, making parameter lists shorter to write.
*
@ -330,7 +349,6 @@ function a()
return $args;
}
/**
* Hierarchical arrays.
*
@ -340,16 +358,22 @@ function a()
function ha()
{
$args = func_get_args();
$count = count($args);
for($l=0 ; $l<count($args) ; $l++)
for($i=0 ; $i < $count ; $i++)
{
$a[$args[$l]] = $l+1<count($args) ? $args[$l+1] : null;
$l++;
if($i+1 < $count)
{
$a[$args[$i]] = $args[$i+1];
}
else
{
$a[$args[$i]] = null;
}
}
return $a;
}
/**
* Convenience method for echo().
*

View file

@ -32,7 +32,7 @@
/**
* List of helpers to include
*/
uses('error_messages', 'object', 'router', DS.'controller'.DS.'controller', DS.'controller'.DS.'scaffold');
uses('error_messages', 'router', DS.'controller'.DS.'controller');
/**
* Dispatcher translates URLs to controller-action-paramter triads.
@ -122,7 +122,7 @@ class Dispatcher extends Object
$ctrlName = Inflector::camelize($params['controller']);
$ctrlClass = $ctrlName.'Controller';
if (!loadController($params['controller']) || !class_exists($ctrlClass))
if (!loadController($params['controller']) || !class_exists($ctrlClass, FALSE))
{
if(preg_match('/([\\.]+)/',$ctrlName))
{
@ -192,6 +192,7 @@ class Dispatcher extends Object
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true))
{
uses(DS.'controller'.DS.'scaffold');
$scaffolding = new Scaffold($controller, $params);
exit;
}

View file

@ -33,8 +33,10 @@
* Included libraries.
*
*/
if(!class_exists('Model', FALSE))
{
uses(DS.'model'.DS.'model');
}
/**
* Caching for Cake.
*

View file

@ -26,11 +26,6 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*/
uses('object');
/**
*
*
@ -111,9 +106,17 @@ class Component extends Object
{
require_once $componentFn;
if(class_exists($componentCn)===true)
if(class_exists($componentCn, FALSE)===true)
{
$this->controller->{$component} =& new $componentCn;
if($componentCn == 'SessionComponent')
{
$param = $this->controller->base.'/';
}
else
{
$param = null;
}
$this->controller->{$component} =& new $componentCn($param);
$loaded[$component] =& $this->controller->{$component};
if (isset($this->controller->{$component}->components) && is_array($this->controller->{$component}->components))
{

View file

@ -45,9 +45,9 @@ class SessionComponent extends Object
* Enter description here...
*
*/
function __construct ()
function __construct ($base = null)
{
$this->CakeSession = New CakeSession();
$this->CakeSession = New CakeSession($base);
parent::__construct();
}

View file

@ -29,7 +29,7 @@
/**
* Include files
*/
uses(DS.'controller'.DS.'component',DS.'model'.DS.'model', 'inflector', 'folder', DS.'view'.DS.'view');
uses(DS.'controller'.DS.'component', DS.'view'.DS.'view');
/**
* Controller
@ -672,6 +672,14 @@ class Controller extends Object
{
if( 0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8) )
$fieldNames[ $tabl['name']]['type'] = $type;
if(isset($data[$model][$tabl['name']]))
{
$fieldNames[ $tabl['name']]['selected'] = $data[$model][$tabl['name']];
}
else
{
$fieldNames[ $tabl['name']]['selected'] = null;
}
}
break;
default:

View file

@ -49,7 +49,7 @@ class PagesController extends AppController{
*
* @var unknown_type
*/
var $helpers = array('html', 'ajax');
var $helpers = array('Html');
/**

View file

@ -28,11 +28,6 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Included libs.
*/
uses(DS.'model'.DS.'model', 'inflector', 'object');
/**
* Scaffolding is a set of automatic views, forms and controllers for starting web development work faster.
*
@ -101,6 +96,7 @@ class Scaffold extends Object {
$this->actionView = $controller->action;
$this->modelKey = Inflector::singularize($controller->name);
$this->scaffoldTitle = Inflector::humanize($this->modelKey);
$this->viewPath = Inflector::underscore($controller->name);
$this->controllerClass->pageTitle = $this->scaffoldTitle;
$this->_renderScaffold($params);
}
@ -142,6 +138,10 @@ class Scaffold extends Object {
$this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read();
$this->controllerClass->set('data', $this->controllerClass->params['data'] );
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) );
if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.show.thtml'))
{
return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.show.thtml');
}
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml');
}
@ -156,6 +156,10 @@ class Scaffold extends Object {
{
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) );
$this->controllerClass->set('data', $this->controllerClass->{$this->modelKey}->findAll());
if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.list.thtml'))
{
return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.list.thtml');
}
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml');
}
@ -169,7 +173,12 @@ class Scaffold extends Object {
function _scaffoldNew($params)
{
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
$this->controllerClass->set('type', 'New');
if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.new.thtml'))
{
return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.new.thtml');
}
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
}
/**
@ -179,11 +188,16 @@ class Scaffold extends Object {
* @return A rendered view with a form to edit a record in the Models database table
* @access private
*/
function _scaffoldEdit($params)
function _scaffoldEdit($params=array())
{
$this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read();
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) );
$this->controllerClass->set('type', 'Edit');
$this->controllerClass->set('data', $this->controllerClass->params['data']);
if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.edit.thtml'))
{
return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.edit.thtml');
}
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
}
@ -227,7 +241,12 @@ class Scaffold extends Object {
}
$this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
$this->controllerClass->set('type', 'New');
if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffolds'.DS.'new.thtml'))
{
return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffolds'.DS.'new.thtml');
}
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
}
}
@ -244,8 +263,9 @@ class Scaffold extends Object {
{
return $this->_scaffoldNew($params);
}
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
$this->_cleanUpFields();
$this->controllerClass->{$this->modelKey}->set($this->controllerClass->params['data']);
if ( $this->controllerClass->{$this->modelKey}->save())
@ -266,15 +286,12 @@ class Scaffold extends Object {
{
if(is_object($this->controllerClass->Session))
{
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'.
Inflector::underscore($this->controllerClass->viewPath));
$this->controllerClass->Session->setFlash('Please correct errors below');
}
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
$this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->set('type', 'Edit');
return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
}
}
@ -415,11 +432,9 @@ class Scaffold extends Object {
{
if('date' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year']))
{
$newDate = mktime( 0,0,0,
$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 );
$newDate = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'].'-';
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-';
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' ';
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
}
else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ) )
@ -429,12 +444,10 @@ class Scaffold extends Object {
{
$hour = $hour + 12;
}
$newDate = mktime( $hour,
$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'],0,
$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 H:i:s', $newDate );
$newDate = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'].'-';
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-';
$newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' ';
$newDate .= $hour.':'.$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'].':00';
$this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate;
}
else if( 'tinyint(1)' == $field['type'] )

View file

@ -31,7 +31,10 @@
* Included libraries.
*
*/
if(!class_exists('Object', FALSE))
{
uses('object');
}
/**
* Convenience class for reading, writing and appending to files.

View file

@ -30,9 +30,12 @@
/**
* Included libraries.
*
*/
if(!class_exists('Object', FALSE))
{
uses('object');
}
/**
* Text-to-HTML parser.
*

View file

@ -31,8 +31,10 @@
* Included libraries.
*
*/
if(!class_exists('Object', FALSE))
{
uses('object');
}
/**
* Folder structure browser, lists folders and files.
*

View file

@ -28,6 +28,14 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Included libraries.
*
*/
if(!class_exists('Object', FALSE))
{
uses('object');
}
/**
* Pluralize and singularize English words.
*

View file

@ -30,8 +30,12 @@
/**
* Included libraries.
*
*/
if(!class_exists('File', FALSE))
{
uses('file');
}
/**
* Logs messages to text files

View file

@ -31,7 +31,7 @@
/**
* Enter description here...
*/
uses('object', 'class_registry', 'validators', 'inflector');
uses('class_registry', 'validators');
/**
@ -1355,15 +1355,16 @@ class Model extends Object
}
/**
* Enter description here...
* Finds all children of $parent_id using 'parent_id' field.
*
* @param int $parent_id
* @param string $conditions SQL conditions (WHERE clause conditions)
* @param unknown_type $fields
* @return unknown
* @return unknown type
*/
function findAllThreaded ($conditions=null, $fields=null, $sort=null)
function findAllThreaded ($conditions=null, $fields=null, $sort=null, $parent_id='0')
{
return $this->_doThread(Model::findAll($conditions, $fields, $sort), null);
return $this->_doThread(Model::findAll($conditions, $fields, $sort), $parent_id);
}
/**
@ -1377,17 +1378,15 @@ class Model extends Object
function _doThread ($data, $root)
{
$out = array();
for ($ii=0; $ii<sizeof($data); $ii++)
{
if ($data[$ii]['parent_id'] == $root)
if ($data[$ii][$this->name]['parent_id'] == $root)
{
$tmp = $data[$ii];
$tmp['children'] = isset($data[$ii]['id'])? $this->_doThread($data, $data[$ii]['id']): null;
$tmp['children'] = isset($data[$ii][$this->name][$this->primaryKey])? $this->_doThread($data, $data[$ii][$this->name][$this->primaryKey]): null;
$out[] = $tmp;
}
}
return $out;
}
@ -1429,20 +1428,12 @@ class Model extends Object
*/
function validates ($data = null)
{
$errors = count($this->invalidFields($data? $data: $this->data));
return $errors == 0;
}
/**
* Returns an array of invalid fields.
*
* @param array $data Posted data
* @return array Array of invalid fields
*/
function invalidFields ($data=null)
if (!$data)
{
return $this->_invalidFields($data);
$data = $this->data;
}
$errors = count($this->invalidFields($data));
return $errors == 0;
}
/**
@ -1450,9 +1441,8 @@ class Model extends Object
*
* @param array $data
* @return array Array of invalid fields
* @access private
*/
function _invalidFields ($data=null)
function invalidFields ($data = null)
{
if (!isset($this->validate))
{
@ -1464,8 +1454,19 @@ class Model extends Object
return $this->validationErrors;
}
$data = ($data? $data: (isset($this->data)? $this->data: array()));
if (!$data)
{
if (isset($this->data))
{
$data = $this->data;
}
else
{
$data = array();
}
}
$errors = array();
foreach ($data as $table => $field)
{
foreach ($this->validate as $field_name=>$validator)

View file

@ -316,8 +316,8 @@ class NeatArray
function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children')
{
$out = array();
for ($ii=0; $ii<sizeof($this->value); $ii++)
$sizeof = sizeof($this->value);
for ($ii=0; $ii < $sizeof; $ii++)
{
if ($this->value[$ii][$parentIdKey] == $root)
{

View file

@ -29,11 +29,6 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Included libraries.
*/
uses('log');
/**
* Object class, allowing __construct and __destruct in PHP4.
*
@ -121,6 +116,10 @@ class Object
*/
function log ($msg, $type=LOG_ERROR)
{
if(!class_exists('Log', FALSE))
{
uses('log');
}
if (is_null($this->_log))
{
$this->_log = new Log ();
@ -182,6 +181,7 @@ class Object
$this->missingView = $this->name;
$this->pageTitle = 'Missing View';
$this->render('../errors/missingView');
exit();
}
/**

View file

@ -27,12 +27,14 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Included libraries.
*
*/
uses('object', 'neat_array');
if(!class_exists('Object', FALSE))
{
uses('object');
}
/**
* Parses the request URL into controller, action, and parameters.
*

View file

@ -91,23 +91,19 @@ class CakeSession extends Object
function __construct($base = null)
{
$this->host = $_SERVER['HTTP_HOST'];
if (strpos($this->host, ':') !== false)
{
$this->host = substr($this->host,0, strpos($this->host, ':'));
}
if (empty($this->path))
if (empty($base))
{
$dispatcher =& new Dispatcher();
$this->path = $dispatcher->baseUrl();
$this->path = '/';
}
else
{
$this->path = $base;
}
if (empty($this->path))
if (strpos($this->host, ':') !== false)
{
$this->path = '/';
$this->host = substr($this->host,0, strpos($this->host, ':'));
}
$this->ip = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

View file

@ -212,10 +212,10 @@ class FormHelper extends Helper
* @param array $htmlOptions
* @return string The formatted INPUT element
*/
function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null )
function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE', '', $htmlOptions);
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE', '', $selected, $htmlOptions);
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
@ -249,10 +249,10 @@ class FormHelper extends Helper
* @param array $htmlOptions
* @return string The formatted datetime option element
*/
function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null )
function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null )
{
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));;
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12', '', $htmlOptions);
$str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12', $selected, $htmlOptions);
$strLabel = $this->labelTag( $tagName, $prompt );
$divClass = "optional";
@ -452,10 +452,10 @@ class FormHelper extends Helper
$strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']);
break;
case "date":
$strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'] );
$strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'], null, null, null, null, $field['selected']);
break;
case "datetime":
$strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'] );
$strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'], '','','', '', $field['selected']);
break;
default:
//bugbug: i don't know how to put out a notice that an unknown type was entered.

View file

@ -933,9 +933,18 @@ class HtmlHelper extends Helper
foreach ($options as $k=>$v)
{
if (!in_array($k, $exclude))
{
$pos = strpos($v, '"');
if($pos === false)
{
$out[] = "{$k}=\"{$v}\"";
}
else
{
$out[] = "{$k}='{$v}'";
}
}
}
$out = join(' ', $out);
return $out? $insert_before.$out.$insert_after: null;
@ -1128,11 +1137,12 @@ class HtmlHelper extends Helper
foreach ($data as $item)
{
$out .= "<li>{$item[$bodyKey]}</li>\n";
$out .= "<li>{$item[$bodyKey]}\n";
if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey]))
{
$out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey);
}
$out .= "</li>\n";
}
$out .= "</ul>\n";
@ -1244,9 +1254,9 @@ class HtmlHelper extends Helper
function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{
$value = isset($value)? $value : $this->tagValue($tagName."_day");
$dayValue = empty($value) ? date('d') : $value;
$days=array('1'=>'1','2'=>'2','3'=>'3','4'=>'4',
'5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9',
$dayValue = empty($selected) ? date('d') : $selected;
$days=array('01'=>'1','02'=>'2','03'=>'3','04'=>'4',
'05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9',
'10'=>'10','11'=>'11','12'=>'12',
'13'=>'13','14'=>'14','15'=>'15',
'16'=>'16','17'=>'17','18'=>'18',
@ -1274,20 +1284,21 @@ class HtmlHelper extends Helper
{
$value = isset($value)? $value : $this->tagValue($tagName."_year");
$yearValue = empty($value) ? date('Y') : $value;
$yearValue = empty($selected) ? date('Y') : $selected;
$currentYear = date('Y');
$maxYear = is_null($maxYear) ? $yearValue + 10 : $maxYear;
$maxYear = is_null($maxYear) ? $currentYear + 11 : $maxYear + 1;
$minYear = is_null($minYear) ? $yearValue - 10 : $minYear;
$minYear = is_null($minYear) ? $currentYear - 60 : $minYear;
if ( $minYear>$minYear)
if ( $minYear > $maxYear)
{
$tmpYear = $minYear;
$minYear = $maxYear;
$maxYear = $tmpYear;
};
$minYear = $yearValue < $minYear ? $yearValue : $minYear;
$maxYear = $yearValue > $maxYear ? $yearValue : $maxYear;
$minYear = $currentYear < $minYear ? $currentYear : $minYear;
$maxYear = $currentYear > $maxYear ? $currentYear : $maxYear;
for ( $yearCounter = $minYear; $yearCounter < $maxYear; $yearCounter++)
{
@ -1311,10 +1322,10 @@ class HtmlHelper extends Helper
function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{
$value = isset($value)? $value : $this->tagValue($tagName."_month");
$monthValue = empty($value) ? date('m') : $value ;
$months=array('1'=>'January','2'=>'February','3'=>'March',
'4'=>'April','5'=>'May','6'=>'June','7'=>'July','8'=>'August',
'9'=>'September','10'=>'October','11'=>'November','12'=>'December');
$monthValue = empty($selected) ? date('m') : $selected ;
$months=array('01'=>'January','02'=>'February','03'=>'March',
'04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August',
'09'=>'September','10'=>'October','11'=>'November','12'=>'December');
$option = $this->selectTag($tagName.'_month', $months, $monthValue,
$optionAttr);
return $option;
@ -1330,23 +1341,20 @@ class HtmlHelper extends Helper
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function hourOptionTag( $tagName,$value=null,
$format24Hours = false,
$selected=null,
$optionAttr=null )
function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $optionAttr=null )
{
$value = isset($value)? $value : $this->tagValue($tagName."_hour");
if ( $format24Hours )
{
$hourValue = empty($value) ? date('H') : $value;
$hourValue = empty($selected) ? date('H') : $selected;
}
else
{
$hourValue = empty($value) ? date('g') : $value;
$hourValue = empty($selected) ? date('g') : $selected;
}
if ( $format24Hours )
{ $hours = array('0'=>'00','1'=>'01','2'=>'02','3'=>'03','4'=>'04',
'5'=>'05','6'=>'06','7'=>'07','8'=>'08','9'=>'09',
{ $hours = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04',
'05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'09',
'10'=>'10','11'=>'11','12'=>'12',
'13'=>'13','14'=>'14','15'=>'15',
'16'=>'16','17'=>'17','18'=>'18',
@ -1355,8 +1363,8 @@ class HtmlHelper extends Helper
}
else
{
$hours = array('1'=>'1','2'=>'2','3'=>'3','4'=>'4',
'5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9',
$hours = array('01'=>'1','02'=>'2','03'=>'3','04'=>'4',
'05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9',
'10'=>'10','11'=>'11','12'=>'12');
}
@ -1377,7 +1385,7 @@ class HtmlHelper extends Helper
function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{
$value = isset($value)? $value : $this->tagValue($tagName."_min");
$minValue = empty($value) ? date('i') : $value ;
$minValue = empty($selected) ? date('i') : $selected ;
for( $minCount=0; $minCount<61; $minCount++)
{
$mins[$minCount] = sprintf('%02d', $minCount);
@ -1400,7 +1408,7 @@ class HtmlHelper extends Helper
function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null)
{
$value = isset($value)? $value : $this->tagValue($tagName."_meridian");
$merValue = empty($value) ? date('a') : $value ;
$merValue = empty($selected) ? date('a') : $selected ;
$meridians = array('am'=>'am','pm'=>'pm');
$option = $this->selectTag($tagName.'_meridian', $meridians, $merValue,
@ -1420,16 +1428,51 @@ class HtmlHelper extends Helper
*/
function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $optionAttr=null)
{
$day = null;
$month = null;
$year = null;
$hour = null;
$min = null;
$meridian = null;
if(!empty($selected))
{
if(is_int($selected))
{
$selected = strftime('%G-%m-%d %T',$selected);
}
$meridian = 'am';
$date = explode('-',$selected);
$day = explode(' ',$date[2]);
$time = explode(':',$day[1]);
if(($time[0] > 12) && $timeFormat == '12')
{
$time[0] = $time[0] - 12;
$meridian = 'pm';
}
elseif($time[0] > 12)
{
$meridian = 'pm';
}
$day = $day[0];
$month = $date[1];
$year = $date[0];
$hour = $time[0];
$min = $time[1];
}
switch ( $dateFormat )
{
case 'DMY' :
$opt = $this->dayOptionTag( $tagName ) . '-' . $this->monthOptionTag( $tagName ) . '-' . $this->yearOptionTag( $tagName );
$opt = $this->dayOptionTag( $tagName ,null ,$day) . '-' . $this->monthOptionTag( $tagName, null, $month ) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year );
break;
case 'MDY' :
$opt = $this->monthOptionTag( $tagName ) .'-'.$this->dayOptionTag( $tagName ) . '-' . $this->yearOptionTag($tagName);
$opt = $this->monthOptionTag($tagName, null, $month) .'-'.$this->dayOptionTag( $tagName, null, $day ) . '-' . $this->yearOptionTag($tagName, null, null, null, $year);
break;
case 'YMD' :
$opt = $this->yearOptionTag($tagName) . '-' . $this->monthOptionTag( $tagName ) . '-' . $this->dayOptionTag( $tagName );
$opt = $this->yearOptionTag($tagName, null, null, null, $year) . '-' . $this->monthOptionTag( $tagName, null, $month ) . '-' . $this->dayOptionTag( $tagName, null, $day );
break;
case 'NONE':
$opt ='';
@ -1441,10 +1484,10 @@ class HtmlHelper extends Helper
switch ($timeFormat)
{
case '24':
$opt .= $this->hourOptionTag( $tagName, null , true ) . ':' . $this->minuteOptionTag( $tagName );
$opt .= $this->hourOptionTag( $tagName, null , true, $hour) . ':' . $this->minuteOptionTag( $tagName, null, $min );
break;
case '12':
$opt .= $this->hourOptionTag( $tagName ) . ':' . $this->minuteOptionTag( $tagName ) . ' ' . $this->meridianOptionTag($tagName);
$opt .= $this->hourOptionTag( $tagName, null, false, $hour) . ':' . $this->minuteOptionTag( $tagName, null, $min) . ' ' . $this->meridianOptionTag($tagName, null, $meridian);
break;
case 'NONE':
$opt .='';

View file

@ -30,8 +30,13 @@
/**
* Included libraries.
*
*/
if(!class_exists('Flay') || !class_exists('Html'))
{
uses('flay', DS.'view'.DS.'helpers'.DS.'html');
}
/**
* Text helper library.

View file

@ -1,5 +1,5 @@
<?php
/* SVN FILE: $Id: html.php 578 2005-08-12 04:09:07Z phpnut $ */
/* SVN FILE: $Id$ */
/**
* Time Helper class file.
@ -20,9 +20,9 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
* @since CakePHP v 0.10.0.1076
* @version $Revision: 578 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2005-08-11 22:09:07 -0600 (Thu, 11 Aug 2005) $
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
@ -50,7 +50,6 @@ class TimeHelper extends Helper
return substr($string, 0, $length).(strlen($string)>$length? $ending: null);
}
/**
* Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string.
*
@ -59,11 +58,15 @@ class TimeHelper extends Helper
*/
function fromString ($date_string)
{
return is_integer($date_string)
? $date_string
: strtotime($date_string);
if (is_integer($date_string))
{
return $date_string;
}
else
{
return strtotime($date_string);
}
}
/**
* Returns a nicely formatted date string for given Datetime string.
@ -75,14 +78,18 @@ class TimeHelper extends Helper
*/
function nice ($date_string=null, $return = false)
{
$date = $date_string? strtotime($date_string): time();
$date = $date_string? $this->fromString($date_string): time();
if($date_string != null)
{
$date = $this->fromString($date_string);
}
else
{
$date = time();
}
$ret = date("D, M jS Y, H:i", $date);
return $this->output($ret, $return);
}
/**
* Returns a formatted descriptive date string for given datetime string.
*
@ -118,11 +125,11 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns true if given datetime string is today.
*
* @param string $date_string Datetime string or Unix timestamp
* @param boolean $return Whether this method should return a value
* or output it. This overrides AUTO_OUTPUT.
* @return boolean True if datetime string is today
@ -135,7 +142,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns a partial SQL string to search for all records between two dates.
*
@ -158,7 +164,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns a partial SQL string to search for all records between two times
* occurring on the same day.
@ -177,7 +182,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns true if given datetime string is within current year.
*
@ -193,7 +197,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns true if given datetime string was yesterday.
*
@ -209,7 +212,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns true if given datetime string is tomorrow.
*
@ -225,7 +227,6 @@ class TimeHelper extends Helper
return $this->output($ret, $return);
}
/**
* Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime().
*
@ -263,14 +264,14 @@ class TimeHelper extends Helper
* or output it. This overrides AUTO_OUTPUT.
* @return string Formatted date string
*/
function toRSS ($date_string, $return = false) {
function toRSS ($date_string, $return = false)
{
$date = TimeHelper::fromString($date_string);
$ret = date("r", $date);
return $this->output($ret, $return);
}
/**
* Returns either a relative date or a formatted date depending
* on the difference between the current time and given datetime.
@ -290,12 +291,19 @@ class TimeHelper extends Helper
* or output it. This overrides AUTO_OUTPUT.
* @return string Relative time string.
*/
function timeAgoInWords ($datetime_string, $return = false)
function timeAgoInWords ($datetime_string, $return = false, $backwards = false)
{
$datetime = $this->fromString($datetime_string);
$in_seconds = $datetime;
if($backwards)
{
$diff = $in_seconds-time();
}
else
{
$diff = time()-$in_seconds;
}
$months = floor($diff/2419200);
$diff -= $months*2419200;
$weeks = floor($diff/604800);
@ -311,11 +319,13 @@ class TimeHelper extends Helper
if ($months>0)
{
// over a month old, just show date (mm/dd/yyyy format)
$ret = 'on '.date("j/n/Y", $in_seconds);
$relative_date = 'on '.date("j/n/Y", $in_seconds);
$old = true;
}
else
{
$relative_date='';
$old = false;
if ($weeks>0)
{
// weeks and days
@ -345,13 +355,17 @@ class TimeHelper extends Helper
$relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':'');
}
}
$ret = $relative_date;
// show relative date and add proper verbiage
$ret = $relative_date.' ago';
if(!$backwards && !$old)
{
$ret .= ' ago';
}
return $this->output($ret, $return);
}
/**
* Alias for timeAgoInWords
* @param string $date_string Datetime string or Unix timestamp
@ -360,8 +374,17 @@ class TimeHelper extends Helper
* @return string Relative time string.
*/
function relativeTime ($datetime_string, $return = false)
{
$date = strtotime($datetime_string);
if(strtotime("now") > $date)
{
$ret = $this->timeAgoInWords($datetime_string);
}
else
{
$ret = $this->timeAgoInWords($datetime_string, $return, true);
}
return $this->output($ret, $return);
}

View file

@ -67,4 +67,4 @@ unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -57,4 +57,4 @@ unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -38,12 +38,10 @@
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?if (DEBUG>1):?>
<?php if (DEBUG > 1) { ?>
<h2>Controller dump:</h2>
<pre>
<?
<?php
unset($this->db);
print_r($this);
pr($this);
?>
</pre>
<?endif?>
<?php } ?>

View file

@ -1,5 +1,5 @@
<?php
/* SVN FILE: $Id:$ */
/* SVN FILE: $Id$ */
/**
*
@ -22,9 +22,9 @@
* @package cake
* @subpackage cake.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision:$
* @modifiedby $LastChangedBy:$
* @lastmodified $Date:$
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
@ -72,4 +72,4 @@ unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -1,5 +1,5 @@
<?php
/* SVN FILE: $Id:$ */
/* SVN FILE: $Id$ */
/**
*
@ -22,9 +22,9 @@
* @package cake
* @subpackage cake.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision:$
* @modifiedby $LastChangedBy:$
* @lastmodified $Date:$
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
@ -72,4 +72,4 @@ unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -38,12 +38,12 @@
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?if (DEBUG>1):?>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?endif?>
<?php endif;?>

View file

@ -30,7 +30,7 @@
?>
<?php $missing = $this->controller->missingTable;?>
<h1>Missing Database Table</h1>
<p class="error">No Database table for model <?php echo $missing;?> (expected "<? echo $this->controller->missingTableName;?>"), create it first.
<p class="error">No Database table for model <?php echo $missing;?> (expected "<?php echo $this->controller->missingTableName;?>"), create it first.
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_table.thtml</code>

View file

@ -53,4 +53,4 @@ unset($this->db);
print_r($this);
?>
</pre>
<?endif?>
<?php endif;?>

View file

@ -47,7 +47,7 @@
</div>
<div id="footer">
<p>&copy; 2005 CakePHP ::
<a href="http://www.cakefoundation.org/copyright/cakephp/"><?php echo 'Cake Software Foundation, Inc.'; ?></a>
<a href="http://www.cakefoundation.org/pages/copyright/"><?php echo 'Cake Software Foundation, Inc.'; ?></a>
</p>
<br />
<p>

View file

@ -30,11 +30,17 @@
$modelKey = $modelName;
?>
<h1>Edit <?php echo Inflector::humanize($modelName);?></h1>
<h1><?php echo $type.' '.Inflector::humanize($modelName);?></h1>
<?php
if($type == 'Edit')
{
echo $html->formTag('/'. Inflector::underscore($this->name) .'/update');
}
else
{
echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
}
echo $form->generateFields( $fieldNames );
@ -44,14 +50,21 @@
</form>
<ul class='actions'>
<?php
if($type == 'Edit')
{
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>";
}
echo "<li>".$html->linkTo('List '.Inflector::humanize($modelName), '/'.$this->viewPath.'/index')."</li>";
foreach( $fieldNames as $field => $value ) {
if($type == 'Edit')
{
foreach( $fieldNames as $field => $value )
{
if( isset( $value['foreignKey'] ) )
{
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$modelKey][$field] )."</li>";
}
}
}
?>
</ul>

View file

@ -30,7 +30,7 @@
/**
* Included libraries.
*/
uses('object', DS.'view'.DS.'helper');
uses(DS.'view'.DS.'helper');
/**
* View, the V in the MVC triad.
@ -247,7 +247,11 @@ class View extends Object
$this->setLayout($layout);
}
$viewFileName = $file? $file: $this->_getViewFileName($action);
$viewFileName = $this->_getViewFileName($action);
if ($file)
{
$viewFileName = $file;
}
if (!is_file($viewFileName))
{
@ -366,7 +370,7 @@ class View extends Object
{
return "(Error rendering {$name})";
}
return $this->_render($fn, array_merge($this->_viewVars, $params));
return $this->_render($fn, array_merge($this->_viewVars, $params), true, false);
}
/**
@ -385,7 +389,7 @@ class View extends Object
if (is_file($layout_fn))
{
$out = $this->_render($layout_fn, $data_for_layout);
$out = $this->_render($layout_fn, $data_for_layout, true, false);
if ($out === false)
{
@ -517,12 +521,12 @@ class View extends Object
* @return string Rendered output
* @access private
*/
function _render($___viewFn, $___data_for_view, $___play_safe = true)
function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true)
{
/**
* Fetching helpers
*/
if ($this->helpers !== false)
if ($this->helpers != false && $loadHelpers = true)
{
$loadedHelpers = array();
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
@ -573,14 +577,17 @@ class View extends Object
* @param array $helpers List of helpers to load.
* @return array
*/
function &_loadHelpers(&$loaded, $helpers) {
function &_loadHelpers(&$loaded, $helpers)
{
foreach ($helpers as $helper)
{
$helperCn = $helper.'Helper';
if(in_array($helper, array_keys($loaded)) !== true)
{
if(!class_exists($helperCn))
{
$helperFn = Inflector::underscore($helper).'.php';
if(file_exists(HELPERS.$helperFn))
{
$helperFn = HELPERS.$helperFn;
@ -589,15 +596,24 @@ class View extends Object
{
$helperFn = LIBS.'view'.DS.'helpers'.DS.$helperFn;
}
$helperCn = $helper.'Helper';
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
if (is_file($helperFn))
{
require_once $helperFn;
if(class_exists($helperCn)===true)
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));
exit();
}
}
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
if(class_exists($helperCn, FALSE))
{
${$camelBackedHelper} =& new $helperCn;
${$camelBackedHelper}->base = $this->base;
@ -612,8 +628,6 @@ class View extends Object
${$camelBackedHelper}->validationErrors = $this->validationErrors;
}
$loaded[$helper] =& ${$camelBackedHelper};
// Find and load helper dependencies
if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
{
$loaded =& $this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);
@ -628,17 +642,7 @@ class View extends Object
exit();
}
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));
exit();
}
}
}
return $loaded;
}
}