Fixed admin/master merge

This commit is contained in:
franck
2013-07-06 11:09:24 +02:00
parent d3a505906b
commit 61fc13309d
2 changed files with 25 additions and 20 deletions

View File

@@ -43,6 +43,10 @@ class TheliaLoop implements SmartyPluginInterface
protected $dispatcher;
protected $varstack = array();
protected $loopstack = array();
public function __construct(Request $request, EventDispatcherInterface $dispatcher)
{
$this->request = $request;
@@ -62,7 +66,7 @@ class TheliaLoop implements SmartyPluginInterface
return null;
}
}
/**
* Process {loop name="loop name" type="loop type" ... } ... {/loop} block
*
@@ -98,7 +102,7 @@ class TheliaLoop implements SmartyPluginInterface
self::$pagination[$name] = null;
$loopResults = $loop->exec(self::$pagination[$name]);
$this->loopstack[$name] = $loopResults;
@@ -197,7 +201,7 @@ class TheliaLoop implements SmartyPluginInterface
return $this->checkEmptyLoop($params, $template) ? '' : $content;
}
}
/**
* Process {pageloop rel="loopname"} ... {/pageloop} block
*
@@ -213,41 +217,42 @@ class TheliaLoop implements SmartyPluginInterface
{
if (empty($params['rel']))
throw new \InvalidArgumentException("Missing 'rel' parameter in page loop");
$loopName = $params['rel'];
// Find loop results in the current template vars
$loopResults = $template->getTemplateVars($loopName);
$loopResults = $this->loopstack[$loopName];
if (empty($loopResults)) {
throw new \InvalidArgumentException("Loop $loopName is not defined.");
}
// Find pagination
$pagination = self::getPagination($loopName);
if ($pagination === null) {
throw new \InvalidArgumentException("Loop $loopName : no pagination found.");
}
if ($content === null) {
$page = 1;
} else {
$page = $template->getTemplateVars('PAGE');
$page++;
}
if ($page <= $pagination->getLastPage()) {
$template->assign('PAGE', $page);
$template->assign('CURRENT', $pagination->getPage());
$template->assign('LAST', $pagination->getLastPage());
$repeat = true;
}
if ($content !== null) {
return $content;
}
}
/**
* Check if a loop has returned results. The loop shoud have been executed before, or an
* InvalidArgumentException is thrown
@@ -317,7 +322,7 @@ class TheliaLoop implements SmartyPluginInterface
$faultDetails = array();
$argumentsCollection = $loop->getArgs();
foreach( $argumentsCollection as $argument ) {
$value = isset($smartyParam[$argument->name]) ? $smartyParam[$argument->name] : null;

View File

@@ -17,7 +17,7 @@ An image from asset directory :
<p>Category loop example</p>
<ul>
{loop type="category" name="catloop1"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}, children: {$NB_CHILD}
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}, children: {$NB_CHILD}
{ifloop rel="inner1"}
<ul>
{loop type="category" name="inner1" parent="{$ID}"}
@@ -40,7 +40,7 @@ An image from asset directory :
Hey ! Loop catloop2 is not empty:
<ul>
{loop type="category" name="catloop2" parent="12"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
</ul>
{/ifloop}
@@ -57,7 +57,7 @@ An image from asset directory :
Loop catloop3 is not empty:
<ul>
{loop type="category" name="catloop3" parent="0"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
</ul>
{/ifloop}
@@ -86,20 +86,20 @@ An image from asset directory :
<p>PAGE 1</p>
<ul>
{loop type="category" name="catloopwithpagination1" limit="2" page="1"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
</ul>
<p>PAGE 2</p>
<ul>
{loop type="category" name="catloopwithpagination2" limit="2" page="2"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
</ul>
<p>PAGE 1000</p>
<ul>
{loop type="category" name="catloopwithpagination1000" limit="2" page="1000"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
{elseloop rel="catloopwithpagination1000"}
@@ -114,7 +114,7 @@ An image from asset directory :
<p>PAGE {$current_page} :</p>
<ul>
{loop type="category" name="catloopwithpaginationchoice" limit="2" page="{$current_page}"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}</li>
<li>{$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}</li>
{/loop}
</ul>
<p>page choice</p>