Skip to content

Commit

Permalink
Fixed nesting > 2 levels.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Ghita committed Jul 10, 2012
1 parent 72cd873 commit 1101670
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions data-sources/data.plh_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public function grab(&$param_pool = NULL){
$fields[] = "plh_h-{$lc}";
}

$result->appendChild(
$this->_addPageXML(FLPageManager::instance()->listAll($fields), $this->_env['param']['current-page-id'], $langs)
);
$r = null;
$this->_addPageXML(FLPageManager::instance()->listAll($fields), $this->_env['param']['current-page-id'], $langs, $r);

$result->appendChild($r);

return $result;
}
Expand All @@ -48,10 +49,11 @@ public function grab(&$param_pool = NULL){
* @param array $pages - contains all pages data
* @param $page_id - current page id
* @param $langs - all supported language codes
* @param $r - resulting XML
*
* @return XMLElement - a pages XML ouput
*/
private function _addPageXML($pages, $page_id, $langs){
private function _addPageXML($pages, $page_id, $langs, &$r = null){
$pageXML = new XMLElement('page', null, array(
'handle' => $pages[$page_id]['handle'],
'id' => $page_id
Expand All @@ -72,16 +74,16 @@ private function _addPageXML($pages, $page_id, $langs){
$pageXML->prependChild($itemXML);
}

if( $r !== null ){
$pageXML->appendChild($r);
}

// if it has a parent, generate it, append current page and return parent
if( !empty($pages[$page_id]['parent']) ){
$parentXML = $this->_addPageXML($pages, $pages[$page_id]['parent'], $langs);
$parentXML->appendChild($pageXML);

return $parentXML;
$this->_addPageXML($pages, $pages[$page_id]['parent'], $langs, $pageXML);
}

// return this page
return $pageXML;
$r = $pageXML;
}

}

0 comments on commit 1101670

Please sign in to comment.