diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 67747ad967f..3815eba9ea3 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -338,6 +338,23 @@ class pix_icon implements renderable { } } +/** + * Data structure representing an emoticon image + * + * @since Moodle 2.0 + */ +class pix_emoticon extends pix_icon implements renderable { + + /** + * Constructor + * @param string $pix short icon name + * @param string $component component name + */ + public function __construct($pix, $alt, $component = 'moodle') { + $attributes = array('class' => 'emoticon'); + parent::__construct($pix, $alt, $component, $attributes); + } +} /** * Data structure representing a simple form with only one button. diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 7696a6414c3..87c307fb4a3 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1358,6 +1358,17 @@ class core_renderer extends renderer_base { return html_writer::empty_tag('img', $attributes); } + /** + * Render emoticon + * @param pix_emoticon $emoticon + * @return string HTML fragment + */ + protected function render_pix_emoticon(pix_emoticon $emoticon) { + $attributes = $emoticon->attributes; + $attributes['src'] = $this->pix_url($emoticon->pix, $emoticon->component); + return html_writer::empty_tag('img', $attributes); + } + /** * Produces the html that represents this rating in the UI * @param $page the page object on which this rating will appear