renderer MDL-23495 change $OUTPUT into $this->output in renderer
authorjerome <jerome>
Wed, 28 Jul 2010 08:53:17 +0000 (08:53 +0000)
committerjerome <jerome>
Wed, 28 Jul 2010 08:53:17 +0000 (08:53 +0000)
admin/registration/renderer.php
course/publish/renderer.php

index 279d5a4..4502290 100644 (file)
@@ -36,18 +36,16 @@ class core_register_renderer extends plugin_renderer_base {
      * @return string
      */
     public function registration_confirmation($confirmationmessage) {
-        global $OUTPUT;
-        $linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'), array('href' => new moodle_url('/local/hub/index.php')));
+        $linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'),
+                        array('href' => new moodle_url('/local/hub/index.php')));
         $message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist;
-        return $OUTPUT->box($message);
+        return $this->output->box($message);
     }
 
     /**
      * Display the page to register on Moodle.org or on a specific hub
      */
     public function registrationselector() {
-        global $OUTPUT;
-
         $table = new html_table();
         $table->head = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
         $table->size = array('50%', '50%');
@@ -71,17 +69,19 @@ class core_register_renderer extends plugin_renderer_base {
         $registeronmoodleorgurl = new moodle_url("/admin/registration/register.php",
                         array('sesskey' => sesskey(), 'huburl' => HUB_MOODLEORGHUBURL
                             , 'hubname' => 'Moodle.org'));
-        $registeronmoodleorgbutton = new single_button($registeronmoodleorgurl, get_string('registeronmoodleorg', 'hub'));
+        $registeronmoodleorgbutton = new single_button($registeronmoodleorgurl,
+                        get_string('registeronmoodleorg', 'hub'));
         $registeronmoodleorgbutton->class = 'centeredbutton';
-        $registeronmoodleorgbuttonhtml = $OUTPUT->render($registeronmoodleorgbutton);
+        $registeronmoodleorgbuttonhtml = $this->output->render($registeronmoodleorgbutton);
         $moodleorgcell = $registeronmoodleorgbuttonhtml;
 
         //Specific hub button cell
         $registeronspecifichuburl = new moodle_url("/admin/registration/hubselector.php",
                         array('sesskey' => sesskey()));
-        $registeronspecifichubbutton = new single_button($registeronspecifichuburl, get_string('registeronspecifichub', 'hub'));
+        $registeronspecifichubbutton = new single_button($registeronspecifichuburl,
+                        get_string('registeronspecifichub', 'hub'));
         $registeronspecifichubbutton->class = 'centeredbutton';
-        $registeronspecifichubbuttonhtml = $OUTPUT->render($registeronspecifichubbutton);
+        $registeronspecifichubbuttonhtml = $this->output->render($registeronspecifichubbutton);
         $specifichubcell = $registeronspecifichubbuttonhtml;
 
         //add button cells
@@ -96,8 +96,6 @@ class core_register_renderer extends plugin_renderer_base {
      * Display the listing of registered on hub
      */
     public function registeredonhublisting($hubs) {
-        global $OUTPUT;
-
         $table = new html_table();
         $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
         $table->size = array('80%', '20%');
@@ -107,11 +105,12 @@ class core_register_renderer extends plugin_renderer_base {
             $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));
 
             $unregisterhuburl = new moodle_url("/admin/registration/index.php",
-                            array('sesskey' => sesskey(), 'huburl' => $hub->huburl, 'unregistration' => 1));
+                            array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
+                                'unregistration' => 1));
             $unregisterbutton = new single_button($unregisterhuburl,
                             get_string('unregister', 'hub'));
             $unregisterbutton->class = 'centeredbutton';
-            $unregisterbuttonhtml = $OUTPUT->render($unregisterbutton);
+            $unregisterbuttonhtml = $this->output->render($unregisterbutton);
 
             //add button cells
             $cells = array($hublinkcell, $unregisterbuttonhtml);
index 163dc44..fcab21a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 // This file is part of Moodle - http://moodle.org/                      //
@@ -33,35 +34,33 @@ class core_publish_renderer extends plugin_renderer_base {
      * Display the selector to advertise or publish a course
      */
     public function publicationselector($courseid) {
-        global $OUTPUT;
-
         $text = '';
 
         $advertiseurl = new moodle_url("/course/publish/hubselector.php",
-                            array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
+                        array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
         $advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub'));
-        $text .= $OUTPUT->render($advertisebutton);
-        $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'), array('class' => 'publishhelp'));
+        $text .= $this->output->render($advertisebutton);
+        $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'),
+                        array('class' => 'publishhelp'));
 
         $text .= html_writer::empty_tag('br');  /// TODO Delete
 
         $uploadurl = new moodle_url("/course/publish/hubselector.php",
-                            array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
+                        array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
         $uploadbutton = new single_button($uploadurl, get_string('share', 'hub'));
-        $text .= $OUTPUT->render($uploadbutton);
-        $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'), array('class' => 'publishhelp'));
+        $text .= $this->output->render($uploadbutton);
+        $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'),
+                        array('class' => 'publishhelp'));
 
         return $text;
     }
 
-     /**
+    /**
      * Display the listing of hub where a course is registered on
      */
     public function registeredonhublisting($courseid, $publications) {
-        global $OUTPUT, $CFG;
-
         $table = new html_table();
-        $table->head  = array(get_string('type', 'hub'), get_string('hub', 'hub'), 
+        $table->head = array(get_string('type', 'hub'), get_string('hub', 'hub'),
             get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub'));
         $table->size = array('10%', '40%', '20%', '%10', '%15');
 
@@ -71,13 +70,15 @@ class core_publish_renderer extends plugin_renderer_base {
 
             $updatebuttonhtml = '';
 
-            $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'hubcourseid' => $publication->hubcourseid,
-                    'huburl' => $publication->huburl, 'hubname' => $publication->hubname,
-                    'cancel' => true, 'publicationid' => $publication->id, 'timepublished' => $publication->timepublished);
+            $params = array('sesskey' => sesskey(), 'id' => $publication->courseid,
+                'hubcourseid' => $publication->hubcourseid,
+                'huburl' => $publication->huburl, 'hubname' => $publication->hubname,
+                'cancel' => true, 'publicationid' => $publication->id,
+                'timepublished' => $publication->timepublished);
             $cancelurl = new moodle_url("/course/publish/index.php", $params);
             $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub'));
             $cancelbutton->class = 'centeredbutton';
-            $cancelbuttonhtml = $OUTPUT->render($cancelbutton);
+            $cancelbuttonhtml = $this->output->render($cancelbutton);
 
             if ($publication->enrollable) {
                 $params = array('sesskey' => sesskey(), 'id' => $publication->courseid,
@@ -86,16 +87,18 @@ class core_publish_renderer extends plugin_renderer_base {
                 $updateurl = new moodle_url("/course/publish/metadata.php", $params);
                 $updatebutton = new single_button($updateurl, get_string('update', 'hub'));
                 $updatebutton->class = 'centeredbutton';
-                $updatebuttonhtml = $OUTPUT->render($updatebutton);
+                $updatebuttonhtml = $this->output->render($updatebutton);
 
                 $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml;
             } else {
                 $operations = $cancelbuttonhtml;
             }
 
-            $hubname = html_writer::tag('a', $publication->hubname?$publication->hubname:$publication->huburl,
-                    array('href' => $publication->huburl));
-            if ($publication->timechecked > 1273127954) { //if the publication check time if bigger than May 2010, it has been checked
+            $hubname = html_writer::tag('a',
+                            $publication->hubname ? $publication->hubname : $publication->huburl,
+                            array('href' => $publication->huburl));
+            //if the publication check time if bigger than May 2010, it has been checked
+            if ($publication->timechecked > 1273127954) {
                 if ($publication->status == 0) {
                     $status = get_string('statusunpublished', 'hub');
                 } else {
@@ -103,48 +106,55 @@ class core_publish_renderer extends plugin_renderer_base {
                 }
 
                 $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'),
-                        array('href' => $CFG->wwwroot.'/course/publish/index.php?id='.$courseid.
-                        "&updatestatusid=".$publication->id."&sesskey=".sesskey())) .
-                        $brtag . get_string('lasttimechecked', 'hub') . ": " . format_time(time() - $publication->timechecked) ;
+                                array('href' => $CFG->wwwroot . '/course/publish/index.php?id='
+                                    . $courseid . "&updatestatusid=" . $publication->id
+                                    . "&sesskey=" . sesskey())) .
+                        $brtag . get_string('lasttimechecked', 'hub') . ": "
+                        . format_time(time() - $publication->timechecked);
             } else {
-                $status = get_string('neverchecked', 'hub') . $brtag .html_writer::tag('a', get_string('updatestatus', 'hub'),
-                        array('href' => $CFG->wwwroot.'/course/publish/index.php?id='.$courseid.
-                        "&updatestatusid=".$publication->id."&sesskey=".sesskey()));
+                $status = get_string('neverchecked', 'hub') . $brtag
+                        . html_writer::tag('a', get_string('updatestatus', 'hub'),
+                                array('href' => $CFG->wwwroot . '/course/publish/index.php?id='
+                                    . $courseid . "&updatestatusid=" . $publication->id
+                                    . "&sesskey=" . sesskey()));
             }
             //add button cells     
-            $cells = array($publication->enrollable?get_string('advertised', 'hub'):get_string('shared', 'hub'),
-                $hubname,  userdate($publication->timepublished, get_string('strftimedatetimeshort')), $status, $operations);
+            $cells = array($publication->enrollable ?
+                        get_string('advertised', 'hub') : get_string('shared', 'hub'),
+                $hubname, userdate($publication->timepublished,
+                        get_string('strftimedatetimeshort')), $status, $operations);
             $row = new html_table_row($cells);
             $table->data[] = $row;
-
         }
 
-        $contenthtml =  html_writer::table($table);
-        
-        return $contenthtml;
+        $contenthtml = html_writer::table($table);
 
+        return $contenthtml;
     }
 
     /**
      * Display unpublishing confirmation page
      * @param object $publication
      *      $publication->courseshortname
-            $publication->courseid
-            $publication->hubname
-            $publication->huburl
-            $publication->id
+      $publication->courseid
+      $publication->hubname
+      $publication->huburl
+      $publication->id
      */
     public function confirmunpublishing($publication) {
-        global $OUTPUT;
-        $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'hubcourseid' => $publication->hubcourseid,
-                    'huburl' => $publication->huburl, 'hubname' => $publication->hubname,
-                    'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true);
-        $optionsno  = array('sesskey'=>sesskey(), 'id' => $publication->courseid);
+        $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid,
+            'hubcourseid' => $publication->hubcourseid,
+            'huburl' => $publication->huburl, 'hubname' => $publication->hubname,
+            'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true);
+        $optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid);
         $publication->hubname = html_writer::tag('a', $publication->hubname,
-                array('href' => $publication->huburl));
-        $formcontinue = new single_button(new moodle_url("/course/publish/index.php", $optionsyes), get_string('unpublish', 'hub'), 'post');
-        $formcancel = new single_button(new moodle_url("/course/publish/index.php", $optionsno), get_string('cancel'), 'get');
-        return $OUTPUT->confirm(get_string('unpublishconfirmation', 'hub', $publication), $formcontinue, $formcancel);
+                        array('href' => $publication->huburl));
+        $formcontinue = new single_button(new moodle_url("/course/publish/index.php",
+                                $optionsyes), get_string('unpublish', 'hub'), 'post');
+        $formcancel = new single_button(new moodle_url("/course/publish/index.php",
+                                $optionsno), get_string('cancel'), 'get');
+        return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication),
+                $formcontinue, $formcancel);
     }
 
 }