/** * Returns an array with pages data for view * * @param AM_Model_Db_Page $oPage * @return array */ public static function parsePage(AM_Model_Db_Page $oPage) { $aPage = $oPage->toArray(); $aPage['tpl_title'] = $oPage->getTemplate()->description; $aPage['has_left'] = $oPage->hasConnection(AM_Model_Db_Page::LINK_LEFT); $aPage['has_right'] = $oPage->hasConnection(AM_Model_Db_Page::LINK_RIGHT); $aPage['has_top'] = $oPage->hasConnection(AM_Model_Db_Page::LINK_TOP); $aPage['has_bottom'] = $oPage->hasConnection(AM_Model_Db_Page::LINK_BOTTOM); //Restrict user to add left and right childs in pages which have bottom or top parent $aPage['tpl']['has_left'] = $oPage->getLinkType() != AM_Model_Db_Page::LINK_RIGHT && !is_null($oPage->getLinkType()) ? 0 : $oPage->getTemplate()->has_left_connector; $aPage['tpl']['has_right'] = $oPage->getLinkType() != AM_Model_Db_Page::LINK_RIGHT && !is_null($oPage->getLinkType()) ? 0 : $oPage->getTemplate()->has_right_connector; $aPage['tpl']['has_top'] = $oPage->getTemplate()->has_top_connector; $aPage['tpl']['has_bottom'] = $oPage->getTemplate()->has_bottom_connector; $oPageRoot = $oPage->getParent(); if (!is_null($oPageRoot)) { $sLinkType = $oPage->reverseLinkType($oPage->getLinkType()); $aPage[$sLinkType] = $oPageRoot->id; $aPage['jumper_' . $sLinkType] = $oPage->getLinkType(); //The direction of the arrow in the pages tree } foreach ($oPage->getChilds() as $oPageChild) { $sLinkType = $oPageChild->getLinkType(); $aPage[$sLinkType] = $oPageChild->id; $aPage['jumper_' . $sLinkType] = $sLinkType; //The direction of the arrow in the pages tree } $aPage['link_type'] = $oPage->getLinkType(); $aPage['thumbnailUri'] = $oPage->getPageBackgroundUri(); return $aPage; }