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
177160
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;
    }
778325
protected function getFormattedSelection(ViewableData $record)
    {
        if ($format = $this->getFormatSelection()) {
            return SSViewer::fromString($format)->process($record);
        }
    }
1102271
protected function getRecordGridfieldRow($record)
    {
        $this->gridField->setList(new ArrayList(array($record)));
        $rowContent = '';

        foreach ($this->gridField->getColumns() as $column) {
            $colContent = $this->gridField->getColumnContent($record, $column);
            // Null means this columns should be skipped altogether.
            if ($colContent === null) {
                continue;
            }

            $colAttributes = $this->gridField->getColumnAttributes($record, $column);
            $rowContent .= HTML::createTag(
                'td',
                $colAttributes,
                $colContent
            );
        }

        $rowAttributes = array(
            'class' => 'ss-gridfield-item ' . implode(' ', $this->successClasses),
            'data-id' => $record->ID,
            'data-class' => $record->ClassName,
        );
        $row = HTML::createTag(
            'tr',
            $rowAttributes,
            $rowContent
        );
        return $row;
    }
1342808
public static function create_from_record($record) {
        $event = static::create([
            'objectid' => $record->id,
            'relateduserid' => $record->userid,
            'context' => \context_user::instance($record->userid),
            'other' => [
                'policyversionid' => $record->policyversionid,
                'note' => $record->note,
                'status' => $record->status,
            ],
        ]);
        $event->add_record_snapshot($event->objecttable, $record);
        return $event;
    }
493988
public function getArchiveAction($gridField, $record)
    {
        /* @var DataObject|Versioned $record */
        if (!$record->hasMethod('canArchive') || !$record->canArchive()) {
            return null;
        }

        $title = _t(__CLASS__ . '.Archive', "Archive");

        $field = GridField_FormAction::create(
            $gridField,
            'ArchiveRecord' . $record->ID,
            false,
            "archiverecord",
            ['RecordID' => $record->ID]
        )
            ->addExtraClass('action--archive btn--icon-md font-icon-box btn--no-text grid-field__icon-action action-menu--handled')
            ->setAttribute('classNames', 'action--archive font-icon-box')
            ->setDescription($title)
            ->setAttribute('aria-label', $title);

        return $field;
    }
891766
public function processRecord(array $record)
    {
        if (is_null($this->requestId)) {
            $this->requestId = uniqid('');
        }

        $record['extra']['requestId'] = $this->requestId;

        return $record;
    }
981839
protected function getDocument($record)
    {
        $document = new Document();
        $document->setData($record);
        $document->setType($this->type);
        $document->setIndex($this->index);

        return $document;
    }
202992
public function get_document($record, $options = array()) {
        $doc = parent::get_document($record, $options);
        if (!$doc) {
            return false;
        }

        $doc->set('description1', $record->externalurl);
        return $doc;
    }
30018
public function listDocuments($collection, array $options = [])
    {
        $this->setOptions($options);
        $doc = new Document($this->client, $this->database, $collection);
        $doc->setHeaders($this->getHeaders());
        $rs = $doc->getAll();
        $this->checkResponse($rs);
        unset($rs['_curl_info']);

        return $rs;
    }
268948
public function addRecord($record)
    {
        if ((isset($this->DBFHeader)) && (is_array($this->DBFHeader))) {
            $record->updateDBFInfo($this->DBFHeader);
        }

        $this->fileLength += ($record->getContentLength() + 4);
        $this->records[] = $record;
        $this->records[count($this->records) - 1]->recordNumber = count($this->records);

        $this->updateBBox('x', $record->SHPData);
        $this->updateBBox('y', $record->SHPData);

        if (in_array($this->shapeType, [11, 13, 15, 18, 21, 23, 25, 28])) {
            $this->updateBBox('m', $record->SHPData);
        }

        if (in_array($this->shapeType, [11, 13, 15, 18])) {
            $this->updateBBox('z', $record->SHPData);
        }

        return count($this->records) - 1;
    }
630263
public function create($document, $options = null)
    {
        $this->assertProperties($document, ['_type'], 'create');
        return $this->createDocument($document, 'create', $options);
    }
1071257
public function getValueFromRecord(\Mmi\Orm\RecordRo $record)
    {
        if (!$this->isFieldInRecord()) {
            return '?';
        }
        if (strpos($this->getName(), '.')) {
            $table = explode('.', $this->getName());
            return $record->getJoined($table[0])->{$table[1]};
        }
        return $record->{$this->getName()};
    }
206857
protected function addRecord(array $record)
    {
        return $this->document->fputcsv($record, $this->delimiter, $this->enclosure, $this->escape);
    }
332481
protected function fetchDocumentData($options)
    {
        $documents = $this->dependencyManager->getDocuments($options['orderId'], $options['locale']);
        if (!empty($documents)) {
            /* @var SalesDocument $document */
            foreach ($documents as $document) {
                $data = $document->getSalesDocumentData();
                parent::addEntry(
                    $this->getProperty($data, 'id'),
                    $this->getProperty($data, 'number'),
                    $this->getProperty($data, 'icon'),
                    $this->getProperty($data, 'date'),
                    parent::getRoute($data['id'], $data['type'], 'details'),
                    $this->getProperty($data, 'pdfBaseUrl'),
                    $this->getProperty($data, 'translationKey')
                );
            }
        }
    }
1186548
protected function extractID($record)
    {
        // Normalize to string:
        $id = (string)$record->header->identifier;

        // Strip prefix if found:
        if (substr($id, 0, strlen($this->idPrefix)) == $this->idPrefix) {
            $id = substr($id, strlen($this->idPrefix));
        }

        // Apply regular expression matching:
        if (!empty($this->idSearch)) {
            $id = preg_replace($this->idSearch, $this->idReplace, $id);
        }

        // Return final value:
        return $id;
    }
438779
public function get_document($record, $options = array()) {
        global $CFG;
        require_once($CFG->dirroot . '/course/lib.php');

        // Get the context, modinfo, and section.
        try {
            $context = \context_course::instance($record->course);
        } catch (\moodle_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;
        }

        // Title - use default if none given.
        $title = get_section_name($record->course, $record->section);

        // 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($title, false));
        $doc->set('content', content_to_text($record->summary, $record->summaryformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->course);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->timemodified);

        return $doc;
    }
221632
protected function defaultFilterCb(\stdClass $record)
    {
        if ($this->skipOver['phpInternals'] && $record->isInternal) {
            return self::SKIP;
        }

        if ($this->skipOver['XDebugTrace']) {
            if ($record->filename === __FILE__) {
                return self::SKIP;
            }

            if (\strpos($record->function, 'XDebug::') === 0) {
                return self::SKIP;
            }
        }

        if ($this->skipOver['Hail'] && \strpos($record->function, 'Hail\\') === 0) {
            return self::SKIP;
        }

        if ($this->skipOver['Composer'] && \strpos($record->function, 'Composer\\') === 0) {
            return self::SKIP;
        }

        if ($this->skipOver['callbacks'] && ($record->function === 'callback' || $record->function === '{closure}')) {
            return self::SKIP;
        }

        if ($this->skipOver['includes'] && $record->includeFile !== null) {
            return self::SKIP;
        }

        return 0;
    }