Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

provisional support for label property of elements outputing as assoc…

…iated label content (Stephane Matamontero)

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Template_Flexy/trunk@299839 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit d098cb99933ee3c0d0a962ea9c5f5f1fb59f0123 1 parent fabe89b
@roojs roojs authored
View
5 HTML/Template/Flexy.php
@@ -131,7 +131,10 @@ class HTML_Template_Flexy
'globalfunctions' => false, // allow GLOBALS.date(#d/m/Y#) to have access to all PHP's methods
// warning dont use unless you trust the template authors
// exec() becomes exposed.
-
+ 'useElementLabels' => true, // WARNING DO NOT ENABLE THIS UNLESS YOU TRUST THE TEMPLATE AUTHORS
+ // look for label elements referring to input elements
+ // you can then set (replace) the label of the corresponding input
+ // element by $element->label="my new label text";
// get text/transalation suppport ------------------------------------------
// (flexy compiler only)
'disableTranslate' => false, // if true, skips the translation functionality completely
View
32 HTML/Template/Flexy/Compiler/Flexy/Tag.php
@@ -1073,7 +1073,37 @@ function parseTagForm()
}
-
+ /**
+ * Deal with Label - build a element object for it (unless flexyignore is set)
+ *
+ *
+ * @return string | false = html output or ignore (just output the tag)
+ * @access public
+ */
+
+ function parseTagLabel()
+ {
+
+ if (empty($GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']['useElementLabels'])) {
+ return false;
+ }
+ // this may need some protection for general usage.....
+
+ $for = $this->element->getAttribute('FOR');
+ $ret = '';
+ $tmp = $this->toStringChildren($this->element, $ret);
+ if (is_a($tmp,'PEAR_Error')) {
+ return $tmp;
+ }
+
+ return $this->compiler->appendPhp(
+ 'echo "<label for="' . $for . '">";' .
+ 'if (!empty($this->elements[\'' . $for . '\']->label)) ' .
+ ' { echo htmlspecialchars($this->elements[\'' . $for . '\']->label); } else { ?>' .
+ htmlspecialchars($ret) . '<? } ' .
+ 'echo "</label>";'
+ );
+ }
View
9 HTML/Template/Flexy/Element.php
@@ -113,6 +113,15 @@ class HTML_Template_Flexy_Element {
*/
var $value = null;
/**
+ * If an input element has a label element associated to it
+ * *and* the 'useElementLabels' option is true, then you can
+ * optionally set the text of this label. This permits
+ * to set custom strings for doing translations.
+ * @var string | null
+ * @access public
+ */
+ var $label = null;
+ /**
* Class constructor
* @param mixed $attributes Associative array of table tag attributes
* or HTML attributes name="value" pairs
Please sign in to comment.
Something went wrong with that request. Please try again.