Example #1
0
 /**
  * Export context for use in mustache templates
  *
  * @see templatable::export_for_template()
  * @param renderer_base $output
  * @return array
  */
 public function export_for_template(\renderer_base $output)
 {
     $data = array('id' => $this->id, 'permalink' => clean_param($this->permalink, PARAM_URL), 'datepublished' => $output->format_published_date($this->timestamp), 'link' => clean_param($this->link, PARAM_URL));
     // If the item does not have a title, create one from the description.
     $title = $this->title;
     if (!$title) {
         $title = strip_tags($this->description);
         $title = \core_text::substr($title, 0, 20) . '...';
     }
     // Allow the renderer to format the title and description.
     $data['title'] = $output->format_title($title);
     $data['description'] = $this->showdescription ? $output->format_description($this->description) : null;
     return $data;
 }