MDL-62899 search: add document icons
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user