public function getPrevNextPage($idPage, $publishedOnly = 1) {
	
	    $output = array(
	        'prev' => null,
	        'next' => null
	    );
	
	    $melisPage = $this->getServiceLocator()->get('MelisEnginePage');
	    $datasPagePublished = $melisPage->getDatasPage($idPage, 'published');
	    $datasPagePublishedTree = $datasPagePublished->getMelisPageTree();
	
	    $melisTree = $this->getServiceLocator()->get('MelisEngineTree');
	    $sisters = $melisTree->getPageChildren($datasPagePublishedTree->tree_father_page_id, $publishedOnly);
	    $sisters = $sisters->toArray();
	
	    if(!empty($sisters)) {
	
	        // Get column list for sort
	        foreach ($sisters as $key => $row) {
	            $order[$key]  = $row['tree_page_order'];
	        }
	
	        // Sort sisters pages by order field
	        array_multisort($order, SORT_ASC, $sisters);
	
	        $posInArray = false;
	
	        foreach($sisters as $key => $uneSister) {
	            if($uneSister['tree_page_id'] == $datasPagePublishedTree->tree_page_id)
	                $posInArray = $key;
	        }
	
	        // If page found, get prev/next
	        if($posInArray !== false) {
	
	            $posPrevPage = (($posInArray-1) >= 0) ? ($posInArray-1) : null;
	            $posNextPage = (($posInArray+1) && array_key_exists($posInArray+1, $sisters)) ? ($posInArray+1) : null;
	
	            if(!is_null($posPrevPage)) {
	
	                $prevItem = $sisters[$posPrevPage];
	                $prevLink = $melisTree->getPageLink($sisters[$posPrevPage]['tree_page_id']);
	
	                // Check if page have a name and link
	                if(!empty($prevItem['page_name']) && !empty($prevLink)) {
	                    $output['prev'] = $prevItem;
	                    $output['prev']['link'] = $prevLink;
	                }
	            }
	
	            if(!is_null($posNextPage)) {
	
	                $nextItem = $sisters[$posNextPage];
	                $nextLink = $melisTree->getPageLink($sisters[$posNextPage]['tree_page_id']);
	
	                // Check if page have a name and link
	                if(!empty($nextItem['page_name']) && !empty($nextLink)) {
	                    $output['next'] = $nextItem;
	                    $output['next']['link'] = $nextLink;
	                }
	            }
	        }
	    }
	
	    return $output;
	}
public function getPrevNextPage($idPage, $publishedOnly = 1) {
	
	    $output = array(
	        'prev' => null,
	        'next' => null
	    );
	
	    $melisPage = $this->getServiceLocator()->get('MelisEnginePage');
	    $datasPagePublished = $melisPage->getDatasPage($idPage, 'published');
	    $datasPagePublishedTree = $datasPagePublished->getMelisPageTree();
	
	    $melisTree = $this->getServiceLocator()->get('MelisEngineTree');
	    $sisters = $melisTree->getPageChildren($datasPagePublishedTree->tree_father_page_id, $publishedOnly);
	    $sisters = $sisters->toArray();
	
	    if(!empty($sisters)) {
	
	        // Get column list for sort
	        foreach ($sisters as $key => $row) {
	            $order[$key]  = $row['tree_page_order'];
	        }
	
	        // Sort sisters pages by order field
	        array_multisort($order, SORT_ASC, $sisters);
	
	        $posInArray = false;
	
	        foreach($sisters as $key => $uneSister) {
	            if($uneSister['tree_page_id'] == $datasPagePublishedTree->tree_page_id)
	                $posInArray = $key;
	        }
	
	        // If page found, get prev/next
	        if($posInArray !== false) {
	
	            $posPrevPage = (($posInArray-1) >= 0) ? ($posInArray-1) : null;
	            $posNextPage = (($posInArray+1) && array_key_exists($posInArray+1, $sisters)) ? ($posInArray+1) : null;
	
	            if(!is_null($posPrevPage)) {
	
	                $prevItem = $sisters[$posPrevPage];
	                $prevLink = $melisTree->getPageLink($sisters[$posPrevPage]['tree_page_id']);
	
	                // Check if page have a name and link
	                if(!empty($prevItem['page_name']) && !empty($prevLink)) {
	                    $output['prev'] = $prevItem;
	                    $output['prev']['link'] = $prevLink;
	                }
	            }
	
	            if(!is_null($posNextPage)) {
	
	                $nextItem = $sisters[$posNextPage];
	                $nextLink = $melisTree->getPageLink($sisters[$posNextPage]['tree_page_id']);
	
	                // Check if page have a name and link
	                if(!empty($nextItem['page_name']) && !empty($nextLink)) {
	                    $output['next'] = $nextItem;
	                    $output['next']['link'] = $nextLink;
	                }
	            }
	        }
	    }
	
	    return $output;
	}
public function getPrevNextPage ( $ idPage , $ publishedOnly = 1 ) { $ output = array ( 'prev' => null , 'next' => null ) ; $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasPagePublished = $ melisPage -> getDatasPage ( $ idPage , 'published' ) ; $ datasPagePublishedTree = $ datasPagePublished -> getMelisPageTree ( ) ; $ melisTree = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTree' ) ; $ sisters = $ melisTree -> getPageChildren ( $ datasPagePublishedTree -> tree_father_page_id , $ publishedOnly ) ; $ sisters = $ sisters -> toArray ( ) ; if ( ! empty ( $ sisters ) ) { // Get column list for sort foreach ( $ sisters as $ key => $ row ) { $ order [ $ key ] = $ row [ 'tree_page_order' ] ; } // Sort sisters pages by order field array_multisort ( $ order , SORT_ASC , $ sisters ) ; $ posInArray = false ; foreach ( $ sisters as $ key => $ uneSister ) { if ( $ uneSister [ 'tree_page_id' ] == $ datasPagePublishedTree -> tree_page_id ) $ posInArray = $ key ; } // If page found, get prev/next if ( $ posInArray !== false ) { $ posPrevPage = ( ( $ posInArray - 1 ) >= 0 ) ? ( $ posInArray - 1 ) : null ; $ posNextPage = ( ( $ posInArray + 1 ) && array_key_exists ( $ posInArray + 1 , $ sisters ) ) ? ( $ posInArray + 1 ) : null ; if ( ! is_null ( $ posPrevPage ) ) { $ prevItem = $ sisters [ $ posPrevPage ] ; $ prevLink = $ melisTree -> getPageLink ( $ sisters [ $ posPrevPage ] [ 'tree_page_id' ] ) ; // Check if page have a name and link if ( ! empty ( $ prevItem [ 'page_name' ] ) && ! empty ( $ prevLink ) ) { $ output [ 'prev' ] = $ prevItem ; $ output [ 'prev' ] [ 'link' ] = $ prevLink ; } } if ( ! is_null ( $ posNextPage ) ) { $ nextItem = $ sisters [ $ posNextPage ] ; $ nextLink = $ melisTree -> getPageLink ( $ sisters [ $ posNextPage ] [ 'tree_page_id' ] ) ; // Check if page have a name and link if ( ! empty ( $ nextItem [ 'page_name' ] ) && ! empty ( $ nextLink ) ) { $ output [ 'next' ] = $ nextItem ; $ output [ 'next' ] [ 'link' ] = $ nextLink ; } } } } return $ output ; }
Gets the previous and next page for a specific page in the treeview

@param int $idPage The page id
@param int $publishedOnly Only active pages will be taken in consideration
Gets the previous and next page for a specific page in the treeview