original_string: public static function get_page_for_editing($pageid, $section = null, $lockonly = false) {
          global $USER;
  
          $params = self::validate_parameters(self::get_page_for_editing_parameters(),
                                              array(
                                                  'pageid' => $pageid,
                                                  'section' => $section,
                                                  'lockonly' => $lockonly
                                              )
              );
  
          $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');
          }
  
          // Get subwiki instance.
          if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
              throw new moodle_exception('incorrectsubwikiid', 'wiki');
          }
  
          // Permission validation.
          $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          if (!wiki_user_can_edit($subwiki)) {
              throw new moodle_exception('cannoteditpage', 'wiki');
          }
  
          if (!wiki_set_lock($params['pageid'], $USER->id, $params['section'], true)) {
              throw new moodle_exception('pageislocked', 'wiki');
          }
  
          $version = wiki_get_current_version($page->id);
          if (empty($version)) {
              throw new moodle_exception('versionerror', 'wiki');
          }
  
          $pagesection = array();
          $pagesection['version'] = $version->version;
  
          // Content requested to be returned.
          if (!$lockonly) {
              if (!is_null($params['section'])) {
                  $content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section']);
              } else {
                  $content = $version->content;
              }
  
              $pagesection['content'] = $content;
              $pagesection['contentformat'] = $version->contentformat;
          }
  
          $result = array();
          $result['pagesection'] = $pagesection;
          $result['warnings'] = $warnings;
          return $result;
  
      }
code: public static function get_page_for_editing($pageid, $section = null, $lockonly = false) {
          global $USER;
  
          $params = self::validate_parameters(self::get_page_for_editing_parameters(),
                                              array(
                                                  'pageid' => $pageid,
                                                  'section' => $section,
                                                  'lockonly' => $lockonly
                                              )
              );
  
          $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');
          }
  
          // Get subwiki instance.
          if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
              throw new moodle_exception('incorrectsubwikiid', 'wiki');
          }
  
          // Permission validation.
          $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          if (!wiki_user_can_edit($subwiki)) {
              throw new moodle_exception('cannoteditpage', 'wiki');
          }
  
          if (!wiki_set_lock($params['pageid'], $USER->id, $params['section'], true)) {
              throw new moodle_exception('pageislocked', 'wiki');
          }
  
          $version = wiki_get_current_version($page->id);
          if (empty($version)) {
              throw new moodle_exception('versionerror', 'wiki');
          }
  
          $pagesection = array();
          $pagesection['version'] = $version->version;
  
          // Content requested to be returned.
          if (!$lockonly) {
              if (!is_null($params['section'])) {
                  $content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section']);
              } else {
                  $content = $version->content;
              }
  
              $pagesection['content'] = $content;
              $pagesection['contentformat'] = $version->contentformat;
          }
  
          $result = array();
          $result['pagesection'] = $pagesection;
          $result['warnings'] = $warnings;
          return $result;
  
      }
code_tokens: public static function get_page_for_editing ( $ pageid , $ section = null , $ lockonly = false ) { global $ USER ; $ params = self :: validate_parameters ( self :: get_page_for_editing_parameters ( ) , array ( 'pageid' => $ pageid , 'section' => $ section , 'lockonly' => $ lockonly ) ) ; $ 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' ) ; } // Get subwiki instance. if ( ! $ subwiki = wiki_get_subwiki ( $ page -> subwikiid ) ) { throw new moodle_exception ( 'incorrectsubwikiid' , 'wiki' ) ; } // Permission validation. $ cm = get_coursemodule_from_instance ( 'wiki' , $ wiki -> id , $ wiki -> course ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; if ( ! wiki_user_can_edit ( $ subwiki ) ) { throw new moodle_exception ( 'cannoteditpage' , 'wiki' ) ; } if ( ! wiki_set_lock ( $ params [ 'pageid' ] , $ USER -> id , $ params [ 'section' ] , true ) ) { throw new moodle_exception ( 'pageislocked' , 'wiki' ) ; } $ version = wiki_get_current_version ( $ page -> id ) ; if ( empty ( $ version ) ) { throw new moodle_exception ( 'versionerror' , 'wiki' ) ; } $ pagesection = array ( ) ; $ pagesection [ 'version' ] = $ version -> version ; // Content requested to be returned. if ( ! $ lockonly ) { if ( ! is_null ( $ params [ 'section' ] ) ) { $ content = wiki_parser_proxy :: get_section ( $ version -> content , $ version -> contentformat , $ params [ 'section' ] ) ; } else { $ content = $ version -> content ; } $ pagesection [ 'content' ] = $ content ; $ pagesection [ 'contentformat' ] = $ version -> contentformat ; } $ result = array ( ) ; $ result [ 'pagesection' ] = $ pagesection ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Locks and retrieves info of page-section to be edited.
  
  @param int $pageid The page ID.
  @param string $section Section page title.
  @param boolean $lockonly If true: Just renew lock and not return content.
  @return array of warnings and page data.
  @since Moodle 3.1
docstring_tokens: Locks and retrieves info of page - section to be edited .