original_string: public static function get_page_contents($pageid) {
  
          $params = self::validate_parameters(self::get_page_contents_parameters(),
                                              array(
                                                  'pageid' => $pageid
                                              )
              );
          $warnings = array();
  
          // Get wiki page.
          if (!$page = wiki_get_page($params['pageid'])) {
              throw new moodle_exception('incorrectpageid', 'wiki');
          }
  
          // Get wiki instance.
          if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
              throw new moodle_exception('incorrectwikiid', 'wiki');
          }
  
          // Permission validation.
          $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          // Check if user can view this wiki.
          if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
              throw new moodle_exception('incorrectsubwikiid', 'wiki');
          }
          if (!wiki_user_can_view($subwiki, $wiki)) {
              throw new moodle_exception('cannotviewpage', 'wiki');
          }
  
          $returnedpage = array();
          $returnedpage['id'] = $page->id;
          $returnedpage['wikiid'] = $wiki->id;
          $returnedpage['subwikiid'] = $page->subwikiid;
          $returnedpage['groupid'] = $subwiki->groupid;
          $returnedpage['userid'] = $subwiki->userid;
          $returnedpage['title'] = $page->title;
          $returnedpage['tags'] = \core_tag\external\util::get_item_tags('mod_wiki', 'wiki_pages', $page->id);
  
          // Refresh page cached content if needed.
          if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
              if ($content = wiki_refresh_cachedcontent($page)) {
                  $page = $content['page'];
              }
          }
  
          list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text(
                              $page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
          $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
  
          // Get page version.
          $version = wiki_get_current_version($page->id);
          if (!empty($version)) {
              $returnedpage['version'] = $version->version;
          }
  
          $result = array();
          $result['page'] = $returnedpage;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_page_contents($pageid) {
  
          $params = self::validate_parameters(self::get_page_contents_parameters(),
                                              array(
                                                  'pageid' => $pageid
                                              )
              );
          $warnings = array();
  
          // Get wiki page.
          if (!$page = wiki_get_page($params['pageid'])) {
              throw new moodle_exception('incorrectpageid', 'wiki');
          }
  
          // Get wiki instance.
          if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
              throw new moodle_exception('incorrectwikiid', 'wiki');
          }
  
          // Permission validation.
          $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          // Check if user can view this wiki.
          if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
              throw new moodle_exception('incorrectsubwikiid', 'wiki');
          }
          if (!wiki_user_can_view($subwiki, $wiki)) {
              throw new moodle_exception('cannotviewpage', 'wiki');
          }
  
          $returnedpage = array();
          $returnedpage['id'] = $page->id;
          $returnedpage['wikiid'] = $wiki->id;
          $returnedpage['subwikiid'] = $page->subwikiid;
          $returnedpage['groupid'] = $subwiki->groupid;
          $returnedpage['userid'] = $subwiki->userid;
          $returnedpage['title'] = $page->title;
          $returnedpage['tags'] = \core_tag\external\util::get_item_tags('mod_wiki', 'wiki_pages', $page->id);
  
          // Refresh page cached content if needed.
          if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
              if ($content = wiki_refresh_cachedcontent($page)) {
                  $page = $content['page'];
              }
          }
  
          list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text(
                              $page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
          $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
  
          // Get page version.
          $version = wiki_get_current_version($page->id);
          if (!empty($version)) {
              $returnedpage['version'] = $version->version;
          }
  
          $result = array();
          $result['page'] = $returnedpage;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_page_contents ( $ pageid ) { $ params = self :: validate_parameters ( self :: get_page_contents_parameters ( ) , array ( 'pageid' => $ pageid ) ) ; $ warnings = array ( ) ; // Get wiki page. if ( ! $ page = wiki_get_page ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectpageid' , 'wiki' ) ; } // Get wiki instance. if ( ! $ wiki = wiki_get_wiki_from_pageid ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectwikiid' , 'wiki' ) ; } // Permission validation. $ cm = get_coursemodule_from_instance ( 'wiki' , $ wiki -> id , $ wiki -> course ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; // Check if user can view this wiki. if ( ! $ subwiki = wiki_get_subwiki ( $ page -> subwikiid ) ) { throw new moodle_exception ( 'incorrectsubwikiid' , 'wiki' ) ; } if ( ! wiki_user_can_view ( $ subwiki , $ wiki ) ) { throw new moodle_exception ( 'cannotviewpage' , 'wiki' ) ; } $ returnedpage = array ( ) ; $ returnedpage [ 'id' ] = $ page -> id ; $ returnedpage [ 'wikiid' ] = $ wiki -> id ; $ returnedpage [ 'subwikiid' ] = $ page -> subwikiid ; $ returnedpage [ 'groupid' ] = $ subwiki -> groupid ; $ returnedpage [ 'userid' ] = $ subwiki -> userid ; $ returnedpage [ 'title' ] = $ page -> title ; $ returnedpage [ 'tags' ] = \ core_tag \ external \ util :: get_item_tags ( 'mod_wiki' , 'wiki_pages' , $ page -> id ) ; // Refresh page cached content if needed. if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { if ( $ content = wiki_refresh_cachedcontent ( $ page ) ) { $ page = $ content [ 'page' ] ; } } list ( $ returnedpage [ 'cachedcontent' ] , $ returnedpage [ 'contentformat' ] ) = external_format_text ( $ page -> cachedcontent , FORMAT_HTML , $ context -> id , 'mod_wiki' , 'attachments' , $ subwiki -> id ) ; $ returnedpage [ 'caneditpage' ] = wiki_user_can_edit ( $ subwiki ) ; // Get page version. $ version = wiki_get_current_version ( $ page -> id ) ; if ( ! empty ( $ version ) ) { $ returnedpage [ 'version' ] = $ version -> version ; } $ result = array ( ) ; $ result [ 'page' ] = $ returnedpage ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Get a page contents.
  
  @param int $pageid The page ID.
  @return array of warnings and page data.
  @since Moodle 3.1
docstring_tokens: Get a page contents .