Merge branch 'MDL-72845-master' of https://github.com/lameze/moodle

This commit is contained in:
Jun Pataleta 2021-12-23 10:49:44 +08:00
commit 057f312cff
8 changed files with 105 additions and 19 deletions

View File

@ -913,6 +913,9 @@ $showcampaigncontent = !isset($CFG->showcampaigncontent) || $CFG->showcampaignco
// Encourage admins to enable the user feedback feature if it is not enabled already.
$showfeedbackencouragement = empty($CFG->enableuserfeedback);
// Check if the service and support content setting is enabled or not.
$servicesandsupportcontent = !isset($CFG->showservicesandsupportcontent) || $CFG->showservicesandsupportcontent;
admin_externalpage_setup('adminnotifications');
$output = $PAGE->get_renderer('core', 'admin');
@ -921,4 +924,4 @@ echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisp
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
$registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir,
$mobileconfigured, $overridetossl, $invalidforgottenpasswordurl, $croninfrequent,
$showcampaigncontent, $showfeedbackencouragement);
$showcampaigncontent, $showfeedbackencouragement, $servicesandsupportcontent);

View File

@ -284,6 +284,7 @@ class core_admin_renderer extends plugin_renderer_base {
* @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
* @param bool $showcampaigncontent Whether the campaign content should be visible or not.
* @param bool $showfeedbackencouragement Whether the feedback encouragement content should be displayed or not.
* @param bool $showservicesandsupport Whether the services and support content should be displayed or not.
*
* @return string HTML to output.
*/
@ -292,7 +293,7 @@ class core_admin_renderer extends plugin_renderer_base {
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
$themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
$overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false,
$showcampaigncontent = false, bool $showfeedbackencouragement = false) {
$showcampaigncontent = false, bool $showfeedbackencouragement = false, bool $showservicesandsupport) {
global $CFG;
$output = '';
@ -317,6 +318,7 @@ class core_admin_renderer extends plugin_renderer_base {
$output .= $this->mobile_configuration_warning($mobileconfigured);
$output .= $this->forgotten_password_url_warning($invalidforgottenpasswordurl);
$output .= $this->userfeedback_encouragement($showfeedbackencouragement);
$output .= $this->services_and_support_content($showservicesandsupport);
$output .= $this->campaign_content($showcampaigncontent);
//////////////////////////////////////////////////////////////////////////////////////////////////
@ -895,7 +897,35 @@ class core_admin_renderer extends plugin_renderer_base {
return '';
}
return $this->render_from_template('core/campaign_content', ['lang' => current_language()]);
$lang = current_language();
$url = "https://campaign.moodle.org/current/lms/{$lang}/install/";
$params = [
'url' => $url,
'iframeid' => 'campaign-content'
];
return $this->render_from_template('core/external_content_banner', $params);
}
/**
* Display services and support content.
*
* @param bool $showservicesandsupport Whether the services and support content should be visible or not.
* @return string the campaign content raw html.
*/
protected function services_and_support_content(bool $showservicesandsupport): string {
if (!$showservicesandsupport) {
return '';
}
$lang = current_language();
$url = "https://campaign.moodle.org/current/lms/{$lang}/servicesandsupport/";
$params = [
'url' => $url,
'iframeid' => 'services-support-content'
];
return $this->render_from_template('core/external_content_banner', $params);
}
/**

View File

@ -1168,6 +1168,15 @@ $CFG->admin = 'admin';
// This setting is only used during the installation process. So once the Moodle site is installed, it is ignored.
//
//=========================================================================
// 19. SERVICES AND SUPPORT CONTENT
//=========================================================================
//
// We have added services and support content to the notifications page, in case you want to hide that from your site
// you just need to set showservicesandsupportcontent setting to false.
//
// $CFG->showservicesandsupportcontent = false;
//
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
//=========================================================================

View File

@ -1335,6 +1335,7 @@ $string['moodledocs'] = 'Moodle Docs';
$string['moodledocslink'] = 'Help and documentation';
$string['moodleversion'] = 'Moodle version';
$string['moodlerelease'] = 'Moodle release';
$string['moodleservicesandsupport'] = 'Services and support';
$string['more'] = 'more';
$string['morehelp'] = 'More help';
$string['morehelpaboutmodule'] = 'More help about the {$a} activity';

View File

@ -401,6 +401,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:t/index_drawer' => 'fa-list',
'core:t/left' => 'fa-arrow-left',
'core:t/less' => 'fa-caret-up',
'core:t/life-ring' => 'fa-life-ring',
'core:t/locked' => 'fa-lock',
'core:t/lock' => 'fa-unlock',
'core:t/locktime' => 'fa-lock',

View File

@ -4146,6 +4146,36 @@ EOD;
return html_writer::tag('a', $icon . $label, ['href' => 'mailto:' . $supportemail]);
}
/**
* Returns the services and support link for the help pop-up.
*
* @return string
*/
public function services_support_link(): string {
global $CFG;
if ((isset($CFG->showservicesandsupportcontent) && $CFG->showservicesandsupportcontent == false) || !is_siteadmin()) {
return '';
}
$liferingicon = $this->pix_icon('t/life-ring', '', 'moodle', ['class' => 'fa fa-life-ring']);
$newwindowicon = $this->pix_icon('i/externallink', get_string('opensinnewwindow'), 'moodle',
['class' => 'fa fa-externallink fa-fw']);
$link = 'https://moodle.com/help/?utm_source=CTA-banner&utm_medium=platform&utm_campaign=name~Moodle4+cat~lms+mp~no';
$content = $liferingicon . get_string('moodleservicesandsupport') . $newwindowicon;
return html_writer::tag('a', $content, ['target' => '_blank', 'href' => $link]);
}
/**
* Helper function to decide whether to show the help popover header or not.
*
* @return bool
*/
public function has_popover_links(): bool {
return !empty($this->services_support_link()) || !empty($this->page_doc_link()) || !empty($this->supportemail());
}
/**
* Returns the page heading menu.
*

View File

@ -15,11 +15,11 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/campaign_content
@template core/external_content_banner
Moodle campaign content template.
Moodle external content banner template.
The purpose of this template is to render an iframe that contains campaign content.
The purpose of this template is to render an iframe that contains external content banner.
Classes required for JS:
* none
@ -31,17 +31,20 @@
* lang User's language.
Example context (json):
{ "lang": "en"}
{
"iframeid": "external-content",
"url": "http://example.com/link",
}
}}
<div class="alert alert-secondary alert-block fade in">
<iframe id="campaign-content" class="w-100 border-0"></iframe>
<iframe id="{{iframeid}}" class="w-100 border-0"></iframe>
</div>
{{#js}}
(function() {
var iframe = document.getElementById('campaign-content');
iframe.src = 'https://campaign.moodle.org/current/lms/{{lang}}/';
var iframe = document.getElementById('{{iframeid}}');
iframe.src = '{{url}}';
window.addEventListener('message', function (event) {
if (event.origin === 'https://campaign.moodle.org') {
if (event.source === iframe.contentWindow) {
iframe.style.height = event.data + 'px';
}
});

View File

@ -24,6 +24,8 @@
"output": {
"page_doc_link": "Help and documentation",
"supportemail": "<a href=\"#\">Contact site support</a>",
"has_popover_links": true,
"services_support": "Services and support",
"login_info": "You are logged in as cute kitten",
"moodle_release": "90210"
}
@ -37,14 +39,21 @@
</button>
</div>
<div class="footer-content-popover container" data-region="footer-content-popover">
<div class="footer-section p-3 border-bottom">
{{# output.page_doc_link }}
<div>{{{ output.page_doc_link }}}</div>
{{/ output.page_doc_link }}
{{# output.supportemail }}
<div>{{{ output.supportemail }}}</div>
{{/ output.supportemail }}
</div>
{{# output.has_popover_links }}
<div class="footer-section p-3 border-bottom">
{{# output.page_doc_link }}
<div>{{{ output.page_doc_link }}}</div>
{{/ output.page_doc_link }}
{{# output.services_support_link }}
<div>{{{ output.services_support_link }}}</div>
{{/ output.services_support_link }}
{{# output.supportemail }}
<div>{{{ output.supportemail }}}</div>
{{/ output.supportemail }}
</div>
{{/ output.has_popover_links }}
<div class="footer-section p-3 border-bottom">
<div class="logininfo">
{{{ output.login_info }}}