本文整理汇总了PHP中license_manager::get_licenses方法的典型用法代码示例。如果您正苦于以下问题:PHP license_manager::get_licenses方法的具体用法?PHP license_manager::get_licenses怎么用?PHP license_manager::get_licenses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类license_manager
的用法示例。
在下文中一共展示了license_manager::get_licenses方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_html
/**
* Builds the XHTML to display the control
*
* @param string $data Unused
* @param string $query
* @return string
*/
public function output_html($data, $query = '')
{
global $CFG, $OUTPUT;
require_once $CFG->libdir . '/licenselib.php';
$url = "licenses.php?sesskey=" . sesskey();
// display strings
$txt = get_strings(array('administration', 'settings', 'name', 'enable', 'disable', 'none'));
$licenses = license_manager::get_licenses();
$return = $OUTPUT->heading(get_string('availablelicenses', 'admin'), 3, 'main', true);
$return .= $OUTPUT->box_start('generalbox editorsui');
$table = new html_table();
$table->head = array($txt->name, $txt->enable);
$table->align = array('left', 'center');
$table->width = '100%';
$table->data = array();
foreach ($licenses as $value) {
$displayname = html_writer::link($value->source, get_string($value->shortname, 'license'), array('target' => '_blank'));
if ($value->enabled == 1) {
$hideshow = html_writer::link($url . '&action=disable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon', 'alt' => 'disable')));
} else {
$hideshow = html_writer::link($url . '&action=enable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon', 'alt' => 'enable')));
}
if ($value->shortname == $CFG->sitedefaultlicense) {
$displayname .= ' ' . html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/lock'), 'class' => 'icon', 'alt' => get_string('default'), 'title' => get_string('default')));
$hideshow = '';
}
$enabled = true;
$table->data[] = array($displayname, $hideshow);
}
$return .= html_writer::table($table);
$return .= $OUTPUT->box_end();
return highlight($query, $return);
}
示例2: definition
//.........这里部分代码省略.........
if (isset($hub['enrollablecourses'])) {
//check needed to avoid warnings for Moodle version < 2011081700
$additionaldesc = get_string('enrollablecourses', 'block_community') . ': ' . $hub['enrollablecourses'] . ' - ' . get_string('downloadablecourses', 'block_community') . ': ' . $hub['downloadablecourses'];
$hubdescriptiontext .= html_writer::tag('span', $additionaldesc, array('class' => 'hubadditionaldesc'));
}
if ($hub['trusted']) {
$hubtrusted = get_string('hubtrusted', 'block_community');
$hubdescriptiontext .= html_writer::tag('span', $hubtrusted . ' ' . $OUTPUT->doc_link('trusted_hubs'), array('class' => 'trusted'));
}
$hubdescriptiontext = html_writer::tag('span', $hubdescriptiontext, array('class' => 'hubdescriptiontext'));
$hubdescription = html_writer::tag('span', $hubdescription . $hubdescriptiontext, array('class' => $hub['trusted'] ? 'hubtrusted' : 'hubnottrusted'));
} else {
$hubdescription = html_writer::tag('a', $hub['name'], array('class' => 'hublink hubtrusted', 'href' => $hub['url']));
}
if (empty($firsthub)) {
$mform->addElement('radio', 'huburl', get_string('selecthub', 'block_community'), $hubdescription, $hub['url']);
$mform->setDefault('huburl', $huburl);
$firsthub = true;
} else {
$mform->addElement('radio', 'huburl', '', $hubdescription, $hub['url']);
}
}
//display enrol/download select box if the USER has the download capability on the course
if (has_capability('moodle/community:download', context_course::instance($this->_customdata['courseid']))) {
$options = array(0 => get_string('enrollable', 'block_community'), 1 => get_string('downloadable', 'block_community'));
$mform->addElement('select', 'downloadable', get_string('enroldownload', 'block_community'), $options);
$mform->addHelpButton('downloadable', 'enroldownload', 'block_community');
} else {
$mform->addElement('hidden', 'downloadable', 0);
}
$options = array();
$options['all'] = get_string('any');
$options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
$options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
$options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
$mform->addElement('select', 'audience', get_string('audience', 'block_community'), $options);
$mform->setDefault('audience', $audience);
unset($options);
$mform->addHelpButton('audience', 'audience', 'block_community');
$options = array();
$options['all'] = get_string('any');
$options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub');
$options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub');
$options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub');
$options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub');
$options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub');
$options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
$options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
$mform->addElement('select', 'educationallevel', get_string('educationallevel', 'block_community'), $options);
$mform->setDefault('educationallevel', $educationallevel);
unset($options);
$mform->addHelpButton('educationallevel', 'educationallevel', 'block_community');
$publicationmanager = new course_publish_manager();
$options = $publicationmanager->get_sorted_subjects();
foreach ($options as $key => &$option) {
$keylength = strlen($key);
if ($keylength == 10) {
$option = " " . $option;
} else {
if ($keylength == 12) {
$option = " " . $option;
}
}
}
$options = array_merge(array('all' => get_string('any')), $options);
$mform->addElement('select', 'subject', get_string('subject', 'block_community'), $options, array('id' => 'communitysubject'));
$mform->setDefault('subject', $subject);
unset($options);
$mform->addHelpButton('subject', 'subject', 'block_community');
$this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => true, 'mode' => 'compact'));
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licences = $licensemanager->get_licenses();
$options = array();
$options['all'] = get_string('any');
foreach ($licences as $license) {
$options[$license->shortname] = get_string($license->shortname, 'license');
}
$mform->addElement('select', 'licence', get_string('licence', 'block_community'), $options);
unset($options);
$mform->addHelpButton('licence', 'licence', 'block_community');
$mform->setDefault('licence', $licence);
$languages = get_string_manager()->get_list_of_languages();
collatorlib::asort($languages);
$languages = array_merge(array('all' => get_string('any')), $languages);
$mform->addElement('select', 'language', get_string('language'), $languages);
$mform->setDefault('language', $language);
$mform->addHelpButton('language', 'language', 'block_community');
$mform->addElement('radio', 'orderby', get_string('orderby', 'block_community'), get_string('orderbynewest', 'block_community'), 'newest');
$mform->addElement('radio', 'orderby', null, get_string('orderbyeldest', 'block_community'), 'eldest');
$mform->addElement('radio', 'orderby', null, get_string('orderbyname', 'block_community'), 'fullname');
$mform->addElement('radio', 'orderby', null, get_string('orderbypublisher', 'block_community'), 'publisher');
$mform->addElement('radio', 'orderby', null, get_string('orderbyratingaverage', 'block_community'), 'ratingaverage');
$mform->setDefault('orderby', $orderby);
$mform->setType('orderby', PARAM_ALPHA);
$mform->addElement('text', 'search', get_string('keywords', 'block_community'));
$mform->addHelpButton('search', 'keywords', 'block_community');
$mform->addElement('submit', 'submitbutton', get_string('search', 'block_community'));
}
}
示例3: definition
//.........这里部分代码省略.........
$mform->addHelpButton('courseshortname', 'courseshortname', 'hub');
$mform->addElement('textarea', 'description', get_string('description'), array('rows' => 10, 'cols' => 57));
$mform->addRule('description', $strrequired, 'required', null, 'client');
$mform->setDefault('description', $defaultsummary);
$mform->setType('description', PARAM_TEXT);
$mform->addHelpButton('description', 'description', 'hub');
$languages = get_string_manager()->get_list_of_languages();
textlib_get_instance()->asort($languages);
$mform->addElement('select', 'language', get_string('language'), $languages);
$mform->setDefault('language', $defaultlanguage);
$mform->addHelpButton('language', 'language', 'hub');
$mform->addElement('text', 'publishername', get_string('publishername', 'hub'), array('class' => 'metadatatext'));
$mform->setDefault('publishername', $defaultpublishername);
$mform->addRule('publishername', $strrequired, 'required', null, 'client');
$mform->addHelpButton('publishername', 'publishername', 'hub');
$mform->addElement('text', 'publisheremail', get_string('publisheremail', 'hub'), array('class' => 'metadatatext'));
$mform->setDefault('publisheremail', $defaultpublisheremail);
$mform->addRule('publisheremail', $strrequired, 'required', null, 'client');
$mform->addHelpButton('publisheremail', 'publisheremail', 'hub');
$mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'), array('class' => 'metadatatext'));
$mform->addRule('creatorname', $strrequired, 'required', null, 'client');
$mform->setType('creatorname', PARAM_TEXT);
$mform->setDefault('creatorname', $defaultcreatorname);
$mform->addHelpButton('creatorname', 'creatorname', 'hub');
$mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'), array('class' => 'metadatatext'));
$mform->setDefault('contributornames', $defaultcontributornames);
$mform->addHelpButton('contributornames', 'contributornames', 'hub');
$mform->addElement('text', 'coverage', get_string('tags', 'hub'), array('class' => 'metadatatext'));
$mform->setType('coverage', PARAM_TEXT);
$mform->setDefault('coverage', $defaultcoverage);
$mform->addHelpButton('coverage', 'tags', 'hub');
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licences = $licensemanager->get_licenses();
$options = array();
foreach ($licences as $license) {
$options[$license->shortname] = get_string($license->shortname, 'license');
}
$mform->addElement('select', 'licence', get_string('license'), $options);
$mform->setDefault('licence', $defaultlicenceshortname);
unset($options);
$mform->addHelpButton('licence', 'licence', 'hub');
$options = $publicationmanager->get_sorted_subjects();
//prepare data for the smartselect
foreach ($options as $key => &$option) {
$keylength = strlen($key);
if ($keylength == 10) {
$option = " " . $option;
} else {
if ($keylength == 12) {
$option = " " . $option;
}
}
}
$options = array('none' => get_string('none', 'hub')) + $options;
$mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
unset($options);
$mform->addHelpButton('subject', 'subject', 'hub');
$mform->setDefault('subject', $defaultsubject);
$mform->addRule('subject', $strrequired, 'required', null, 'client');
$this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact'));
$options = array();
$options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
$options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
$options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
$mform->addElement('select', 'audience', get_string('audience', 'hub'), $options);
示例4: course_list
/**
* Display a list of courses
* @param array $courses
* @param boolean $withwriteaccess
* @param int $contextcourseid context course id
* @return string
*/
public function course_list($courses, $huburl, $contextcourseid)
{
global $CFG;
$renderedhtml = '';
if (empty($courses)) {
if (isset($courses)) {
$renderedhtml .= get_string('nocourse', 'block_community');
}
} else {
$courseiteration = 0;
foreach ($courses as $course) {
$course = (object) $course;
$courseiteration = $courseiteration + 1;
//create visit link html
if (!empty($course->courseurl)) {
$courseurl = new moodle_url($course->courseurl);
$linktext = get_string('visitsite', 'block_community');
} else {
$courseurl = new moodle_url($course->demourl);
$linktext = get_string('visitdemo', 'block_community');
}
$visitlinkhtml = html_writer::tag('a', $linktext, array('href' => $courseurl, 'class' => 'hubcoursedownload', 'onclick' => 'this.target="_blank"'));
//create title html
$coursename = html_writer::tag('h3', $course->fullname, array('class' => 'hubcoursetitle'));
$coursenamehtml = html_writer::tag('div', $coursename, array('class' => 'hubcoursetitlepanel'));
// create screenshots html
$screenshothtml = '';
if (!empty($course->screenshots)) {
$baseurl = new moodle_url($huburl . '/local/hub/webservice/download.php', array('courseid' => $course->id, 'filetype' => HUB_SCREENSHOT_FILE_TYPE));
$screenshothtml = html_writer::empty_tag('img', array('src' => $baseurl, 'alt' => $course->fullname));
}
$coursescreenshot = html_writer::tag('div', $screenshothtml, array('class' => 'coursescreenshot', 'id' => 'image-' . $course->id));
//create description html
$deschtml = html_writer::tag('div', $course->description, array('class' => 'hubcoursedescription'));
//create users related information html
$courseuserinfo = get_string('userinfo', 'block_community', $course);
if ($course->contributornames) {
$courseuserinfo .= ' - ' . get_string('contributors', 'block_community', $course->contributornames);
}
$courseuserinfohtml = html_writer::tag('div', $courseuserinfo, array('class' => 'hubcourseuserinfo'));
//create course content related information html
$course->subject = get_string($course->subject, 'edufields');
$course->audience = get_string('audience' . $course->audience, 'hub');
$course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub');
$coursecontentinfo = '';
if (empty($course->coverage)) {
$course->coverage = '';
} else {
$coursecontentinfo .= get_string('coverage', 'block_community', $course->coverage);
$coursecontentinfo .= ' - ';
}
$coursecontentinfo .= get_string('contentinfo', 'block_community', $course);
$coursecontentinfohtml = html_writer::tag('div', $coursecontentinfo, array('class' => 'hubcoursecontentinfo'));
///create course file related information html
//language
if (!empty($course->language)) {
$languages = get_string_manager()->get_list_of_languages();
$course->lang = $languages[$course->language];
} else {
$course->lang = '';
}
//licence
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licenses = $licensemanager->get_licenses();
foreach ($licenses as $license) {
if ($license->shortname == $course->licenceshortname) {
$course->license = $license->fullname;
}
}
$course->timeupdated = userdate($course->timemodified);
$coursefileinfo = get_string('fileinfo', 'block_community', $course);
$coursefileinfohtml = html_writer::tag('div', $coursefileinfo, array('class' => 'hubcoursefileinfo'));
//Create course content html
$blocks = get_plugin_list('block');
$activities = get_plugin_list('mod');
if (!empty($course->contents)) {
$activitieshtml = '';
$blockhtml = '';
foreach ($course->contents as $content) {
$content = (object) $content;
if ($content->moduletype == 'block') {
if (!empty($blockhtml)) {
$blockhtml .= ' - ';
}
if (array_key_exists($content->modulename, $blocks)) {
$blockname = get_string('pluginname', 'block_' . $content->modulename);
} else {
$blockname = $content->modulename;
}
$blockhtml .= $blockname . " (" . $content->contentcount . ")";
} else {
if (!empty($activitieshtml)) {
//.........这里部分代码省略.........
示例5: definition
public function definition()
{
global $CFG;
$strrequired = get_string('required');
//retrieve the publication
$hub = new local_hub();
$course = $hub->get_course($this->_customdata['id']);
$mform =& $this->_form;
$mform->addElement('header', 'moodle', get_string('coursesettingsform', 'local_hub', $course->fullname));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
$mform->addElement('checkbox', 'visible', get_string('coursevisibility', 'local_hub'));
$mform->addHelpButton('visible', 'coursevisibility', 'local_hub');
$mform->setDefault('visible', $course->privacy);
$mform->addElement('text', 'fullname', get_string('coursename', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('fullname', PARAM_TEXT);
$mform->addHelpButton('fullname', 'coursename', 'local_hub');
$mform->setDefault('fullname', $course->fullname);
$mform->addRule('fullname', $strrequired, 'required', null, 'client');
if (!empty($course->courseurl)) {
$mform->addElement('text', 'courseurl', get_string('courseurl', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('courseurl', PARAM_URL);
$mform->addHelpButton('courseurl', 'courseurl', 'local_hub');
$mform->setDefault('courseurl', $course->courseurl);
$mform->addRule('courseurl', $strrequired, 'required', null, 'client');
} else {
$mform->addElement('text', 'demourl', get_string('demourl', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('demourl', PARAM_URL);
$mform->addHelpButton('demourl', 'demourl', 'local_hub');
$mform->setDefault('demourl', $course->demourl);
}
$mform->addElement('textarea', 'description', get_string('coursedesc', 'local_hub'), array('rows' => 10, 'cols' => 56, 'class' => 'coursesettingstextarea'));
$mform->addHelpButton('description', 'coursedesc', 'local_hub');
$mform->addRule('description', $strrequired, 'required', null, 'client');
$mform->setDefault('description', $course->description);
$languages = get_string_manager()->get_list_of_languages();
asort($languages, SORT_LOCALE_STRING);
$mform->addElement('select', 'language', get_string('courselang', 'local_hub'), $languages);
$mform->setDefault('language', $course->language);
$mform->addHelpButton('language', 'courselang', 'local_hub');
$mform->addElement('text', 'publishername', get_string('publishername', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('publishername', PARAM_TEXT);
$mform->setDefault('publishername', $course->publishername);
$mform->addRule('publishername', $strrequired, 'required', null, 'client');
$mform->addHelpButton('publishername', 'publishername', 'local_hub');
$mform->addElement('text', 'publisheremail', get_string('publisheremail', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('publisheremail', PARAM_EMAIL);
$mform->setDefault('publisheremail', $course->publisheremail);
$mform->addRule('publisheremail', $strrequired, 'required', null, 'client');
$mform->addHelpButton('publisheremail', 'publisheremail', 'local_hub');
$mform->addElement('text', 'creatorname', get_string('creatorname', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->addRule('creatorname', $strrequired, 'required', null, 'client');
$mform->setType('creatorname', PARAM_TEXT);
$mform->setDefault('creatorname', $course->creatorname);
$mform->addHelpButton('creatorname', 'creatorname', 'local_hub');
$mform->addElement('text', 'contributornames', get_string('contributornames', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('contributornames', PARAM_TEXT);
$mform->setDefault('contributornames', $course->contributornames);
$mform->addHelpButton('contributornames', 'contributornames', 'local_hub');
$mform->addElement('text', 'coverage', get_string('tags', 'local_hub'), array('class' => 'coursesettingstextfield'));
$mform->setType('coverage', PARAM_TEXT);
$mform->setDefault('coverage', $course->coverage);
$mform->addHelpButton('coverage', 'tags', 'local_hub');
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licences = $licensemanager->get_licenses();
$options = array();
foreach ($licences as $license) {
$options[$license->shortname] = get_string($license->shortname, 'license');
}
$mform->addElement('select', 'licence', get_string('licence', 'local_hub'), $options);
$mform->setDefault('licence', $course->licenceshortname);
unset($options);
$mform->addHelpButton('licence', 'licence', 'local_hub');
require_once $CFG->dirroot . "/course/publish/lib.php";
$publicationmanager = new course_publish_manager();
$options = $publicationmanager->get_sorted_subjects();
//prepare data for the smartselect
foreach ($options as $key => &$option) {
$keylength = strlen($key);
if ($keylength == 10) {
$option = " " . $option;
} else {
if ($keylength == 12) {
$option = " " . $option;
}
}
}
$options = array('none' => get_string('none', 'local_hub')) + $options;
$mform->addElement('select', 'subject', get_string('subject', 'local_hub'), $options);
unset($options);
$mform->addHelpButton('subject', 'subject', 'local_hub');
$mform->setDefault('subject', $course->subject);
$mform->addRule('subject', $strrequired, 'required', null, 'client');
$this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact'));
$options = array();
$options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'local_hub');
$options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'local_hub');
$options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'local_hub');
$mform->addElement('select', 'audience', get_string('audience', 'local_hub'), $options);
//.........这里部分代码省略.........
示例6: definition
//.........这里部分代码省略.........
$additionaldesc = get_string('enrollablecourses', 'block_community') . ': ' . $hub['enrollablecourses'] . ' - ' . get_string('downloadablecourses', 'block_community') . ': ' . $hub['downloadablecourses'];
$hubstats .= html_writer::tag('div', $additionaldesc);
}
if ($hub['trusted']) {
$hubtrusted = get_string('hubtrusted', 'block_community');
$hubstats .= $OUTPUT->doc_link('trusted_hubs') . html_writer::tag('div', $hubtrusted);
}
$hubstats = html_writer::tag('div', $hubstats, array('class' => 'hubstats'));
// hub name link + hub description.
$hubnamelink = html_writer::link($hub['url'], html_writer::tag('h2', $hubname), array('class' => 'hubtitlelink'));
// The description can come from the hub directory - need to clean.
$hubdescription = clean_param($hub['description'], PARAM_TEXT);
$hubdescriptiontext = html_writer::tag('div', format_text($hubdescription, FORMAT_PLAIN), array('class' => 'hubdescription'));
$hubtext = html_writer::tag('div', $hubdescriptiontext . $hubstats, array('class' => 'hubtext'));
$hubimgandtext = html_writer::tag('div', $hubimage . $hubtext, array('class' => 'hubimgandtext'));
$hubfulldesc = html_writer::tag('div', $hubnamelink . $hubimgandtext, array('class' => 'hubmainhmtl'));
} else {
$hubfulldesc = html_writer::link($hub['url'], $hubname);
}
// Add hub to the hub items.
$hubinfo = new stdClass();
$hubinfo->mainhtml = $hubfulldesc;
$hubinfo->rowhtml = html_writer::tag('div', $smalllogohtml, array('class' => 'hubsmalllogo')) . $hubname;
$hubitems[$hub['url']] = $hubinfo;
}
// Hub listing form element.
$mform->addElement('listing', 'huburl', '', '', array('items' => $hubitems, 'showall' => get_string('showall', 'block_community'), 'hideall' => get_string('hideall', 'block_community')));
$mform->setDefault('huburl', $huburl);
//display enrol/download select box if the USER has the download capability on the course
if (has_capability('moodle/community:download', context_course::instance($this->_customdata['courseid']))) {
$options = array(0 => get_string('enrollable', 'block_community'), 1 => get_string('downloadable', 'block_community'));
$mform->addElement('select', 'downloadable', get_string('enroldownload', 'block_community'), $options);
$mform->addHelpButton('downloadable', 'enroldownload', 'block_community');
$mform->setDefault('downloadable', $downloadable);
} else {
$mform->addElement('hidden', 'downloadable', 0);
}
$mform->setType('downloadable', PARAM_INT);
$options = array();
$options['all'] = get_string('any');
$options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
$options[HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
$options[HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
$mform->addElement('select', 'audience', get_string('audience', 'block_community'), $options);
$mform->setDefault('audience', $audience);
unset($options);
$mform->addHelpButton('audience', 'audience', 'block_community');
$options = array();
$options['all'] = get_string('any');
$options[HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub');
$options[HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub');
$options[HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub');
$options[HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub');
$options[HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub');
$options[HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
$options[HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
$mform->addElement('select', 'educationallevel', get_string('educationallevel', 'block_community'), $options);
$mform->setDefault('educationallevel', $educationallevel);
unset($options);
$mform->addHelpButton('educationallevel', 'educationallevel', 'block_community');
$publicationmanager = new course_publish_manager();
$options = $publicationmanager->get_sorted_subjects();
$mform->addElement('searchableselector', 'subject', get_string('subject', 'block_community'), $options, array('id' => 'communitysubject'));
$mform->setDefault('subject', $subject);
unset($options);
$mform->addHelpButton('subject', 'subject', 'block_community');
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licences = $licensemanager->get_licenses();
$options = array();
$options['all'] = get_string('any');
foreach ($licences as $license) {
$options[$license->shortname] = get_string($license->shortname, 'license');
}
$mform->addElement('select', 'licence', get_string('licence', 'block_community'), $options);
unset($options);
$mform->addHelpButton('licence', 'licence', 'block_community');
$mform->setDefault('licence', $licence);
$languages = get_string_manager()->get_list_of_languages();
core_collator::asort($languages);
$languages = array_merge(array('all' => get_string('any')), $languages);
$mform->addElement('select', 'language', get_string('language'), $languages);
$mform->setDefault('language', $language);
$mform->addHelpButton('language', 'language', 'block_community');
$mform->addElement('select', 'orderby', get_string('orderby', 'block_community'), array('newest' => get_string('orderbynewest', 'block_community'), 'eldest' => get_string('orderbyeldest', 'block_community'), 'fullname' => get_string('orderbyname', 'block_community'), 'publisher' => get_string('orderbypublisher', 'block_community'), 'ratingaverage' => get_string('orderbyratingaverage', 'block_community')));
$mform->setDefault('orderby', $orderby);
$mform->addHelpButton('orderby', 'orderby', 'block_community');
$mform->setType('orderby', PARAM_ALPHA);
$mform->setAdvanced('audience');
$mform->setAdvanced('educationallevel');
$mform->setAdvanced('subject');
$mform->setAdvanced('licence');
$mform->setAdvanced('language');
$mform->setAdvanced('orderby');
$mform->addElement('text', 'search', get_string('keywords', 'block_community'), array('size' => 30));
$mform->addHelpButton('search', 'keywords', 'block_community');
$mform->setType('search', PARAM_NOTAGS);
$mform->addElement('submit', 'submitbutton', get_string('search', 'block_community'));
}
}
示例7: course_list
//.........这里部分代码省略.........
//create description html
$deschtml = html_writer::tag('div', $course->description, array('class' => 'hubcoursedescription'));
//create users related information html
$courseuserinfo = get_string('userinfo', 'local_hub', $course);
if ($course->contributornames) {
$courseuserinfo .= ' - ' . get_string('contributors', 'local_hub', $course->contributornames);
}
$courseuserinfo .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/email'), 'class' => 'hubcoursemail', 'alt' => get_string('msgtopublisher', 'local_hub', $course->fullname))), array('href' => new moodle_url('/local/hub/sendmessage.php', array('id' => $course->id, 'admin' => $withwriteaccess))));
$courseuserinfohtml = html_writer::tag('div', $courseuserinfo, array('class' => 'hubcourseuserinfo'));
//create course content related information html
$course->subject = get_string($course->subject, 'edufields');
$course->audience = get_string('audience' . $course->audience, 'hub');
$course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub');
$coursecontentinfo = '';
if (empty($course->coverage)) {
$course->coverage = '';
} else {
$coursecontentinfo .= get_string('coverage', 'local_hub', $course->coverage);
$coursecontentinfo .= ' - ';
}
$coursecontentinfo .= get_string('contentinfo', 'local_hub', $course);
$coursecontentinfohtml = html_writer::tag('div', $coursecontentinfo, array('class' => 'hubcoursecontentinfo'));
///create course file related information html
//language
if (!empty($course->language)) {
$languages = get_string_manager()->get_list_of_languages();
$course->lang = $languages[$course->language];
} else {
$course->lang = '';
}
//licence
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licenses = $licensemanager->get_licenses();
foreach ($licenses as $license) {
if ($license->shortname == $course->licenceshortname) {
$course->license = $license->fullname;
}
}
$course->timeupdated = userdate($course->timemodified);
$coursefileinfo = get_string('fileinfo', 'local_hub', $course);
$coursefileinfohtml = html_writer::tag('div', $coursefileinfo, array('class' => 'hubcoursefileinfo'));
//Create course content html
$blocksandactivities = '';
if (!empty($course->contents)) {
$activitieshtml = '';
$blockhtml = '';
foreach ($course->contents as $content) {
if ($content->moduletype == 'block') {
if (!empty($blockhtml)) {
$blockhtml .= ' - ';
}
$blockpath = get_component_directory('block_' . $content->modulename);
$blockname = !is_dir($blockpath) ? $content->modulename : get_string('pluginname', 'block_' . $content->modulename);
$blockhtml .= $blockname . " (" . $content->contentcount . ")";
} else {
if (!empty($activitieshtml)) {
$activitieshtml .= ' - ';
}
$activitypath = get_component_directory($content->modulename);
$activityname = !is_dir($activitypath) ? $content->modulename : get_string('modulename', $content->modulename);
$activitieshtml .= $activityname . " (" . $content->contentcount . ")";
}
}
$blocksandactivities = html_writer::tag('div', get_string('activities', 'local_hub') . " : " . $activitieshtml);
//Uncomment following lines to display blocks information
示例8: local_hub_rss_generate_feed_info
/**
* Generate courses feed content
* @param object $courses
* @return array
*/
function local_hub_rss_generate_feed_info($courses)
{
global $CFG;
$rssfeedinfo = array();
foreach ($courses as $course) {
$courserss = new stdClass();
$courserss->title = $course->fullname;
$courserss->author = $course->creatorname;
$courserss->pubdate = $course->timemodified;
$courseurl = new moodle_url($CFG->wwwroot . '/index.php', array('courseid' => $course->id, 'rss' => true));
$courserss->link = $courseurl->out(false);
//create description
$course->subject = get_string($course->subject, 'edufields');
$course->audience = get_string('audience' . $course->audience, 'hub');
$course->educationallevel = get_string('edulevel' . $course->educationallevel, 'hub');
//add course type (enrollable/downloadable)
$typetext = empty($course->enrollable) ? get_string('typedownloadable', 'local_hub') : get_string('typeenrollable', 'local_hub');
$deschtml = get_string('coursetype', 'local_hub', $typetext);
$deschtml .= html_writer::empty_tag('br');
$deschtml .= $course->description;
//the description
//create the additional description
$additionaldesc = html_writer::empty_tag('br');
$additionaldesc .= get_string('userinfo', 'local_hub', $course);
if ($course->contributornames) {
$additionaldesc .= ' - ';
$additionaldesc .= get_string('contributors', 'local_hub', $course->contributornames);
}
if (empty($course->coverage)) {
$course->coverage = '';
} else {
$additionaldesc .= ' - ';
$additionaldesc .= get_string('coverage', 'local_hub', $course->coverage);
}
//retrieve language string
//construct languages array
if (!empty($course->language)) {
$languages = get_string_manager()->get_list_of_languages();
$course->lang = $languages[$course->language];
} else {
$course->lang = '';
}
//licence
require_once $CFG->libdir . "/licenselib.php";
$licensemanager = new license_manager();
$licenses = $licensemanager->get_licenses();
foreach ($licenses as $license) {
if ($license->shortname == $course->licenceshortname) {
$course->license = $license->fullname;
}
}
//time modified
$course->timeupdated = userdate($course->timemodified);
$additionaldesc .= ' - ' . get_string('fileinfo', 'local_hub', $course);
//subject/audience/level
$additionaldesc .= ' - ' . get_string('contentinfo', 'local_hub', $course);
$deschtml .= html_writer::tag('span', $additionaldesc, array('class' => 'additionaldesc'));
$courserss->description = $deschtml;
$rssfeedinfo[] = $courserss;
}
return $rssfeedinfo;
}