Skip to content

Commit

Permalink
publication MDL-25040 display hub information (logo - description - l…
Browse files Browse the repository at this point in the history
…ink) on the publication metadata page
  • Loading branch information
mouneyrac committed Nov 15, 2010
1 parent ddd11b6 commit 6dfa3c0
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 8 deletions.
35 changes: 27 additions & 8 deletions course/publish/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@
'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();
Expand Down Expand Up @@ -173,16 +182,10 @@
}

// 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) {
Expand Down Expand Up @@ -248,6 +251,22 @@

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();
}
25 changes: 25 additions & 0 deletions course/publish/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,29 @@ public function sentbackupinfo($id, $huburl, $hubname) {
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;
}

}
10 changes: 10 additions & 0 deletions theme/canvas/style/course.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
10 changes: 10 additions & 0 deletions theme/standard/style/course.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;}

0 comments on commit 6dfa3c0

Please sign in to comment.