Attempts to get the mastery page by the id.

@param int $masteryPageId
@return MasteryPage|null
768517
public function masteryPage($masteryPageId)
	{
		if ( ! isset($this->info['masteryPages']))
		{
			// no rune pages
			return null;
		}
		$masteryPages = $this->info['masteryPages'];
		if (isset($masteryPages[$masteryPageId]))
		{
			return $masteryPages[$masteryPageId];
		}

		return null;
	}
250571
public function get_lastpageid() {
        global $DB;
        if ($this->lastpageid == null) {
            if (!$this->loadedallpages) {
                $lastpageid = $DB->get_field('lesson_pages', 'id', array('lessonid'=>$this->properties->id, 'nextpageid'=>0));
                if (!$lastpageid) {
                    print_error('cannotfindlastpage', 'lesson');
                }
                $this->lastpageid = $lastpageid;
            } else {
                $lastpageid = $this->get_lastpage();
                $this->lastpageid = $lastpageid->id;
            }
        }

        return $this->lastpageid;
    }
678296
public function find_instance($instanceid) {
        foreach ($this->regions as $region => $notused) {
            $this->ensure_instances_exist($region);
            foreach($this->blockinstances[$region] as $instance) {
                if ($instance->instance->id == $instanceid) {
                    return $instance;
                }
            }
        }
        throw new block_not_on_page_exception($instanceid, $this->page);
    }
33885
protected function pageResourceMapper($resourceId)
    {
        if (!$this->resourceName->isPagesResourceId($resourceId)) {
            return null;
        }

        $resources = explode('.', $resourceId);

        if (empty($resources[1])) {
            return null;
        }

        $siteResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1]);

        $return = [
            'resourceId' => $resourceId,
            'parentResourceId' => $siteResourceId,
        ];

        if ($this->resourceName->isPageResourceId($resourceId)) {
            $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1], self::RESOURCE_PAGES);
            $return['parentResourceId'] = $pagesResourceId;
        }

        return array_merge(
            $this->resources[self::RESOURCE_PAGES],
            $return
        );
    }
287112
public static function data_for_course_competencies_page($courseid) {
        global $PAGE;
        $params = self::validate_parameters(self::data_for_course_competencies_page_parameters(), array(
            'courseid' => $courseid,
        ));
        self::validate_context(context_course::instance($params['courseid']));

        $renderable = new output\course_competencies_page($params['courseid']);
        $renderer = $PAGE->get_renderer('tool_lp');

        $data = $renderable->export_for_template($renderer);

        return $data;
    }
671773
public function getSitePage(
        SiteEntity $site,
        $pageId
    ) {
        try {
            /** @var \Rcm\Entity\Page $page */
            $page = $this->findOneBy(
                [
                    'site' => $site,
                    'pageId' => $pageId
                ]
            );
        } catch (\Exception $e) {
            $page = null;
        }

        return $page;
    }
1014913
protected function processPageId($page_id) {
    $page_ids = array_keys($this->getVisiblePages());

    // Redirect to default page (first page) if no page or invalid page is
    // requested.
    if (empty($page_id) || !in_array($page_id, $page_ids)) {
      $page_id = reset($page_ids);
    }

    return $page_id;
  }
71382
protected function getSubPageIds($pageId)
    {
        /** @var $queryGenerator \TYPO3\CMS\Core\Database\QueryGenerator */
        $queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class);

        // here we retrieve only the subpages of this page because the permission clause is not evaluated
        // on the root node.
        $permissionClause = ' 1 ' . BackendUtility::BEenableFields('pages');
        $treePageIdList = $queryGenerator->getTreeList($pageId, 20, 0, $permissionClause);
        $treePageIds = array_map('intval', explode(',', $treePageIdList));

            // the first one can be ignored because this is the page itself
        array_shift($treePageIds);

        return $treePageIds;
    }
1009116
public function getIsRootPageId($pageId)
    {
        // Page 0 can never be a root page
        if ($pageId === 0) {
            return false;
        }

        // Page -1 is a workspace thing
        if ($pageId === -1) {
            return false;
        }

        $cacheId = 'RootPageResolver' . '_' . 'getIsRootPageId' . '_' . $pageId;
        $isSiteRoot = $this->runtimeCache->get($cacheId);

        if (!empty($isSiteRoot)) {
            return $isSiteRoot;
        }

        $page = $this->getPageRecordByPageId($pageId);
        if (empty($page)) {
            throw new \InvalidArgumentException(
                'The page for the given page ID \'' . $pageId
                . '\' could not be found in the database and can therefore not be used as site root page.',
                1487171426
            );
        }

        $isSiteRoot = Site::isRootPage($page);
        $this->runtimeCache->set($cacheId, $isSiteRoot);

        return $isSiteRoot;
    }
597965
public function buildPageQuery($pageId)
    {
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
        $site = $siteRepository->getSiteByPageId($pageId);

        return $this->newSearchQuery('')
            ->useQueryString('*:*')
            ->useFilter('(type:pages AND uid:' . $pageId . ') OR (*:* AND pid:' . $pageId . ' NOT type:pages)', 'type')
            ->useFilter('siteHash:' . $site->getSiteHash(), 'siteHash')
            ->useReturnFields(ReturnFields::fromString('*'))
            ->useSortings(Sortings::fromString('type asc, title asc'))
            ->useQueryType('standard')
            ->getQuery();
    }
978921
public function getPagePart($id, $context = 'main', $sequenceNumber)
    {
        $ppRef = $this->find($id);
        $ppRef->setContext($context);
        $ppRef->setSequenceNumber($sequenceNumber);
        $this->getEntityManager()->persist($ppRef);
        $this->getEntityManager()->flush($ppRef);

        return $this->getEntityManager()->getRepository($ppRef->getPagePartEntityName())->find($ppRef->getPagePartId());
    }
1302455
public static function getMasteryIconO( StaticMasteryDto $mastery, array $attributes = [] ): Html
	{
		return self::getMasteryIcon($mastery->id, $attributes);
	}
1219688
public function masteryPages($identities)
	{
		$ids = $this->extractIds($identities);
		$ids = implode(',', $ids);

		$array     = $this->request('summoner/'.$ids.'/masteries');
		$summoners = [];
		foreach ($array as $summonerId => $data)
		{
			$masteryPages = [];
			foreach ($data['pages'] as $info)
			{
				if ( ! isset($info['masteries']))
				{
					// seting the talents to an empty array
					$info['masteries'] = [];
				}

				$masteriesInfo = $info['masteries'];
				unset($info['masteries']);
				$masteryPage = $this->attachStaticDataToDto(new MasteryPage($info));
				// set masterys
				$masteries = [];
				foreach ($masteriesInfo as $mastery)
				{
					$id             = $mastery['id'];
					$mastery        = $this->attachStaticDataToDto(new Mastery($mastery));
					$masteries[$id] = $mastery;
				}
				$masteryPage->masteries = $masteries;
				$masteryPages[]         = $masteryPage;
			}
			$summoners[$summonerId] = $masteryPages;
		}

		$this->attachResponses($identities, $summoners, 'masteryPages');

		if (is_array($identities))
		{
			return $summoners;
		}
		else
		{
			return reset($summoners);
		}
	}
1069850
public static function list_courses_using_competency($competencyid) {
        global $PAGE;

        $params = self::validate_parameters(self::list_courses_using_competency_parameters(), array(
            'id' => $competencyid,
        ));

        $competency = api::read_competency($params['id']);
        self::validate_context($competency->get_context());
        $output = $PAGE->get_renderer('tool_lp');

        $results = array();
        $courses = api::list_courses_using_competency($params['id']);
        foreach ($courses as $course) {
            $context = context_course::instance($course->id);
            $exporter = new course_summary_exporter($course, array('context' => $context));
            $result = $exporter->export($output);
            array_push($results, $result);
        }
        return $results;
    }
713784
public static function get_jumptooptions($pageid, lesson $lesson) {
        global $DB;
        $jump = array();
        $jump[0] = get_string("thispage", "lesson");
        $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
        $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
        $jump[LESSON_EOL] = get_string("endoflesson", "lesson");

        if ($pageid == 0) {
            return $jump;
        }

        $pages = $lesson->load_all_pages();
        if ($pages[$pageid]->qtype == LESSON_PAGE_BRANCHTABLE || $lesson->is_sub_page_of_type($pageid, array(LESSON_PAGE_BRANCHTABLE), array(LESSON_PAGE_ENDOFBRANCH, LESSON_PAGE_CLUSTER))) {
            $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
            $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
        }
        if($pages[$pageid]->qtype == LESSON_PAGE_CLUSTER || $lesson->is_sub_page_of_type($pageid, array(LESSON_PAGE_CLUSTER), array(LESSON_PAGE_ENDOFCLUSTER))) {
            $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
        }
        if (!optional_param('firstpage', 0, PARAM_INT)) {
            $apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0));
            while (true) {
                if ($apageid) {
                    $title = $DB->get_field("lesson_pages", "title", array("id" => $apageid));
                    $jump[$apageid] = strip_tags(format_string($title,true));
                    $apageid = $DB->get_field("lesson_pages", "nextpageid", array("id" => $apageid));
                } else {
                    // last page reached
                    break;
                }
            }
        }
        return $jump;
    }
866650
public function getPage($id)
    {
        $found_page = null;

        foreach ($this->pages as $page) {
            if ($page->id == $id) {
                $found_page = $page;
                break;
            }
        }

        return $found_page;
    }
352001
public function getSinglePageDownloadUrl($pageId)
    {
        try {
            $response = $this->client->get($this->PagesUrl . '/' . $pageId, [
                'headers' => ['Authorization' => 'Bearer '. $this->login->apiKey],
                'verify' => $this->certFile,
            ]);

            $body = json_decode($response->getBody(), true);
            $url = $body['_meta']['publishUrl'];
            $responseText = ['url' => $url];

            $response = [
                'code' => '200',
                'response' => json_encode($responseText),
                'error' => false
            ];

        } catch (ClientException $e) {
            $httpResponse = $e->getResponse();
            // 404 means their Leadpage in their account probably got deleted
            if ($httpResponse->getStatusCode() == 404) {
                $response = [
                    'code' => $httpResponse->getStatusCode(),
                    'response' => "
                    Your Leadpage could not be found! Please make sure it is published in your Leadpages Account <br />
                    <br />
                    Support Info:<br />
                    <strong>Page id:</strong> {$pageId} <br />
                    <strong>Page url:</strong> {$this->PagesUrl}/{$pageId}",
                    'error' => true
                ];

            } else {
                $message = 'Something went wrong, please contact Leadpages support.';
                $response = $this->parseException($e);
            }

        } catch (ServerException $e) {
            $response = $this->parseException($e);

        } catch (ConnectException $e) {
            $message = 'Can not connect to Leadpages Server:';
            $response = $this->parseException($e, $message);

        } catch (RequestException $e) {
            $response = $this->parseException($e);
        }

        return $response;
    }