mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
publication MDL-25040 display hub information (logo - description - link) on the publication metadata page
This commit is contained in:
parent
ddd11b6c78
commit
6dfa3c07e8
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;}
|
@ -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;}
|
Loading…
x
Reference in New Issue
Block a user