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
12184
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;
	}
999201
public function setPageDeleted(
        PageEntity $page,
        string $modifiedByUserId,
        string $modifiedReason = Tracking::UNKNOWN_REASON
    ) {
        $pageType = $page->getPageType();

        if (strpos($pageType, self::PAGE_TYPE_DELETED) !== false) {
            return;//This page is already deleted so we don't need to do anything further
        }

        $page->setPageType(self::PAGE_TYPE_DELETED . $pageType);
        $page->setModifiedByUserId(
            $modifiedByUserId,
            $modifiedReason
        );

        $this->_em->persist($page);
        $this->_em->flush($page);
    }
95700
public function versionPickerAction($id, $current, $published = 0)
    {
        if ($this->getDoctrine()->getManager()->getFilters()->isEnabled('draftversion')) {
            $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');
        }

        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');
        $block   = $manager->find($id);

        $logEntries = $manager->getRootVersions($block);

        return $this->render('OpiferContentBundle:Editor:version_picker.html.twig', ['logentries' => $logEntries, 'current' => $current, 'published' => $published]);
    }
1202038
public function getGuildMember4GuildId($id, $page = 1)
    {
        $memberList = $this->getGuildMemberList4GuildId($id);

        $result = null;
        if ($memberList) {
            $result = $this->getPaginator4QueryBuilder($memberList, $page);
        }

        return $result;
    }
192935
public function _INDEX_NewPage(&$page)
    {
        if ($page) {
            $oldPage = $this->pdf->getPage();
            $this->pdf->setPage($page);
            $this->pdf->SetXY($this->_margeLeft, $this->_margeTop);
            $this->_maxH = 0;
            $page++;
            return $oldPage;
        } else {
            $this->_setNewPage();
            return null;
        }
    }
1269669
protected function getRevisionList(
        $published = false,
        $limit = 10
    ) {
        $revisions = $this->findRevisionList->__invoke(
            $this->currentSite->getSiteId(),
            $this->page->getName(),
            $this->page->getPageType(),
            $published,
            $limit
        );

        return $revisions;
    }
1263988
public function getChilds($idParent, $ordering = 'ASC')
    {
        if ($childs = $this->qb
            ->select($this->table . '.*')
            ->from($this->table)
            ->from($this->table . ' AS node')
            ->whereBetween('node.record_left', [$this->table . '.record_left', $this->table . '.record_right'])
            ->where([
                $this->table . '.id' => $id,
            ])
            ->get()) {
            if ($childs->count()) {
                return $childs;
            }
        }

        return false;
    }
461768
public function findCollectionPagesById($collectionId, $published = true)
    {
        $this->makeCollectionPageSelect();
        $this->sql .= ' and c.id = ?';
        $this->bindValues[] = $collectionId;

        if ($published) {
            $this->sql .= " and p.published_date <= '{$this->today()}'";
        }

        return $this->find();
    }
277081
public function getNodeById($id, $published)
    {
        return $published ? PublishedNode::find($id) : Node::find($id);
    }
1286695
public function getPageChildrenByidPage($id, $publishedOnly = 0)
	{
		$select = $this->tableGateway->getSql()->select();
		
		$select->columns(array('*'));
		
		$select->join('melis_cms_page_lang', 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id', 
						array('plang_lang_id'));
		$select->join('melis_cms_lang', 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id', 
						array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_published', 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id', 
						array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_style', 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id', array(), $select::JOIN_LEFT);
		
		$select->join('melis_cms_style', ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id', array('*'), $select::JOIN_LEFT);
		
		if ($publishedOnly == 1)
			$select->where('melis_cms_page_published.page_status=1');
		
		if ($publishedOnly == 0)
		{
    		$columns = $this->aliasColumnsFromTableDefinition('MelisEngine\MelisPageColumns', 's_');
		    $select->join('melis_cms_page_saved', 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id',
					$columns, $select::JOIN_LEFT);
		}
		
		$select->join('melis_cms_page_seo', 'melis_cms_page_seo.pseo_id = melis_cms_page_tree.tree_page_id',
	       array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_default_urls', 'melis_cms_page_default_urls.purl_page_id = melis_cms_page_tree.tree_page_id',
	       array('*'), $select::JOIN_LEFT);
			
		$select->where('tree_father_page_id = ' . $id);
		$select->order('tree_page_order ASC');
		
		$resultSet = $this->tableGateway->selectWith($select);
		
		return $resultSet;
	}
1256987
public function savePublish(Page $page, bool $published) : void
    {
        $page->setPublished($published);
        $page->save();
    }
915254
public function getPage($intPage = 1)
    {
        $intPage--; // Convert page no. to index no.
        if ($intPage < 0) {
            $intPage = 0;
        }

        $this->__elements->seek($intPage);

        $objReturn = $this->__elements->current();
        if ($objReturn === false || get_class($objReturn) !== "ValidFormBuilder\\Page") {
            $objReturn = null;
        }

        return $objReturn;
    }
969500
public function getSeoPageForm($idPage)
	{
		$pathAppConfigForm = self::PageSeoAppConfigPath;
		 
		/**
		 * Get the config for this form
		 */
		$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
		$appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm, $idPage . '_');
		
		
		/**
		 * Generate the form through factory and change ElementManager to
		 * have access to our custom Melis Elements
		 * Bind with datas
		 */
		$factory = new \Zend\Form\Factory();
		$formElements = $this->serviceLocator->get('FormElementManager');
		$factory->setFormElementManager($formElements);
		$appConfigForm['attributes']['action'] .= '?idPage=' . $idPage;
		$seoForm = $factory->createForm($appConfigForm);
	
		return $seoForm;
	}
1109668
public int getNextPage(int prevPage) {
		reportFreePage(prevPage);
		
		if (iter.hasNextULL()) {
			//ArrayList<Long> toDelete = new ArrayList<>();
			LongLongIndex.LLEntry e = iter.nextULL();
			long pageId = e.getKey();
			long value = e.getValue();
			
			// do not return pages that are PID_DO_NOT_USE.
			while ((value > maxFreeTxId || value < 0) && iter.hasNextULL()) {
				if (value < 0 && ((-value) <= maxFreeTxId)) {
					//optimisation:, collect in list and remove later?
					toDelete.add((int)pageId);
//					idx.removeLong(pageId);
//					//idx.insertLong(pageId, -currentTxId);
//					iter.close();
//					iter = (LLIterator) idx.iterator(pageId+1, Long.MAX_VALUE);
					//idx.removeLong(pageId, value);
					//TODO or implement iter.remove() ?!
				}
				e = iter.nextULL();
				pageId = e.getKey();
				value = e.getValue();
			}
//			if (!toDelete.isEmpty()) {
//				for (Long l: toDelete) {
//					idx.removeLong(l);
//				}
//			}
			if (value >= 0 && value <= maxFreeTxId) {
				//TODO or implement iter.updateValue() ?!
				//idx.removeLong(pageId);
				idx.insertLong(pageId, -currentTxId);
				iter.close();
				iter = idx.iterator(pageId+1, Long.MAX_VALUE);
				return (int) pageId;
			}
//			if (!toDelete.isEmpty()) {
//				iter.close();
//				iter = (LLIterator) idx.iterator(pageId+1, Long.MAX_VALUE);
//			}
		}
		
		//If we didn't find any we allocate a new page.
		return lastPage.addAndGet(1);
	}
577082
def published_children(self):
        """"""
        key = self.PUB_CHILDREN_KEY % self.pk
        #children = cache.get(key, None)
        # if children is None:
        children = Page.objects.filter_published(self.get_children()).all()
        #cache.set(key, children)
        return children
436936
private function findChildrenPages(Page $page)
    {
        $pages = Page::where('parent_id', $page->id)->orderBy('header_order')->get();

        return $pages;
    }
162968
public function getOrFind($id, $published = true)
    {
        $node = $this->get($id);

        if (is_null($node))
        {
            $node = $published ?
                PublishedNode::find($id) :
                Node::find($id);

            $this->put($id, $node);
        }

        return $node;
    }