publication MDL-25040 display hub information (logo - description - link) on the...
authorjerome mouneyrac <jerome@moodle.com>
Mon, 15 Nov 2010 08:38:02 +0000 (08:38 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Mon, 15 Nov 2010 08:38:02 +0000 (08:38 +0000)
course/publish/metadata.php
course/publish/renderer.php
theme/canvas/style/course.css
theme/standard/style/course.css

index 4cfa38b..9a952f7 100644 (file)
@@ -78,6 +78,15 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
                         'id' => $id, 'page' => $PAGE));
     $fromform = $coursepublicationform->get_data();
 
+    //retrieve the token to call the hub
+    $registrationmanager = new registration_manager();
+    $registeredhub = $registrationmanager->get_registeredhub($huburl);
+
+    //setup web service xml-rpc client
+    $serverurl = $huburl . "/local/hub/webservice/webservices.php";
+    require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
+    $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
+
     if (!empty($fromform)) {
 
         $publicationmanager = new course_publish_manager();
@@ -173,16 +182,10 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
         }
 
         // PUBLISH ACTION
-        //retrieve the token to call the hub
-        $registrationmanager = new registration_manager();
-        $registeredhub = $registrationmanager->get_registeredhub($huburl);
-
+        
         //publish the course information
         $function = 'hub_register_courses';
-        $params = array('courses' => array($courseinfo));
-        $serverurl = $huburl . "/local/hub/webservice/webservices.php";
-        require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
-        $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
+        $params = array('courses' => array($courseinfo));     
         try {
             $courseids = $xmlrpcclient->call($function, $params);
         } catch (Exception $e) {
@@ -248,6 +251,22 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
 
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('publishcourseon', 'hub', !empty($hubname) ? $hubname : $huburl), 3, 'main');
+
+    //display hub information (logo, name, description)
+    $function = 'hub_get_info';
+    $params = array();
+    try {
+        $hubinfo = $xmlrpcclient->call($function, $params);
+    } catch (Exception $e) {
+        //only print error log in apache (for backward compatibility)
+        error_log(print_r($e->getMessage(), true));
+    }
+    $renderer = $PAGE->get_renderer('core', 'publish');
+    if (!empty($hubinfo)) {
+        echo $renderer->hubinfo($hubinfo);
+    }
+
+    //display metadata form
     $coursepublicationform->display();
     echo $OUTPUT->footer();
 }
index ead613b..64483e8 100644 (file)
@@ -190,4 +190,29 @@ class core_publish_renderer extends plugin_renderer_base {
         return $html;
     }
 
+    /**
+     * Hub information (logo - name - description - link)
+     * @param object $hubinfo
+     * @return string html code
+     */
+    public function hubinfo($hubinfo) {
+        $params = array('filetype' => HUB_HUBSCREENSHOT_FILE_TYPE);
+        $imgurl = new moodle_url($hubinfo['url'] .
+                        "/local/hub/webservice/download.php", $params);
+        $screenshothtml = html_writer::empty_tag('img',
+                        array('src' => $imgurl, 'alt' => $hubinfo['name']));
+        $hubdescription = html_writer::tag('div', $screenshothtml,
+                        array('class' => 'hubscreenshot'));
+
+        $hubdescription .= html_writer::tag('a', $hubinfo['name'],
+                        array('class' => 'hublink', 'href' => $hubinfo['url'],
+                            'onclick' => 'this.target="_blank"'));
+        
+        $hubdescription .= html_writer::tag('div', format_text($hubinfo['description'], FORMAT_PLAIN),
+                        array('class' => 'hubdescription'));
+        $hubdescription = html_writer::tag('div', $hubdescription, array('class' => 'hubinfo'));
+
+        return $hubdescription;
+    }
+
 }
index 02c7fde..a3347fc 100644 (file)
 
 /* Publication */
 #page-course-publish-metadata .metadatatext {width: 400px;}
+#page-course-publish-metadata .hubscreenshot {
+    border:1px solid;
+    display:inline;
+    float:left;
+    margin-right:10px;
+}
+#page-course-publish-metadata .hubscreenshot img {vertical-align: bottom;}
+#page-course-publish-metadata .hubdescription {}
+#page-course-publish-metadata .hubinfo {display:block; margin-bottom:20px;}
+#page-course-publish-metadata .hublink {}
 #page-course-publish-backup .courseuploadtextinfo {text-align: center;}
 #page-course-publish-backup .sharecoursecontinue  {text-align: center;}
\ No newline at end of file
index 34c9e10..9ba483c 100644 (file)
 
 /* Publication */
 #page-course-publish-metadata .metadatatext {width: 400px;}
+#page-course-publish-metadata .hubscreenshot {
+    border:1px solid;
+    display:inline;
+    float:left;
+    margin-right:10px;
+}
+#page-course-publish-metadata .hubscreenshot img {vertical-align: bottom;}
+#page-course-publish-metadata .hubdescription {}
+#page-course-publish-metadata .hubinfo {display:block; margin-bottom:20px;}
+#page-course-publish-metadata .hublink {}
 #page-course-publish-backup .courseuploadtextinfo {text-align: center;}
 #page-course-publish-backup .sharecoursecontinue  {text-align: center;}
\ No newline at end of file