[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-cvs
Subject:    [PEAR-CVS] cvs: pear /HTML_Template_Flexy/Flexy/Compiler/Flexy Tag.php
From:       "Alan Knowles" <alan_k () php ! net>
Date:       2008-01-31 11:03:13
Message-ID: cvsalan_k1201777393 () cvsserver
[Download RAW message or body]

alan_k		Thu Jan 31 11:03:13 2008 UTC

  Modified files:              
    /pear/HTML_Template_Flexy/Flexy/Compiler/Flexy	Tag.php 
  Log:
  revert changes for CustomFlexyAttributes - they broke the whole thing!
  
["alan_k-20080131110313.txt" (text/plain)]

http://cvs.php.net/viewvc.cgi/pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php?r1=1.30&r2=1.31&diff_format=u
                
Index: pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php
diff -u pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php:1.30 \
                pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php:1.31
--- pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php:1.30	Fri Aug  3 07:05:33 \
                2007
+++ pear/HTML_Template_Flexy/Flexy/Compiler/Flexy/Tag.php	Thu Jan 31 11:03:13 2008
@@ -16,7 +16,7 @@
 // | Authors:  Alan Knowles <alan@akbkhome>                               |
 // +----------------------------------------------------------------------+
 //
-// $Id: Tag.php,v 1.30 2007/08/03 07:05:33 alan_k Exp $
+// $Id: Tag.php,v 1.31 2008/01/31 11:03:13 alan_k Exp $
 /* FC/BC compatibility with php5 */
 if ( (substr(phpversion(),0,1) < 5) && !function_exists('clone')) {
     eval('function clone($t) { return $t; }');
@@ -31,7 +31,7 @@
 * one instance of these exists for each namespace.
 *
 *
-* @version    $Id: Tag.php,v 1.30 2007/08/03 07:05:33 alan_k Exp $
+* @version    $Id: Tag.php,v 1.31 2008/01/31 11:03:13 alan_k Exp $
 */
 
 class HTML_Template_Flexy_Compiler_Flexy_Tag 
@@ -178,125 +178,7 @@
         $ret  = $this->parseAttributeForeach();
         $ret .= $this->parseAttributeIf();
         
-        // support Custom Attributes...
-        require_once 'HTML/Template/Flexy/Compiler/Flexy/CustomFlexyAttributes.php';
-		$customFlexyAttributes = new \
                HTML_Template_Flexy_Compiler_Flexy_CustomFlexyAttributes();
-		$customFlexyAttributes->doCustomAttributes($element);
-		
-        
-        $add = $this->toStringOpenTag($element,$ret);
-        
-        if (is_a($add,'PEAR_Error')) {
-            return $add;
-        }
-        
-        
-        
-        
-         
-        // post stuff this is probably in the wrong place...
-        
-        if ($element->postfix) {
-            foreach ($element->postfix as $e) {
-                $add = $e->compile($this->compiler);
-                if (is_a($add,'PEAR_Error')) {
-                    return $add;
-                }
-                $ret .= $add;
-            }
-        } else if ($this->element->postfix) { // if postfixed by self..
-            foreach ($this->element->postfix as $e) {
-                $add = $e->compile($this->compiler);
-                if (is_a($add,'PEAR_Error')) {
-                    return $add;
-                }
-            
-                $ret .= $add;
-            }
-        }
-        // dump contents of script raw - to prevent gettext additions..
-        //  print_r($element);
-        if ($element->tag == 'SCRIPT') {
-            foreach($element->children as $c) {
-                //print_R($c);
-                if (!$c) {
-                    continue;
-                }
-                if ($c->token == 'Text') {
-                    $ret .= $c->value;
-                    continue;
-                }
-                // techically we shouldnt have anything else inside of script tags.
-                // as the tokeinzer is supposted to ignore it..
-            }
-        } else {
-            $add = $element->compileChildren($this->compiler);
-            if (is_a($add,'PEAR_Error')) {
-                return $add;
-            }
-            $ret .= $add;
-        }
-        
-        
-        
-        // output the closing tag.
-        
-        if ($element->close) {
-            $add = $element->close->compile($this->compiler);
-            if (is_a($add,'PEAR_Error')) {
-                return $add;
-            }
-            $ret .= $add;
-        }
-        
-        $tmp = $this->toStringChildren($element,$ret);
-        if (is_a($tmp,'PEAR_Error')) {
-            return  $tmp;
-        }
-        $tmp = $this->toStringCloseTag($element,$ret);
-        if (is_a($tmp,'PEAR_Error')) {
-            return  $tmp;
-        }
-        
-        
-        // reset flexyignore
-        
-        $_HTML_TEMPLATE_FLEXY_TOKEN['flexyIgnore'] = $flexyignore;
-        
-        if (isset($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block']) && 
-            ($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block'] == \
                $element->getAttribute('ID'))) {
-                
-           // echo $_HTML_TEMPLATE_FLEXY['compiledTemplate'];
-            
-            $fh = fopen($_HTML_TEMPLATE_FLEXY['compiledTemplate'],'w');
-            fwrite($fh,$ret);
-            fclose($fh);   
-           
-        }
-            
-        
-        
-        return $ret;
-    }
-    
-    /**
-     * convert a tag into compiled version
-     * @arg object Element 
-     * @arg inout output string to template
-     * @return none? or pear error.
-     * 
-     */
-    
-    function toStringOpenTag(&$element,&$ret)
-	{
-		// START ADDITION...
-		if ((empty($element->tag)) || (empty($element->oTag))) {
-			return;
-		}
-		// ...END ADDITION
-
-
-		// spit ou the tag and attributes.
+        // spit ou the tag and attributes.
         
         if ($element->oTag{0} == '?') {
             $ret .= '<?php echo "<"; ?>';
@@ -377,21 +259,30 @@
             }
         }
         $ret .= ">";
-	}
-    /**
-     * compile children to string.
-     * @arg object Element 
-     * @arg inout output string to template
-     * @return none? or pear error.
-     */
-	
-	function toStringChildren(&$element,&$ret)
-	{
-		 // dump contents of script raw - to prevent gettext additions..
+        
+        // post stuff this is probably in the wrong place...
+        
+        if ($element->postfix) {
+            foreach ($element->postfix as $e) {
+                $add = $e->compile($this->compiler);
+                if (is_a($add,'PEAR_Error')) {
+                    return $add;
+                }
+                $ret .= $add;
+            }
+        } else if ($this->element->postfix) { // if postfixed by self..
+            foreach ($this->element->postfix as $e) {
+                $add = $e->compile($this->compiler);
+                if (is_a($add,'PEAR_Error')) {
+                    return $add;
+                }
+            
+                $ret .= $add;
+            }
+        }
+        // dump contents of script raw - to prevent gettext additions..
         //  print_r($element);
-		//  make sure tag isn't empty because it wouldn't make sense to output script \
                without script tags
-        if (((! empty($element->tag)) && ($element->tag == 'SCRIPT')) 
-			|| ((! empty($element->oTag)) && ($element->oTag == 'SCRIPT'))) {
+        if ($element->tag == 'SCRIPT') {
             foreach($element->children as $c) {
                 //print_R($c);
                 if (!$c) {
@@ -404,68 +295,45 @@
                 // techically we shouldnt have anything else inside of script tags.
                 // as the tokeinzer is supposted to ignore it..
             }
-            return;
-        } 
-        $add = $element->compileChildren($this->compiler);
-        if (is_a($add,'PEAR_Error')) {
-            return $add;
-        }
-        $ret .= $add;
-
-	}
-  /**
-     * compile closing tag to string.
-     * @arg object Element 
-     * @arg inout output string to template
-     * @return none? or pear error.
-     */
-	
-	function toStringCloseTag(&$element,&$ret)
-	{
-		// output the closing tag.
-		//  If the tag is empty don't output closing tags, just output postfixes if any \
                exist...
-        if ( !$element->close) {
-            return;
+        } else {
+            $add = $element->compileChildren($this->compiler);
+            if (is_a($add,'PEAR_Error')) {
+                return $add;
+            }
+            $ret .= $add;
         }
-    
-        if ((! empty($element->tag)) && (! empty($element->oTag)))
-        {
+        
+        
+        
+        // output the closing tag.
+        
+        if ($element->close) {
             $add = $element->close->compile($this->compiler);
             if (is_a($add,'PEAR_Error')) {
                 return $add;
             }
             $ret .= $add;
-            return;
-        } 
-        // RICK - added by me
-        // element has a seperate closing tag (eg. </something>) and opening and \
                closing tags should be removed 
-        // because FLEXY:OMITTAG element attribute is set, but still need postfix \
                stuff like for ending ifs and foreach
-        // so this is NOT OPTIONAL if foreach and if are not optional.
-        if ($element->close->postfix)  {
-            foreach ($element->close->postfix as $e)  {
-                $add = $e->compile($this->compiler);
-                if (is_a($add,'PEAR_Error'))  {
-                    return $add;
-                }
-                $ret .= $add;
-            }
-            return;
-        }  
-        if ($this->element->close->postfix)  { // if postfixed by self..
-            foreach ($this->element->close->postfix as $e)  {
-                $add = $e->compile($this->compiler);
-                if (is_a($add,'PEAR_Error'))  {
-                    return $add;
-                }
+        }
+        
+        // reset flexyignore
+        
+        $_HTML_TEMPLATE_FLEXY_TOKEN['flexyIgnore'] = $flexyignore;
+        
+        if (isset($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block']) && 
+            ($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block'] == \
$element->getAttribute('ID'))) { +                
+           // echo $_HTML_TEMPLATE_FLEXY['compiledTemplate'];
             
-                $ret .= $add;
-            }
-            return;
+            $fh = fopen($_HTML_TEMPLATE_FLEXY['compiledTemplate'],'w');
+            fwrite($fh,$ret);
+            fclose($fh);   
+           
         }
-		
-	}
-
-    
+            
+        
+        
+        return $ret;
+    }
     /**
     * Reads an flexy:foreach attribute - 
     *
@@ -926,7 +794,7 @@
                 echo  $element->toHtml();' . $unset; 
         
         }
-        return $ret . 'echo $this->elements[\''.$id.'\']->toHtml();'. $unset;
+        return $ret . 'echo $this->elements[\''.$id.'\']->toHtml();'. $unset;
         
     }
     
@@ -984,7 +852,7 @@
         
         // as a general rule, this uses name, rather than ID except on 
         // radio
-        $mergeWithName = false;
+        $mergeWithName = false;
         $id = $this->element->getAttribute('NAME');
         
         
@@ -998,12 +866,14 @@
             );
         }
         // checkboxes need more work.. - at the momemnt assume one with the same \
value... +   
+   
+   
         if (!in_array(strtoupper($this->element->getAttribute('TYPE')), \
array('RADIO'))) {  if (!$id) {
                 return false;
             }
             return $this->compiler->appendPhp($this->getElementPhp( \
                $id,$mergeWithName));
-             
         }
         // now we are only dealing with radio buttons.. which are a bit odd...
         
@@ -1027,7 +897,9 @@
         $mergeWithName = true;
          
         return $this->compiler->appendPhp($this->getElementPhp( \
                $id,$mergeWithName));
-
+        
+        
+        
     }
     
     /**
@@ -1153,7 +1025,7 @@
             return;
         }
         $this->element->ucAttributes[$which] = '"'. $new . '"';
-    } 
+    } 
     
     /**
     * Convert flexy tokens to HTML_Template_Flexy_Elements.
@@ -1208,7 +1080,7 @@
             $ret->children[] = \
$this->toElement($element->children[$i],$stripspaces);  }
         return $ret;
-    }
+    }
         
       /**
     * do the reverse of htmlspecialchars on an attribute..
@@ -1305,4 +1177,4 @@
 
 }
 
- 
+ 
\ No newline at end of file



-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic