mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-40759 icons: Split pix_icon from activity_icon
Activity icons always use the standard icon renderer.
This commit is contained in:
parent
95b06c13c6
commit
c2dde7eebc
7 changed files with 48 additions and 7 deletions
|
@ -271,7 +271,7 @@ abstract class backup_activity_task extends backup_task {
|
||||||
// - section_included setting (if exists)
|
// - section_included setting (if exists)
|
||||||
$settingname = $settingprefix . 'included';
|
$settingname = $settingprefix . 'included';
|
||||||
$activity_included = new backup_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true);
|
$activity_included = new backup_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true);
|
||||||
$activity_included->get_ui()->set_icon(new pix_icon('icon', get_string('pluginname', $this->modulename),
|
$activity_included->get_ui()->set_icon(new activity_icon('icon', get_string('pluginname', $this->modulename),
|
||||||
$this->modulename, array('class' => 'iconlarge icon-post')));
|
$this->modulename, array('class' => 'iconlarge icon-post')));
|
||||||
$this->add_setting($activity_included);
|
$this->add_setting($activity_included);
|
||||||
// Look for "activities" root setting
|
// Look for "activities" root setting
|
||||||
|
|
|
@ -287,7 +287,7 @@ abstract class restore_activity_task extends restore_task {
|
||||||
// - section_included setting (if exists)
|
// - section_included setting (if exists)
|
||||||
$settingname = $settingprefix . 'included';
|
$settingname = $settingprefix . 'included';
|
||||||
$activity_included = new restore_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true);
|
$activity_included = new restore_activity_generic_setting($settingname, base_setting::IS_BOOLEAN, true);
|
||||||
$activity_included->get_ui()->set_icon(new pix_icon('icon', get_string('pluginname', $this->modulename),
|
$activity_included->get_ui()->set_icon(new activity_icon('icon', get_string('pluginname', $this->modulename),
|
||||||
$this->modulename, array('class' => 'iconlarge icon-post')));
|
$this->modulename, array('class' => 'iconlarge icon-post')));
|
||||||
$this->add_setting($activity_included);
|
$this->add_setting($activity_included);
|
||||||
// Look for "activities" root setting
|
// Look for "activities" root setting
|
||||||
|
|
|
@ -171,7 +171,7 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||||
$table->data = array();
|
$table->data = array();
|
||||||
}
|
}
|
||||||
$name = get_string('pluginname', $activity->modulename);
|
$name = get_string('pluginname', $activity->modulename);
|
||||||
$icon = new pix_icon('icon', $name, $activity->modulename, array('class' => 'iconlarge icon-pre'));
|
$icon = new activity_icon('icon', $name, $activity->modulename, array('class' => 'iconlarge icon-pre'));
|
||||||
$table->data[] = array(
|
$table->data[] = array(
|
||||||
$this->output->render($icon).$name,
|
$this->output->render($icon).$name,
|
||||||
$activity->title,
|
$activity->title,
|
||||||
|
|
|
@ -184,7 +184,7 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
$output .= html_writer::start_tag('div', array('class' => 'activity_overview'));
|
$output .= html_writer::start_tag('div', array('class' => 'activity_overview'));
|
||||||
$url = new moodle_url("/mod/$module/index.php", array('id' => $cid));
|
$url = new moodle_url("/mod/$module/index.php", array('id' => $cid));
|
||||||
$modulename = get_string('modulename', $module);
|
$modulename = get_string('modulename', $module);
|
||||||
$icontext = html_writer::link($url, $this->output->pix_icon('icon', $modulename, 'mod_'.$module, array('class'=>'iconlarge')));
|
$icontext = html_writer::link($url, $this->output->activity_icon('icon', $modulename, 'mod_'.$module, array('class'=>'iconlarge')));
|
||||||
if (get_string_manager()->string_exists("activityoverview", $module)) {
|
if (get_string_manager()->string_exists("activityoverview", $module)) {
|
||||||
$icontext .= get_string("activityoverview", $module);
|
$icontext .= get_string("activityoverview", $module);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -705,6 +705,18 @@ class pix_icon implements renderable, templatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure representing an activity icon.
|
||||||
|
*
|
||||||
|
* The difference is that activity icons will always render with the standard icon system (no font icons).
|
||||||
|
*
|
||||||
|
* @copyright 2017 Damyon Wiese
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
* @package core
|
||||||
|
*/
|
||||||
|
class activity_icon extends pix_icon {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure representing an emoticon image
|
* Data structure representing an emoticon image
|
||||||
*
|
*
|
||||||
|
|
|
@ -2028,6 +2028,36 @@ class core_renderer extends renderer_base {
|
||||||
return html_writer::tag('a', $icon.$text, $attributes);
|
return html_writer::tag('a', $icon.$text, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return HTML for an activity_icon.
|
||||||
|
*
|
||||||
|
* Theme developers: DO NOT OVERRIDE! Please override function
|
||||||
|
* {@link core_renderer::render_activity_icon()} instead.
|
||||||
|
*
|
||||||
|
* @param string $pix short pix name
|
||||||
|
* @param string $alt mandatory alt attribute
|
||||||
|
* @param string $component standard compoennt name like 'moodle', 'mod_forum', etc.
|
||||||
|
* @param array $attributes htm lattributes
|
||||||
|
* @return string HTML fragment
|
||||||
|
*/
|
||||||
|
public function activity_icon($pix, $alt, $component='moodle', array $attributes = null) {
|
||||||
|
$icon = new activity_icon($pix, $alt, $component, $attributes);
|
||||||
|
return $this->render($icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a pix_icon widget and returns the HTML to display it.
|
||||||
|
*
|
||||||
|
* @param pix_icon $icon
|
||||||
|
* @return string HTML fragment
|
||||||
|
*/
|
||||||
|
protected function render_activity_icon(activity_icon $icon) {
|
||||||
|
global $PAGE;
|
||||||
|
|
||||||
|
$system = \core\output\icon_system::instance('standard');
|
||||||
|
return $system->render_pix_icon($this, $icon);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML for a pix_icon.
|
* Return HTML for a pix_icon.
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,11 +3,10 @@ information provided here is intended especially for developers.
|
||||||
=== 3.3 ===
|
=== 3.3 ===
|
||||||
* Moodle has support for font-awesome icons. Plugins should use the xxx_get_fontawesome_icon_map callback
|
* Moodle has support for font-awesome icons. Plugins should use the xxx_get_fontawesome_icon_map callback
|
||||||
to map their custom icons to one from font-awesome.
|
to map their custom icons to one from font-awesome.
|
||||||
|
|
||||||
=== 3.3 ===
|
|
||||||
|
|
||||||
* The method moodleform::after_definition() has been added and can now be used to add some logic
|
* The method moodleform::after_definition() has been added and can now be used to add some logic
|
||||||
to be performed after the form's definition was set. This is useful for intermediate subclasses.
|
to be performed after the form's definition was set. This is useful for intermediate subclasses.
|
||||||
|
* Activity icons have been split from standard icons. Use $OUTPUT->activity_icon instead of $OUTPUT->pix_icon for these
|
||||||
|
type of icons (the coloured main icon for each activity).
|
||||||
* YUI module moodle-core-formautosubmit has been removed, use jquery .change() instead (see lib/templates/url_select.mustache for
|
* YUI module moodle-core-formautosubmit has been removed, use jquery .change() instead (see lib/templates/url_select.mustache for
|
||||||
an example)
|
an example)
|
||||||
* $mform->init_javascript_enhancement() is deprecated and no longer does anything. Existing uses of smartselect enhancement
|
* $mform->init_javascript_enhancement() is deprecated and no longer does anything. Existing uses of smartselect enhancement
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue