foreach ($entries as $entryid => $entry) {
$viewblogurl->param('entryid', $entryid);
- $entrylink = html_link::make($viewblogurl, shorten_text($entry->subject));
- $entrieslist->add_item($OUTPUT->link($entrylink));
+ $entrylink = html_writer::link($viewblogurl, shorten_text($entry->subject));
+ $entrieslist->add_item($entrylink);
}
$this->content->text .= $OUTPUT->htmllist($entrieslist);
if (!empty($blogheaders['strview'])) {
$strview = $blogheaders['strview'];
}
- $viewallentrieslink = html_link::make($blogheaders['url'], $strview);
- $this->content->text .= $OUTPUT->link($viewallentrieslink);
+ $viewallentrieslink = html_writer::link($blogheaders['url'], $strview);
+ $this->content->text .= $viewallentrieslink;
} else {
$this->content->text .= get_string('norecentblogentries', 'block_blog_recent');
}
}
$blogurl->param('tagid', $tag->id);
- $link = html_link::make($blogurl, tag_display_name($tag));
- $link->add_class($tag->class);
- $link->title = get_string('numberofentries','blog',$tag->ct);
- $this->content->text .= '<li>' . $OUTPUT->link($link) . '</li> ';
+ $link = html_writer::link($blogurl, tag_display_name($tag), array('class'=>$tag->class, 'title'=>get_string('numberofentries','blog',$tag->ct)));
+ $this->content->text .= '<li>' . $link . '</li> ';
}
$this->content->text .= "\n</ul>\n";
$feedtitle = s($feed->title);
}
- $viewlink = new html_link();
- $viewlink->url = $CFG->wwwroot .'/blocks/rss_client/viewfeed.php?rssid=' . $feed->id . $extraparams;
- $viewlink->text = $feedtitle;
+ $viewlink = html_writer::link($CFG->wwwroot .'/blocks/rss_client/viewfeed.php?rssid=' . $feed->id . $extraparams, $feedtitle);
- $feedinfo = '<div class="title">' . $OUTPUT->link($viewlink) . '</div>' .
- '<div class="url">' . $OUTPUT->link($feed->url, $feed->url) .'</div>' .
+ $feedinfo = '<div class="title">' . $viewlink . '</div>' .
+ '<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;
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $COURSE->id)));
$by = new object();
- $by->name = $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $COURSE->id)), $fullname));
+ $by->name = html_writer::link(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $COURSE->id)), $fullname);
$by->date = $template['created'];
$topiccell->text .= get_string('bynameondate', 'forum', $by);
if ($this->uniquehash && $this->content) {
if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
$urlparts = parse_url($externalblog->url);
- $topiccell->text .= $OUTPUT->container(get_string('retrievedfrom', 'blog') . $OUTPUT->link(html_link::make($urlparts['scheme'].'://'.$urlparts['host'], $externalblog->name)), 'externalblog');
+ $topiccell->text .= $OUTPUT->container(get_string('retrievedfrom', 'blog') . html_writer::link($urlparts['scheme'].'://'.$urlparts['host'], $externalblog->name), 'externalblog');
}
}
// Uniquehash is used as a link to an external blog
if (!empty($this->uniquehash)) {
$contentcell->text .= $OUTPUT->container_start('externalblog');
- $contentcell->text .= $OUTPUT->link(html_link::make($this->uniquehash, get_string('linktooriginalentry', 'blog')));
+ $contentcell->text .= html_writer::link($this->uniquehash, get_string('linktooriginalentry', 'blog'));
$contentcell->text .= $OUTPUT->container_end();
}
$contentcell->text .= $OUTPUT->container_start('commands');
if (blog_user_can_edit_entry($this) && empty($this->uniquehash)) {
- $contentcell->text .= $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/blog/edit.php', array('action' => 'edit', 'entryid' => $this->id)), $stredit)) . ' | ';
- $contentcell->text .= $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/blog/edit.php', array('action' => 'delete', 'entryid' => $this->id)), $strdelete)) . ' | ';
+ $contentcell->text .= html_writer::link(new moodle_url($CFG->wwwroot.'/blog/edit.php', array('action' => 'edit', 'entryid' => $this->id)), $stredit) . ' | ';
+ $contentcell->text .= html_writer::link(new moodle_url($CFG->wwwroot.'/blog/edit.php', array('action' => 'delete', 'entryid' => $this->id)), $strdelete) . ' | ';
}
- $contentcell->text .= $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/blog/index.php', array('entryid' => $this->id)), get_string('permalink', 'blog')));
+ $contentcell->text .= html_writer::link(new moodle_url($CFG->wwwroot.'/blog/index.php', array('entryid' => $this->id)), get_string('permalink', 'blog'));
$contentcell->text .= $OUTPUT->container_end();
$image = $OUTPUT->image("/f/$icon", array('alt'=>$filename, 'class'=>'icon'));
if ($return == "html") {
- $output .= $OUTPUT->link(html_link::make($ffurl, $OUTPUT->image($image)));
- $output .= $OUTPUT->link(html_link::make($ffurl, $filename));
+ $output .= html_writer::link($ffurl, $OUTPUT->image($image));
+ $output .= html_writer::link($ffurl, $filename);
} else if ($return == "text") {
$output .= "$strattachment $filename:\n$ffurl\n";
$image = $OUTPUT->image($ffurl, array('alt'=>$filename));
$imagereturn .= "<br />" . $OUTPUT->image($image);
} else {
- $imagereturn .= $OUTPUT->link(html_link::make($ffurl, $image));
- $imagereturn .= filter_text($OUTPUT->link(html_link::make($ffurl, $filename)));
+ $imagereturn .= html_writer::link($ffurl, $image);
+ $imagereturn .= filter_text(html_writer::link($ffurl, $filename));
}
}
}
$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));
+ $attributes = array();
if (!$cm->visible) {
- $activitylink->add_class('dimmed');
+ $attributes['class'] = 'dimmed';
}
- $activitycell->text = $activityicon . $OUTPUT->link($activitylink);
+ $activitycell->text = $activityicon . html_writer::link("$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id", format_string($cm->name), $attributes);;
$reportrow->cells[] = $activitycell;
$blogcell = new html_table_cell();
$blogcell->add_class('blog');
if ($blogcount = blog_get_associated_count($course->id, $cm->id)) {
- $blogcell->text = $OUTPUT->link(html_link::make('/blog/index.php?modid='.$cm->id, $blogcount));
+ $blogcell->text = html_writer::link('/blog/index.php?modid='.$cm->id, $blogcount);
} else {
$blogcell->text = '-';
}
$headerrow->cells[] = $studentheader;
if ($showuseridnumber) {
- $sortidnumberlink = html_link::make(clone($this->baseurl), get_string('idnumber'));
- $sortidnumberlink->url->param('sortitemid', 'idnumber');
+ // TODO: weird, this is not used anywhere
+ $sortidnumberlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid'=>'idnumber')), get_string('idnumber'));
$idnumberheader = new html_table_cell();
$idnumberheader->add_classes(array('header', 'c0', 'useridnumber'));
$usercell->text = $OUTPUT->container($OUTPUT->user_picture($user), 'userpic');
}
- $usercell->text .= $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user)));
+ $usercell->text .= html_writer::link(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user));
$userrow->cells[] = $usercell;
$strfirstname = $this->get_lang_string('firstname');
$strlastname = $this->get_lang_string('lastname');
- $firstlink = html_link::make(clone($this->baseurl), $strfirstname);
- $firstlink->url->param('sortitemid', 'firstname');
- $lastlink = html_link::make(clone($this->baseurl), $strlastname);
- $lastlink->url->param('sortitemid', 'lastname');
- $idnumberlink = html_link::make(clone($this->baseurl), get_string('idnumber'));
- $idnumberlink->url->param('sortitemid', 'idnumber');
+ $firstlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid'=>'firstname')), $strfirstname);
+ $lastlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid'=>'lastname')), $strlastname);
+ $idnumberlink = html_writer::link(new moodle_url($this->baseurl, array('sortitemid'=>'idnumber')), get_string('idnumber'));
- $arrows['studentname'] = $OUTPUT->link($lastlink);
+ $arrows['studentname'] = $lastlink;
if ($this->sortitemid === 'lastname') {
if ($this->sortorder == 'ASC') {
}
}
- $arrows['studentname'] .= ' ' . $OUTPUT->link($firstlink);
+ $arrows['studentname'] .= ' ' . $firstlink;
if ($this->sortitemid === 'firstname') {
if ($this->sortorder == 'ASC') {
}
}
- $arrows['idnumber'] = $OUTPUT->link($idnumberlink);
+ $arrows['idnumber'] = $idnumberlink;
if ('idnumber' == $this->sortitemid) {
if ($this->sortorder == 'ASC') {
public static function random_id($base='random') {
return uniqid($base);
}
+
+ /**
+ * Generates a simple html link
+ * @param string|moodle_url $url
+ * @param string $text link txt
+ * @param array $attributes extra html attributes
+ * @return string HTML fragment
+ */
+ public static function link($url, $text, array $attributes = null) {
+ $attributes = (array)$attributes;
+ $attributes['href'] = $url;
+ return self::tag('a', $attributes, $text);
+ }
}
$output = $this->output->box(get_string('youhaveseen','lesson'), 'generalbox boxaligncenter');
$output .= $this->output->box_start('center');
- $yeslink = html_link::make(new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lastpageseenid, 'startlastseen'=>'yes')), get_string('yes'));
- $output .= $this->output->span($this->output->link($yeslink), 'lessonbutton standardbutton');
+ $yeslink = html_writer::link(new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lastpageseenid, 'startlastseen'=>'yes')), get_string('yes'));
+ $output .= $this->output->span($yeslink, 'lessonbutton standardbutton');
- $nolink = html_link::make(new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lesson->firstpageid, 'startlastseen'=>'no')), get_string('no'));
- $output .= $this->output->span($this->output->link($nolink), 'lessonbutton standardbutton');
+ $nolink = html_writer::link(new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$this->page->cm->id, 'pageid'=>$lesson->firstpageid, 'startlastseen'=>'no')), get_string('no'));
+ $output .= $this->output->span($nolink, 'lessonbutton standardbutton');
$output .= $this->output->box_end();
return $output;
$links = array();
$importquestionsurl = new moodle_url($CFG->wwwroot.'/mod/lesson/import.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
- $links[] = html_link::make($importquestionsurl, get_string('importquestions', 'lesson'));
+ $links[] = html_writer::link($importquestionsurl, get_string('importquestions', 'lesson'));
$manager = lesson_page_type_manager::get($lesson);
$links = array_merge($links, $manager->get_add_page_type_links($prevpageid));
$addquestionurl = new moodle_url($CFG->wwwroot.'/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
- $links[] = html_link::make($addquestionurl, get_string('addaquestionpagehere', 'lesson'));
-
- foreach ($links as $key=>$link) {
- $links[$key] = $this->output->link($link);
- }
+ $links[] = html_writer::link($addquestionurl, get_string('addaquestionpagehere', 'lesson'));
return $this->output->box(implode(" | \n", $links), 'addlinks');
}
$lessoncontent .= get_string("nothighscore", "lesson", $lesson->maxhighscores)."<br />";
}
}
- $link = html_link::make(new moodle_url($CFG->wwwroot.'/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'link'=>'1')), get_string('viewhighscores', 'lesson'));
- $link->set_classes(array('centerpadded','lessonbutton','standardbutton'));
- $lessoncontent .= $OUTPUT->link($link);
+ $url = new moodle_url($CFG->wwwroot.'/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'link'=>'1'));
+ $lessoncontent .= html_writer::link($url, get_string('viewhighscores', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
$lessoncontent .= $OUTPUT->box_end();
}
$lastattempt = end($attempts);
$USER->modattempts[$lesson->id] = $lastattempt->pageid;
- $link = html_link::make(new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$PAGE->cm->id, 'pageid'=>$pageid)), get_string('reviewlesson', 'lesson'));
- $link->set_classes(array('centerpadded','lessonbutton','standardbutton'));
- $lessoncontent .= $OUTPUT->link($link);
+ $url = new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$PAGE->cm->id, 'pageid'=>$pageid));
+ $lessoncontent .= html_writer::link($url, get_string('reviewlesson', 'lesson'), array('class' => 'centerpadded lessonbutton standardbutton'));
} elseif ($lesson->modattempts && $canmanage) {
$lessoncontent .= $lessonoutput->paragraph(get_string("modattemptsnoteacher", "lesson"), 'centerpadded');
}
}
- $link = html_link::make(new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id)), get_string('returnto', 'lesson', format_string($course->fullname, true)));
- $link->set_classes(array('centerpadded','lessonbutton','standardbutton'));
- $lessoncontent .= $OUTPUT->link($link);
+ $url = new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id));
+ $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)), array('class'=>'centerpadded lessonbutton standardbutton'));
- $link = html_link::make(new moodle_url($CFG->wwwroot.'/grade/index.php', array('id'=>$course->id)), get_string('viewgrades', 'lesson'));
- $link->set_classes(array('centerpadded','lessonbutton','standardbutton'));
- $lessoncontent .= $OUTPUT->link($link);
+ $url = new moodle_url($CFG->wwwroot.'/grade/index.php', array('id'=>$course->id));
+ $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid);
$classes .= ' anonymous';
}
$o .= $this->output->container_start($classes); // main wrapper
- $link = new html_link();
- $link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php',
- array('cmid' => $this->page->context->instanceid, 'id' => $submission->id));
- $link->text = format_string($submission->title);
- $link->set_classes('title');
- $o .= $this->output->link($link);
+ $url = new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php',
+ array('cmid' => $this->page->context->instanceid, 'id' => $submission->id));
+ $o .= html_writer::link($url, format_string($submission->title), array('class'=>'title'));
if ($showauthorname) {
$author = new stdclass();
$author->id = $submission->authorid;
// title
$o .= $this->output->container_start('example-title');
- $link = new html_link();
- $link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/exsubmission.php',
- array('cmid' => $this->page->context->instanceid, 'id' => $summary->example->id));
- $link->text = format_string($summary->example->title);
- $link->set_classes('title');
- $o .= $this->output->link($link);
+ $url = new moodle_url($CFG->wwwroot . '/mod/workshop/exsubmission.php',
+ array('cmid' => $this->page->context->instanceid, 'id' => $summary->example->id));
+ $o .= html_writer::link($url, format_string($summary->example->title), array('class'=>'title'));
// dirty hack to guess if the current user is example manager or not
if ($summary->example->weight == 1) {
if (is_null($task->link)) {
$title = $task->title;
} else {
- $link = new html_link();
- $link->url = $task->link;
- $link->text = $task->title;
- $title = $this->output->link($link);
+ $title = html_writer::link($task->link, $task->text);
}
$title = $this->output->container($title, 'title');
$details = $this->output->container($task->details, 'details');
if (is_null($participant->submissionid)) {
$out = $this->output->container(get_string('nosubmissionfound', 'workshop'), 'info');
} else {
- $link = new html_link();
- $link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php',
- array('cmid' => $this->page->context->instanceid, 'id' => $participant->submissionid));
- $link->text = format_string($participant->submissiontitle);
- $link->set_classes('title');
- $out = $this->output->link($link);
+ $url = new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php',
+ array('cmid' => $this->page->context->instanceid, 'id' => $participant->submissionid));
+ $out = html_writer::link($url, format_string($participant->submissiontitle), array('class'=>'title'));
}
return $out;
$grade = get_string('formatpeergradeoverweighted', 'workshop', $a);
}
}
- $link = new html_link();
- $link->text = $grade;
- $link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/assessment.php',
- array('asid' => $assessment->assessmentid));
- $link->set_classes('grade');
- $grade = $this->output->link($link);
+ $url = new moodle_url($CFG->wwwroot . '/mod/workshop/assessment.php',
+ array('asid' => $assessment->assessmentid));
+ $grade = html_writer::link($url, $grade, array('class'=>'grade'));
if ($shownames) {
$userid = $assessment->userid;
$url->param('type', $i->options['type']);
$url->param('edit', $i->id);
- $link = html_link::make($url->out(), $settingsstr);
- $settings .= $OUTPUT->link($link);
+ $settings .= html_writer::link($url, $settingsstr);
$url->remove_params('edit');
$url->param('delete', $i->id);
- $link = html_link::make($url->out(), $deletestr);
- $delete .= $OUTPUT->link($link);
+ $delete .= html_writer::link($url, $deletestr);
$url->remove_params('type');
}
}
if ($user->maildisplay == 1 or ($user->maildisplay == 2 and ($course->id != SITEID) and !isguestuser()) or
has_capability('moodle/course:viewhiddenuserfields', $context)) {
- $link = new html_link();
- $link->url = "mailto:$user->email";
- $link->text = $user->email;
- $row->cells[1]->text .= get_string('email') .': ' . $OUTPUT->link($link) . '<br />';
+ $row->cells[1]->text .= get_string('email') .': ' . html_writer::link("mailto:$user->email", $user->email) . '<br />';
}
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
$row->cells[1]->text .= get_string('city') .': ';
$links = array();
if ($CFG->bloglevel > 0) {
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/blog/index.php?userid='.$user->id), get_string('blogs','blog'));
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/blog/index.php?userid='.$user->id), get_string('blogs','blog'));
}
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context))) {
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/notes/index.php?course=' . $course->id. '&user='.$user->id), get_string('notes','notes'));
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/notes/index.php?course=' . $course->id. '&user='.$user->id), get_string('notes','notes'));
}
if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) {
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/course/user.php?id='. $course->id .'&user='. $user->id), get_string('activity'));
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/course/user.php?id='. $course->id .'&user='. $user->id), get_string('activity'));
}
if (has_capability('moodle/role:assign', $context) and get_user_roles($context, $user->id, false)) { // I can unassign and user has some role
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/course/unenrol.php?id='. $course->id .'&user='. $user->id), get_string('unenrol'));
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/course/unenrol.php?id='. $course->id .'&user='. $user->id), get_string('unenrol'));
}
if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) &&
! has_capability('moodle/site:doanything', $context, $user->id, false)) {
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/course/loginas.php?id='. $course->id .'&user='. $user->id .'&sesskey='. sesskey()), get_string('loginas'));
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/course/loginas.php?id='. $course->id .'&user='. $user->id .'&sesskey='. sesskey()), get_string('loginas'));
}
- $links[] = html_link::make(new moodle_url($CFG->wwwroot.'/user/view.php?id='. $user->id .'&course='. $course->id), get_string('fullprofile') . '...');
+ $links[] = html_writer::link(new moodle_url($CFG->wwwroot.'/user/view.php?id='. $user->id .'&course='. $course->id), get_string('fullprofile') . '...');
- foreach ($links as $link) {
- $row->cells[2]->text .= $OUTPUT->link($link);
- }
+ $row->cells[2]->text .= implode('', $link);
if (!empty($messageselect)) {
$row->cells[2]->text .= '<br /><input type="checkbox" name="user'.$user->id.'" /> ';
$perpageurl->remove_params('perpage');
if ($perpage == SHOW_ALL_PAGE_SIZE) {
$perpageurl->param('perpage', DEFAULT_PAGE_SIZE);
- echo $OUTPUT->container($OUTPUT->link(html_link::make($perpageurl, get_string('showperpage', '', DEFAULT_PAGE_SIZE))), array(), 'showall');
+ echo $OUTPUT->container(html_writer::link($perpageurl, get_string('showperpage', '', DEFAULT_PAGE_SIZE)), array(), 'showall');
} else if ($matchcount > 0 && $perpage < $matchcount) {
$perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE);
- echo $OUTPUT->container($OUTPUT->link(html_link::make($perpageurl, get_string('showall', '', $matchcount))), array(), 'showall');
+ echo $OUTPUT->container(html_writer::link($perpageurl, get_string('showall', '', $matchcount)), array(), 'showall');
}
echo $OUTPUT->footer();