Let the theme initialise the page object (usually $PAGE).

This may be used for example to request jQuery in add-ons.

@param moodle_page $page
513972
public function init_page(moodle_page $page) {
        $themeinitfunction = 'theme_'.$this->name.'_page_init';
        if (function_exists($themeinitfunction)) {
            $themeinitfunction($page);
        }
    }
374105
protected void setPageData(SinglePage<T> page) {
    setPage(page);
    this.pageIndex = page.getPageIndex();
    this.totalPages = page.getTotalPages();
  }
1244432
void setPage(Page page) {
		synchronized(lock) {
			checkNotFrozen();
			if(this.page != null) throw new IllegalStateException("element already has a page: " + this);
			this.page = page;
		}
		assert checkPageAndParentElement();
	}
1010976
public void addPage(DialogPage page) {
		pages.add(page);
		if (autoConfigureChildPages) {
			String id = getId() + "." + page.getId();
			ValkyrieRepository.getInstance().getApplicationConfig().applicationObjectConfigurer().configure(page, id);
		}
	}
742628
public static function startPage($page = null)
    {
        if ($page !== null) {
            self::$_startPage = $page;
        }
        return self::$_startPage;
    }
1133915
protected function loadPage($page)
    {
        $this->pageStart = $page * $this->pageSize;
        $this->pageData = $this->query->setFirstResult($this->pageStart)->setMaxResults($this->pageSize)->getResult();
    }
271167
public function setPage(Page $page)
    {
        $this->_page = $page;
        $page->setMainSection($this);

        return $this;
    }
442787
public function get_nojslink(moodle_page $page = null) {
        if ($page === null) {
            global $PAGE;
            $page = $PAGE;
        }

        $link = new moodle_url($page->url, array(
            'nonjscomment'    => true,
            'comment_itemid'  => $this->itemid,
            'comment_context' => $this->context->id,
            'comment_component' => $this->get_component(),
            'comment_area'    => $this->commentarea,
        ));
        $link->remove_params(array('comment_page'));
        return $link;
    }
799020
public function setApplicationPage($page)
    {
        if (null !== $page) {
            Assert::string($page, 'The application page must be a string or null. Got: %s');
            Assert::notEmpty($page, 'The application page must not be empty.');
        }

        $this->applicationPage = $page;
    }
1306393
public function addPage(PagingPage $page)
    {
        if (!in_array($page, $this->pages, true)) {
            array_push($this->pages, $page);
        }
        return $this;
    }
1196797
protected function changePage($page)
    {
        $this->currentPage = $page;
        $this->manialinkFactory->update($this->manialink->getUserGroup());
    }
1352759
public function initialise_rating_javascript(moodle_page $page) {
        global $CFG;

        // Only needs to be initialized once.
        static $done = false;
        if ($done) {
            return true;
        }

        $page->requires->js_init_call('M.core_rating.init');
        $done = true;

        return true;
    }
559108
public function Index($Page = FALSE) {
      // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
      $Layout = C('Vanilla.Discussions.Layout');
      switch($Layout) {
         case 'table':
            if ($this->SyndicationMethod == SYNDICATION_NONE)
               $this->View = 'table';
            break;
         default:
            // $this->View = 'index';
            break;
      }
      Gdn_Theme::Section('DiscussionList');
      
      // Determine offset from $Page
      list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
      $Page = PageNumber($Offset, $Limit);
      $this->CanonicalUrl(Url(ConcatSep('/', 'discussions', PageNumber($Offset, $Limit, TRUE, FALSE)), TRUE));
      
      // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
      $MaxPages = C('Vanilla.Discussions.MaxPages');
      if ($MaxPages && $Page > $MaxPages) {
         throw NotFoundException();
      }
      
      // Setup head.
      if (!$this->Data('Title')) {
         $Title = C('Garden.HomepageTitle');
         if ($Title)
            $this->Title($Title, '');
         else
            $this->Title(T('Recent Discussions'));
      }
      if (!$this->Description())
         $this->Description(C('Garden.Description', NULL));
      if ($this->Head)
         $this->Head->AddRss(Url('/discussions/feed.rss', TRUE), $this->Head->Title());
      
      // Add modules
      $this->AddModule('DiscussionFilterModule');
      $this->AddModule('NewDiscussionModule');
      $this->AddModule('CategoriesModule');
      $this->AddModule('BookmarkedModule');
      $this->SetData('Breadcrumbs', array(array('Name' => T('Recent Discussions'), 'Url' => '/discussions')));
      
      
      // Set criteria & get discussions data
      $this->SetData('Category', FALSE, TRUE);
      $DiscussionModel = new DiscussionModel();
      $DiscussionModel->Watching = TRUE;
      
      // Get Discussion Count
      $CountDiscussions = $DiscussionModel->GetCount();
      
      if ($MaxPages)
         $CountDiscussions = $MaxPages * $Limit;
      
      $this->SetData('CountDiscussions', $CountDiscussions);
      
      // Get Announcements
      $this->AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements() : FALSE;
		$this->SetData('Announcements', $this->AnnounceData !== FALSE ? $this->AnnounceData : array(), TRUE);
      
      // Get Discussions
      $this->DiscussionData = $DiscussionModel->GetWhere(FALSE, $Offset, $Limit);
      
      $this->SetData('Discussions', $this->DiscussionData, TRUE);
      $this->SetJson('Loading', $Offset . ' to ' . $Limit);

      // Build a pager
      $PagerFactory = new Gdn_PagerFactory();
		$this->EventArguments['PagerType'] = 'Pager';
		$this->FireEvent('BeforeBuildPager');
      $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
      $this->Pager->ClientID = 'Pager';
      $this->Pager->Configure(
         $Offset,
         $Limit,
         $CountDiscussions,
         'discussions/%1$s'
      );
      if (!$this->Data('_PagerUrl'))
         $this->SetData('_PagerUrl', 'discussions/{Page}');
      $this->SetData('_Page', $Page);
      $this->SetData('_Limit', $Limit);
		$this->FireEvent('AfterBuildPager');
      
      // Deliver JSON data if necessary
      if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'discussions';
      }
      
      // We don't want search engines to index these pages because they can go in through the individual categories MUCH faster.
      if ($this->Head)
         $this->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
      
      $this->Render();
   }
1133848
public function render_preview(moodle_page $page) {

        if (!$this->is_form_defined()) {
            throw new coding_exception('It is the caller\'s responsibility to make sure that the form is actually defined');
        }

        // Check if current user is able to see preview
        $options = $this->get_options();
        if (empty($options['alwaysshowdefinition']) && !has_capability('moodle/grade:managegradingforms', $page->context))  {
            return '';
        }

        $criteria = $this->definition->guide_criteria;
        $comments = $this->definition->guide_comments;
        $output = $this->get_renderer($page);

        $guide = '';
        $guide .= $output->box($this->get_formatted_description(), 'gradingform_guide-description');
        if (has_capability('moodle/grade:managegradingforms', $page->context)) {
            $guide .= $output->display_guide_mapping_explained($this->get_min_max_score());
            $guide .= $output->display_guide($criteria, $comments, $options, self::DISPLAY_PREVIEW, 'guide');
        } else {
            $guide .= $output->display_guide($criteria, $comments, $options, self::DISPLAY_PREVIEW_GRADED, 'guide');
        }

        return $guide;
    }
962217
public function setup($page) {

        // Load dynamic loader. It will scan page for videojs media and load necessary modules.
        // Loader will be loaded on absolutely every page, however the videojs will only be loaded
        // when video is present on the page or added later to it in AJAX.
        $path = new moodle_url('/media/player/videojs/videojs/video-js.swf');
        $contents = 'videojs.options.flash.swf = "' . $path . '";' . "\n";
        $contents .= $this->find_language(current_language());
        $page->requires->js_amd_inline(<<<EOT
require(["media_videojs/loader"], function(loader) {
    loader.setUp(function(videojs) {
        $contents
    });
});
EOT
        );
    }
550428
final protected function initPageMetas(Page $page)
    {
        if (!isset($this->pageMetas))
        {
            $this->pageMetas = array();
            if ($page->getId() > 0)
            {
                $metas = $this->doctrine->getRepository('FulgurioLightCMSBundle:PageMeta')->findByPage($page->getId());
                foreach ($metas as $meta)
                {
                    $this->pageMetas[$meta->getMetaKey()] = $meta;
                }
            }
        }
    }
906262
private static function page($page, array $details)
    {
        if(($page === '*' && is_page()) || is_page($page))
        {
            self::loadController($details);
            exit;
        }
    }