From 4b9df4fda42171eaf1ac877f36880ad715da7456 Mon Sep 17 00:00:00 2001 From: phpnut Date: Wed, 26 Oct 2005 10:55:44 +0000 Subject: [PATCH] [1210] Author: phpnut Date: 4:44:45 AM, Wednesday, October 26, 2005 Message: AJAX is now available as a by default in the $html variable in the templates. You access it like this: $html->Ajax->xxx(); Updated default templates. [1208] Author: phpnut Date: 6:49:26 PM, Tuesday, October 25, 2005 Message: Adding fix in Controller::generateFieldNames(); [1203] Author: phpnut Date: 10:40:28 AM, Tuesday, October 25, 2005 Message: Changes made to core templates and css. Fixed added for Ticket #60 [1202] Author: phpnut Date: 2:30:58 AM, Tuesday, October 25, 2005 Message: Fix for cake error templates Fixed a key for tables that are underscored in scaffolded code. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0 --- app/webroot/css/cake.default.css | 35 +++++++++---- app/webroot/css/cake.forms.css | 2 + app/webroot/css/cake.scaffold.css | 3 ++ cake/dispatcher.php | 2 +- cake/libs/controller/component.php | 13 ++--- cake/libs/controller/controller.php | 4 +- cake/libs/controller/scaffold.php | 4 +- .../controller/templates/scaffolds/edit.thtml | 1 + .../controller/templates/scaffolds/show.thtml | 5 +- cake/libs/model/model.php | 26 +++++----- cake/libs/view/helpers/ajax.php | 34 ++++++------ cake/libs/view/helpers/form.php | 22 ++++---- cake/libs/view/helpers/html.php | 8 ++- .../libs/view/templates/layouts/default.thtml | 27 +++++----- cake/libs/view/templates/pages/home.thtml | 40 +++++++------- cake/libs/view/view.php | 52 +++++++++++-------- 16 files changed, 153 insertions(+), 125 deletions(-) diff --git a/app/webroot/css/cake.default.css b/app/webroot/css/cake.default.css index 680a98387..254996c0c 100644 --- a/app/webroot/css/cake.default.css +++ b/app/webroot/css/cake.default.css @@ -20,8 +20,20 @@ h1 em { font-weight: normal; font-variant: normal; } +h2 a { + color: #fff; + font-style: normal; + font-weight: normal; + font-variant: normal; +} +h2 a:hover { + color: #DBA941; + font-style: normal; + font-weight: normal; + font-variant: normal; +} -h2 +h2.cake { margin-top: 20px; margin-bottom: 6px; @@ -80,7 +92,7 @@ p height: 114px; background: #fff url("../img/cake.bg.header.gif") repeat-x; border-bottom: 1px solid #D2D7D8; - margin-bottom: 30px; + margin-bottom: 16px; text-align: right; } #header img @@ -89,24 +101,24 @@ p vertical-align: middle; border: 0; } -.headerNav +#headerNav { - float: right; - margin-top: 3px; - padding-right: 30px; - font-size: 13px; + float: left; + margin-top: 56px; + margin-left: 20px; + font-size: 15px; font-weight: bold; color: #71300F; } -.headerNav a { +#headerNav a { padding: 4px 10px; } -.headerNav a:hover { +#headerNav a:hover { padding: 4px 10px; - background-color: #fff; + background-color: #D2D7D8; } -.headerNav .active { +#headerNav .active { padding: 4px 10px; background-color: #fff; } @@ -151,6 +163,7 @@ p border-left: 1px solid #D2D7D8; border-right: 1px solid #D2D7D8; border-bottom: 1px solid #D2D7D8; + text-align: left; } a { diff --git a/app/webroot/css/cake.forms.css b/app/webroot/css/cake.forms.css index bde160adc..20545ca8d 100644 --- a/app/webroot/css/cake.forms.css +++ b/app/webroot/css/cake.forms.css @@ -134,6 +134,8 @@ form div fieldset label.labelCheckbox, form div fieldset label.labelRadio { p.error { color: #71300F; background-color: #DBA941; + font-size: 14px; + padding: 1em; } form div input, form div select, form div textarea { diff --git a/app/webroot/css/cake.scaffold.css b/app/webroot/css/cake.scaffold.css index 2da21bd3f..cfae6c54a 100644 --- a/app/webroot/css/cake.scaffold.css +++ b/app/webroot/css/cake.scaffold.css @@ -43,11 +43,14 @@ li { color: #71300F; background-color: #DBA941; font-family: Verdana; + display: block; padding: 1em; } .tip { color: #71300F; + font-size: 14px; background-color: #DBA941; + display: block; padding: 1em; } diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 341dfe2aa..36c7b30b1 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -275,7 +275,7 @@ class Dispatcher extends Object { if(!empty($r[1])) { - return $r[1]; + return $base.$r[1]; } } } diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 9a79494a9..8ae766159 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -83,17 +83,18 @@ class Component extends Object { if(in_array($component, array_keys($loaded)) !== true) { - $componentFn = COMPONENTS.Inflector::underscore($component).'.php'; - if(file_exists(COMPONENTS.Inflector::underscore($component).'.php')) + $componentFn = Inflector::underscore($component).'.php'; + + if(file_exists(COMPONENTS.$componentFn)) { - $componentFn = COMPONENTS.Inflector::underscore($component).'.php'; + $componentFn = COMPONENTS.$componentFn; } - else if(file_exists(LIBS.'controller'.DS.'components'.DS.Inflector::underscore($component).'.php')) + else if(file_exists(LIBS.'controller'.DS.'components'.DS.$componentFn)) { - $componentFn = LIBS.'controller'.DS.'components'.DS.Inflector::underscore($component).'.php'; + $componentFn = LIBS.'controller'.DS.'components'.DS.$componentFn; } - $componentCn = ucfirst($component).'Component'; + $componentCn = $component.'Component'; if (is_file($componentFn)) { diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 53cd2b908..0781500fe 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -94,7 +94,7 @@ class Controller extends Object * @var mixed A single name as a string or a list of names as an array. * @access protected */ - var $helpers = array('html'); + var $helpers = array('Html'); /** * Enter description here... @@ -731,7 +731,7 @@ class Controller extends Object // get the list of options from the other model. $registry = ClassRegistry::getInstance(); - $otherModel = $registry->getObject($fieldNames[$tabl['name']]['model']); + $otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['model'])); if( is_object($otherModel) ) { diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 0ad8f4afb..b0406c9a8 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -288,9 +288,9 @@ class Scaffold extends Object { */ function _scaffoldView ($params) { - if(!in_array('form', $this->controllerClass->helpers)) + if(!in_array('Form', $this->controllerClass->helpers)) { - $this->controllerClass->helpers[] = 'form'; + $this->controllerClass->helpers[] = 'Form'; } $isDataBaseSet = DboFactory::getInstance($this->controllerClass->useDbConfig); diff --git a/cake/libs/controller/templates/scaffolds/edit.thtml b/cake/libs/controller/templates/scaffolds/edit.thtml index 3d97aa269..41d0c98bd 100644 --- a/cake/libs/controller/templates/scaffolds/edit.thtml +++ b/cake/libs/controller/templates/scaffolds/edit.thtml @@ -31,6 +31,7 @@ $modelName = Inflector::singularize($this->name); $modelKey = $modelName; + ?>

Edit

diff --git a/cake/libs/controller/templates/scaffolds/show.thtml b/cake/libs/controller/templates/scaffolds/show.thtml index 5a8673783..2f6ff898e 100644 --- a/cake/libs/controller/templates/scaffolds/show.thtml +++ b/cake/libs/controller/templates/scaffolds/show.thtml @@ -34,7 +34,7 @@ $modelName = Inflector::singularize($this->name); $modelKey = Inflector::underscore($modelName); $registry =& ClassRegistry::getInstance(); - $objModel = $registry->getObject($modelName); + $objModel = $registry->getObject($modelKey); ?>

Show

@@ -45,7 +45,8 @@ echo "
".$value['prompt']."
"; if(isset($value['foreignKey'])) { - $otherModelObject = $registry->getObject($objModel->tableToModel[$value['table']]); + + $otherModelObject = $registry->getObject(Inflector::underscore($objModel->tableToModel[$value['table']])); $displayField = $otherModelObject->getDisplayField(); $displayText = $data[$objModel->tableToModel[$value['table']]][$displayField]; diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index ab3bdac57..a5f8433df 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -226,7 +226,7 @@ class Model extends Object $this->setTablePrefix(); } - $this->tablePrefix? $this->useTable($this->tablePrefix.$tableName): $this->useTable ($tableName); + $this->tablePrefix? $this->setTable($this->tablePrefix.$tableName): $this->setTable($tableName); parent::__construct(); $this->createLinks(); @@ -551,7 +551,7 @@ class Model extends Object * * @param string $tableName Name of the custom table */ - function useTable ($tableName) + function setTable($tableName) { if (!in_array(strtolower($tableName), $this->db->tables())) { @@ -666,28 +666,26 @@ class Model extends Object */ function field ($name, $conditions=null, $order=null) { + if (isset($this->data[$this->name][$name])) + { + return $this->data[$this->name][$name]; + } + if ($conditions) { $conditions = $this->parseConditions($conditions); - $data = $this->find($conditions, $name, $order); - return $data[$name]; } - elseif (isset($this->data[$name])) + + if ($data = $this->find($conditions, $name, $order)) { - return $this->data[$name]; + return isset($data[$this->name][$name])? $data[$this->name][$name]: false; } else { - if ($this->id && $data = $this->read($name)) - { - return isset($data[$name])? $data[$name]: false; - } - else - { - return false; - } + return false; } } + /** * Saves a single field to the database. diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index a6fd9b2b2..004fa1611 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -52,7 +52,7 @@ class AjaxHelper extends Helper * * @var array */ - var $helpers = array('html', 'javascript'); + var $helpers = array('Html', 'Javascript'); /** * Enter description here... @@ -156,12 +156,12 @@ class AjaxHelper extends Helper $href = (!empty($options['fallback'])) ? $options['fallback'] : '#'; if(isset($html_options['id'])) { - return $this->html->link($title, $href, $html_options) . $this->javascript->event("$('{$html_options['id']}')", "click", "function() {" . $this->remoteFunction($options) . "; return true; }"); + return $this->Html->link($title, $href, $html_options) . $this->Javascript->event("$('{$html_options['id']}')", "click", "function() {" . $this->remoteFunction($options) . "; return true; }"); } else { $html_options['onclick'] = $this->remoteFunction($options); - return $this->html->link($title, $href, $html_options); + return $this->Html->link($title, $href, $html_options); } } @@ -181,7 +181,7 @@ class AjaxHelper extends Helper $javascript_options = $this->_optionsForAjax($options); $func = isset($options['update']) ? "new Ajax.Updater('{$options['update']}'," : "new Ajax.Request("; - $func .= "'" . $this->html->url(isset($options['url']) ? $options['url'] : "") . "'"; + $func .= "'" . $this->Html->url(isset($options['url']) ? $options['url'] : "") . "'"; $func .= "$javascript_options)"; if (isset($options['before'])) @@ -198,7 +198,7 @@ class AjaxHelper extends Helper } if (isset($options['confirm'])) { - $func = "if (confirm('" . $this->javascript->escapeScript($options['confirm']) . "')) { $func; } else { return false; }"; + $func = "if (confirm('" . $this->Javascript->escapeScript($options['confirm']) . "')) { $func; } else { return false; }"; } return $func; } @@ -217,7 +217,7 @@ class AjaxHelper extends Helper { $frequency = (isset($options['frequency']))? $options['frequency'] : 10; $code = "new PeriodicalExecuter(function() {" . $this->remote_function($options) . "}, $frequency)"; - return $this->javascript->codeBlock($code); + return $this->Javascript->codeBlock($code); } /** @@ -236,7 +236,7 @@ class AjaxHelper extends Helper { $options['id'] = $id; //$options['html']['onsubmit'] = $this->remoteFunction($options) . "; return false;"; - return $this->html->formTag(null, "post", $options) . $this->javascript->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . "; return false;}"); + return $this->Html->formTag(null, "post", $options) . $this->Javascript->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . "; return false;}"); } /** @@ -257,7 +257,7 @@ class AjaxHelper extends Helper $options['html']['onclick'] = $this->remoteFunction($options) . "; return false;"; $options['html']['name'] = $name; $options['html']['value'] = $value; - return $this->html->tag("input", $options['html'], false); + return $this->Html->tag("input", $options['html'], false); } /** @@ -294,7 +294,7 @@ class AjaxHelper extends Helper { $options['with'] = "Form.Element.serialize('$field_id')"; } - return $this->javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options)); + return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options)); } /** @@ -315,7 +315,7 @@ class AjaxHelper extends Helper { $options['with'] = 'Form.serialize(this.form)'; } - return $this->javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options)); + return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options)); } /** @@ -356,16 +356,16 @@ class AjaxHelper extends Helper $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => "auto_complete"); - return $this->html->input($field, $htmlOptions) . - $this->html->tag("div", $divOptions, true) . "" . - $this->javascript->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" . - $divOptions['id'] . "', '" . $this->html->url($url) . "', " . $this->_optionsForAjax($ajaxOptions) . ");"); + return $this->Html->input($field, $htmlOptions) . + $this->Html->tag("div", $divOptions, true) . "" . + $this->Javascript->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" . + $divOptions['id'] . "', '" . $this->Html->url($url) . "', " . $this->_optionsForAjax($ajaxOptions) . ");"); } function drag($id, $options = array()) { $options = $this->_optionsForDraggable($options); - return $this->javascript->codeBlock("new Draggable('$id'$options);"); + return $this->Javascript->codeBlock("new Draggable('$id'$options);"); } /** @@ -389,7 +389,7 @@ class AjaxHelper extends Helper function drop($id, $options = array()) { $options = $this->_optionsForDroppable($options); - return $this->javascript->codeBlock("Droppables.add('$id'$options);"); + return $this->Javascript->codeBlock("Droppables.add('$id'$options);"); } function _optionsForDroppable ($options) @@ -421,7 +421,7 @@ class AjaxHelper extends Helper $options['onUpdate'] = 'function(sortable){' . $this->remoteFunction($options).'}'; } $options = $this->_optionsForSortable($options); - return $this->javascript->codeBlock("Sortable.create('$id'$options);"); + return $this->Javascript->codeBlock("Sortable.create('$id'$options);"); } function _optionsForSortable ($options) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 4bf586379..bbcca0ead 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -65,7 +65,7 @@ define('TAG_FIELDSET', '
%s%s'); class FormHelper extends Helper { - var $helpers = array('html'); + var $helpers = array('Html'); /** * Constructor which takes an instance of the HtmlHelper class. * @@ -85,8 +85,8 @@ class FormHelper extends Helper function isFieldError($field ) { $error = 1; - $this->html->setFormTag( $field ); - if( $error == $this->html->tagIsInvalid( $this->html->model, $this->html->field) ) + $this->Html->setFormTag( $field ); + if( $error == $this->Html->tagIsInvalid( $this->Html->model, $this->Html->field) ) { return true; } else { @@ -143,7 +143,7 @@ class FormHelper extends Helper */ function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $this->html->inputTag( $tagName, $size, $htmlOptions ); + $str = $this->Html->inputTag( $tagName, $size, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -180,7 +180,7 @@ class FormHelper extends Helper function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) { $htmlOptions['class'] = "inputCheckbox"; - $str = $this->html->checkbox( $tagName, null, $htmlOptions ); + $str = $this->Html->checkbox( $tagName, null, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -215,7 +215,7 @@ class FormHelper extends Helper */ function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $this->html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE' ); + $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE' ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -251,7 +251,7 @@ class FormHelper extends Helper */ function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $this->html->dateTimeOptionTag( $tagName, 'MDY' , '12' ); + $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12' ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -288,7 +288,7 @@ class FormHelper extends Helper */ function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) { - $str = $this->html->areaTag( $tagName, $cols, $rows, $htmlOptions ); + $str = $this->Html->areaTag( $tagName, $cols, $rows, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -325,7 +325,7 @@ class FormHelper extends Helper */ function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) { - $str = $this->html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); + $str = $this->Html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -356,7 +356,7 @@ class FormHelper extends Helper */ function generateSubmitDiv($displayText, $htmlOptions = null) { - return $this->divTag( 'submit', $this->html->submitTag( $displayText, $htmlOptions) ); + return $this->divTag( 'submit', $this->Html->submitTag( $displayText, $htmlOptions) ); } @@ -446,7 +446,7 @@ class FormHelper extends Helper $strFormFields = $strFormFields.$strFieldSet; break; case "hidden"; - $strFormFields = $strFormFields . $this->html->hiddenTag( $field['tagName']); + $strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']); break; case "date": $strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'] ); diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index aee20bc34..bb63588d3 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -47,7 +47,13 @@ class HtmlHelper extends Helper /**#@+ * @access public */ - + /** + * Included helpers. + * + * @var array + */ + var $helpers = array('Ajax'); + /** * Base URL * diff --git a/cake/libs/view/templates/layouts/default.thtml b/cake/libs/view/templates/layouts/default.thtml index cf7d39356..1216a2520 100644 --- a/cake/libs/view/templates/layouts/default.thtml +++ b/cake/libs/view/templates/layouts/default.thtml @@ -16,36 +16,35 @@ image('cake.logo.png', array('alt'=>"CakePHP : Rapid Development Framework")); ?> - +
link('Blog', 'blog',array('class'=>$css_class)); + echo $html->link('API', 'http://api.cakephp.org/'); + + echo $html->link('Wiki', 'http://wiki.cakephp.org'); - echo $html->link('Wiki', 'http://wiki.cakephp.org',array('class'=>$css_class)); + echo $html->link('CakeForge', 'http://cakeforge.org'); - echo $html->link('CakeForge', 'http://cakeforge.org',array('class'=>$css_class)); + echo $html->link('Trac', 'https://trac.cakephp.org'); - echo $html->link('Trac', 'https://trac.cakephp.org',array('class'=>$css_class)); - - $css_class = ($title_for_layout == 'Pastes') ? 'active' : ''; - echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>$css_class)); ?> - +
@@ -54,7 +53,7 @@
© 2005 CakePHP :: CakePHP Developers and Authors -

CakePHP version 0.10.0.1076_dev

+

CakePHP version 0.10.0.1211_alpha

image('cake.power.png', array('alt'=>"CakePHP : Rapid Development Framework", 'border'=>"0"))?> diff --git a/cake/libs/view/templates/pages/home.thtml b/cake/libs/view/templates/pages/home.thtml index b55234b81..7b4338489 100644 --- a/cake/libs/view/templates/pages/home.thtml +++ b/cake/libs/view/templates/pages/home.thtml @@ -32,42 +32,40 @@ */ ?>
-

CakePHP Works!

-

Your database configuration file is

+

Cake Alpha is sooo tasty

+

+The Alpha release is exciting. We changed quite a few things, but hope you agree with +our efforts to make the code easier to read and handle. +It all comes back to our desire to make the best RAD framework available. +

+

See CakePHP.org for major changes in this release

+

If you plan to upgrade from an older version, you may also want to read the changelog

+

+ +

Your database configuration file is

-

Cake connected ? "is able to" : "is not able to" ?> connect to the database.

+

Cake connected ? "is able to" : "is not able to" ?> connect to the database.

Editing this Page

-To change the content of this page, create /app/views/pages/home.thtml. To change it's layout, create /app/views/layouts/default.thtml. You can also add some CSS styles for your pages at /webroot/css/. +To change the content of this page, create /app/views/pages/home.thtml. +To change it's layout, create /app/views/layouts/default.thtml. +see the wiki for more info +You can also add some CSS styles for your pages at /webroot/css/.

-

Introducing Cake

+

More about Cake

Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.

-

What's New

-

Release 0.10.0.1076_dev with:

-
    -
  • Scaffolding
  • -
  • Output Types
  • -
  • Standard Modules (ACL, etc.)
  • -
  • Associations
  • -
  • Evolved Directory Structure and API to make your life easier.
  • -
-

Getting Involved

-

We are always looking for people to help with tutorials, bug requests, and documenation. -Best place to get involved is IRC. We will be implementing some contributor guidlines shortly for those of you who would like to code for the project. -Obviously, everyone and anyone can always make a suggestion, raise a new idea, help us brainstorm, and all that stuff that makes this fun. -

+

#cakephp at irc.freenode.net · Cake PHP Google Group · Cake TRAC (Wiki, SVN repository, etc.) -

-
+

\ No newline at end of file diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 79341a85c..a9754f995 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -91,7 +91,7 @@ class View extends Object * @var mixed A single name as a string or a list of names as an array. * @access protected */ - var $helpers = array('html'); + var $helpers = array('Html'); /** * Path to View. @@ -525,12 +525,15 @@ class View extends Object foreach(array_keys($loadedHelpers) as $helper) { - ${$helper} =& $loadedHelpers[$helper]; - if(isset(${$helper}->helpers) && is_array(${$helper}->helpers)) + $replace = strtolower(substr($helper, 0, 1)); + $camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1); + + ${$camelBackedHelper} =& $loadedHelpers[$helper]; + if(isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) { - foreach(${$helper}->helpers as $subHelper) + foreach(${$camelBackedHelper}->helpers as $subHelper) { - ${$helper}->{$subHelper} =& $loadedHelpers[$subHelper]; + ${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper]; } } } @@ -572,41 +575,44 @@ class View extends Object { if(in_array($helper, array_keys($loaded)) !== true) { - $helperFn = HELPERS.Inflector::underscore($helper).'.php'; - if(file_exists(HELPERS.Inflector::underscore($helper).'.php')) + $helperFn = Inflector::underscore($helper).'.php'; + + if(file_exists(HELPERS.$helperFn)) { - $helperFn = HELPERS.Inflector::underscore($helper).'.php'; + $helperFn = HELPERS.$helperFn; } - else if(file_exists(LIBS.'view'.DS.'helpers'.DS.Inflector::underscore($helper).'.php')) + else if(file_exists(LIBS.'view'.DS.'helpers'.DS.$helperFn)) { - $helperFn = LIBS.'view'.DS.'helpers'.DS.Inflector::underscore($helper).'.php'; + $helperFn = LIBS.'view'.DS.'helpers'.DS.$helperFn; } - $helperCn = ucfirst($helper).'Helper'; - + $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) { - ${$helper} =& new $helperCn; - ${$helper}->base = $this->base; - ${$helper}->webroot = $this->webroot; - ${$helper}->here = $this->here; - ${$helper}->params = $this->params; - ${$helper}->action = $this->action; - ${$helper}->data = $this->data; + ${$camelBackedHelper} =& new $helperCn; + ${$camelBackedHelper}->base = $this->base; + ${$camelBackedHelper}->webroot = $this->webroot; + ${$camelBackedHelper}->here = $this->here; + ${$camelBackedHelper}->params = $this->params; + ${$camelBackedHelper}->action = $this->action; + ${$camelBackedHelper}->data = $this->data; if(!empty($this->validationErrors)) { - ${$helper}->validationErrors = $this->validationErrors; + ${$camelBackedHelper}->validationErrors = $this->validationErrors; } - $loaded[$helper] =& ${$helper}; + $loaded[$helper] =& ${$camelBackedHelper}; // Find and load helper dependencies - if (isset(${$helper}->helpers) && is_array(${$helper}->helpers)) + if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) { - $loaded =& $this->_loadHelpers($loaded, ${$helper}->helpers); + $loaded =& $this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers); } } else