From 3ea5951efba564d65c0f2bc1a14ea14d06c5d162 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Tue, 16 Feb 2010 15:27:16 +0000 Subject: [PATCH] MDL-20204 converting some more html_links --- .../block_global_navigation_tree.php | 5 +-- .../block_settings_navigation_tree.php | 5 +-- course/report/log/lib.php | 2 +- lib/simpletest/testoutputlib.php | 39 ------------------- message/lib.php | 6 +-- .../type/upload/assignment.class.php | 2 +- 6 files changed, 9 insertions(+), 50 deletions(-) diff --git a/blocks/global_navigation_tree/block_global_navigation_tree.php b/blocks/global_navigation_tree/block_global_navigation_tree.php index c7138d2d08a..c2d6cff9cc4 100644 --- a/blocks/global_navigation_tree/block_global_navigation_tree.php +++ b/blocks/global_navigation_tree/block_global_navigation_tree.php @@ -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; diff --git a/blocks/settings_navigation_tree/block_settings_navigation_tree.php b/blocks/settings_navigation_tree/block_settings_navigation_tree.php index f04cb74eac4..8949bc11e60 100644 --- a/blocks/settings_navigation_tree/block_settings_navigation_tree.php +++ b/blocks/settings_navigation_tree/block_settings_navigation_tree.php @@ -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); diff --git a/course/report/log/lib.php b/course/report/log/lib.php index 53495e087f0..46dc3bf5cc7 100644 --- a/course/report/log/lib.php +++ b/course/report/log/lib.php @@ -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', '')); } diff --git a/lib/simpletest/testoutputlib.php b/lib/simpletest/testoutputlib.php index 518352878b5..a4c8b37747a 100644 --- a/lib/simpletest/testoutputlib.php +++ b/lib/simpletest/testoutputlib.php @@ -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; diff --git a/message/lib.php b/message/lib.php index f56a25c3e98..20df4e2d164 100644 --- a/message/lib.php +++ b/message/lib.php @@ -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 = ''.$str.''; @@ -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))); diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index 7537d631970..c91fa1bc8f8 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -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')));