Skip to content

Commit

Permalink
MDL-6820 - make block icons clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijaya committed Aug 20, 2010
1 parent 59e2938 commit 710363c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 45 deletions.
8 changes: 4 additions & 4 deletions blocks/activity_modules/block_activity_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function get_content() {

foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/resources.php?id='.$course->id.'">'.$modfullname.'</a>';
$this->content->icons[] = '<img src="'.$OUTPUT->pix_url('f/html') . '" class="icon" alt="" />';
$icon = '<img src="'.$OUTPUT->pix_url('f/html') . '" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/resources.php?id='.$course->id.'">'.$icon.$modfullname.'</a>';
} else {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$modfullname.'</a>';
$this->content->icons[] = '<img src="'.$OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" />';
$icon = '<img src="'.$OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$icon.$modfullname.'</a>';
}
}

Expand Down
9 changes: 4 additions & 5 deletions blocks/community/block_community.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ function get_content() {
if (!isloggedin()) {
return $this->content;
}


$icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'),
'class' => 'icon', 'alt' => get_string('addcourse', 'block_community')));
$addcourseurl = new moodle_url('/blocks/community/communitycourse.php',
array('add' => true, 'courseid' => $this->page->course->id));
$searchlink = html_writer::tag('a', get_string('addcourse', 'block_community'),
$searchlink = html_writer::tag('a', $icon .'&nbsp;'.get_string('addcourse', 'block_community'),
array('href' => $addcourseurl->out(false)));
$this->content->items[] = $searchlink;
$icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'),
'class' => 'icon', 'alt' => get_string('addcourse', 'block_community')));
$this->content->icons[] = $icon;

require_once($CFG->dirroot . '/blocks/community/locallib.php');
$communitymanager = new block_community_manager();
Expand Down
20 changes: 7 additions & 13 deletions blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function get_content() {
$this->content->icons = array();
$this->content->footer = '';

$icon = "<img src=\"" . $OUTPUT->pix_url('i/course') . "\"".
" class=\"icon\" alt=\"".get_string("coursecategory")."\" />";
$icon = '<img src="' . $OUTPUT->pix_url('i/course') . '" class="icon" alt="" />&nbsp;';

$adminseesall = true;
if (isset($CFG->block_course_list_adminview)) {
Expand All @@ -39,8 +38,7 @@ function get_content() {
foreach ($courses as $course) {
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
$this->content->items[]="<a $linkcss title=\"" . format_string($course->shortname) . "\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">" . format_string($course->fullname) . "</a>";
$this->content->icons[]=$icon;
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">".$icon.format_string($course->fullname). "</a>";
}
$this->title = get_string('mycourses');
/// If we can update any course of the view all isn't hidden, show the view all courses link
Expand All @@ -59,8 +57,7 @@ function get_content() {
if (count($categories) > 1 || (count($categories) == 1 && $DB->count_records('course') > 200)) { // Just print top level category links
foreach ($categories as $category) {
$linkcss = $category->visible ? "" : " class=\"dimmed\" ";
$this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">" . format_string($category->name) . "</a>";
$this->content->icons[]=$icon;
$this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">".$icon . format_string($category->name) . "</a>";
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) || empty($CFG->block_course_list_hideallcourseslink)) {
Expand All @@ -78,8 +75,7 @@ function get_content() {
$this->content->items[]="<a $linkcss title=\""
. format_string($course->shortname)."\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">"
. format_string($course->fullname) . "</a>";
$this->content->icons[]=$icon;
.$icon. format_string($course->fullname) . "</a>";
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) || empty($CFG->block_course_list_hideallcourseslink)) {
Expand Down Expand Up @@ -110,7 +106,7 @@ function get_remote_courses() {
return;
}

$icon = '<img src="'.$OUTPUT->pix_url('i/mnethost') . '" class="icon" alt="'.get_string('course').'" />';
$icon = '<img src="'.$OUTPUT->pix_url('i/mnethost') . '" class="icon" alt="" />&nbsp;';

// shortcut - the rest is only for logged in users!
if (!isloggedin() || isguestuser()) {
Expand All @@ -123,8 +119,7 @@ function get_remote_courses() {
foreach ($courses as $course) {
$this->content->items[]="<a title=\"" . format_string($course->shortname) . "\" ".
"href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&amp;wantsurl=/course/view.php?id={$course->remoteid}\">"
. format_string($course->fullname) . "</a>";
$this->content->icons[]=$icon;
.$icon. format_string($course->fullname) . "</a>";
}
// if we listed courses, we are done
return true;
Expand All @@ -134,8 +129,7 @@ function get_remote_courses() {
$this->content->items[] = get_string('remotehosts', 'mnet');
$this->content->icons[] = '';
foreach($USER->mnet_foreign_host_array as $somehost) {
$this->content->items[] = $somehost['count'].get_string('courseson','mnet').'<a title="'.$somehost['name'].'" href="'.$somehost['url'].'">'.$somehost['name'].'</a>';
$this->content->icons[] = $icon;
$this->content->items[] = $somehost['count'].get_string('courseson','mnet').'<a title="'.$somehost['name'].'" href="'.$somehost['url'].'">'.$icon.$somehost['name'].'</a>';
}
// if we listed hosts, done
return true;
Expand Down
4 changes: 2 additions & 2 deletions blocks/feedback/block_feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function get_content() {
foreach ($feedbacks as $feedback) {
$url = new moodle_url($baseurl);
$url->params(array('id'=>$feedback->cmid, 'courseid'=>$courseid));
$this->content->text = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
$this->content->text .= ' <a href="'.$url->out().'">'.$feedback->name.'</a>';
$icon = '<img src="'.$OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />&nbsp;';
$this->content->text = ' <a href="'.$url->out().'">'.$icon.$feedback->name.'</a>';
}
}

Expand Down
9 changes: 4 additions & 5 deletions blocks/mnet_hosts/block_mnet_hosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ function get_content() {

if ($hosts) {
foreach ($hosts as $host) {
$icon = '<img src="'.$OUTPUT->pix_url('i/'.$host->application.'_host') . '"'.
' class="icon" alt="'.get_string('server', 'block_mnet_hosts').'" />';
$icon = '<img src="'.$OUTPUT->pix_url('i/'.$host->application.'_host') . '"'.
' class="icon" alt="'.get_string('server', 'block_mnet_hosts').'" />&nbsp;';

$this->content->icons[]=$icon;
if ($host->id == $USER->mnethostid) {
$this->content->items[]="<a title=\"" .s($host->name).
"\" href=\"{$host->wwwroot}\">". s($host->name) ."</a>";
"\" href=\"{$host->wwwroot}\">".$icon. s($host->name) ."</a>";
} else {
$this->content->items[]="<a title=\"" .s($host->name).
"\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) ."</a>";
"\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" .$icon. s($host->name) ."</a>";
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions blocks/participants/block_participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ function get_content() {
return $this->content;
}
}

$icon = '<img src="'.$OUTPUT->pix_url('i/users') . '" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
$this->content->icons[] = '<img src="'.$OUTPUT->pix_url('i/users') . '" class="icon" alt="" />';
$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.$icon.get_string('participants').'</a>';

return $this->content;
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/private_files/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function htmllize_tree($tree, $dir) {
$filename = $file->get_filename();
$icon = mimeinfo("icon", $filename);
$image = $this->output->pix_icon("f/$icon", $filename, 'moodle', array('class'=>'icon'));
$result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.html_writer::link($url, $filename).'</div></li>';
$result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.html_writer::link($url, $image.'&nbsp;'.$filename).'</div></li>';
}
$result .= '</ul>';

Expand Down
12 changes: 6 additions & 6 deletions blocks/site_main_menu/block_site_main_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ function get_content() {
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
$instancename = format_string($cm->name, true, $course->id);
$this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
' href="'.$CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id.'">'.$instancename.'</a>';
//Accessibility: incidental image - should be empty Alt text
if (!empty($cm->icon)) {
$icon = $OUTPUT->pix_url($cm->icon);
} else {
$icon = $OUTPUT->pix_url('icon', $cm->modname);
}
$this->content->icons[] = '<img src="'.$icon.'" class="icon" alt="" />';
$icon = '<img src="'.$icon.'" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
' href="'.$CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id.'">'.$icon.$instancename.'</a>';
}
}
}
Expand Down Expand Up @@ -130,10 +130,10 @@ function get_content() {
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
$this->content->icons[] = '';
} else {
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
//Accessibility: incidental image - should be empty Alt text
$this->content->icons[] = '<img src="'.$icon.'" class="icon" alt="" />';
$icon = '<img src="'.$icon.'" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$icon.$instancename.'</a>'.$editbuttons;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions blocks/social_activities/block_social_activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ function get_content() {
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
$instancename = format_string($cm->name, true, $course->id);
$this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
' href="'.$CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id.'">'.$instancename.'</a>';
//Accessibility: incidental image - should be empty Alt text
if (!empty($cm->icon)) {
$icon = $OUTPUT->pix_url($cm->icon);
} else {
$icon = $OUTPUT->pix_url('icon', $cm->modname);
}
$this->content->icons[] = '<img src="'.$icon.'" class="icon" alt="" />';
$icon = '<img src="'.$icon.'" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra.
' href="'.$CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id.'">'.$icon.$instancename.'</a>';
}
}
}
Expand Down Expand Up @@ -139,10 +139,10 @@ function get_content() {
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
$this->content->icons[] = '';
} else {
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
//Accessibility: incidental image - should be empty Alt text
$this->content->icons[] = '<img src="'.$icon.'" class="icon" alt="" />';
$icon = '<img src="'.$icon.'" class="icon" alt="" />&nbsp;';
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$icon.$instancename.'</a>'.$editbuttons;
}
}
}
Expand Down

0 comments on commit 710363c

Please sign in to comment.