[limb-svn] r6759 - in 3.x/trunk/limb/macro: src/tags/list src/tags/pager tests/cases/tags/list tests/cases/tags/pager
svn at limb-project.com
svn at limb-project.com
Wed Jan 30 11:15:29 MSK 2008
Author: serega
Date: 2008-01-30 11:15:29 +0300 (Wed, 30 Jan 2008)
New Revision: 6759
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6759
Modified:
3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php
3.x/trunk/limb/macro/src/tags/pager/lmbMacroPagerHelper.class.php
3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/pager/lmbMacroPagerHelperTest.class.php
Log:
-- fix for "using" attribute in {{list}} tag
-- lmbMacroPagerHelper :: getCurrentPageOffset() added
Modified: 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php 2008-01-29 13:30:01 UTC (rev 6758)
+++ 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php 2008-01-30 08:15:29 UTC (rev 6759)
@@ -18,6 +18,14 @@
*/
class lmbMacroListFillTag extends lmbMacroTag
{
+ function preParse($compiler)
+ {
+ $list = $this->findParentByClass('lmbMacroListTag');
+ $list->countSource();
+
+ return parent :: preParse($compiler);
+ }
+
protected function _generateContent($code)
{
$ratio_var = $code->generateVar();
Modified: 3.x/trunk/limb/macro/src/tags/pager/lmbMacroPagerHelper.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/pager/lmbMacroPagerHelper.class.php 2008-01-29 13:30:01 UTC (rev 6758)
+++ 3.x/trunk/limb/macro/src/tags/pager/lmbMacroPagerHelper.class.php 2008-01-30 08:15:29 UTC (rev 6759)
@@ -123,6 +123,15 @@
return $this->items_per_page * ($this->current_page - 1) + 1;
}
+
+ function getCurrentPageOffset()
+ {
+ $number = $this->getCurrentPageBeginItem();
+ if(!$number)
+ return 0;
+ else
+ return $number - 1;
+ }
function getCurrentPageEndItem()
{
Modified: 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php 2008-01-29 13:30:01 UTC (rev 6758)
+++ 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php 2008-01-30 08:15:29 UTC (rev 6759)
@@ -236,5 +236,25 @@
$this->assertEqual($macro->render(), '');
}
+
+
+ function testListFillTag_WithoutGlueTag_AndListHasTheSameNumberOfItemsAndFillTagUpTo()
+ {
+ $list = '{{list using="$#list" as="$item"}}List#'.
+ '{{list:item}}{$item}'.
+ '{{/list:item}}'.
+ '{{list:fill upto="3" items_left="$items_left"}}{$items_left}{{/list:fill}}'.
+ '{{/list}}';
+
+ $list_tpl = $this->_createTemplate($list, 'list.html');
+
+ $macro = $this->_createMacro($list_tpl);
+ lmb_require('limb/core/src/lmbArrayIterator.class.php');
+ $list = new lmbArrayIterator(array('John', 'Pavel', 'Serega', 'Viktor'));
+ $list->paginate(0, 3);
+ $macro->set('list', $list);
+
+ $this->assertEqual($macro->render(), 'List#JohnPavelSerega');
+ }
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/pager/lmbMacroPagerHelperTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/pager/lmbMacroPagerHelperTest.class.php 2008-01-29 13:30:01 UTC (rev 6758)
+++ 3.x/trunk/limb/macro/tests/cases/tags/pager/lmbMacroPagerHelperTest.class.php 2008-01-30 08:15:29 UTC (rev 6759)
@@ -55,6 +55,7 @@
$this->assertTrue($this->pager->hasPrev());
$this->assertEqual($this->pager->getCurrentPageBeginItem(), 11);
$this->assertEqual($this->pager->getCurrentPageEndItem(), 20);
+ $this->assertEqual($this->pager->getCurrentPageOffset(), 10);
}
function testGettingCurrentPageWithGetIfCurrentPageWasNotSet()
@@ -79,6 +80,7 @@
$this->assertTrue($this->pager->hasPrev());
$this->assertEqual($this->pager->getCurrentPageBeginItem(), 11);
$this->assertEqual($this->pager->getCurrentPageEndItem(), 20);
+ $this->assertEqual($this->pager->getCurrentPageOffset(), 10);
}
function testTotalItemsZero()
@@ -101,6 +103,7 @@
$this->assertFalse($this->pager->hasPrev());
$this->assertEqual($this->pager->getCurrentPageBeginItem(), 0);
$this->assertEqual($this->pager->getCurrentPageEndItem(), 0);
+ $this->assertEqual($this->pager->getCurrentPageOffset(), 0);
}
function testNextPage()
More information about the limb-svn
mailing list