Moving all tags from Helper to child classes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3892 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-11-22 03:51:21 +00:00
parent 22588729d4
commit 056bda7e4b
5 changed files with 70 additions and 83 deletions

View file

@ -79,49 +79,7 @@ class Helper extends Overloadable {
* @access public
* @var array
*/
var $tags = array('metalink' => '<link href="%s" title="%s"%s />',
'link' => '<a href="%s" %s>%s</a>',
'mailto' => '<a href="mailto:%s" %s>%s</a>',
'form' => '<form %s>',
'input' => '<input name="data[%s][%s]" %s/>',
'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
'hidden' => '<input type="hidden" name="data[%s][%s]" %s/>',
'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
'checkbox' => '<input type="checkbox" name="data[%s][%s]" %s/>',
'radio' => '<input type="radio" name="data[%s][%s]" id="%s" %s />%s',
'selectstart' => '<select name="data[%s][%s]" %s>',
'selectmultiplestart' => '<select name="data[%s][%s][]" %s>',
'selectempty' => '<option value="" %s>&nbsp;</option>',
'selectoption' => '<option value="%s" %s>%s</option>',
'selectend' => '</select>',
'optiongroup' => '<optgroup label="%s"%s>',
'optiongroupend' => '</optgroup>',
'password' => '<input type="password" name="data[%s][%s]" %s/>',
'file' => '<input type="file" name="data[%s][%s]" %s/>',
'file_no_model' => '<input type="file" name="%s" %s/>',
'submit' => '<input type="submit" %s/>',
'submitimage' => '<input type="image" src="%s" %s/>',
'image' => '<img src="%s" %s/>',
'tableheader' => '<th%s>%s</th>',
'tableheaderrow' => '<tr%s>%s</tr>',
'tablecell' => '<td%s>%s</td>',
'tablerow' => '<tr%s>%s</tr>',
'block' => '<div%s>%s</div>',
'blockstart' => '<div%s>',
'blockend' => '</div>',
'para' => '<p%s>%s</p>',
'parastart' => '<p%s>',
'label' => '<label for="%s"%s>%s</label>',
'fieldset' => '<fieldset><legend>%s</legend>%s</fieldset>',
'fieldsetstart' => '<fieldset><legend>%s</legend>',
'fieldsetend' => '</fieldset>',
'legend' => '<legend>%s</legend>',
'css' => '<link rel="%s" type="text/css" href="%s" %s/>',
'style' => '<style type="text/css"%s>%s</style>',
'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />',
'javascriptblock' => '<script type="text/javascript">%s</script>',
'javascriptstart' => '<script type="text/javascript">',
'javascriptlink' => '<script type="text/javascript" src="%s"></script>');
var $tags = array();
/**
* Parses tag templates into $this->tags.

View file

@ -44,13 +44,6 @@ class AjaxHelper extends AppHelper {
* @var array
*/
var $helpers = array('Html', 'Javascript');
/**
* html tags used by this helper.
*
* @var array
*/
var $tags = array('blockstart' => '<div%s>',
'blockend' => '</div>');
/**
* Names of Javascript callback functions.
*
@ -483,7 +476,7 @@ class AjaxHelper extends AppHelper {
}
}
$attr = $this->_parseAttributes(am($options, array('id' => $id)));
return $this->output(sprintf($this->tags['blockstart'], $attr));
return $this->output(sprintf($this->Html->tags['blockstart'], $attr));
}
/**
* Closes an Ajax-updateable DIV element
@ -501,7 +494,7 @@ class AjaxHelper extends AppHelper {
return '';
}
}
return $this->output($this->tags['blockend']);
return $this->output($this->Html->tags['blockend']);
}
/**
* Detects Ajax requests

View file

@ -56,23 +56,6 @@
class FormHelper extends AppHelper {
var $helpers = array('Html');
/**
* html tags used by this helper.
*
* @var array
*/
var $tags = array('form' => '<form %s>',
'label' => '<label for="%s"%s>%s</label>',
'input' => '<input name="data[%s][%s]" %s/>',
'password' => '<input type="password" name="data[%s][%s]" %s/>',
'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
'submitimage' => '<input type="image" src="%s" %s/>',
'selectmultiplestart' => '<select name="data[%s][%s][]" %s>',
'selectstart' => '<select name="data[%s][%s]" %s>',
'selectend' => '</select>',
'optiongroupend' => '</optgroup>',
'optiongroup' => '<optgroup label="%s"%s>',
'selectoption' => '<option value="%s" %s>%s</option>');
/**
* Returns an HTML FORM element.
@ -92,7 +75,7 @@ class FormHelper extends AppHelper {
$token = $this->Html->hidden('_Token/key', array('value' => $this->params['_Token']['key']), true);
}
return sprintf($this->tags['form'], $this->Html->parseHtmlOptions($htmlAttributes, null, '')) . $token;
return sprintf($this->Html->tags['form'], $this->Html->parseHtmlOptions($htmlAttributes, null, '')) . $token;
}
/**
* Returns a formatted error message for given FORM field, NULL if no errors.
@ -114,7 +97,7 @@ class FormHelper extends AppHelper {
* @deprecated
*/
function labelTag($tagName, $text) {
return sprintf($this->tags['label'], Inflector::camelize(r('/', '_', $tagName)), $text);
return sprintf($this->Html->tags['label'], Inflector::camelize(r('/', '_', $tagName)), $text);
}
/**
* Returns a formatted LABEL element for HTML FORMs.
@ -135,7 +118,7 @@ class FormHelper extends AppHelper {
if (strpos($tagName, '/') !== false) {
$tagName = Inflector::camelize(r('/', '_', $tagName));
}
return $this->output(sprintf($this->tags['label'], $tagName, $this->_parseAttributes($attributes), $text));
return $this->output(sprintf($this->Html->tags['label'], $tagName, $this->_parseAttributes($attributes), $text));
}
/**
* Generates a form input element complete with label and wrapper div
@ -233,7 +216,7 @@ class FormHelper extends AppHelper {
if ($this->tagIsInvalid()) {
$htmlAttributes = $this->Html->addClass($htmlAttributes, 'form_error');
}
return $this->output(sprintf($this->tags['input'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
return $this->output(sprintf($this->Html->tags['input'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
}
/**
* Creates a password input widget.
@ -248,7 +231,7 @@ class FormHelper extends AppHelper {
if ($this->tagIsInvalid()) {
$htmlAttributes = $this->addClass($htmlAttributes, 'form_error');
}
return $this->output(sprintf($this->tags['password'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
return $this->output(sprintf($this->Html->tags['password'], $this->model(), $this->field(), $this->_parseAttributes($htmlAttributes, null, ' ', ' ')));
}
/**
* Creates a textarea widget.
@ -268,7 +251,7 @@ class FormHelper extends AppHelper {
if ($this->tagIsInvalid()) {
$htmlAttributes = $this->Html->addClass($htmlAttributes, 'form_error');
}
return $this->output(sprintf($this->tags['textarea'], $this->model(), $this->field(), $this->Html->_parseAttributes($htmlAttributes, null, ' '), $value));
return $this->output(sprintf($this->Html->tags['textarea'], $this->model(), $this->field(), $this->Html->_parseAttributes($htmlAttributes, null, ' '), $value));
}
/**
* Creates a button tag.
@ -313,7 +296,7 @@ class FormHelper extends AppHelper {
} else {
$url = $this->webroot . $this->themeWeb . IMAGES_URL . $path;
}
return $this->output(sprintf($this->tags['submitimage'], $url, $this->_parseAttributes($htmlAttributes, null, '', ' ')));
return $this->output(sprintf($this->Html->tags['submitimage'], $url, $this->_parseAttributes($htmlAttributes, null, '', ' ')));
}
/**
* Returns a formatted SELECT element.
@ -339,9 +322,9 @@ class FormHelper extends AppHelper {
}
if (isset($attributes) && array_key_exists("multiple", $attributes)) {
$tag = $this->tags['selectmultiplestart'];
$tag = $this->Html->tags['selectmultiplestart'];
} else {
$tag = $this->tags['selectstart'];
$tag = $this->Html->tags['selectstart'];
}
$select[] = sprintf($tag, $this->model(), $this->field(), $this->Html->parseHtmlOptions($attributes));
@ -354,7 +337,7 @@ class FormHelper extends AppHelper {
$options = array_reverse($options, true);
}
$select = am($select, $this->__selectOptions(array_reverse($options, true), $selected, array(), $showParents));
$select[] = sprintf($this->tags['selectend']);
$select[] = sprintf($this->Html->tags['selectend']);
return $this->output(implode("\n", $select));
}
/**
@ -368,12 +351,12 @@ class FormHelper extends AppHelper {
$htmlOptions = array();
if (is_array($title) && (!isset($title['name']) || !isset($title['value']))) {
if (!empty($name)) {
$select[] = $this->tags['optiongroupend'];
$select[] = $this->Html->tags['optiongroupend'];
$parents[] = $name;
}
$select = am($select, $this->__selectOptions($title, $selected, $parents, $showParents));
if (!empty($name)) {
$select[] = sprintf($this->tags['optiongroup'], $name, '');
$select[] = sprintf($this->Html->tags['optiongroup'], $name, '');
}
$name = null;
} elseif (is_array($title)) {
@ -390,7 +373,7 @@ class FormHelper extends AppHelper {
}
if($showParents || (!in_array($title, $parents))) {
$select[] = sprintf($this->tags['selectoption'], $name, $this->Html->parseHtmlOptions($htmlOptions), h($title));
$select[] = sprintf($this->Html->tags['selectoption'], $name, $this->Html->parseHtmlOptions($htmlOptions), h($title));
}
}
}

View file

@ -40,6 +40,51 @@ class HtmlHelper extends AppHelper {
/**#@+
* @access public
*/
/**
* html tags used by this helper.
*
* @var array
*/
var $tags = array('metalink' => '<link href="%s" title="%s"%s />',
'link' => '<a href="%s" %s>%s</a>',
'mailto' => '<a href="mailto:%s" %s>%s</a>',
'form' => '<form %s>',
'input' => '<input name="data[%s][%s]" %s/>',
'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
'hidden' => '<input type="hidden" name="data[%s][%s]" %s/>',
'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
'checkbox' => '<input type="checkbox" name="data[%s][%s]" %s/>',
'radio' => '<input type="radio" name="data[%s][%s]" id="%s" %s />%s',
'selectstart' => '<select name="data[%s][%s]" %s>',
'selectmultiplestart' => '<select name="data[%s][%s][]" %s>',
'selectempty' => '<option value="" %s>&nbsp;</option>',
'selectoption' => '<option value="%s" %s>%s</option>',
'selectend' => '</select>',
'optiongroup' => '<optgroup label="%s"%s>',
'optiongroupend' => '</optgroup>',
'password' => '<input type="password" name="data[%s][%s]" %s/>',
'file' => '<input type="file" name="data[%s][%s]" %s/>',
'file_no_model' => '<input type="file" name="%s" %s/>',
'submit' => '<input type="submit" %s/>',
'submitimage' => '<input type="image" src="%s" %s/>',
'image' => '<img src="%s" %s/>',
'tableheader' => '<th%s>%s</th>',
'tableheaderrow' => '<tr%s>%s</tr>',
'tablecell' => '<td%s>%s</td>',
'tablerow' => '<tr%s>%s</tr>',
'block' => '<div%s>%s</div>',
'blockstart' => '<div%s>',
'blockend' => '</div>',
'para' => '<p%s>%s</p>',
'parastart' => '<p%s>',
'label' => '<label for="%s"%s>%s</label>',
'fieldset' => '<fieldset><legend>%s</legend>%s</fieldset>',
'fieldsetstart' => '<fieldset><legend>%s</legend>',
'fieldsetend' => '</fieldset>',
'legend' => '<legend>%s</legend>',
'css' => '<link rel="%s" type="text/css" href="%s" %s/>',
'style' => '<style type="text/css"%s>%s</style>',
'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />');
/**
* Base URL
*

View file

@ -44,6 +44,14 @@ class JavascriptHelper extends AppHelper {
var $_cacheAll = false;
var $_rules = array();
var $safe = false;
/**
* html tags used by this helper.
*
* @var array
*/
var $tags = array('javascriptblock' => '<script type="text/javascript">%s</script>',
'javascriptstart' => '<script type="text/javascript">',
'javascriptlink' => '<script type="text/javascript" src="%s"></script>');
/**
* Returns a JavaScript script tag.