$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
if ($filterinfo->active != TEXTFILTER_DISABLED) {
if (!$isfirstrow) {
- $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), get_string('up'), 't/up');
+ $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up')));
} else {
$updown .= $spacer;
}
if (!$islastactive) {
- $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), get_string('down'), 't/down');
+ $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down')));
} else {
$updown .= $spacer;
}
$reloadlink = new moodle_url($this->page->url, array('regenerate'=>'navigation'));
- $this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload', array('class'=>'customcommand'));
+ $this->content->footer .= $OUTPUT->action_icon($reloadlink, new pix_icon('t/reload', get_string('reload')), null, array('class'=>'customcommand'));
// Set content generated to true so that we know it has been done
$this->contentgenerated = true;
'<div class="url">' . html_writer::link($feed->url, $feed->url) .'</div>' .
'<div class="description">' . $feed->description . '</div>';
- $editurl = $CFG->wwwroot .'/blocks/rss_client/editfeed.php?rssid=' . $feed->id . $extraparams;
- $editaction = $OUTPUT->action_icon($editurl, get_string('edit'), 't/edit');
+ $editurl = new moodle_url('/blocks/rss_client/editfeed.php?rssid=' . $feed->id . $extraparams);
+ $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')));
- $deleteurl = $CFG->wwwroot .'/blocks/rss_client/managefeeds.php?deleterssid=' . $feed->id . '&sesskey=' . sesskey() . $extraparams;
- $deletelink = new html_link($deleteurl);
- $deletelink->add_confirm_action(get_string('deletefeedconfirm', 'block_rss_client'));
- $deleteaction = $OUTPUT->action_icon($deletelink, get_string('delete'), 't/delete');
+ $deleteurl = new moodle_url('/blocks/rss_client/managefeeds.php?deleterssid=' . $feed->id . '&sesskey=' . sesskey() . $extraparams);
+ $deleteicon = new pix_icon('t/delete', get_string('delete'));
+ $deleteaction = $OUTPUT->action_icon($deleteurl, $deleteicon, new confirm_action(get_string('deletefeedconfirm', 'block_rss_client')));
$feedicons = $editaction . ' ' . $deleteaction;
}
$reloadlink = new moodle_url($this->page->url, array('regenerate'=>'navigation'));
- $this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload', array('class'=>'customcommand'));
+ $this->content->footer .= $OUTPUT->action_icon($reloadlink, new pix_icon('t/reload', get_string('reload')), null, array('class'=>'customcommand'));
if (!empty($this->config->enablesidebarpopout) && $this->config->enablesidebarpopout == 'yes') {
user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav'.block_settings_navigation_tree::$navcount, PARAM_INT);
}
$editurl = new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id));
- $editicon = $OUTPUT->action_icon($editurl, get_string('editexternalblog', 'blog'), 't/edit');
+ $editicon = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('editexternalblog', 'blog')));
- $deletelink = new html_link(new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id, 'sesskey'=>sesskey())));
- $deletelink->add_confirm_action(get_string('externalblogdeleteconfirm', 'blog'));
- $deleteicon = $OUTPUT->action_icon($deletelink, get_string('deleteexternalblog', 'blog'), 't/delete');
+ $deletelink = new moodle_url('/blog/external_blog_edit.php', array('id' => $blog->id, 'sesskey'=>sesskey()));
+ $action = new confirm_action(get_string('externalblogdeleteconfirm', 'blog'));
+ $deleteicon = $OUTPUT->action_icon($deletelink, new pix_icon('t/delete', get_string('deleteexternalblog', 'blog')), $action);
$table->data[] = html_table_row::make(array($blog->name, $blog->url, userdate($blog->timefetched), $validicon, $editicon . $deleteicon));
}
if ($contextrec->contextlevel == CONTEXT_COURSE) {
$url = new moodle_url('/course/view.php', array('id' => $contextrec->instanceid));
$text = $DB->get_field('course', 'shortname', array('id' => $contextrec->instanceid)); //TODO: performance!!!!
- $assocstr .= $OUTPUT->action_icon($associconurl, $text, 'i/course');
+ $assocstr .= $OUTPUT->action_icon($associconurl, new pix_icon('i/course', $text));
$hascourseassocs = true;
$assoctype = get_string('course');
}
$url = new moodle_url('/mod/'.$modname.'/view.php', array('id' => $modinfo->id));
$text = $DB->get_field($modname, 'name', array('id' => $modinfo->instance)); //TODO: performance!!!!
- $assocstr .= $OUTPUT->action_icon($associconurl, $text, $OUTPUT->pix_url('icon', $modname));
+ $assocstr .= $OUTPUT->action_icon($associconurl, new pix_icon('icon', $text, $modname));
$assocstr .= ', ';
$assoctype = get_string('modulename', $modname);
$link = new moodle_url("/iplookup/index.php?ip=$log->ip&user=$log->userid");
$row[] = $OUTPUT->action_link($link, $log->ip, new popup_action('click', $link, 'iplookup', array('height' => 440, 'width' => 700)));
- $row[] = html_writer::link(new moodle_url("/user/view.php?id={$log->userid}&course={$log->course}", fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)))));
+ $row[] = html_writer::link(new moodle_url("/user/view.php?id={$log->userid}&course={$log->course}"), fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))));
$displayaction="$log->module $log->action";
if ($brokenurl) {
}
if (has_capability('coursereport/log:viewlive', $context)) {
$livelogs = get_string('livelogs');
- $link = new moodle_url('/course/report/log/live.php', array('id'=>$course->id));
- $link->add_action(new popup_action('click', $link->url, 'livelog', array('height' => 500, 'width' => 800)));
+ $url = new moodle_url('/course/report/log/live.php', array('id'=>$course->id));
+ $link = new action_link($url, $livelogs, new popup_action('click', $url, 'livelog', array('height' => 500, 'width' => 800)));
$navigation->add($livelogs, $link, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
}
\ No newline at end of file
if ($element['type'] == 'item' or ($element['type'] == 'category' and $element['depth'] > 1)) {
if ($this->element_deletable($element)) {
$aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'delete', 'eid' => $eid, 'sesskey' => sesskey()));
- $actions .= $OUTPUT->action_icon($aurl, get_string('delete'), 't/delete', array('class'=>'iconsmall'));
+ $actions .= $OUTPUT->action_icon($aurl, new pix_icon('t/delete', get_string('delete')));
}
$aurl = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'moveselect', 'eid' => $eid, 'sesskey' => sesskey()));
- $actions .= $OUTPUT->action_icon($aurl, get_string('move'), 't/move', array('class'=>'iconsmall'));
+ $actions .= $OUTPUT->action_icon($aurl, new pix_icon('t/move', get_string('move')));
}
$actions .= $this->gtree->get_hiding_icon($element, $this->gpr);
$cell = new html_table_cell();
$cell->colspan = 12;
- $cell->text = $OUTPUT->action_icon($aurl, $strmovehere, 'movehere', array('class'=>'movetarget'));
+ $cell->text = $OUTPUT->action_icon($aurl, $strmovehere, new pix_icon(array('class'=>'movetarget'), 'movehere'));
$moveto = html_table_row::make(array($cell));
}
$url->param('id', $key->id);
}
- $buttons = $OUTPUT->action_icon($url, $stredit, 't/edit', array('class'=>'iconsmall'));
+ $buttons = $OUTPUT->action_icon($url, new pix_icon('t/edit', $stredit));
$url->param('delete', 1);
$url->param('sesskey', sesskey());
- $buttons .= $OUTPUT->action_icon($url, $strdelete, 't/delete', array('class'=>'iconsmall'));
+ $buttons .= $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdelete));
$line[3] = $buttons;
$data[] = $line;
$url = new moodle_url('key.php', array('id' => $key->id));
- $buttons = $OUTPUT->action_icon($url, $stredit, 't/edit');
+ $buttons = $OUTPUT->action_icon($url, new pix_icon('t/edit', $stredit));
$url->param('delete', 1);
$url->param('sesskey', sesskey());
- $buttons .= $OUTPUT->action_icon($url, $strdelete, 't/delete');
+ $buttons .= $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdelete));
$line[3] = $buttons;
$data[] = $line;
}
if ($url) {
- return $OUTPUT->action_icon($gpr->add_url_params($url), $stredit, 't/edit', array('class'=>'iconsmall'));
+ return $OUTPUT->action_icon($gpr->add_url_params($url), new pix_icon('t/edit', $stredit));
} else {
return '';
$url->param('action', 'show');
- $hideicon = $OUTPUT->action_icon($url, $tooltip, 't/'.$type, array('alt'=>$strshow, 'class'=>'iconsmall'));
+ $hideicon = $OUTPUT->action_icon($url, new pix_icon('t/'.$type, $tooltip, 'moodle', array('alt'=>$strshow, 'class'=>'iconsmall')));
} else {
$url->param('action', 'hide');
- $hideicon = $OUTPUT->action_icon($url, $strhide, 't/hide', array('class'=>'iconsmall'));
+ $hideicon = $OUTPUT->action_icon($url, new pix_icon('t/hide', $strhide));
}
return $hideicon;
$action = '';
} else {
$url->param('action', 'unlock');
- $action = $OUTPUT->action_icon($url, $tooltip, 't/'.$type, array('alt'=>$strunlock, 'class'=>'smallicon'));
+ $action = $OUTPUT->action_icon($url, new pix_icon('t/'.$type, $tooltip, 'moodle', array('alt'=>$strunlock, 'class'=>'smallicon')));
}
} else {
$action = '';
} else {
$url->param('action', 'lock');
- $action = $OUTPUT->action_icon($url, $strlock, 't/lock', array('class'=>'smallicon'));
+ $action = $OUTPUT->action_icon($url, new pix_icon('t/lock', $strlock));
}
}
$url = new moodle_url('/grade/edit/tree/calculation.php', array('courseid' => $this->courseid, 'id' => $object->id));
$url = $gpr->add_url_params($url);
- return $OUTPUT->action_icon($url, $streditcalculation, $icon, array('class'=>'smallicon')) . "\n";
+ return $OUTPUT->action_icon($url, new pix_icon($icon, $streditcalculation)) . "\n";
}
}
$url = new moodle_url('edit.php', array('courseid' => $courseid, 'id' => $object->id));
}
- return $OUTPUT->action_icon($url, ${'str'.$type}, 't/'.$type, array('class'=>'iconsmall'));
+ return $OUTPUT->action_icon($url, new pix_icon('t/'.$type, ${'str'.$type}));
}
$aurl = clone($this->baseurl);
$url->params(array('toggle' => $toggleaction, 'toggle_type' => $type));
- $retval = $OUTPUT->container($OUTPUT->action_icon($url, $string, $imagename, array('class'=>'iconsmall'))); // TODO: this container looks wrong here
+ $retval = $OUTPUT->container($OUTPUT->action_icon($url, new pix_icon($imagename, $string))); // TODO: this container looks wrong here
return $retval;
}
$a->user = fullname($user);
$strgradesforuser = get_string('gradesforuser', 'grades', $a);
$url = new moodle_url('/grade/report/'.$CFG->grade_profilereport.'/index.php', array('userid' => $user->id, 'id' => $this->course->id));
- $userreportcell->text = $OUTPUT->action_icon($url, $strgradesforuser, 't/grades', array('class'=>'iconsmall'));
+ $userreportcell->text = $OUTPUT->action_icon($url, new pix_icon('t/grades', $strgradesforuser));
$userrow->cells[] = $userreportcell;
}
if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {
$url->param('action', 'switch_plus');
- $icon = $OUTPUT->action_icon($url, $strswitchplus, 't/switch_plus', array('class'=>'iconsmall'));
+ $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_plus', $strswitchplus));
} else if (in_array($element['object']->id, $this->collapsed['gradesonly'])) {
$url->param('action', 'switch_whole');
- $icon = $OUTPUT->action_icon($url, $strswitchwhole, 't/switch_whole', array('class'=>'iconsmall'));
+ $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_whole', $strswitchwhole));
$contractexpandicon->image->src = $OUTPUT->pix_url('t/switch_whole');
} else {
$url->param('action', 'switch_minus');
- $icon = $OUTPUT->action_icon($url, $strswitchminus, 't/switch_minus', array('class'=>'iconsmall'));
+ $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_minus', $strswitchminus));
}
}
return $icon;
return '';
}
- if ($this->action instanceof html_link) {
+ if ($this->action instanceof action_link) {
//TODO: to be replaced with something else
$link = $this->action;
if ($this->hidden) {
$link->add_class('dimmed');
}
- $content = $OUTPUT->link($link);
+ $content = $OUTPUT->render($link);
} else if ($this->action instanceof moodle_url) {
$attributes = array();
}
}
+
+/**
+ * Confirm action
+ */
+class confirm_action extends component_action {
+ public function __construct($message, $callback=null) {
+ parent::__construct('click', 'M.util.show_confirm_dialog', array('message' => $message, 'callback' => $callback));
+ }
+}
+
+
/**
* Component action for a popup window.
*
public function add_action(component_action $action) {
$this->actions[] = $action;
}
+
+ public function add_class($class) {
+ if (empty($this->atribbutes['class'])) {
+ $this->atribbutes['class'] = $class;
+ } else {
+ $this->atribbutes['class'] = $this->atribbutes['class'].' '.$class;
+ }
+ }
}
/**
* Given a html_link object, outputs an <a> tag that uses the object's attributes.
*
- * @param mixed $link A html_link object or a string URL (text param required in second case)
- * @param string $text A descriptive text for the link. If $link is a html_link, this is ignored.
- * @param array $options a tag attributes and link otpions. If $link is a html_link, this is ignored.
+ * @param string|moodle_url $url
+ * @param string $text A descriptive text for the link
+ * @param array $options a tag attributes and link otpions
* @return string HTML fragment
*/
public function link($link_or_url, $text = null, array $options = null) {
* @param array $attributes associative array of html link attributes + disabled
* @return HTML fragment
*/
- public function action_link($url, $text, component_action $action, array $attributes=null) {
+ public function action_link($url, $text, component_action $action = null, array $attributes=null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
return html_writer::tag('a', $attributes, $link->text);
}
+
+ /**
+ * Similar to action_link, image is used instead of the text
+ *
+ * @param string|moodle_url $url A string URL or moodel_url
+ * @param pix_icon $pixicon
+ * @param component_action $action
+ * @param array $attributes associative array of html link attributes + disabled
+ * @param bool $linktext show title next to image in link
+ * @return string HTML fragment
+ */
+ public function action_icon($url, pix_icon $pixicon, component_action $action = null, array $attributes = null, $linktext=false) {
+ if (!($url instanceof moodle_url)) {
+ $url = new moodle_url($url);
+ }
+ $attributes = (array)$attributes;
+
+ if (empty($options['class'])) {
+ // let ppl override the class via $options
+ $attributes['class'] = 'action-icon';
+ }
+
+ $icon = $this->render($pixicon);
+
+ if ($linktext) {
+ $text = $pixicon->attributes['alt'];
+ } else {
+ $text = '';
+ }
+
+ return $this->action_link($url, $text.$icon, $action, $attributes);
+ }
+
/**
* Print a message along with button choices for Continue/Cancel
*
return html_writer::empty_tag('img', $attributes);
}
- /**
- * Given a moodle_action_icon object, outputs an image linking to an action (URL or AJAX).
- *
- * @param mixed $url_or_link A html_link object or a string URL (text param required in second case)
- * @param string $title link title and also image alt if no alt specified in $options
- * @param html_image|moodle_url|string $image_or_url image or url of the image,
- * it is also possible to use short pix name for core images
- * @param array $options image attributes such as title, id, alt, widht, height
- * @param bool $linktext show title next to image in link
- * @return string HTML fragment
- */
- public function action_icon($url_or_link, $title, $image_or_url, array $options = null, $linktext=false) {
- $options = (array)$options;
- if (empty($options['class'])) {
- // let ppl override the class via $options
- $options['class'] = 'action-icon';
- }
-
- if (empty($title)) {
- debugging('$title should not be empty in action_icon() call');
- }
-
- if (!$linktext) {
- $options['alt'] = $title;
- }
-
- $icon = $this->image($image_or_url, $options);
-
- if ($linktext) {
- $icon = $icon . $title;
- }
-
- if ($url_or_link instanceof html_link) {
- $link = clone($url_or_link);
- $link->text = ($icon);
- } else {
- $link = new html_link($url_or_link, $icon);
- }
- $url = $link->url;
-
- return $this->link($link);
- }
-
/*
* Centered heading with attached help button (same title text)
* and optional icon attached
$links = array();
if (!empty($USER->screenreader)) {
- $links[] = html_link::make(new moodle_url($target.'gui_basic/index.php', $params), $strenterchat);
+ $url = new moodle_url($target.'gui_basic/index.php', $params);
+ $links[] = new action_link($url, $strenterchat, $action);
} else {
- $links[] = html_link::make(new moodle_url($target.'gui_'.$CFG->chat_method.'/index.php', $params), $strenterchat);
+ $url = new moodle_url($target.'gui_'.$CFG->chat_method.'/index.php', $params);
+ $action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700));
+ $links[] = new action_link($url, $strenterchat, $action);
}
if ($CFG->enableajax) {
- $links[] = html_link::make(new moodle_url($target.'gui_ajax/index.php', $params), get_string('ajax_gui', 'message'));
+ $url = new moodle_url($target.'gui_ajax/index.php', $params);
+ $action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700));
+ $links[] = new action_link($url, get_string('ajax_gui', 'message'), $action);
}
if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) {
- $links[] = html_link::make(new moodle_url($target.'gui_basic/index.php', $params), get_string('noframesjs', 'message'));
+ $url = new moodle_url($target.'gui_basic/index.php', $params);
+ $action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700));
+ $links[] = new action_link($url, get_string('noframesjs', 'message'), $action);
}
foreach ($links as $link) {
- $link->add_action(new popup_action('click', $link->url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700)));
- $link->title = get_string('modulename', 'chat');
- $navigation->add($link->title, $link, navigation_node::TYPE_ACTIVITY, null ,null, new pix_icon('c/group' , ''));
+ $navigation->add($link->text, $link, navigation_node::TYPE_ACTIVITY, null ,null, new pix_icon('c/group' , ''));
}
}
* @return html code to be displayed
*/
protected function remove_allocation_icon($link) {
- return $this->output->action_icon($link, 'X', 'i/cross_red_big');
+ return $this->output->action_icon($link, new pix_icon('i/cross_red_big', 'X'));
}
}
if ($summary->example->weight == 1) {
$url = new moodle_url('/mod/workshop/exsubmission.php',
array('cmid' => $this->page->context->instanceid, 'id' => $summary->example->id, 'edit' => 'on'));
- $o .= $this->output->action_icon($url, get_string('edit'), 'i/edit');
+ $o .= $this->output->action_icon($url, new pix_icon('i/edit', get_string('edit')));
}
$o .= $this->output->container_end();
foreach ($phase->actions as $action) {
switch ($action->type) {
case 'switchphase':
- $actions .= $this->output->action_icon($action->url, get_string('switchphase', 'workshop'), 'i/marker');
+ $actions .= $this->output->action_icon($action->url, new pix_icon('i/marker', get_string('switchphase', 'workshop')));
break;
}
}
if ($sortby !== $sortid or $sorthow !== 'ASC') {
$url = new moodle_url($PAGE->url);
$url->params(array('sortby' => $sortid, 'sorthow' => 'ASC'));
- $out .= $this->output->action_icon($url, get_string('sortasc', 'workshop'), 't/up', array('class' => 'sort asc'));
+ $out .= $this->output->action_icon($url, new pix_icon('t/up', get_string('sortasc', 'workshop')), null, array('class' => 'sort asc'));
}
if ($sortby !== $sortid or $sorthow !== 'DESC') {
$url = new moodle_url($PAGE->url);
$url->params(array('sortby' => $sortid, 'sorthow' => 'DESC'));
- $out .= $this->output->action_icon($url, get_string('sortdesc', 'workshop'), 't/down', array('class' => 'sort desc'));
+ $out .= $this->output->action_icon($url, new pix_icon('t/down', get_string('sortdesc', 'workshop')), null, array('class' => 'sort desc'));
}
}
return $out;
if ($env == 'filemanager' && $info->type == 'draft') {
continue;
}
- echo '<li>' . $OUTPUT->action_icon($aurl, $info->name, $info->icon, array('class'=>'smallicon')) . '</li>'; // no hardcoded styles!
+ echo '<li>' . $OUTPUT->action_icon($aurl, new pix_icon($info->icon, $info->name)) . '</li>'; // no hardcoded styles!
}
echo '</ul>';
echo '</div>';
$contentheading = $group->name;
if (has_capability('moodle/course:managegroups', $context)) {
$aurl = new moodle_url('/group/group.php', array('id' => $group->id, 'courseid' => $group->courseid));
- $contentheading .= ' ' . $OUTPUT->action_icon($aurl, get_string('editgroupprofile'), 't/edit');
+ $contentheading .= ' ' . $OUTPUT->action_icon($aurl, new pix_icon('t/edit', get_string('editgroupprofile')));
}
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'course_group_description', $group->id);
$queued = $e->get('queued');
$baseurl = new moodle_url('/portfolio/add.php', array('id'=>$q->id, 'logreturn'=>1, 'sesskey'=>sesskey()));
- $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), get_string('cancel'), 't/stop');
+ $iconstr = $OUTPUT->action_icon(new moodle_url($baseurl, array('cancel'=>1)), new pix_icon('t/stop', get_string('cancel')));
if (!$e->get('queued') && $e->get('expirytime') > $now) {
- $iconstr .= ' ' . $OUTPUT->action_icon($baseurl, get_string('continue'), 't/go');
+ $iconstr .= ' ' . $OUTPUT->action_icon($baseurl, new pix_icon('t/go', get_string('continue')));
}
$table->data[] = array(
$e->get('caller')->display_name(),