Updating helper class hierarchy, and adding 1.2 fix for Ticket #1569

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3750 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-10-27 21:40:34 +00:00
parent 45f27cda1c
commit de52eb88c9
13 changed files with 51 additions and 15 deletions

View file

@ -28,6 +28,11 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Included libs
*/
uses('overloadable');
/**
* Backend for helpers.
*
@ -36,7 +41,7 @@
* @package cake
* @subpackage cake.cake.libs.view
*/
class Helper extends Object {
class Helper extends Overloadable {
/**
* Base URL

View file

@ -36,7 +36,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class AjaxHelper extends Helper {
class AjaxHelper extends AppHelper {
/**
* Included helpers.
@ -105,8 +105,6 @@ class AjaxHelper extends Helper {
* (using the url() format) that's called in the background using
* XMLHttpRequest. The result of that request can then be inserted into a
* DOM object whose id can be specified with <i>options[update]</i>.
* Usually, the result would be a partial prepared by the controller with
* either renderPartial or renderPartialCollection.
*
* Examples:
* <code>

View file

@ -36,7 +36,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class CacheHelper extends Helper{
class CacheHelper extends AppHelper {
/**
* Array of strings replaced in cached views.
* The strings are found between <cake:nocache><cake:nocache> in views

View file

@ -53,7 +53,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class FormHelper extends Helper {
class FormHelper extends AppHelper {
var $helpers = array('Html');

View file

@ -32,7 +32,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class HtmlHelper extends Helper {
class HtmlHelper extends AppHelper {
/*************************************************************************
* Public variables
*************************************************************************/

View file

@ -35,8 +35,9 @@
* @subpackage cake.cake.libs.view.helpers
*/
class JavascriptHelper extends Helper{
class JavascriptHelper extends AppHelper {
var $__scriptBuffer = null;
var $_cachedEvents = array();
var $_cacheEvents = false;
var $_cacheToFile = false;
@ -57,13 +58,20 @@ class JavascriptHelper extends Helper{
$this->_cachedEvents[] = $script;
} else {
$block = ($script !== null);
if ($safe || $this->safe) {
if (($safe || $this->safe) && !($this->_cacheAll && $allowCache)) {
$script = "\n" . '<!--//--><![CDATA[//><!--' . "\n" . $script;
if ($block) {
$script .= "\n" . '//--><!]]>' . "\n";
}
}
if ($script === null && $this->_cacheAll && $allowCache) {
$this->__scriptBuffer = @ob_get_contents();
@ob_end_clean();
ob_start();
return null;
}
if ($block) {
return sprintf($this->tags['javascriptblock'], $script);
} else {
@ -72,6 +80,24 @@ class JavascriptHelper extends Helper{
}
}
/**
* Ends a block of cached JavaScript code
*
* @return mixed
*/
function blockEnd() {
$script = @ob_get_contents();
@ob_end_clean();
ob_start();
echo $this->__scriptBuffer;
$this->__scriptBuffer = null;
if (!empty($script)) {
$this->_cachedEvents[] = $script;
}
}
/**
* Returns a JavaScript include tag (SCRIPT element)
*
* @param string $url URL to JavaScript file.

View file

@ -36,7 +36,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class NumberHelper extends Helper {
class NumberHelper extends AppHelper {
/**
* Formats a number with a level of precision.
*

View file

@ -32,7 +32,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class PaginatorHelper extends Helper {
class PaginatorHelper extends AppHelper {
/**
* Helper dependencies

View file

@ -150,6 +150,7 @@ class RssHelper extends XmlHelper {
$out = '';
$c = count($items);
for ($i = 0; $i < $c; $i++) {
$out .= $this->item(array(), $items[$i]);
}
@ -165,6 +166,7 @@ class RssHelper extends XmlHelper {
function item($attrib = array(), $elements = array()) {
$content = null;
foreach ($elements as $key => $val) {
$attrib = array();
switch ($key) {
case 'pubDate' :
@ -208,6 +210,11 @@ class RssHelper extends XmlHelper {
}
$elements[$key] = $this->elem($key, array(), $val);
}
if (isset($elements['link']) && !isset($elements['guid'])) {
$elements['guid'] = $elements['link'];
}
if (!empty($elements)) {
$content = join('', $elements);
}

View file

@ -37,7 +37,7 @@
* @subpackage cake.cake.libs.view.helpers
*
*/
class SessionHelper extends Helper{
class SessionHelper extends AppHelper {
var $__Session;
var $__active = true;

View file

@ -45,7 +45,7 @@ if (!class_exists('HtmlHelper')) {
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class TextHelper extends Helper {
class TextHelper extends AppHelper {
/**
* Highlights a given phrase in a text.

View file

@ -34,7 +34,7 @@
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class TimeHelper extends Helper {
class TimeHelper extends AppHelper {
/**
* Returns given string trimmed to given length, adding an ending (default: "..") if necessary.

View file

@ -34,7 +34,7 @@ uses('set');
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class XmlHelper extends Helper {
class XmlHelper extends AppHelper {
var $helpers = array('Html');
/**