Merge pull request #5658 from kinglozzer/5656-up-top

FIX: Regression with <% with $Up/$Top %> (fixes #5656)
This commit is contained in:
Daniel Hensby 2016-06-06 11:21:14 +01:00
commit f9ad2e2bbe
3 changed files with 24 additions and 6 deletions

View File

@ -0,0 +1 @@
$Title<% with $Item %> - <% with $Up %>$Title<% end_with %> - <% with $NestedItem %><% with $Top %>$Title<% end_with %><% end_with %><% end_with %>

View File

@ -726,6 +726,16 @@ after')
'A - B - C - B - A'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeScopeInheritanceWithUpAndTop Title="A" %>',
new ArrayData(array(
'Item' => new ArrayData(array(
'Title' =>'B', 'NestedItem' => new ArrayData(array('Title' => 'C'))
)))
)),
'A - A - A'
);
$data = new ArrayData(array(
'Nested' => new ArrayData(array(
'Object' => new ArrayData(array('Key' => 'A'))

View File

@ -558,12 +558,15 @@ class SSViewer_DataPresenter extends SSViewer_Scope {
*/
public function pushScope() {
$scope = parent::pushScope();
$upIndex = $this->getUpIndex();
$itemStack = $this->getItemStack();
$itemStack[$this->getUpIndex()][SSViewer_Scope::ITEM_OVERLAY] = $this->overlay;
if ($upIndex !== null) {
$itemStack = $this->getItemStack();
$itemStack[$upIndex][SSViewer_Scope::ITEM_OVERLAY] = $this->overlay;
$this->setItemStack($itemStack);
$this->overlay = array();
$this->setItemStack($itemStack);
$this->overlay = array();
}
return $scope;
}
@ -575,8 +578,12 @@ class SSViewer_DataPresenter extends SSViewer_Scope {
* @return SSViewer_Scope
*/
public function popScope() {
$itemStack = $this->getItemStack();
$this->overlay = $itemStack[$this->getUpIndex()][SSViewer_Scope::ITEM_OVERLAY];
$upIndex = $this->getUpIndex();
if ($upIndex !== null) {
$itemStack = $this->getItemStack();
$this->overlay = $itemStack[$this->getUpIndex()][SSViewer_Scope::ITEM_OVERLAY];
}
return parent::popScope();
}