original_string: public function get_document($record, $options = array()) {
          try {
              $cm = $this->get_cm('wiki', $record->wikiid, $record->courseid);
              $context = \context_module::instance($cm->id);
          } catch (\dml_missing_record_exception $ex) {
              // Notify it as we run here as admin, we should see everything.
              debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                  $ex->getMessage(), DEBUG_DEVELOPER);
              return false;
          } catch (\dml_exception $ex) {
              // Notify it as we run here as admin, we should see everything.
              debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
              return false;
          }
  
          // Make a page object without extra fields.
          $page = clone $record;
          unset($page->courseid);
          unset($page->wikiid);
  
          // Conversion based wiki_print_page_content().
          // Check if we have passed the cache time.
          if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
              $content = wiki_refresh_cachedcontent($page);
              $page = $content['page'];
          }
          // Convert to text.
          $content = content_to_text($page->cachedcontent, FORMAT_MOODLE);
  
          // Prepare associative array with data from DB.
          $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
          $doc->set('title', content_to_text($record->title, false));
          $doc->set('content', $content);
          $doc->set('contextid', $context->id);
          $doc->set('courseid', $record->courseid);
          if ($record->groupid > 0) {
              $doc->set('groupid', $record->groupid);
          }
          $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
          $doc->set('modified', $record->timemodified);
  
          // Check if this document should be considered new.
          if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->timecreated)) {
              // If the document was created after the last index time, it must be new.
              $doc->set_is_new(true);
          }
  
          return $doc;
      }
code: public function get_document($record, $options = array()) {
          try {
              $cm = $this->get_cm('wiki', $record->wikiid, $record->courseid);
              $context = \context_module::instance($cm->id);
          } catch (\dml_missing_record_exception $ex) {
              // Notify it as we run here as admin, we should see everything.
              debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                  $ex->getMessage(), DEBUG_DEVELOPER);
              return false;
          } catch (\dml_exception $ex) {
              // Notify it as we run here as admin, we should see everything.
              debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
              return false;
          }
  
          // Make a page object without extra fields.
          $page = clone $record;
          unset($page->courseid);
          unset($page->wikiid);
  
          // Conversion based wiki_print_page_content().
          // Check if we have passed the cache time.
          if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
              $content = wiki_refresh_cachedcontent($page);
              $page = $content['page'];
          }
          // Convert to text.
          $content = content_to_text($page->cachedcontent, FORMAT_MOODLE);
  
          // Prepare associative array with data from DB.
          $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
          $doc->set('title', content_to_text($record->title, false));
          $doc->set('content', $content);
          $doc->set('contextid', $context->id);
          $doc->set('courseid', $record->courseid);
          if ($record->groupid > 0) {
              $doc->set('groupid', $record->groupid);
          }
          $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
          $doc->set('modified', $record->timemodified);
  
          // Check if this document should be considered new.
          if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->timecreated)) {
              // If the document was created after the last index time, it must be new.
              $doc->set_is_new(true);
          }
  
          return $doc;
      }
code_tokens: public function get_document ( $ record , $ options = array ( ) ) { try { $ cm = $ this -> get_cm ( 'wiki' , $ record -> wikiid , $ record -> courseid ) ; $ context = \ context_module :: instance ( $ cm -> id ) ; } catch ( \ dml_missing_record_exception $ ex ) { // Notify it as we run here as admin, we should see everything. debugging ( 'Error retrieving ' . $ this -> areaid . ' ' . $ record -> id . ' document, not all required data is available: ' . $ ex -> getMessage ( ) , DEBUG_DEVELOPER ) ; return false ; } catch ( \ dml_exception $ ex ) { // Notify it as we run here as admin, we should see everything. debugging ( 'Error retrieving ' . $ this -> areaid . ' ' . $ record -> id . ' document: ' . $ ex -> getMessage ( ) , DEBUG_DEVELOPER ) ; return false ; } // Make a page object without extra fields. $ page = clone $ record ; unset ( $ page -> courseid ) ; unset ( $ page -> wikiid ) ; // Conversion based wiki_print_page_content(). // Check if we have passed the cache time. if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ content = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ content [ 'page' ] ; } // Convert to text. $ content = content_to_text ( $ page -> cachedcontent , FORMAT_MOODLE ) ; // Prepare associative array with data from DB. $ doc = \ core_search \ document_factory :: instance ( $ record -> id , $ this -> componentname , $ this -> areaname ) ; $ doc -> set ( 'title' , content_to_text ( $ record -> title , false ) ) ; $ doc -> set ( 'content' , $ content ) ; $ doc -> set ( 'contextid' , $ context -> id ) ; $ doc -> set ( 'courseid' , $ record -> courseid ) ; if ( $ record -> groupid > 0 ) { $ doc -> set ( 'groupid' , $ record -> groupid ) ; } $ doc -> set ( 'owneruserid' , \ core_search \ manager :: NO_OWNER_ID ) ; $ doc -> set ( 'modified' , $ record -> timemodified ) ; // Check if this document should be considered new. if ( isset ( $ options [ 'lastindexedtime' ] ) && ( $ options [ 'lastindexedtime' ] < $ record -> timecreated ) ) { // If the document was created after the last index time, it must be new. $ doc -> set_is_new ( true ) ; } return $ doc ; }
docstring: Returns the document for a particular page.
  
  @param \stdClass $record A record containing, at least, the indexed document id and a modified timestamp
  @param array     $options Options for document creation
  @return \core_search\document
docstring_tokens: Returns the document for a particular page .