MDL-20204 converting link to html_writer or action_link

This commit is contained in:
Petr Skoda 2010-02-11 16:56:00 +00:00
parent 75015e5fc1
commit 57cd3739a4
17 changed files with 48 additions and 66 deletions

View File

@ -1408,11 +1408,10 @@ class core_renderer extends renderer_base {
$icon = $this->image($this->pix_url('help'), array('class'=>'iconhelp', 'alt'=>get_string('scales')));
$link = new html_link(new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scale->id)), $icon);
$popupaction = new popup_action('click', $link->url, 'ratingscale');
$link->add_action($popupaction);
$link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scale->id));
$action = new popup_action('click', $link->url, 'ratingscale');
return html_writer::tag('span', array('class' => 'helplink'), $this->link($link));
return html_writer::tag('span', array('class' => 'helplink'), $this->action_link($link, $icon, $action));
}
/**

View File

@ -2428,10 +2428,9 @@ function print_grade_menu($courseid, $name, $current, $includenograde=true, $ret
$output .= html_writer::select($grades, $name, $current, false);
$linkobject = '<span class="helplink"><img class="iconhelp" alt="'.$strscales.'" src="'.$OUTPUT->pix_url('help') . '" /></span>';
$link = html_link::make('/course/scales.php?id='. $courseid .'&list=true', $linkobject);
$link->add_action(new popup_action('click', $link->url, 'ratingscales', array('height' => 400, 'width' => 500)));
$link->title = $strscales;
$output .= $OUTPUT->link($link);
$link = new moodle_url('/course/scales.php', array('id'=>$courseid, 'list'=>1));
$action = new popup_action('click', $link->url, 'ratingscales', array('height' => 400, 'width' => 500));
$output .= $OUTPUT->action_link($link, $linkobject, $action, array('title'=>$strscales));
if ($return) {
return $output;
@ -2468,13 +2467,10 @@ function modgradehelpbutton($courseid){
global $CFG, $OUTPUT;
$url = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true));
$link = new html_link();
$link->url = $url;
$link->text = '<span class="helplink"><img alt="' . get_string('scales') . '" class="iconhelp" src="' . $OUTPUT->pix_url('help') . '" /></span>';
$link->add_action(new popup_action('click', $link->url, 'ratingscales', array('height' => 400, 'width' => 500)));
$link->title = get_string('newwindow');
$text = '<span class="helplink"><img alt="' . get_string('scales') . '" class="iconhelp" src="' . $OUTPUT->pix_url('help') . '" /></span>';
$action = new popup_action('click', $link->url, 'ratingscales', array('height' => 400, 'width' => 500));
return $OUTPUT->link($link);
return $OUTPUT->link($url, $text, $action, array('title'=>get_string('newwindow')));
}
/**

View File

@ -766,13 +766,9 @@ class assignment_base {
'userid' => $submission->userid,
'mode' => 'single',
'offset' => (optional_param('offset', '', PARAM_INT)-1)));
$button = $OUTPUT->action_link($url, $buttontext, new popup_action('click', $url, 'grade'.$submission->userid, array('height' => 450, 'width' => 700)), array('ttile'=>$buttontext));
$link = html_link::make($url, $buttontext);
$link->add_action(new popup_action('click', $link->url, 'grade'.$submission->userid, array('height' => 450, 'width' => 700)));
$link->title = $buttontext;
$button = $OUTPUT->link($link);
$output.= 'opener.document.getElementById("up'.$submission->userid.'").innerHTML="'.addslashes_js($button).'";';
$output .= 'opener.document.getElementById("up'.$submission->userid.'").innerHTML="'.addslashes_js($button).'";';
}
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $submission->userid);

View File

@ -75,7 +75,7 @@ if (!$ratings = data_get_ratings($record->id, $sqlsort)) {
echo '<td class="picture">';
echo $OUTPUT->user_picture($rating, array('courseid'=>$data->course));
echo '</td>';
echo '<td class="author">' . $OUTPUT->link($CFG->wwwroot.'/user/view.php?id='.$rating->id.'&course='.$data->course, fullname($rating)) . '</td>';
echo '<td class="author">' . html_writer::link($CFG->wwwroot.'/user/view.php?id='.$rating->id.'&course='.$data->course, fullname($rating)) . '</td>';
echo '<td style="white-space:nowrap" align="center" class="rating">'.$scalemenu[$rating->rating].'</td>';
echo "</tr>\n";
}

View File

@ -58,7 +58,7 @@ class hotpot_report extends hotpot_default_report {
$name = fullname($u);
if ($is_html) {
$picture = $OUTPUT->user_picture($u, array('courseid'=>$course->id));
$name = $OUTPUT->link($CFG->wwwroot.'/user/view.php?id='.$u->userid.'&course='.$course->id, $name);
$name = html_writer::link($CFG->wwwroot.'/user/view.php?id='.$u->userid.'&course='.$course->id, $name);
}
if (isset($user->grade)) {
$grade = $user->grade;

View File

@ -345,14 +345,14 @@ switch ($mode) {
}
// email link for this user
$url = new moodle_url('/mod/lesson/essay.php', array('id'=>$cm->id,'mode'=>'email','userid'=>$userid,'sesskey'=>sesskey()));
$emaillink = $OUTPUT->link(html_link::make($url, get_string('emailgradedessays', 'lesson')));
$emaillink = html_writer::link($url, get_string('emailgradedessays', 'lesson'));
$table->data[] = array($OUTPUT->user_picture($users[$userid], array('courseid'=>$course->id)).$studentname, implode("<br />", $essaylinks), $emaillink);
}
// email link for all users
$url = new moodle_url('/mod/lesson/essay.php', array('id'=>$cm->id,'mode'=>'email','sesskey'=>sesskey()));
$emailalllink = $OUTPUT->link(html_link::make($url, get_string('emailallgradedessays', 'lesson')));
$emailalllink = html_writer::link($url, get_string('emailallgradedessays', 'lesson'));
$table->data[] = array(' ', ' ', $emailalllink);

View File

@ -215,10 +215,10 @@ switch ($mode) {
echo $OUTPUT->box_start('mdl-align');
echo $OUTPUT->box_start('lessonbutton standardbutton');
if ($link) {
echo $OUTPUT->link(html_link::make(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("returntocourse", "lesson")));
echo html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("returntocourse", "lesson"));
} else {
echo $OUTPUT->link(html_link::make(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("cancel", "lesson"))). ' ';
echo $OUTPUT->link(html_link::make(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'viewed'=>'1')), get_string("startlesson", "lesson")));
echo html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), get_string("cancel", "lesson")). ' ';
echo html_writer::link(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'viewed'=>'1')), get_string("startlesson", "lesson"));
}
echo $OUTPUT->box_end();
echo $OUTPUT->box_end();

View File

@ -996,7 +996,7 @@ function lesson_get_media_html($lesson, $context) {
$url = $file_info->get_url();
$title = $lesson->mediafile;
$clicktoopen = $OUTPUT->link(new moodle_url($url), get_string('download'));
$clicktoopen = html_writer::link(new moodle_url($url), get_string('download'));
$mimetype = resourcelib_guess_url_mimetype($url);
@ -1572,13 +1572,13 @@ class lesson extends lesson_base {
if ($modname) {
$instancename = $DB->get_field($modname, 'name', array('id' => $module->instance));
if ($instancename) {
$link = html_link::make(new moodle_url('/mod/'.$modname.'/view.php', array('id'=>$this->properties->activitylink)), get_string('returnto', 'lesson', get_string('activitylinkname', 'lesson', $instancename)));
$link->set_classes(array('centerpadded','lessonbutton','standardbutton'));
return $link;
return html_writer::link(new moodle_url('/mod/'.$modname.'/view.php', array('id'=>$this->properties->activitylink)),
get_string('returnto', 'lesson', get_string('activitylinkname', 'lesson', $instancename)),
array('class'=>'centerpadded lessonbutton standardbutton'));
}
}
}
return false;
return '';
}
/**
@ -2922,9 +2922,9 @@ class lesson_page_type_manager {
$links = array();
foreach ($this->types as $type) {
if (($link = $type->add_page_link($previd)) instanceof html_link) {
$links[] = $OUTPUT->link($link);
foreach ($this->types as $key=>$type) {
if ($link = $type->add_page_link($previd)) {
$links[$key] = $link;
}
}

View File

@ -216,8 +216,8 @@ class lesson_page_type_branchtable extends lesson_page {
}
public function add_page_link($previd) {
global $PAGE, $CFG;
$addbranchurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'qtype'=>LESSON_PAGE_BRANCHTABLE));
return html_link::make($addbranchurl, get_string('addabranchtable', 'lesson'));
$addurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'qtype'=>LESSON_PAGE_BRANCHTABLE));
return array('addurl'=>$addurl, 'type'=>LESSON_PAGE_BRANCHTABLE, 'name'=>get_string('addabranchtable', 'lesson'));
}
protected function get_displayinmenublock() {
return true;

View File

@ -69,8 +69,8 @@ class lesson_page_type_cluster extends lesson_page {
}
public function add_page_link($previd) {
global $PAGE, $CFG;
$addclusterurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_CLUSTER));
return html_link::make($addclusterurl, get_string('addcluster', 'lesson'));
$addurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_CLUSTER));
return array('addurl'=>$addurl, 'type'=>LESSON_PAGE_CLUSTER, 'name'=>get_string('addcluster', 'lesson'));
}
public function valid_page_and_view(&$validpages, &$pageviews) {
$validpages[$this->properties->id] = 1; // add the cluster page as a valid page

View File

@ -136,8 +136,8 @@ class lesson_page_type_endofbranch extends lesson_page {
public function add_page_link($previd) {
global $PAGE, $CFG;
if ($previd != 0) {
$addendofbranchurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_ENDOFBRANCH));
return html_link::make($addendofbranchurl, get_string('addanendofbranch', 'lesson'));
$addurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_ENDOFBRANCH));
return array('addurl'=>$addurl, 'type'=>LESSON_PAGE_ENDOFBRANCH, 'name'=>get_string('addanendofbranch', 'lesson'));
}
return false;
}

View File

@ -117,8 +117,8 @@ class lesson_page_type_endofcluster extends lesson_page {
public function add_page_link($previd) {
global $PAGE, $CFG;
if ($previd != 0) {
$endofclusterurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_ENDOFCLUSTER));
return html_link::make($endofclusterurl, get_string('addendofcluster', 'lesson'));
$addurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$PAGE->cm->id, 'pageid'=>$previd, 'sesskey'=>sesskey(), 'qtype'=>LESSON_PAGE_ENDOFCLUSTER));
return array('addurl'=>$addurl, 'type'=>LESSON_PAGE_ENDOFCLUSTER, 'name'=>get_string('addendofcluster', 'lesson'));
}
return false;
}

View File

@ -335,7 +335,9 @@ class mod_lesson_renderer extends plugin_renderer_base {
$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));
foreach($manager->get_add_page_type_links($prevpageid) as $link) {
$links[] = html_writer::link($link['addurl'], $link['name']);
}
$addquestionurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
$links[] = html_writer::link($addquestionurl, get_string('addaquestionpagehere', 'lesson'));
@ -356,24 +358,19 @@ class mod_lesson_renderer extends plugin_renderer_base {
$links = array();
$importquestionsurl = new moodle_url('/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'));
$importppturl = new moodle_url('/mod/lesson/importppt.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
$links[] = html_link::make($importppturl, get_string('importppt', 'lesson'));
$links[] = html_writer::link($importppturl, get_string('importppt', 'lesson'));
$manager = lesson_page_type_manager::get($lesson);
$newpagelinks = $manager->get_add_page_type_links($prevpageid);
foreach ($newpagelinks as $link) {
$link->url->param('firstpage', 1);
$links[] = $link;
foreach ($manager->get_add_page_type_links($prevpageid) as $link) {
$link['addurl']->param('firstpage', 1);
$links[] = html_writer::link($link['addurl'], $link['name']);
}
$addquestionurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid, 'firstpage'=>1));
$links[] = html_link::make($addquestionurl, get_string('addaquestionpage', 'lesson'));
foreach ($links as $key=>$link) {
$links[$key] = $this->output->link($link);
}
$links[] = html_writer::link($addquestionurl, get_string('addaquestionpage', 'lesson'));
return $this->output->box($output.'<p>'.implode('</p><p>', $links).'</p>', 'generalbox firstpageoptions');
}
@ -409,7 +406,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
$manager = lesson_page_type_manager::get($page->lesson);
$links = $manager->get_add_page_type_links($page->id);
foreach ($links as $link) {
$options[$link->url->param('qtype')] = $link->text;
$options[$link['type']] = $link['name'];
}
$options[0] = get_string('question', 'lesson');
@ -418,9 +415,6 @@ class mod_lesson_renderer extends plugin_renderer_base {
$addpageselector = $this->output->render($addpageselect);
}
foreach ($actions as $key=>$action) {
$actions[$key] = $this->output->link($action);
}
if (isset($addpageselector)) {
$actions[] = $addpageselector;
}

View File

@ -541,10 +541,7 @@ if ($pageid != LESSON_EOL) {
}
if ($lesson->activitylink) {
$link = $lesson->link_for_activitylink();
if ($link instanceof html_link) {
$lessoncontent .= $OUTPUT->link($link);
}
$lessoncontent .= $lesson->link_for_activitylink();
}
$url = new moodle_url('/course/view.php', array('id'=>$course->id));

View File

@ -1282,7 +1282,7 @@ function ewiki_page_info($id, &$data, $action) {
$COURSE->id = SITEID;
}
$picture = $OUTPUT->user_picture($user);
$value = $picture . $OUTPUT->link("$CFG->wwwroot/user/view.php?id=$user->id&course=$COURSE->id", fullname($user));
$value = $picture . html_writer::link("$CFG->wwwroot/user/view.php?id=$user->id&course=$COURSE->id", fullname($user));
} else {
continue;
//$value = @$current['author'];

View File

@ -349,7 +349,7 @@ function ewiki_entry_downloads($row, $show_section=0, $fullinfo=false) {
$course->id = 1;
}
$picture = $OUTPUT->user_picture($user, array('courseid'=>$course->id));
$value = $picture . $OUTPUT->link("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", fullname($user));
$value = $picture . html_writer::link("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", fullname($user));
}
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br />'.

View File

@ -238,7 +238,7 @@ class mod_workshop_renderer extends plugin_renderer_base {
$type = mimeinfo_from_type("type", $type);
$image = html_writer::empty_tag('img', array('src'=>$this->output->pix_url(file_mimetype_icon($type)), 'alt'=>$type, 'class'=>'icon'));
$linkhtml = $this->output->link($fileurl, $image) . $this->output->link($fileurl, $filename);
$linkhtml = html_writer::link($fileurl, $image) . $this->output->link($fileurl, $filename);
$linktxt = "$filename [$fileurl]";
if ($format == "html") {