Author: as
Date: Tue Jan  8 13:32:58 2008
New Revision: 7101

Log:
- Fixed issue #11056:
  * {dynamic} is only allowed after {cache_template} or in {cache_block}.
  * corrected documentation in regard to TTL vs. ttl.

Added:
    trunk/Template/tests/templates/cache_dynamic_after_cache_block.tpl   (with 
props)
    trunk/Template/tests/templates/cache_dynamic_before_cache_block.tpl   (with 
props)
    trunk/Template/tests/templates/cache_dynamic_in_block_after_cache_block.tpl 
  (with props)
    
trunk/Template/tests/templates/cache_dynamic_in_block_before_cache_block.tpl   
(with props)
    
trunk/Template/tests/templates/cache_dynamic_in_include_after_cache_template.tpl
   (with props)
    trunk/Template/tests/templates/cache_dynamic_in_include_in_cache_block.tpl  
 (with props)
    trunk/Template/tests/templates/cache_template_after_dynamic.tpl   (with 
props)
    trunk/Template/tests/templates/cache_template_after_dynamic_in_block.tpl   
(with props)
    trunk/Template/tests/templates/dynamic_included.tpl   (with props)
Modified:
    trunk/Template/ChangeLog
    trunk/Template/src/syntax_trees/tst/nodes/dynamic_block.php
    trunk/Template/tests/cache_test.php

Modified: trunk/Template/ChangeLog
==============================================================================
--- trunk/Template/ChangeLog [iso-8859-1] (original)
+++ trunk/Template/ChangeLog [iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -10,6 +10,10 @@
   defined.
 - Fixed issue #12323: Using {cache_template} inside a block will now throw an
   exception.
+- Fixed issue #11056:
+
+  * {dynamic} is only allowed after {cache_template} or in {cache_block}.
+  * corrected documentation in regard to TTL vs. ttl.
 
 
 1.2 - Monday 02 July 2007

Modified: trunk/Template/src/syntax_trees/tst/nodes/dynamic_block.php
==============================================================================
--- trunk/Template/src/syntax_trees/tst/nodes/dynamic_block.php [iso-8859-1] 
(original)
+++ trunk/Template/src/syntax_trees/tst/nodes/dynamic_block.php [iso-8859-1] 
Tue Jan  8 13:32:58 2008
@@ -26,11 +26,50 @@
     public function __construct( ezcTemplateSourceCode $source, 
/*ezcTemplateCursor*/ $start, /*ezcTemplateCursor*/ $end )
     {
         parent::__construct( $source, $start, $end );
+        $this->name = 'dynamic';
     }
 
     public function getTreeProperties()
     {
         return array( );
     }
+
+    /**
+     * Checks if the given node can be attached to its parent.
+     *
+     * @throws ezcTemplateParserException if the node cannot be attached.
+     * @param ezcTemplateTstNode $parentElement
+     * @return void
+     */
+    public function canAttachToParent( $parentElement )
+    {
+        // Must at least have one parent with cache_block, or be after 
cache_template
+
+        $p = $parentElement;
+
+        while ( !$p instanceof ezcTemplateProgramTstNode )
+        {
+            if ( $p instanceof ezcTemplateCacheBlockTstNode )
+            {
+                return; // Perfect, we are inside a cache_block
+            }
+
+            $p = $p->parentBlock;
+        }
+
+        if ( $p instanceof ezcTemplateProgramTstNode )
+        {
+            foreach ( $p->children as $node )
+            {
+                if ( $node instanceof ezcTemplateCacheTstNode )
+                {
+                    return; // Perfect, we are after cache_template
+                }
+            }
+        }
+
+        throw new ezcTemplateParserException( $this->source, 
$this->startCursor, $this->startCursor, 
+            "{" . $this->name . "} can only be a child of {cache_template} or 
a {cache_block} block." );
+    }
 }
 ?>

Modified: trunk/Template/tests/cache_test.php
==============================================================================
--- trunk/Template/tests/cache_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/cache_test.php [iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -462,6 +462,126 @@
         catch ( Exception $e )
         {
             $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{cache_template} cannot be declared inside a template block' ) );
+        }
+    }
+
+    public function testCacheTemplateAfterDynamic()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( "cache_template_after_dynamic.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheTemplateAfterDynamicInBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( "cache_template_after_dynamic_in_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicBeforeCacheBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( "cache_dynamic_before_cache_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicAfterCacheBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( "cache_dynamic_after_cache_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicInBlockBeforeCacheBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( 
"cache_dynamic_in_block_before_cache_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicInBlockAfterCacheBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( 
"cache_dynamic_in_block_after_cache_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicInIncludeInCacheBlock()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( "cache_dynamic_in_include_in_cache_block.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
+        }
+    }
+
+    public function testCacheDynamicInIncludeAfterCacheTemplate()
+    {
+        $t = new ezcTemplate();
+
+        try
+        {
+            $out = $t->process( 
"cache_dynamic_in_include_after_cache_template.tpl");
+            $this->fail("Expected an exception");
+        } 
+        catch ( ezcTemplateParserException $e )
+        {
+            $this->assertNotEquals( false, strpos( $e->getMessage(), 
'{dynamic} can only be a child of {cache_template} or a {cache_block} block' ) 
);
         }
     }
 

Added: trunk/Template/tests/templates/cache_dynamic_after_cache_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_dynamic_after_cache_block.tpl (added)
+++ trunk/Template/tests/templates/cache_dynamic_after_cache_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,7 @@
+{cache_block}
+[cached]
+{/cache_block}
+
+{dynamic}
+[dynamic]
+{/dynamic}

Propchange: trunk/Template/tests/templates/cache_dynamic_after_cache_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Template/tests/templates/cache_dynamic_before_cache_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_dynamic_before_cache_block.tpl (added)
+++ trunk/Template/tests/templates/cache_dynamic_before_cache_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,7 @@
+{dynamic}
+[dynamic]
+{/dynamic}
+
+{cache_block}
+[cached]
+{/cache_block}

Propchange: trunk/Template/tests/templates/cache_dynamic_before_cache_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
trunk/Template/tests/templates/cache_dynamic_in_block_after_cache_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_dynamic_in_block_after_cache_block.tpl 
(added)
+++ trunk/Template/tests/templates/cache_dynamic_in_block_after_cache_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,9 @@
+{cache_block}
+[cached]
+{/cache_block}
+
+{if true}
+{dynamic}
+[dynamic]
+{/dynamic}
+{/if}

Propchange: 
trunk/Template/tests/templates/cache_dynamic_in_block_after_cache_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
trunk/Template/tests/templates/cache_dynamic_in_block_before_cache_block.tpl
==============================================================================
--- 
trunk/Template/tests/templates/cache_dynamic_in_block_before_cache_block.tpl 
(added)
+++ 
trunk/Template/tests/templates/cache_dynamic_in_block_before_cache_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,9 @@
+{if true}
+{dynamic}
+[dynamic]
+{/dynamic}
+{/if}
+
+{cache_block}
+[cached]
+{/cache_block}

Propchange: 
trunk/Template/tests/templates/cache_dynamic_in_block_before_cache_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
trunk/Template/tests/templates/cache_dynamic_in_include_after_cache_template.tpl
==============================================================================
--- 
trunk/Template/tests/templates/cache_dynamic_in_include_after_cache_template.tpl
 (added)
+++ 
trunk/Template/tests/templates/cache_dynamic_in_include_after_cache_template.tpl
 [iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,3 @@
+{cache_template}
+[cached]
+{include "dynamic_included.tpl"}

Propchange: 
trunk/Template/tests/templates/cache_dynamic_in_include_after_cache_template.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
trunk/Template/tests/templates/cache_dynamic_in_include_in_cache_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_dynamic_in_include_in_cache_block.tpl 
(added)
+++ trunk/Template/tests/templates/cache_dynamic_in_include_in_cache_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,4 @@
+{cache_block}
+[cached]
+{include "dynamic_included.tpl"}
+{/cache_block}

Propchange: 
trunk/Template/tests/templates/cache_dynamic_in_include_in_cache_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Template/tests/templates/cache_template_after_dynamic.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_template_after_dynamic.tpl (added)
+++ trunk/Template/tests/templates/cache_template_after_dynamic.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,6 @@
+{dynamic}
+[dynamic]
+{/dynamic}
+
+{cache_template}
+[cached]

Propchange: trunk/Template/tests/templates/cache_template_after_dynamic.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Template/tests/templates/cache_template_after_dynamic_in_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_template_after_dynamic_in_block.tpl 
(added)
+++ trunk/Template/tests/templates/cache_template_after_dynamic_in_block.tpl 
[iso-8859-1] Tue Jan  8 13:32:58 2008
@@ -1,0 +1,8 @@
+{if true}
+{dynamic}
+[dynamic]
+{/dynamic}
+{/if}
+
+{cache_template}
+[cached]

Propchange: 
trunk/Template/tests/templates/cache_template_after_dynamic_in_block.tpl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Template/tests/templates/dynamic_included.tpl
==============================================================================
--- trunk/Template/tests/templates/dynamic_included.tpl (added)
+++ trunk/Template/tests/templates/dynamic_included.tpl [iso-8859-1] Tue Jan  8 
13:32:58 2008
@@ -1,0 +1,4 @@
+{* dynamic in an include follows the same rules as dynamic in the main 
template *}
+{dynamic}
+[dynamic]
+{/dynamic}

Propchange: trunk/Template/tests/templates/dynamic_included.tpl
------------------------------------------------------------------------------
    svn:eol-style = native


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to