MDL-62899 search: add document icons

This commit is contained in:
Dmitrii Metelkin
2018-08-07 17:40:57 +10:00
parent 6e8235c7d3
commit 66f145efd1
21 changed files with 403 additions and 1 deletions
+27
View File
@@ -58,6 +58,11 @@ class document implements \renderable, \templatable {
*/
protected $contexturl = null;
/**
* @var \core_search\document_icon Document icon instance.
*/
protected $docicon = null;
/**
* @var int|null The content field filearea.
*/
@@ -496,6 +501,24 @@ class document implements \renderable, \templatable {
return $this->docurl;
}
/**
* Sets document icon instance.
*
* @param \core_search\document_icon $docicon
*/
public function set_doc_icon(document_icon $docicon) {
$this->docicon = $docicon;
}
/**
* Gets document icon instance.
*
* @return \core_search\document_icon
*/
public function get_doc_icon() {
return $this->docicon;
}
public function set_context_url(\moodle_url $url) {
$this->contexturl = $url;
}
@@ -628,6 +651,10 @@ class document implements \renderable, \templatable {
$data['userfullname'] = format_string($this->get('userfullname'), true, array('context' => $this->get('contextid')));
}
if ($docicon = $this->get_doc_icon()) {
$data['icon'] = $output->image_url($docicon->get_name(), $docicon->get_component());
}
return $data;
}