Moves a page by updating its nextpageid and prevpageid values within
the database

@final
@param int $nextpageid
@param int $prevpageid
173363
final public function move($nextpageid=null, $prevpageid=null) {
        global $DB;
        if ($nextpageid === null) {
            $nextpageid = $this->properties->nextpageid;
        }
        if ($prevpageid === null) {
            $prevpageid = $this->properties->prevpageid;
        }
        $obj = new stdClass;
        $obj->id = $this->properties->id;
        $obj->prevpageid = $prevpageid;
        $obj->nextpageid = $nextpageid;
        $DB->update_record('lesson_pages', $obj);
    }
103103
public function moveAsFirstChildOf(Page $page, Page $target)
    {
        return $this->moveAsChildOf($page, $target, true);
    }
80089
public function move($destinationId){
        $parameter = new ClientValueObject();
        $parameter->setProperty("DestinationId",$destinationId);
        $qry = new InvokePostMethodQuery($this->getResourcePath(),"Move",null,$parameter);
        $this->getContext()->addQuery($qry);
    }
500852
function MoveNext()
	{
		$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
		if($ret !== false) {
		global $ADODB_ANSI_PADDING_OFF;
			$this->fields = $ret;
			$this->_currentRow++;
			$this->_updatefields();

			if (!empty($ADODB_ANSI_PADDING_OFF)) {
				foreach($this->fields as $k => $v) {
					if (is_string($v)) $this->fields[$k] = rtrim($v);
				}
			}
			return true;
		}
		if (!$this->EOF) {
			$this->EOF = true;
			$this->_currentRow++;
		}
		return false;
	}
1372324
public function upPagesPosition($parentId, $position, $positionLimit = NULL)
    {
        if (is_null($positionLimit))
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:pageType');
        }
        else
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.position<=:positionLimit AND p.parent=:parentId AND p.page_type=:pageType');
            $query->setParameter('positionLimit', $positionLimit);
        }
        $query->setParameter('pageType', 'page');
        $query->setParameter('position', $position);
        $query->setParameter('parentId', $parentId);
        $query->getResult();
    }
109489
public function moveFirst($parentId = false)
    {
        if ( $this->parentIdField && $parentId === false ) {
            $parentId = $this->owner->{$this->parentIdField};
        }
        $minIdx = $this->getMinIdx($parentId);
        if ( ! $minIdx ) {
            $this->reorder($parentId);
            $minIdx = $this->getMinIdx($parentId);
        }
        if ( $this->parentIdField ) {
            call_user_func("$this->ownerClassName::updateAll", [
                $this->sortField => floor($minIdx / 2),
                $this->parentIdField => $parentId,
            ], [ $this->primaryKey => $this->owner->primaryKey ]);
        } else {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => floor($minIdx / 2) ],
                [ $this->primaryKey => $this->owner->primaryKey ]);
        }
        $this->invalidateTagDependency();
    }
479262
protected function setNextNumPage()
	{
		$this->next_num_page = 0;
		if ( $this->current_page_number < $this->num_pages )
		{
			$this->next_num_page = ( $this->current_page_number + 1 );
		}
	}
940777
public function resort_pages($pageid, $after) {
        global $CFG;

        $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course);
        $context = context_module::instance($cm->id);

        $pages = $this->load_all_pages();

        if (!array_key_exists($pageid, $pages) || ($after!=0 && !array_key_exists($after, $pages))) {
            print_error('cannotfindpages', 'lesson', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
        }

        $pagetomove = clone($pages[$pageid]);
        unset($pages[$pageid]);

        $pageids = array();
        if ($after === 0) {
            $pageids['p0'] = $pageid;
        }
        foreach ($pages as $page) {
            $pageids[] = $page->id;
            if ($page->id == $after) {
                $pageids[] = $pageid;
            }
        }

        $pageidsref = $pageids;
        reset($pageidsref);
        $prev = 0;
        $next = next($pageidsref);
        foreach ($pageids as $pid) {
            if ($pid === $pageid) {
                $page = $pagetomove;
            } else {
                $page = $pages[$pid];
            }
            if ($page->prevpageid != $prev || $page->nextpageid != $next) {
                $page->move($next, $prev);

                if ($pid === $pageid) {
                    // We will trigger an event.
                    $pageupdated = array('next' => $next, 'prev' => $prev);
                }
            }

            $prev = $page->id;
            $next = next($pageidsref);
            if (!$next) {
                $next = 0;
            }
        }

        // Trigger an event: page moved.
        if (!empty($pageupdated)) {
            $eventparams = array(
                'context' => $context,
                'objectid' => $pageid,
                'other' => array(
                    'pagetype' => $page->get_typestring(),
                    'prevpageid' => $pageupdated['prev'],
                    'nextpageid' => $pageupdated['next']
                )
            );
            $event = \mod_lesson\event\page_moved::create($eventparams);
            $event->trigger();
        }

    }
649339
public function setID($page_id)
    {
        if ($page_id == $this->page_id) {
            return true;
        }

        if (!$this->isValidId($page_id)) {
            return false;
        }

        if(!$this->pageOrder->changeId($this, $page_id)){
            return false;
        }

        $this->page_id = $page_id;
        return true;
    }
674014
public function moveAsNextSiblingOf(Page $page, Page $target)
    {
        return $this->moveAsSiblingOf($page, $target, false);
    }
916969
public void acknowledgePages(long sequenceId)
    {
        checkArgument(sequenceId >= 0, "Invalid sequence id");

        List<SerializedPageReference> removedPages = new ArrayList<>();
        synchronized (this) {
            if (destroyed.get()) {
                return;
            }

            // if pages have already been acknowledged, just ignore this
            long oldCurrentSequenceId = currentSequenceId.get();
            if (sequenceId < oldCurrentSequenceId) {
                return;
            }

            int pagesToRemove = toIntExact(sequenceId - oldCurrentSequenceId);
            checkArgument(pagesToRemove <= pages.size(), "Invalid sequence id");

            long bytesRemoved = 0;
            for (int i = 0; i < pagesToRemove; i++) {
                SerializedPageReference removedPage = pages.removeFirst();
                removedPages.add(removedPage);
                bytesRemoved += removedPage.getRetainedSizeInBytes();
            }

            // update current sequence id
            verify(currentSequenceId.compareAndSet(oldCurrentSequenceId, oldCurrentSequenceId + pagesToRemove));

            // update memory tracking
            verify(bufferedBytes.addAndGet(-bytesRemoved) >= 0);
        }

        // dereference outside of synchronized to avoid making a callback while holding a lock
        removedPages.forEach(SerializedPageReference::dereferencePage);
    }
97943
public function move( Page $page, Title $target, array $extraParams = [] ) {
		$this->api->postRequest(
			new SimpleRequest(
				'move', $this->getMoveParams( $page->getId(), $target, $extraParams )
			)
		);

		return true;
	}
820281
protected function updateSeoPage(PageInterface $pageInterface)
    {
        /** @var SeoPage $seoPage */
        $seoPage = $this->seoPage;

        if ($pageInterface instanceof SnapshotPageProxy) {
            $page = $pageInterface->getPage();
        } else {
            $page = $pageInterface;
        }

        $seoPage->addVar('page_internal', $page);

        $route = $page->getRouteName();

        if ('page_slug' === $route) {
            $seoPage->setLinkCanonical($this->getContainer()->get('router')->generate(
                $route,
                [
                    'path' => $page->getUrl(),
                ],
                0
            ));
        }

        if ('page_slug' === $route
            ||
            '_page_internal_error_not_found' === $route
        ) {
            $seoPage->build();
        }
    }
850118
protected function calculateClosestPageIdWithActiveTemplate($startPageId)
    {
        $rootLine = $this->pageRepository->getRootLine($startPageId);
        // when no rootline is present the startpage it's self is the closest page
        if (!is_array($rootLine)) {
            return $startPageId;
        }

        $closestPageIdWithTemplate = $this->systemTemplateRepository->findOneClosestPageIdWithActiveTemplateByRootLine($rootLine);
        if ($closestPageIdWithTemplate === 0) {
            return $startPageId;
        }

        return (int)$closestPageIdWithTemplate;
    }
1250732
public function replaceChild(int $childId, AbstractNode $newChild): void
    {
        $oldChild = $this->children[$childId];

        $newChild->prev = $oldChild['prev'];
        $newChild->next = $oldChild['next'];

        $keys = array_keys($this->children);
        $index = array_search($childId, $keys, true);
        $keys[$index] = $newChild->id();
        $this->children = array_combine($keys, $this->children);
        $this->children[$newChild->id()] = array(
            'prev' => $oldChild['prev'],
            'node' => $newChild,
            'next' => $oldChild['next']
        );

        // chnge previous child id to new child
        if ($oldChild['prev'] && isset($this->children[$newChild->prev])) {
            $this->children[$oldChild['prev']]['next'] = $newChild->id();
        }

        // change next child id to new child
        if ($oldChild['next'] && isset($this->children[$newChild->next])) {
            $this->children[$oldChild['next']]['prev'] = $newChild->id();
        }
        
        // remove old child
        unset($this->children[$childId]);

        // clean out cache
        $this->clear();
    }
1133704
public function add($parentId = null)
    {
        /** @var Page $page */
        $page = $this->Pages->newEntity();

        ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));

        if ($this->request->is('post') && !empty($this->request->data)) {
            $this->request->data['parent_id'] = $parentId;

            /** @var Connection $conn */
            $conn = $this->Pages->connection();
            $conn->begin();
            $this->Pages->behaviors()->unload('Translate');
            $page = $this->Pages->newEntity([
                'name' => $this->request->data('name'),
                'parent_id' => $this->request->data('parent_id'),
                'layout' => $this->request->data('layout')
            ]);

            if ($this->Pages->save($page, ['associated' => false])) {
                $this->Pages->behaviors()->load('Translate', PagesTable::$translateOptions);

                $page = $this->Pages->patchEntity($page, $this->request->data);
                if ($this->Pages->save($page)) {
                    $conn->commit();
                    $this->Flash->success(__d('wasabi_cms', 'The page <strong>{0}</strong> has been created.', $page->name));
                    $this->redirect(['action' => 'index']);
                    return;
                } else {
                    $conn->rollback();
                    $this->Flash->error($this->formErrorMessage);
                }
            } else {
                $conn->rollback();
                $this->Flash->error($this->formErrorMessage);
            }
        } else {
            $page->layout = 'Default';
            $page->current = [
                (new Content())->set('content', json_encode($page->getLayout()->content()))
            ];
            $page->display_page_title_suffix = true;
        }

        if ($page->meta_robots_index === null) {
            $page->meta_robots_index = (bool)Configure::read('Settings.Cms.SEO.meta-robots-index');
        }

        if ($page->meta_robots_follow === null) {
            $page->meta_robots_follow = (bool)Configure::read('Settings.Cms.SEO.meta-robots-follow');
        }

        $this->set([
            'page' => $page,
            'layouts' => ThemeManager::theme()->getLayoutsForSelect(),
            'availableModules' => ModuleManager::getAvailableModules(),
            'attributes' => $page->getLayout()->attributes(),
            'changeAttributesUrl' => Router::url([
                'plugin' => 'Wasabi/Cms',
                'controller' => 'Pages',
                'action' => 'attributes'
            ])
        ]);
    }
941570
public function next()
    {
        $this->position++;
        $this->page = $this->nextResultToken()
            ? $this->executeCall()
            : null;
    }