Moodle PHP Documentation 4.1
Moodle 4.1dev (Build: 20220512) (5e5e12e0)
|
Respresents a document to index. More...
Public Member Functions | |
add_stored_file ($file) | |
Add a stored file to the document. More... | |
export_file_for_engine ($file) | |
Export the data for the given file in relation to this document. More... | |
export_for_engine () | |
Returns the document ready to submit to the search engine. More... | |
export_for_template (\renderer_base $output) | |
Export the document data to be used as a template context. More... | |
export_for_template (renderer_base $output) | |
Function to export the renderer data in a format that is suitable for a mustache template. More... | |
get ($field) | |
Getter. More... | |
get_context_url () | |
Gets the url to the context. More... | |
get_doc_icon () | |
Gets document icon instance. More... | |
get_doc_url () | |
Gets the url to the doc. More... | |
get_files () | |
Returns the array of attached files. More... | |
get_is_new () | |
Returns if the document is new. More... | |
is_set ($field) | |
Checks if a field is set. More... | |
set ($fieldname, $value) | |
Setter. More... | |
set_context_url (\moodle_url $url) | |
set_data_from_engine ($docdata) | |
Fills the document with data coming from the search engine. More... | |
set_doc_icon (document_icon $docicon) | |
Sets document icon instance. More... | |
set_doc_url (\moodle_url $url) | |
Sets the document url. More... | |
set_extra ($fieldname, $value) | |
Sets data to this->extradata. More... | |
set_is_new ($new) | |
Set if this is a new document. More... | |
Static Public Member Functions | |
static | format_string_for_engine ($string) |
Formats the timestamp according to the search engine needs. More... | |
static | format_text_for_engine ($text) |
Formats a text value for the search engine. More... | |
static | format_time_for_engine ($timestamp) |
Formats the timestamp according to the search engine needs. More... | |
static | get_default_fields_definition () |
Returns all default fields definitions. More... | |
static | import_time_from_engine ($time) |
Returns a timestamp from the value stored in the search engine. More... | |
Public Attributes | |
const | INDEXED_FILE_ERROR = -1 |
Indicates the file contents were not indexed due to an error. | |
const | INDEXED_FILE_FALSE = 0 |
Indicates the file contents were not indexed due filtering/settings. | |
const | INDEXED_FILE_TRUE = 1 |
Indicates the file contents are indexed with the record. | |
int const | SCHEMA_VERSION = 2017091700 |
Change list (for engine implementers): 2017091700 - add optional field groupid. More... | |
Protected Member Functions | |
apply_defaults () | |
Apply any defaults to unset fields before export. More... | |
format_text ($text) | |
Formats a text string coming from the search engine. More... | |
get_text_format () | |
Overwritten to use markdown format as we use markdown for solr highlighting. More... | |
Protected Attributes | |
int null | $contentfilearea = null |
The content field filearea. | |
int null | $contentitemid = null |
The content field itemid. | |
moodle_url | $contexturl = null |
Link to the document context. | |
array | $data = array() |
$data The document data. | |
core_search document_icon | $docicon = null |
Document icon instance. | |
moodle_url | $docurl = null |
Link to the document. | |
array | $extradata = array() |
Extra data needed to render the document. | |
stored_file[] | $files = array() |
An array of stored files to attach to the document. | |
bool | $isnew = false |
Should be set to true if document hasn't been indexed before. More... | |
Static Protected Attributes | |
static array | $enginefields |
Any fields that are engine specifc. More... | |
static array | $optionalfields |
All optional fields docs can contain. More... | |
static array | $requiredfields |
All required fields any doc should contain. More... | |
Respresents a document to index.
|
inherited |
Add a stored file to the document.
stored_file | int | $file | The file to add, or file id. |
void |
|
protected |
Apply any defaults to unset fields before export.
Called after document building, but before export.
Sub-classes of this should make sure to call parent::apply_defaults().
Reimplemented from core_search\document.
search_solr\document::export_file_for_engine | ( | $file | ) |
Export the data for the given file in relation to this document.
stored_file | $file | The stored file we are talking about. |
array |
|
inherited |
Returns the document ready to submit to the search engine.
coding_exception |
array |
|
inherited |
Export the document data to be used as a template context.
Adding more info than the required one as people might be interested in extending the template.
Although content is a required field when setting up the document, it accepts '' (empty) values as they may be the result of striping out HTML.
SECURITY NOTE: It is the responsibility of the document to properly escape any text to be displayed. The renderer will output the content without any further cleaning.
renderer_base | $output | The renderer. |
array |
|
inherited |
Function to export the renderer data in a format that is suitable for a mustache template.
This means:
renderer_base | $output | Used to do a final render of any components that need to be rendered for export. |
stdClass|array |
Implemented in tool_admin_presets\output\export_import, tool_admin_presets\output\presets_list, tool_componentlibrary\local\examples\dynamictabs\tab1, tool_componentlibrary\local\examples\dynamictabs\tab2, tool_customlang\output\translator, tool_dataprivacy\output\categories, tool_dataprivacy\output\data_deletion_page, tool_dataprivacy\output\data_registry_compliance_page, tool_dataprivacy\output\data_registry_page, tool_dataprivacy\output\data_requests_page, tool_dataprivacy\output\defaults_page, tool_dataprivacy\output\my_data_requests_page, tool_dataprivacy\output\purposes, tool_dataprivacy\output\request_filter, tool_dataprivacy\output\summary_page, tool_langimport\output\langimport_page, tool_lp\output\competency_plan_navigation, tool_lp\output\competency_summary, tool_lp\output\course_competencies_page, tool_lp\output\manage_competencies_page, tool_lp\output\manage_competency_frameworks_page, tool_lp\output\manage_templates_page, tool_lp\output\module_navigation, tool_lp\output\plans_page, tool_lp\output\related_competencies, tool_lp\output\template_competencies_page, tool_lp\output\user_competency_course_navigation, tool_lp\output\user_competency_summary, tool_lp\output\user_competency_summary_in_course, tool_lp\output\user_evidence_list_page, tool_policy\output\acceptances, tool_policy\output\guestconsent, tool_policy\output\page_agreedocs, tool_policy\output\page_managedocs_list, tool_policy\output\page_nopermission, tool_policy\output\page_viewalldoc, tool_policy\output\page_viewdoc, tool_templatelibrary\output\list_templates_page, core_auth\output\digital_minor_page, core_auth\output\login, core_auth\output\verify_age_location_page, core_badges\output\manage_badge_action_bar, core_badges\output\recipients_action_bar, core_badges\output\standard_action_bar, block_lp\output\competencies_to_review_page, block_lp\output\plans_to_review_page, block_lp\output\summary, block_myoverview\output\main, block_myprofile\output\myprofile, block_recentlyaccessedcourses\output\main, block_recentlyaccesseditems\output\main, block_search_forums\output\search_form, block_starredcourses\output\main, block_timeline\output\main, core_contentbank\output\bankcontent, core_contentbank\output\viewcontent, core_course\output\activity_information, core_course\output\completion_action_bar, core_courseformat\output\local\content\cm, core_courseformat\output\local\content\section, enrol_lti\output\registration, core_group\output\group_details, core_group\output\index_page, core_h5p\output\libraries, core\navigation\output\more_menu, core\output\activity_header, core\output\checkbox_toggleall, core\output\chooser, core\output\chooser_item, core\output\chooser_section, core\output\dynamic_tabs, MoodleQuickForm_advcheckbox, MoodleQuickForm_autocomplete, MoodleQuickForm_checkbox, MoodleQuickForm_date_selector, MoodleQuickForm_date_time_selector, MoodleQuickForm_editor, MoodleQuickForm_filemanager, MoodleQuickForm_filepicker, MoodleQuickForm_grading, MoodleQuickForm_group, MoodleQuickForm_passwordunmask, MoodleQuickForm_recaptcha, MoodleQuickForm_select, MoodleQuickForm_selectgroups, MoodleQuickForm_selectwithlink, MoodleQuickForm_static, MoodleQuickForm_submit, MoodleQuickForm_tags, MoodleQuickForm_textarea, MoodleQuickForm_url, MoodleQuickForm_warning, component_action, help_icon, pix_icon_font, pix_icon, single_select, url_select, paging_bar, initials_bar, custom_menu_item, tabobject, tabtree, action_menu, progress_bar, login_signup_form, mod_assign\output\grading_app, mod_assign\output\timelimit_panel, assign_attempt_history_chooser, mod_bigbluebuttonbn\output\import_view, mod_bigbluebuttonbn\output\instance_updated_message, mod_bigbluebuttonbn\output\recording_row_actionbar, mod_bigbluebuttonbn\output\recording_row_playback, mod_bigbluebuttonbn\output\recording_row_preview, mod_bigbluebuttonbn\output\recordings_session, mod_bigbluebuttonbn\output\view_page, booktool_print\output\print_book_chapter_page, booktool_print\output\print_book_page, mod_feedback\output\base_action_bar, mod_feedback\output\summary, mod_forum\output\big_search_form, mod_forum\output\forum_actionbar, mod_forum\output\quick_search_form, mod_forum\output\subscription_actionbar, mod_glossary\output\standard_action_bar, mod_h5pactivity\output\attempt, mod_h5pactivity\output\reportattempts, mod_h5pactivity\output\reportlink, mod_h5pactivity\output\reportresults, mod_h5pactivity\output\result, mod_h5pactivity\output\result\longfillin, mod_h5pactivity\output\result\other, mod_lti\output\external_registration_return_page, mod_lti\output\registration_upgrade_choice_page, mod_lti\output\repost_crosssite_page, mod_lti\output\tool_configure_page, mod_quiz\output\overrides_actions, mod_scorm\output\actionbar, mod_scorm\output\userreportsactionbar, mod_survey\output\actionbar, MoodleQuickForm_wikieditor, mod_workshop\output\actionbar, core_privacy\output\exported_html_page, core_privacy\output\exported_navigation_page, core_question\output\qbank_action_menu, report_competency\output\report, report_competency\output\user_course_navigation, core_reportbuilder\output\custom_report, core_reportbuilder\output\dynamictabs\access, core_reportbuilder\output\dynamictabs\audience, core_reportbuilder\output\dynamictabs\editor, core_reportbuilder\output\dynamictabs\schedules, core_reportbuilder\output\system_report, core_tag\output\tag, core_tag\output\tagcloud, core_tag\output\tagfeed, core_tag\output\tagindex, core_tag\output\taglist, core_user\output\participants_filter, core_user\output\status_field, core_user\output\unified_filter, and forumreport_summary\output\filters.
|
static |
Formats the timestamp according to the search engine needs.
int | $timestamp |
string |
Reimplemented from core_search\document.
|
protected |
Formats a text string coming from the search engine.
string | $text | Text to format |
string | HTML text to be renderer |
Reimplemented from core_search\document.
|
staticinherited |
Formats a text value for the search engine.
Search engines may overwrite this method to apply restrictions, like limiting the size. The default behaviour is just returning the string.
string | $text |
string |
|
static |
Formats the timestamp according to the search engine needs.
int | $timestamp |
string |
Reimplemented from core_search\document.
|
inherited |
Getter.
Use self::is_set if you are not sure if this field is set or not as otherwise it will trigger a coding_exception
coding_exception |
string | $field |
string|int |
|
inherited |
Gets the url to the context.
moodle_url |
|
staticinherited |
Returns all default fields definitions.
array |
|
inherited |
Gets document icon instance.
core_search::document_icon |
|
inherited |
Gets the url to the doc.
moodle_url |
|
inherited |
Returns the array of attached files.
stored_file[] |
|
inherited |
Returns if the document is new.
False if unknown.
bool |
|
protected |
Overwritten to use markdown format as we use markdown for solr highlighting.
int |
Reimplemented from core_search\document.
|
static |
Returns a timestamp from the value stored in the search engine.
string | $time |
int |
Reimplemented from core_search\document.
|
inherited |
Checks if a field is set.
string | $field |
bool |
|
inherited |
Setter.
Basic checkings to prevent common issues.
If the field is a string tags will be stripped, if it is an integer or a date it will be casted to a PHP integer. tdate fields values are expected to be timestamps.
coding_exception |
string | $fieldname | The field name |
string | int | $value | The value to store |
string|int | The stored value |
|
inherited |
Fills the document with data coming from the search engine.
core_search::engine_exception |
array | $docdata |
void |
|
inherited |
Sets document icon instance.
core_search::document_icon | $docicon |
|
inherited |
|
inherited |
Sets data to this->extradata.
This data can be retrieved using core_search::document->get($fieldname).
string | $fieldname | |
string | $value |
void |
|
inherited |
Set if this is a new document.
False if unknown.
bool | $new |
|
staticprotected |
Any fields that are engine specifc.
These are fields that are solely used by a seach engine plugin for internal purposes.
|
protectedinherited |
Should be set to true if document hasn't been indexed before.
False if unknown.
|
staticprotectedinherited |
All optional fields docs can contain.
Although it matches solr fields format, this is just to define the field types. Search engine plugins are responsible of setting their appropriate field types and map these naming to whatever format they need.
|
staticprotectedinherited |
All required fields any doc should contain.
We have to choose a format to specify field types, using solr format as we have to choose one and solr is the default search engine.
Search engine plugins are responsible of setting their appropriate field types and map these naming to whatever format they need.
|
inherited |
Change list (for engine implementers): 2017091700 - add optional field groupid.
Schema version number (update if any change)