From 6dfa3c07e8447eb761770b5004e4528bd9e6fc47 Mon Sep 17 00:00:00 2001 From: jerome mouneyrac Date: Mon, 15 Nov 2010 08:38:02 +0000 Subject: [PATCH] publication MDL-25040 display hub information (logo - description - link) on the publication metadata page --- course/publish/metadata.php | 35 +++++++++++++++++++++++++-------- course/publish/renderer.php | 25 +++++++++++++++++++++++ theme/canvas/style/course.css | 10 ++++++++++ theme/standard/style/course.css | 10 ++++++++++ 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/course/publish/metadata.php b/course/publish/metadata.php index 4cfa38bda35..9a952f7dd1c 100644 --- a/course/publish/metadata.php +++ b/course/publish/metadata.php @@ -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(); } diff --git a/course/publish/renderer.php b/course/publish/renderer.php index ead613b4dcd..64483e8bca5 100644 --- a/course/publish/renderer.php +++ b/course/publish/renderer.php @@ -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; + } + } diff --git a/theme/canvas/style/course.css b/theme/canvas/style/course.css index 02c7fde2d70..a3347fcd827 100644 --- a/theme/canvas/style/course.css +++ b/theme/canvas/style/course.css @@ -121,5 +121,15 @@ /* 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 diff --git a/theme/standard/style/course.css b/theme/standard/style/course.css index 34c9e108047..9ba483c140d 100644 --- a/theme/standard/style/course.css +++ b/theme/standard/style/course.css @@ -105,5 +105,15 @@ /* 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