Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Fixing bug with not-working opt:gridelse.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxist committed Oct 13, 2010
1 parent ec9336e commit 46e2208
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Instruction/Grid.php
Expand Up @@ -58,10 +58,11 @@ private function _processGrid(Opt_Xml_Node $node)
$node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, '$_'.$section['name'].'_rows = ceil('.$section['format']->get('section:count').' / '.$section['cols'].'); $_'.$section['name'].'_remain = ('.$section['cols'].
' - ('.$section['format']->get('section:count').' % '.$section['cols'].')) % '.$section['cols'].'; '.$section['format']->get('section:loopBefore').' '.$section['format']->get('section:reset').' '.
' for($_'.$section['name'].'_j = 0; $_'.$section['name'].'_j < $_'.$section['name'].'_rows; $_'.$section['name'].'_j++){ ');
$node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');


$emptyItemNode[0]->set('priv:section-validity', $section['format']->get('section:valid'));

$node->set('postprocess', true);
$this->_process($node);
} // end _processGrid();

Expand Down Expand Up @@ -108,10 +109,14 @@ private function _postprocessGrid(Opt_Xml_Element $node)
$section = $node->get('priv:section');
if($node->hasAttributes())
{
if(!$node->get('priv:alternative'))
if($node->get('priv:alternative'))
{
$this->_sortSectionContents($node, 'opt', 'gridelse');
}
else
{
$node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
}
}

} // end _postprocessGrid();
Expand All @@ -135,7 +140,7 @@ private function _processGridelse(Opt_Xml_Element $node)
$parent->set('priv:alternative', true);

$section = $parent->get('priv:section');
$node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' } else { ');
$node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' } } else { ');
// $this->_deactivateSection($parent->get('sectionName'));
$this->_process($node);
}
Expand Down
23 changes: 23 additions & 0 deletions tests/instruction/grid_10.txt
@@ -0,0 +1,23 @@
The test checks the basic opt:grid functionality with opt:gridelse.

>>>>templates/test.tpl
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:root>
<opt:grid name="items" cols="3">
:ROW START
<opt:item>
{$items.foo}
</opt:item>
<opt:emptyItem>
Empty
</opt:emptyItem>
:ROW END
<opt:gridelse>No data</opt:gridelse>
</opt:grid>
</opt:root>

>>>>expected.txt
OUTPUT

>>>>result.txt
No data
1 change: 1 addition & 0 deletions tests/instructionTest.php
Expand Up @@ -148,6 +148,7 @@ public static function correctProvider()
array('grid_7.txt'),
array('grid_8.txt'),
array('grid_9.txt'),
array('grid_10.txt'),
array('if_1.txt'),
array('if_2.txt'),
array('if_3.txt'),
Expand Down

0 comments on commit 46e2208

Please sign in to comment.