Skip to content

Commit

Permalink
MDL-20204 converting link to html_writer or action_link
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 11, 2010
1 parent c80877a commit 75015e5
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 135 deletions.
12 changes: 3 additions & 9 deletions admin/lang.php
Expand Up @@ -839,9 +839,7 @@
echo '</form>';
$preview_url = lang_help_preview_url($currentfile, !$uselocal);
if ($preview_url) {
$link = html_link::make($preview_url, get_string('preview'));
$link->add_action(new popup_action('click', $link->url));
echo $OUTPUT->link($link);
echo $OUTPUT->action_link($preview_url, get_string('preview'), new popup_action('click', $preview_url));
}
echo '</fieldset>';
}
Expand All @@ -859,9 +857,7 @@
echo "</textarea>\n</div>\n";
$preview_url = lang_help_preview_url($currentfile, $uselocal);
if ($preview_url) {
$link = html_link::make($preview_url, get_string('preview'));
$link->add_action(new popup_action('click', $link->url));
echo $OUTPUT->link($link);
echo $OUTPUT->action_link($preview_url, get_string('preview'), new popup_action('click', $preview_url));
}
echo '</fieldset>';
}
Expand All @@ -883,9 +879,7 @@
echo "</textarea>\n</div>\n";
$preview_url = lang_help_preview_url($currentfile, true, 'en_utf8'); // do not display en_utf8_local
if ($preview_url) {
$link = html_link::make($preview_url, get_string('preview'));
$link->add_action(new popup_action('click', $link->url));
echo $OUTPUT->link($link);
echo $OUTPUT->action_link($preview_url, get_string('preview'), new popup_action('click', $preview_url));
}
echo '</fieldset>';
}
Expand Down
2 changes: 1 addition & 1 deletion admin/localplugins.php
Expand Up @@ -87,7 +87,7 @@

foreach ($plugins as $plugin => $name) {
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
$delete = $OUTPUT->link($delete, get_string('delete'));
$delete = html_writer::link($delete, get_string('delete'));

$version = get_config('local_' . $plugin);
if (!empty($version->version)) {
Expand Down
12 changes: 6 additions & 6 deletions admin/mnet/mnet_themes.html
Expand Up @@ -58,14 +58,14 @@

if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) {
$readme = '<li>'.
$link = html_link::make($CFG->themewww .'/'. $theme .'/README.html', $strinfo);
$link->add_action(new popup_action('click', $link->url, $theme, array('height' => 400, 'width' => 500)));
echo $OUTPUT->link($link);
$link = $CFG->themewww .'/'. $theme .'/README.html';
$action = new popup_action('click', $link, $theme, array('height' => 400, 'width' => 500));
echo $OUTPUT->action_link($link, strinfo, $action);
} else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) {
$readme = '<li>'.
$link = html_link::make($CFG->themewww .'/'. $theme .'/README.txt', $strinfo);
$link->add_action(new popup_action('click', $link->url, $theme, array('height' => 400, 'width' => 500)));
echo $OUTPUT->link($link);
$link = $CFG->themewww .'/'. $theme .'/README.txt';
$action = new popup_action('click', $link, $theme, array('height' => 400, 'width' => 500));
echo $OUTPUT->action_link($link, $strinfo, $action);
}
if (file_exists("$theme/screenshot.png")) {
$screenshotpath = "$theme/screenshot.png";
Expand Down
6 changes: 3 additions & 3 deletions admin/mnet/peers.php
Expand Up @@ -221,7 +221,7 @@
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
// process all hosts first since it's the easiest
if ($host->id == $CFG->mnet_all_hosts_id) {
$table->data[] = array($OUTPUT->link($hosturl, $host->name), '', '', '');
$table->data[] = array(html_writer::tag('a', array('href'=>$hosturl), $host->name), '', '', '');
continue;
}

Expand All @@ -231,8 +231,8 @@
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time);
}
$table->data[] = array(
$OUTPUT->link($hosturl, $host->name),
$OUTPUT->link($hosturl, $host->wwwroot),
html_writer::link($hosturl, $host->name),
html_writer::link($hosturl, $host->wwwroot),
$last_connect,
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
);
Expand Down
6 changes: 3 additions & 3 deletions admin/mnet/testclient.php
Expand Up @@ -49,7 +49,7 @@
continue;
}
$newurl = new moodle_url($url, array('hostid' => $host->id));
echo '<p>' . $OUTPUT->link($newurl, $host->wwwroot) . '</p>';
echo '<p>' . html_writer::link($newurl, $host->wwwroot) . '</p>';
}

if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
Expand Down Expand Up @@ -118,7 +118,7 @@
$servicedata['apiversion'],
$yesno[$servicedata['publish']],
$yesno[$servicedata['subscribe']],
$OUTPUT->link($newurl, get_string('listservices', 'mnet'))
html_writer::link($newurl, get_string('listservices', 'mnet'))
);

}
Expand Down Expand Up @@ -153,7 +153,7 @@
$newurl = new moodle_url($url, $params);
$table->data[] = array(
$method,
$OUTPUT->link($newurl, get_string('inspect', 'mnet'))
html_writer::link($newurl, get_string('inspect', 'mnet'))
);
}
echo $OUTPUT->table($table);
Expand Down
17 changes: 7 additions & 10 deletions admin/roles/lib.php
Expand Up @@ -250,10 +250,10 @@ protected function add_row_cells($capability) {
echo '<td>' . $result . '</td>';
echo '<td>';

$link = html_link::make($this->baseurl . $capability->name, $this->strexplanation);
$link->add_action(new popup_action('click', $link->url, 'hascapabilityexplanation', array('height' => 600, 'width' => 600)));
$link->title = get_string($tooltip, 'role', $a);
echo $OUTPUT->link($link);
$url = $this->baseurl . $capability->name;
echo $OUTPUT->action_link($url, $this->strexplanation,
new popup_action('click', $url, 'hascapabilityexplanation', array('height' => 600, 'width' => 600)),
array('title'=>get_string($tooltip, 'role', $a)));

echo '</td>';
}
Expand Down Expand Up @@ -419,12 +419,9 @@ function get_risk_icon($type) {
global $OUTPUT;
if (!isset($this->riskicons[$type])) {
$iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type));

$link = html_link::make($this->risksurl, '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />');
$link->add_action(new popup_action('click', $link->url, 'docspopup'));
$link->title = get_string($type, 'admin');

$this->riskicons[$type] = $OUTPUT->link($link);
$text = '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />';
$action = new popup_action('click', $this->risksurl, 'docspopup');
$this->riskicons[$type] = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin')));
}
return $this->riskicons[$type];
}
Expand Down
35 changes: 18 additions & 17 deletions blocks/blog_menu/block_blog_menu.php
Expand Up @@ -79,43 +79,44 @@ function get_content() {
$menulist->add_class('list');

if (!empty($blogheaders['strview']) && $CFG->useblogassociations) {
$url = html_link::make($blogheaders['url'], $blogheaders['strview']);
if ($blogheaders['url']->compare($PAGE->url)) {
$url->disabled = true;
if ($blogheaders['url']->compare($PAGE->url) == URL_MATCH_EXACT) {
$menulist->add_item(html_writer::tag('span', array('class'=>'current'), $blogheaders['strview']));
} else {
$menulist->add_item(html_writer::link($blogheaders['url'], $blogheaders['strview']));
}
$menulist->add_item($OUTPUT->link($url));
}

// show View site entries link
if ($CFG->bloglevel >= BLOG_SITE_LEVEL && $canviewblogs) {
$viewsiteentriesurl = html_link::make($CFG->wwwroot .'/blog/index.php', get_string('viewsiteentries', 'blog'));
if (!$PAGE->url->param('search') && !$PAGE->url->param('tag') && !$PAGE->url->param('tagid') &&
!$PAGE->url->param('modid') && !$PAGE->url->param('courseid') && !$PAGE->url->param('userid') && !$PAGE->url->param('entryid')) {
$viewsiteentriesurl->disableifcurrent = true;
// no
} else {
$menulist->add_item(html_writer::add($CFG->wwwroot .'/blog/index.php', get_string('viewsiteentries', 'blog')));
}
$menulist->add_item($OUTPUT->link($viewsiteentriesurl));
}

$output .= '';

// show View my entries link
$myentrieslink = html_link::make(new moodle_url('/blog/index.php', array('userid' => $USER->id)), get_string('viewmyentries', 'blog'));
$myentrieslink->url->params($blogheaders['url']->params());
$myentrieslink->url->param('userid', $USER->id);
$pageuserid = $PAGE->url->param('userid');
if (!empty($pageuserid) && $pageuserid == $USER->id) {
$myentrieslink->disabled = true;
// no
} else {
$murl = new moodle_url('/blog/index.php', array('userid' => $USER->id));
$murl->params($blogheaders['url']->params());
$murl->param('userid', $USER->id);
$menulist->add_item(html_writer::link($murl, get_string('viewmyentries', 'blog')));
}

$menulist->add_item($OUTPUT->link($myentrieslink));

// show "Add entry" or "Blog about this" link
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/blog:create', $sitecontext)) {
$addentrylink = html_link::make(new moodle_url('/blog/edit.php', array('action' => 'add')), $blogheaders['stradd']);
$addentrylink->url->params($blogheaders['url']->params());
$addentrylink->disableifcurrent = true;
$menulist->add_item($OUTPUT->link($addentrylink));
$aurl = new moodle_url('/blog/edit.php', array('action' => 'add'));
$aurl->params($blogheaders['url']->params());
if ($PAGE->url->compare($aurl) != URL_MATCH_EXACT) {
$menulist->add_item(html_writer::link($aurl, $blogheaders['stradd']));
}
}

// Full-text search field
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/managefeeds.php
Expand Up @@ -135,7 +135,7 @@


if ($returnurl) {
echo '<div class="backlink">' . $OUTPUT->link($returnurl, get_string('back')) . '</div>';
echo '<div class="backlink">' . html_writer::link($returnurl, get_string('back')) . '</div>';
}

echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion blog/external_blogs.php
Expand Up @@ -91,6 +91,6 @@
}

$newexternalurl = new moodle_url('/blog/external_blog_edit.php');
echo $OUTPUT->link(html_link::make($newexternalurl, $straddnewexternalblog));
echo html_writer::link($newexternalurl, $straddnewexternalblog);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
7 changes: 3 additions & 4 deletions course/category.php
Expand Up @@ -412,10 +412,9 @@
$OUTPUT->pix_url('i/key') . '" alt="'.$strrequireskey.'" /></a>';
}
if (!empty($acourse->summary)) {
$link = html_link::make("/course/info.php?id=$acourse->id", '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />');
$link->add_action(new popup_action('click', $link->url, 'courseinfo'));
$link->title = $strsummary;
echo $OUTPUT->link($link);
$link = new moodle_url("/course/info.php?id=$acourse->id");
echo $OUTPUT->action_link($link, '<img alt="'.get_string('info').'" class="icon" src="'.$OUTPUT->pix_url('i/info') . '" />',
new popup_action('click', $link, 'courseinfo'), array('title'=>$strsummary));
}
echo "</td>";
}
Expand Down
25 changes: 11 additions & 14 deletions course/lib.php
Expand Up @@ -403,19 +403,17 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per

$row[] = userdate($log->time, '%a').' '.userdate($log->time, $strftimedatetime);

$link = html_link::make("/iplookup/index.php?ip=$log->ip&user=$log->userid", $log->ip);
$link->add_action(new popup_action('click', $link->url, 'iplookup', array('height' => 440, 'width' => 700)));
$row[] = $OUTPUT->link($link);
$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[] = $OUTPUT->link(html_link::make("/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) {
$row[] = $displayaction;
} else {
$link = html_link::make(make_log_url($log->module,$log->url), $displayaction);
$link->add_action(new popup_action('click', $link->url, 'fromloglive'), array('height' => 440, 'width' => 700));
$row[] = $OUTPUT->link($link);
$link = make_log_url($log->module,$log->url);
$row[] = $OUTPUT->action_link($link, $displayaction, new popup_action('click', $link, 'fromloglive'), array('height' => 440, 'width' => 700));
}
$row[] = $log->info;
$table->data[] = $row;
Expand Down Expand Up @@ -511,9 +509,8 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
echo "<td class=\"r$row c1\" align=\"right\">".userdate($log->time, '%a').
' '.userdate($log->time, $strftimedatetime)."</td>\n";
echo "<td class=\"r$row c2\" >\n";
$link = html_link::make("/iplookup/index.php?ip=$log->ip&user=$log->userid", $log->ip);
$link->add_action(new popup_action('click', $link->url, 'iplookup', array('height' => 400, 'width' => 700)));
echo $OUTPUT->link($link);
$link = new moodle_url("/iplookup/index.php?ip=$log->ip&user=$log->userid");
echo $OUTPUT->action_link($link, $log->ip, new popup_action('click', $link, 'iplookup', array('height' => 400, 'width' => 700)));
echo "</td>\n";
$fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
echo "<td class=\"r$row c3\" >\n";
Expand Down Expand Up @@ -2000,10 +1997,10 @@ function print_category_info($category, $depth, $showcourses = false) {
echo '<img alt="" style="width:18px;height:16px;" src="'.$OUTPUT->pix_url('spacer') . '" />';
}
if ($course->summary) {
$link = html_link::make('/course/info.php?id='.$course->id, '<img alt="'.$strsummary.'" src="'.$OUTPUT->pix_url('i/info') . '" />');
$link->add_action(new popup_action('click', $link->url, 'courseinfo', array('height' => 400, 'width' => 500)));
$link->title = $strsummary;
echo $OUTPUT->link($link);
$link = new moodle_url('/course/info.php?id='.$course->id);
echo $OUTPUT->action_link($link, '<img alt="'.$strsummary.'" src="'.$OUTPUT->pix_url('i/info') . '" />',
new popup_action('click', $link, 'courseinfo', array('height' => 400, 'width' => 500)),
array('title'=>$strsummary));
} else {
echo '<img alt="" style="width:18px;height:16px;" src="'.$OUTPUT->pix_url('spacer') . '" />';
}
Expand Down
5 changes: 2 additions & 3 deletions course/report/log/indexlive.php
Expand Up @@ -35,9 +35,8 @@
echo $OUTPUT->heading(get_string('loglive', 'coursereport_log'));

echo $OUTPUT->container_start('info');
$link = html_link::make('/course/report/log/live.php?id='. $course->id, get_string('livelogs'));
$link->add_action(new popup_action('click', $link->url, 'livelog', array('height' => 500, 'width' => 800)));
echo $OUTPUT->link($link);
$link = new moodle_url('/course/report/log/live.php?id='. $course->id);
echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
echo $OUTPUT->container_end();

echo $OUTPUT->footer();
Expand Down
5 changes: 2 additions & 3 deletions course/report/log/mod.php
Expand Up @@ -16,9 +16,8 @@
if (has_capability('coursereport/log:viewlive', $context)) {
echo $OUTPUT->heading(get_string('chooselivelogs') .':');
echo '<p>';
$link = html_link::make('/course/report/log/live.php?id='. $course->id, get_string('livelogs'));
$link->add_action(new popup_action('click', $link->url, 'livelog', array('height' => 500, 'width' => 800)));
echo $OUTPUT->link($link);
$link = new moodle_url('/course/report/log/live.php?id='. $course->id);
echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
echo '</p>';
}

5 changes: 2 additions & 3 deletions files/index.php
Expand Up @@ -298,9 +298,8 @@ function displaydir($file_info) {
}

if ($viewurl = $child_info->get_url()) {
$link = html_link::make($viewurl, "display", "<img src=\"" . $OUTPUT->pix_url('t/preview') . "\" class=\"iconsmall\" alt=\"$strfile\" />&nbsp;");
$link->add_action(new popup_action('click', $link->url, 'display', array('height' => 480, 'width' => 640)));
$viewurl = "&nbsp;".$OUTPUT->link($link);
$viewurl = "&nbsp;".$OUTPUT->action_link($viewurl, "<img src=\"" . $OUTPUT->pix_url('t/preview') . "\" class=\"iconsmall\" alt=\"$strfile\" />&nbsp;",
new popup_action('click', $viewurl, 'display', array('height' => 480, 'width' => 640)));
} else {
$viewurl = '';
}
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/outcome/index.php
Expand Up @@ -268,6 +268,6 @@ function grade_print_scale_link($courseid, $scale, $gpr) {
global $CFG, $OUTPUT;
$url = new moodle_url('/grade/edit/scale/edit.php', array('courseid' => $courseid, 'id' => $scale->id));
$url = $gpr->add_url_params($url);
return $OUTPUT->link($url, $scale->get_name());
return html_writer::link($url, $scale->get_name());
}

2 changes: 1 addition & 1 deletion grade/export/lib.php
Expand Up @@ -307,7 +307,7 @@ public function print_continue() {

$link = $CFG->wwwroot.'/grade/export/'.$this->plugin.'/dump.php'.$paraM.str.'&key='.$this->userkey;

echo get_string('download', 'admin').': ' . $OUTPUT->link($link, $link);
echo get_string('download', 'admin').': ' . html_writer::link($link, $link);
}
echo $OUTPUT->container_end();
}
Expand Down
5 changes: 1 addition & 4 deletions grade/report/lib.php
Expand Up @@ -325,10 +325,7 @@ protected function get_sort_arrow($direction='move', $sortlink=null) {
$strsort = $this->get_lang_string('sort' . $matrix[$direction]);

$arrow = print_arrow($direction, $strsort, true);
$link = html_link::make($sortlink, $arrow);
$link->title = $strsort;
$html = $OUTPUT->link($link);
return $html;
return html_writer::link($sortlink, $arrow, array('title'=>$strsort));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/blocklib.php
Expand Up @@ -816,7 +816,7 @@ protected function create_block_contents($instances, $output, $region) {
if ($content->blockinstanceid == $this->movingblock) {
$content->add_class('beingmoved');
$content->annotation .= get_string('movingthisblockcancel', 'block',
$output->link($this->page->url, get_string('cancel')));
html_writer::link($this->page->url, get_string('cancel')));
}

$results[] = $content;
Expand Down

0 comments on commit 75015e5

Please sign in to comment.