Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix label feature (Stephane Matamontero) , move element merge code in…

…to element (Alan)

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Template_Flexy/trunk@299896 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit a87767eaa82870e68c653500c6b1b99939f7a69e 1 parent d098cb9
@roojs roojs authored
View
62 HTML/Template/Flexy.php
@@ -362,11 +362,11 @@ function compile( $file )
DIRECTORY_SEPARATOR .basename($tmplDirUsed) . '_' .md5($tmplDirUsed) : '';
- $compileDest = @$this->options['compileDir'];
+ $compileDest = isset($this->options['compileDir']) ? $this->options['compileDir'] : '';
$isTmp = false;
// Use a default compile directory if one has not been set.
- if (!@$compileDest) {
+ if (!$compileDest) {
// Use session.save_path + 'compiled_templates_' + md5(of sourcedir)
$compileDest = ini_get('session.save_path') . DIRECTORY_SEPARATOR . 'flexy_compiled_templates';
if (!file_exists($compileDest)) {
@@ -510,7 +510,7 @@ function outputObject(&$t,$elements=array())
}
// Call the clever element merger - that understands form values and
// how to display them...
- $this->elements[$k] = $this->mergeElement($this->elements[$k] ,$v);
+ $this->elements[$k] = $this->elements[$k]->merge($v);
}
//echo '<PRE>'; print_r(array($elements,$this->elements));
@@ -618,68 +618,22 @@ function debug($string)
/**
- * A general Utility method that merges HTML_Template_Flexy_Elements
- * Static method - no native debug avaiable..
+ * @depreciated
+ * See element->merge
*
- * @param HTML_Template_Flexy_Element $original (eg. from getElements())
- * @param HTML_Template_Flexy_Element $new (with data to replace/merge)
- * @return HTML_Template_Flexy_Element the combined/merged data.
- * @static
* @access public
*/
function mergeElement($original,$new)
{
// Clone objects is possible to avoid creating references between elements
- if (version_compare(PHP_VERSION,'5.0.0',">=")) {
- if ($original) {
- $original = clone($original);
- }
- if ($new) {
- $new = clone($new);
- }
- }
-
+
// no original - return new
if (!$original) {
- return $new;
- }
- // no new - return original
- if (!$new) {
- return $original;
- }
- // If the properties of $original differ from those of $new and
- // they are set on $new, set them to $new's. Otherwise leave them
- // as they are.
-
- if ($new->tag && ($new->tag != $original->tag)) {
- $original->tag = $new->tag;
- }
-
- if ($new->override !== false) {
- $original->override = $new->override;
- }
-
- if (count($new->children)) {
- //echo "<PRE> COPY CHILDREN"; print_r($from->children);
- $original->children = $new->children;
+ return clone($new);
}
+ return $original->merge($new);
- if (is_array($new->attributes)) {
-
- foreach ($new->attributes as $key => $value) {
- $original->attributes[$key] = $value;
- }
- }
- // originals never have prefixes or suffixes..
- $original->prefix = $new->prefix;
- $original->suffix = $new->suffix;
-
- if ($new->value !== null) {
- $original->setValue($new->value);
- }
-
- return $original;
}
View
2  HTML/Template/Flexy/Compiler/Flexy.php
@@ -829,7 +829,7 @@ function translateString($string)
{
if (!empty($this->options['disableTranslate'])) {
- return;
+ return $string;
}
if (is_a($this->options['Translation2'], 'Translation2')) {
View
56 HTML/Template/Flexy/Element.php
@@ -693,6 +693,62 @@ function childrenToHtml()
} // end func toHtml
+ /**
+ * merge this element with another
+ * originally was in main engine
+ *
+ * @param HTML_Template_Flexy_Element $new (with data to replace/merge)
+ * @return HTML_Template_Flexy_Element the combined/merged data.
+ * @static
+ * @access public
+ */
+ function merge($new)
+ {
+ // Clone objects is possible to avoid creating references between elements
+ $original = clone($this);
+ // no new - return original
+ if (!$new) {
+ return $original;
+ }
+
+ $new = clone($new);
+
+ // If the properties of $original differ from those of $new and
+ // they are set on $new, set them to $new's. Otherwise leave them
+ // as they are.
+
+ if ($new->tag && ($new->tag != $original->tag)) {
+ $original->tag = $new->tag;
+ }
+
+ if ($new->override !== false) {
+ $original->override = $new->override;
+ }
+
+ if (count($new->children)) {
+ //echo "<PRE> COPY CHILDREN"; print_r($from->children);
+ $original->children = $new->children;
+ }
+
+ if (is_array($new->attributes)) {
+
+ foreach ($new->attributes as $key => $value) {
+ $original->attributes[$key] = $value;
+ }
+ }
+ // originals never have prefixes or suffixes..
+ $original->prefix = $new->prefix;
+ $original->suffix = $new->suffix;
+
+ if ($new->value !== null) {
+ $original->setValue($new->value);
+ }
+ if ($new->label !== null) {
+ $original->label = $new->label;
+ }
+ return $original;
+
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.