MDL-20204 converting some more html_links

This commit is contained in:
Petr Skoda
2010-02-16 15:27:16 +00:00
parent 5a18a8fa74
commit 3ea5951efb
6 changed files with 9 additions and 50 deletions
@@ -162,10 +162,9 @@ class block_global_navigation_tree extends block_tree {
// Grab the items to display
$this->content->items = array($this->page->navigation);
$reloadlink = new html_link(new moodle_url($this->page->url, array('regenerate'=>'navigation')));
$reloadlink->add_class('customcommand');
$reloadlink = new moodle_url($this->page->url, array('regenerate'=>'navigation'));
$this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload');
$this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload', array('class'=>'customcommand'));
// Set content generated to true so that we know it has been done
$this->contentgenerated = true;
@@ -143,9 +143,8 @@ class block_settings_navigation_tree extends block_tree {
$this->content->footer = '';
}
$reloadlink = new html_link(new moodle_url($this->page->url, array('regenerate'=>'navigation')));
$reloadlink->add_class('customcommand');
$this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload');
$reloadlink = new moodle_url($this->page->url, array('regenerate'=>'navigation'));
$this->content->footer .= $OUTPUT->action_icon($reloadlink, get_string('reload'), 't/reload', array('class'=>'customcommand'));
if (!empty($this->config->enablesidebarpopout) && $this->config->enablesidebarpopout == 'yes') {
user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav'.block_settings_navigation_tree::$navcount, PARAM_INT);
+1 -1
View File
@@ -555,7 +555,7 @@ function log_report_extend_navigation($navigation, $course, $context) {
}
if (has_capability('coursereport/log:viewlive', $context)) {
$livelogs = get_string('livelogs');
$link = html_link::make('/course/report/log/live.php?id='. $course->id, $livelogs);
$link = new moodle_url('/course/report/log/live.php', array('id'=>$course->id));
$link->add_action(new popup_action('click', $link->url, 'livelog', array('height' => 500, 'width' => 800)));
$navigation->add($livelogs, $link, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
-39
View File
@@ -567,45 +567,6 @@ class core_renderer_test extends UnitTestCase {
$this->assertEqual('', $html);
}
public function test_link_to_popup_empty_link() {
// Empty link object: link MUST have a text value
$link = new html_link();
$popupaction = new popup_action('click', 'http://test.com', 'my_popup');
$link->add_action($popupaction);
$this->expectException();
$html = $this->renderer->link_to_popup($link);
}
public function test_link_to_popup() {
$link = new html_link();
$link->text = 'Click here';
$link->url = 'http://test.com';
$link->title = 'Popup window';
$popupaction = new popup_action('click', 'http://test.com', 'my_popup');
$link->add_action($popupaction);
$html = $this->renderer->link_to_popup($link);
$expectedattributes = array('title' => 'Popup window', 'href' => 'http://test.com');
$this->assert(new ContainsTagWithAttributes('a', $expectedattributes), $html);
$this->assert(new ContainsTagWithContents('a', 'Click here'), $html);
// Try a different url for the link than for the popup
$link->url = 'http://otheraddress.com';
$html = $this->renderer->link_to_popup($link);
$this->assert(new ContainsTagWithAttribute('a', 'title', 'Popup window'), $html);
$this->assert(new ContainsTagWithAttribute('a', 'href', 'http://otheraddress.com'), $html);
$this->assert(new ContainsTagWithContents('a', 'Click here'), $html);
// Give it a moodle_url object instead of a string
$link->url = new moodle_url('http://otheraddress.com');
$html = $this->renderer->link_to_popup($link);
$this->assert(new ContainsTagWithAttribute('a', 'title', 'Popup window'), $html);
$this->assert(new ContainsTagWithAttribute('a', 'href', 'http://otheraddress.com'), $html);
$this->assert(new ContainsTagWithContents('a', 'Click here'), $html);
}
public function test_paging_bar() {
global $CFG;
+3 -3
View File
@@ -642,8 +642,8 @@ function message_history_link($userid1, $userid2=0, $returnstr=false, $keywords=
'scrollbars' => true,
'resizable' => true);
$link = html_link::make("/message/history.php?user1=$userid1&user2=$userid2$keywords$position");
$action = new popup_action('click', $link->url, "message_history_$userid1", $popupoptions);
$link = new moodle_url("/message/history.php?user1=$userid1&user2=$userid2$keywords$position");
$action = new popup_action('click', $link, "message_history_$userid1", $popupoptions);
$str = $OUTPUT->action_link($link, $fulllink, $action, array('title'=>$strmessagehistory));
$str = '<span class="history">'.$str.'</span>';
@@ -1071,7 +1071,7 @@ function message_print_contactlist_user($contact, $incontactlist = true){
'scrollbars' => true,
'resizable' => true);
$link = html_link::make("/message/discussion.php?id=$contact->id");
$link = new moodle_url("/message/discussion.php?id=$contact->id");
$action = new popup_action('click', $link, "message_$contact->id", $popupoptions);
echo $OUTPUT->action_link($link, $fullnamelink, $action, array('title'=>get_string('sendmessageto', 'message', $fullname)));
@@ -273,7 +273,7 @@ class assignment_upload extends assignment_base {
}
if ($this->notes_allowed() and !empty($submission->data1)) {
$link = html_link::make("/mod/assignment/type/upload/notes.php?id=$this->cm->id&userid=$userid");
$link = new moodle_url("/mod/assignment/type/upload/notes.php", array('id'=>$this->cm->id, 'userid'=>$userid));
$action = new popup_action('click', $link, 'notes', array('height' => 500, 'width' => 780));
$output .= $OUTPUT->action_link($link, get_string('notes', 'assignment'), $action, array('title'=>get_string('notes', 'assignment')));