if (!empty($info->extraclasses)) {
$mod[$seq]->extraclasses = $info->extraclasses;
}
+ if (!empty($info->iconurl)) {
+ $mod[$seq]->iconurl = $info->iconurl;
+ }
if (!empty($info->onclick)) {
$mod[$seq]->onclick = $info->onclick;
}
// Minimise the database size by unsetting default options when they are
// 'empty'. This list corresponds to code in the cm_info constructor.
foreach (array('idnumber', 'groupmode', 'groupingid', 'groupmembersonly',
- 'indent', 'completion', 'extra', 'extraclasses', 'onclick', 'content',
+ 'indent', 'completion', 'extra', 'extraclasses', 'iconurl', 'onclick', 'content',
'icon', 'iconcomponent', 'customdata', 'showavailability', 'availablefrom',
'availableuntil', 'conditionscompletion', 'conditionsgrade',
'completionview', 'completionexpected', 'score', 'showdescription')
*/
private $extraclasses;
+ /**
+ * @var moodle_url full external url pointing to icon image for activity
+ */
+ private $iconurl;
+
/**
* @var string
*/
/**
* Note: Will collect view data, if not already obtained.
- * @return string Extra HTML code to display after link
+ * @return string Extra HTML code to display after link
*/
public function get_after_link() {
$this->obtain_view_data();
if (!$output) {
$output = $OUTPUT;
}
- if (!empty($this->icon)) {
+ // Support modules setting their own, external, icon image
+ if (!empty($this->iconurl)) {
+ $icon = $this->iconurl;
+
+ // Fallback to normal local icon + component procesing
+ } else if (!empty($this->icon)) {
if (substr($this->icon, 0, 4) === 'mod/') {
list($modname, $iconname) = explode('/', substr($this->icon, 4), 2);
$icon = $output->pix_url($iconname, $modname);
$this->extraclasses = $extraclasses;
}
+ /**
+ * Sets the external full url that points to the icon being used
+ * by the activity. Useful for external-tool modules (lti...)
+ * If set, takes precedence over $icon and $iconcomponent
+ *
+ * @param moodle_url $iconurl full external url pointing to icon image for activity
+ * @return void
+ */
+ public function set_icon_url(moodle_url $iconurl) {
+ $this->iconurl = $iconurl;
+ }
+
/**
* Sets value of on-click attribute for JavaScript.
* Note: May not be called from _cm_info_view (only _cm_info_dynamic).
$this->indent = isset($mod->indent) ? $mod->indent : 0;
$this->extra = isset($mod->extra) ? $mod->extra : '';
$this->extraclasses = isset($mod->extraclasses) ? $mod->extraclasses : '';
+ $this->iconurl = isset($mod->iconurl) ? $mod->iconurl : '';
$this->onclick = isset($mod->onclick) ? $mod->onclick : '';
$this->content = isset($mod->content) ? $mod->content : '';
$this->icon = isset($mod->icon) ? $mod->icon : '';
*/
public $extraclasses;
+ /**
+ * External URL image to be used by activity as icon, useful for some external-tool modules
+ * like lti. If set, takes precedence over $icon and $iconcomponent
+ * @var $moodle_url
+ */
+ public $iconurl;
+
/**
* Content of onclick JavaScript; escaped HTML to be inserted as attribute value
* @var string
*/
public $onclick;
-}
\ No newline at end of file
+}