<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,28 +9,88 @@ class TalCondition_PXHTMLNode extends PXHTMLNode {
         $attr = $node-&gt;getAttribute('tal:condition');
         $attr = str_replace(';;', ';', $attr);
         
-        // check for &quot;not&quot;. If found, wrap the segment in a not execution
-        $not = FALSE;
-        if (stripos($attr, 'not:') === 0) {
-            $attr = trim(substr($attr, 4));
-            $not = TRUE;
+        $terms = preg_split('/(([\s]+and[\s]+)|([\s]+or[\s]+))/', $attr, -1, PREG_SPLIT_OFFSET_CAPTURE);
+
+        $ifs = array();
+        $endphps = array();
+        $phps = array();
+        foreach ($terms as $idx =&gt; $term_info) {
+            $term = $term_info[0];
+            $pos = $term_info[1];
+            
+            // check for &quot;not&quot;. If found, wrap the segment in a not execution
+            $not = FALSE;
+            if (stripos($attr, 'not:') === 0) {
+                $attr = trim(substr($attr, 4));
+                $not = TRUE;
+            }
+            
+            $c = $this-&gt;createLocalVariable();
+            
+            $str = 'try {';
+            if ($not) {
+                $str .= $this-&gt;processTales($term, $c.' = (%s) ? FALSE : TRUE;', TRUE);
+            }
+            else {
+                $str .= $this-&gt;processTales($term, $c.' = (%s) ? TRUE : FALSE;', TRUE);
+            }
+            $str .= '} catch (Exception $e) { '.$c.' = FALSE; }';
+            $phps[] = $str;
+            $endphps[] = 'unset('.$c.');';
+
+            // get the closest occurance of &quot;and&quot; or &quot;or&quot;
+            $and_pos = strrpos(substr($attr, 0, $pos), ' and ');
+            $or_pos = strrpos(substr($attr, 0, $pos), ' or ');
+            
+            if ($and_pos &lt; $or_pos &amp;&amp; $pos &gt; 0) { // if &quot;or&quot; is after &quot;and&quot;
+                $ifs[] = ' || '.$c;
+            }
+            elseif ($or_pos &lt; $and_pos &amp;&amp; $pos &gt; 0) { // if &quot;and&quot; is after &quot;or&quot;
+                $ifs[] = ' &amp;&amp; '.$c;
+            }
+            else { // neither &quot;and&quot; nor &quot;or&quot;
+                $ifs[] = $c;
+            }
         }
         
-        // convert the tales expression into a php statement
-        $c = $this-&gt;createLocalVariable();
-        $str = 'try {';
-        $str .= $this-&gt;processTales($attr, $c.' = (%s) ? TRUE : FALSE;', TRUE);
-        $str .= '} catch (Exception $e) { '.$c.' = FALSE; }';
+        $statement_begin = implode('', array(
+            implode('', $phps),
+            'if ('.implode($ifs).') {',
+        ));
         
-        if ($not) {
-            $str .= 'if (!('.$c.')) {';
-        }
-        else {
-            $str .= 'if ('.$c.') {';
-        }
+        $statement_end = implode('', array(
+            '}',
+            implode('', $endphps),
+        ));
+        
+        // var_dump($statement_begin);
+        // var_dump($statement_end);
+        
+        $php_inst_st = $this-&gt;createProcessingInstruction($statement_begin);
+        $php_inst_ed = $this-&gt;createProcessingInstruction($statement_end);
+        
+        // // check for &quot;not&quot;. If found, wrap the segment in a not execution
+        // $not = FALSE;
+        // if (stripos($attr, 'not:') === 0) {
+        //     $attr = trim(substr($attr, 4));
+        //     $not = TRUE;
+        // }
+        // 
+        // // convert the tales expression into a php statement
+        // $c = $this-&gt;createLocalVariable();
+        // $str = 'try {';
+        // $str .= $this-&gt;processTales($attr, $c.' = (%s) ? TRUE : FALSE;', TRUE);
+        // $str .= '} catch (Exception $e) { '.$c.' = FALSE; }';
+        // 
+        // if ($not) {
+        //     $str .= 'if (!('.$c.')) {';
+        // }
+        // else {
+        //     $str .= 'if ('.$c.') {';
+        // }
         
-        $php_inst_st = $this-&gt;createProcessingInstruction($str);
-        $php_inst_ed = $this-&gt;createProcessingInstruction('} unset('.$c.');');
+        // $php_inst_st = $this-&gt;createProcessingInstruction($str);
+        // $php_inst_ed = $this-&gt;createProcessingInstruction('} unset('.$c.');');
         
         $node-&gt;parentNode-&gt;insertBefore($php_inst_st, $node);
         </diff>
      <filename>apps/chippino/template/classes/node/tal/condition.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d8b0a83ae5e825e14f8c3d87148c485c4d5474fe</id>
    </parent>
  </parents>
  <author>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </author>
  <url>http://github.com/Jakobo/chippino/commit/c04c030164f0b70ff58e9a6b43b27799ebf98bbc</url>
  <id>c04c030164f0b70ff58e9a6b43b27799ebf98bbc</id>
  <committed-date>2009-04-17T09:07:42-07:00</committed-date>
  <authored-date>2009-04-17T09:07:42-07:00</authored-date>
  <message>rewrote the way conditionals are formed to support 'and' and 'or' support, as well as 'not' tags on individual clauses</message>
  <tree>8fc7d10dc09eee6216348d23e75e74749d5c8895</tree>
  <committer>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </committer>
</commit>
