foreach ($blogs as $blog) {
if ($blog->failedlastsync) {
- $validicon = html_image::make($OUTPUT->pix_url('i/cross_red_big'));
- $validicon->alt = get_string('feedisinvalid', 'blog');
- $validicon->title = get_string('feedisinvalid', 'blog');
+ $validicon = $OUTPUT->image('i/cross_red_big', array('alt'=>get_string('feedisinvalid', 'blog'), 'title'=>get_string('feedisinvalid', 'blog')));
} else {
- $validicon = html_image::make($OUTPUT->pix_url('i/tick_green_big'));
- $validicon->alt = get_string('feedisvalid', 'blog');
- $validicon->title = get_string('feedisvalid', 'blog');
+ $validicon = $OUTPUT->image('i/tick_green_big', array('alt'=>get_string('feedisvalid', 'blog'), 'title'=>get_string('feedisvalid', 'blog')));
}
$editicon = new moodle_action_icon;
$deleteicon->image->alt = get_string('deleteexternalblog', 'blog');
$deleteicon->add_confirm_action(get_string('externalblogdeleteconfirm', 'blog'));
$icons = $OUTPUT->action_icon($editicon) . $OUTPUT->action_icon($deleteicon);
- $table->data[] = html_table_row::make(array($blog->name, $blog->url, userdate($blog->timefetched), $OUTPUT->image($validicon), $icons));
+ $table->data[] = html_table_row::make(array($blog->name, $blog->url, userdate($blog->timefetched), $validicon, $icons));
}
echo $OUTPUT->table($table);
}
$icon = substr(mimeinfo_from_type("icon", $mimetype), 0, -4);
$type = mimeinfo_from_type("type", $mimetype);
- $image = new html_image();
- $image->src = $OUTPUT->pix_url("/f/$icon");
- $image->add_class('icon');
- $image->alt = $filename;
+ $image = $OUTPUT->image("/f/$icon", array('alt'=>$filename, 'class'=>'icon'));
if ($return == "html") {
$output .= $OUTPUT->link(html_link::make($ffurl, $OUTPUT->image($image)));
} else {
if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links
- $image = new html_image();
- $image->src = $ffurl;
- $image->alt = $filename;
+ $image = $OUTPUT->image($ffurl, array('alt'=>$filename));
$imagereturn .= "<br />" . $OUTPUT->image($image);
} else {
- $imagereturn .= $OUTPUT->link(html_link::make($ffurl, $OUTPUT->image($image)));
+ $imagereturn .= $OUTPUT->link(html_link::make($ffurl, $image));
$imagereturn .= filter_text($OUTPUT->link(html_link::make($ffurl, $filename)));
}
}
$strrequireskey = get_string('requireskey');
// Loop over requested courses.
- $keyicon = new html_image();
- $keyicon->src = $OUTPUT->pix_url('i/key');
- $keyicon->alt = $strrequireskey;
- $keyicon->add_class('icon');
- $keyicon = $OUTPUT->image($keyicon);
+ $keyicon = $OUTPUT->image('i/key', array('alt'=>$strrequireskey, 'class'=>'icon'));
foreach ($pending as $course) {
$course = new course_request($course);
$activitycell = new html_table_cell();
$activitycell->add_class('activity');
- $activityicon = html_image::make($OUTPUT->pix_url('icon', $cm->modname));
- $activityicon->add_class('icon');
- $activityicon->alt = $modulename;
+ $activityicon = $OUTPUT->image($OUTPUT->pix_url('icon', $cm->modname), array('alt'=>$modulename, 'class'=>'icon'));
$activitylink = html_link::make("$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id", format_string($cm->name));
if (!$cm->visible) {
$activitylink->add_class('dimmed');
}
- $activitycell->text = $OUTPUT->image($activityicon) . $OUTPUT->link($activitylink);
+ $activitycell->text = $activityicon . $OUTPUT->link($activitylink);
$reportrow->cells[] = $activitycell;
$strparamobj->itemname = $element['object']->grade_item->itemname;
$strnonunlockable = get_string('nonunlockableverbose', 'grades', $strparamobj);
- $lockicon = new html_image();
- $lockicon->image->src = $OUTPUT->pix_url('t/unlock_gray');
- $lockicon->image->alt = s($strnonunlockable);
- $lockicon->image->title = s($strnonunlockable);
- $lockicon->image->add_class('iconsmall');
+ $action = $OUTPUT->image('t/unlock_gray', array('alt'=>$strnonunlockable, 'title'=>$strnonunlockable, 'class'=>'iconsmall'));
$action = $OUTPUT->image($lockicon);
} else if ($element['object']->is_locked()) {
$icon = 'unlock';
}
if ($this->icon!==null) {
- $icon = new html_image();
- $icon->src = $this->icon;
- $content = $OUTPUT->image($icon).' '.$content;
+ $icon = $OUTPUT->image($this->icon, array('alt'=>'', 'class'=>'icon'));
+ $content = $icon.$content; // use CSS for spacing of icons
} else if ($this->helpbutton!==null) {
$content = sprintf('%s<span class="clearhelpbutton">%s</span>',trim($this->helpbutton),$content);
}
$this->alt = HTML_ATTR_EMPTY;
}
}
-
- /**
- * Shortcut for initialising a html_image.
- *
- * @param mixed $url The URL to the image (string or moodle_url)
- */
- public static function make($src) {
- return new html_image($src);
- }
}
$this->helppage = $helppage;
$this->text = $text;
- $this->component = $module;
+ $this->component = $component;
$this->linktext = $linktext;
$this->link = new html_link();
/**
* Creates and returns an image.
*
- * @param html_image|moodle_url|string $image_or_url image or url of the image
+ * @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
*
* @return string HTML fragment
*/
public function image($image_or_url, array $options = null) {
- if ($image_or_url === false) {
- return false;
+ if (empty($image_or_url)) {
+ throw new coding_exception('Empty $image_or_url value in $OUTPTU->image()');
}
if ($image_or_url instanceof html_image) {
$image = clone($image_or_url);
} else {
- $image = new html_image($image_or_url, $options);
+ if (strpos($image_or_url, 'http')) {
+ $url = new moodle_url($image_or_url);
+ } else {
+ $url = $this->pix_url($image_or_url, 'moodle');
+ }
+ $image = new html_image($url, $options);
}
$image->prepare($this, $this->page, $this->target);
$this->prepare_event_handlers($image);
$attributes = array('class' => $image->get_classes_string(),
- 'src' => prepare_url($image->src),
- 'alt' => $image->alt,
+ 'src' => prepare_url($image->src),
+ 'alt' => $image->alt,
'style' => $image->style,
'title' => $image->title,
- 'id' => $image->id);
+ 'id' => $image->id);
// do not use prepare_legacy_width_and_height() here,
// xhtml strict allows width&height and inline styles break theming too!