Skip to content

Commit

Permalink
MDL-20204 converted action_icon
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 16, 2010
1 parent 3ea5951 commit c63923b
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 103 deletions.
4 changes: 2 additions & 2 deletions admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
$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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function get_content() {

$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;
Expand Down
11 changes: 5 additions & 6 deletions blocks/rss_client/managefeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,12 @@
'<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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function get_content() {
}

$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);
Expand Down
8 changes: 4 additions & 4 deletions blog/external_blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
}

$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));
}
Expand Down
4 changes: 2 additions & 2 deletions blog/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function print_html($return=false) {
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');
}
Expand All @@ -260,7 +260,7 @@ public function print_html($return=false) {

$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);

Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
$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) {
Expand Down
4 changes: 2 additions & 2 deletions course/report/log/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ function log_report_extend_navigation($navigation, $course, $context) {
}
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', ''));
}
}
6 changes: 3 additions & 3 deletions grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public function build_html_tree($element, $totals, $parents, $level, &$row_count
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);
Expand Down Expand Up @@ -215,7 +215,7 @@ public function build_html_tree($element, $totals, $parents, $level, &$row_count

$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));
}
Expand Down
4 changes: 2 additions & 2 deletions grade/export/keymanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
$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;
Expand Down
4 changes: 2 additions & 2 deletions grade/import/keymanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@

$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;
Expand Down
14 changes: 7 additions & 7 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ public function get_edit_icon($element, $gpr) {
}

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 '';
Expand Down Expand Up @@ -1508,11 +1508,11 @@ public function get_hiding_icon($element, $gpr) {

$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;
Expand Down Expand Up @@ -1559,15 +1559,15 @@ public function get_locking_icon($element, $gpr) {
$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 {
if (!has_capability('moodle/grade:manage', $this->context) and !has_capability('moodle/grade:lock', $this->context)) {
$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));
}
}

Expand Down Expand Up @@ -1608,7 +1608,7 @@ public function get_calculation_icon($element, $gpr) {

$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";
}
}

Expand Down Expand Up @@ -2236,6 +2236,6 @@ function grade_button($type, $courseid, $object) {
$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}));

}
10 changes: 5 additions & 5 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public function print_toggle($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;
}
Expand Down Expand Up @@ -611,7 +611,7 @@ public function get_left_rows() {
$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;
}

Expand Down Expand Up @@ -1440,16 +1440,16 @@ protected function get_collapsing_icon($element) {

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;
Expand Down
4 changes: 2 additions & 2 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,13 @@ public function content($shorttext=false) {
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();
Expand Down
11 changes: 11 additions & 0 deletions lib/outputactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ public function __construct($event, $jsfunction, $jsfunctionargs=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.
*
Expand Down
8 changes: 8 additions & 0 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ public function __construct(moodle_url $url, $text, component_action $action=nul
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;
}
}
}


Expand Down
Loading

0 comments on commit c63923b

Please sign in to comment.