Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Alan Knowles roojs authored
62 HTML/Template/Flexy.php
@@ -362,11 +362,11 @@ function compile( $file )
362 362 DIRECTORY_SEPARATOR .basename($tmplDirUsed) . '_' .md5($tmplDirUsed) : '';
363 363
364 364
365   - $compileDest = @$this->options['compileDir'];
  365 + $compileDest = isset($this->options['compileDir']) ? $this->options['compileDir'] : '';
366 366
367 367 $isTmp = false;
368 368 // Use a default compile directory if one has not been set.
369   - if (!@$compileDest) {
  369 + if (!$compileDest) {
370 370 // Use session.save_path + 'compiled_templates_' + md5(of sourcedir)
371 371 $compileDest = ini_get('session.save_path') . DIRECTORY_SEPARATOR . 'flexy_compiled_templates';
372 372 if (!file_exists($compileDest)) {
@@ -510,7 +510,7 @@ function outputObject(&$t,$elements=array())
510 510 }
511 511 // Call the clever element merger - that understands form values and
512 512 // how to display them...
513   - $this->elements[$k] = $this->mergeElement($this->elements[$k] ,$v);
  513 + $this->elements[$k] = $this->elements[$k]->merge($v);
514 514 }
515 515 //echo '<PRE>'; print_r(array($elements,$this->elements));
516 516
@@ -618,68 +618,22 @@ function debug($string)
618 618
619 619
620 620 /**
621   - * A general Utility method that merges HTML_Template_Flexy_Elements
622   - * Static method - no native debug avaiable..
  621 + * @depreciated
  622 + * See element->merge
623 623 *
624   - * @param HTML_Template_Flexy_Element $original (eg. from getElements())
625   - * @param HTML_Template_Flexy_Element $new (with data to replace/merge)
626   - * @return HTML_Template_Flexy_Element the combined/merged data.
627   - * @static
628 624 * @access public
629 625 */
630 626
631 627 function mergeElement($original,$new)
632 628 {
633 629 // Clone objects is possible to avoid creating references between elements
634   - if (version_compare(PHP_VERSION,'5.0.0',">=")) {
635   - if ($original) {
636   - $original = clone($original);
637   - }
638   - if ($new) {
639   - $new = clone($new);
640   - }
641   - }
642   -
  630 +
643 631 // no original - return new
644 632 if (!$original) {
645   - return $new;
646   - }
647   - // no new - return original
648   - if (!$new) {
649   - return $original;
650   - }
651   - // If the properties of $original differ from those of $new and
652   - // they are set on $new, set them to $new's. Otherwise leave them
653   - // as they are.
654   -
655   - if ($new->tag && ($new->tag != $original->tag)) {
656   - $original->tag = $new->tag;
657   - }
658   -
659   - if ($new->override !== false) {
660   - $original->override = $new->override;
661   - }
662   -
663   - if (count($new->children)) {
664   - //echo "<PRE> COPY CHILDREN"; print_r($from->children);
665   - $original->children = $new->children;
  633 + return clone($new);
666 634 }
  635 + return $original->merge($new);
667 636
668   - if (is_array($new->attributes)) {
669   -
670   - foreach ($new->attributes as $key => $value) {
671   - $original->attributes[$key] = $value;
672   - }
673   - }
674   - // originals never have prefixes or suffixes..
675   - $original->prefix = $new->prefix;
676   - $original->suffix = $new->suffix;
677   -
678   - if ($new->value !== null) {
679   - $original->setValue($new->value);
680   - }
681   -
682   - return $original;
683 637
684 638 }
685 639
2  HTML/Template/Flexy/Compiler/Flexy.php
@@ -829,7 +829,7 @@ function translateString($string)
829 829 {
830 830
831 831 if (!empty($this->options['disableTranslate'])) {
832   - return;
  832 + return $string;
833 833 }
834 834
835 835 if (is_a($this->options['Translation2'], 'Translation2')) {
56 HTML/Template/Flexy/Element.php
@@ -693,6 +693,62 @@ function childrenToHtml()
693 693 } // end func toHtml
694 694
695 695
  696 + /**
  697 + * merge this element with another
  698 + * originally was in main engine
  699 + *
  700 + * @param HTML_Template_Flexy_Element $new (with data to replace/merge)
  701 + * @return HTML_Template_Flexy_Element the combined/merged data.
  702 + * @static
  703 + * @access public
  704 + */
  705 + function merge($new)
  706 + {
  707 + // Clone objects is possible to avoid creating references between elements
  708 + $original = clone($this);
  709 + // no new - return original
  710 + if (!$new) {
  711 + return $original;
  712 + }
  713 +
  714 + $new = clone($new);
  715 +
  716 + // If the properties of $original differ from those of $new and
  717 + // they are set on $new, set them to $new's. Otherwise leave them
  718 + // as they are.
  719 +
  720 + if ($new->tag && ($new->tag != $original->tag)) {
  721 + $original->tag = $new->tag;
  722 + }
  723 +
  724 + if ($new->override !== false) {
  725 + $original->override = $new->override;
  726 + }
  727 +
  728 + if (count($new->children)) {
  729 + //echo "<PRE> COPY CHILDREN"; print_r($from->children);
  730 + $original->children = $new->children;
  731 + }
  732 +
  733 + if (is_array($new->attributes)) {
  734 +
  735 + foreach ($new->attributes as $key => $value) {
  736 + $original->attributes[$key] = $value;
  737 + }
  738 + }
  739 + // originals never have prefixes or suffixes..
  740 + $original->prefix = $new->prefix;
  741 + $original->suffix = $new->suffix;
  742 +
  743 + if ($new->value !== null) {
  744 + $original->setValue($new->value);
  745 + }
  746 + if ($new->label !== null) {
  747 + $original->label = $new->label;
  748 + }
  749 + return $original;
  750 +
  751 + }
696 752
697 753
698 754

0 comments on commit a87767e

Please sign in to comment.
Something went wrong with that request. Please try again.