Browse Source

Parametrização para exibir curso em destaque na página inicial

MOODLE_37_STABLE
Matheus Garcia 5 years ago
parent
commit
d99a125372
  1. 14
      layout/frontpage_ilb.php
  2. BIN
      pix/engitec.jpg
  3. 86
      settings.php
  4. 12
      templates/frontpage_ilb.mustache
  5. 2
      version.php

14
layout/frontpage_ilb.php

@ -28,6 +28,12 @@ require_once($CFG->libdir . '/../config.php');
$bodyattributes = $OUTPUT->body_attributes([]); $bodyattributes = $OUTPUT->body_attributes([]);
$habilitar_destaque = $this->page->theme->settings->habilitar_destaque;
$curso_destaque = $this->page->theme->settings->curso_destaque;
$imagem_destaque = $this->page->theme->settings->imagem_destaque;
if (isloggedin()) { if (isloggedin()) {
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA); user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php'); require_once($CFG->libdir . '/behat/lib.php');
@ -78,6 +84,9 @@ if (isloggedin()) {
'moodle_url' => $CFG->wwwroot, 'moodle_url' => $CFG->wwwroot,
'userpictureurl' => $user_picture_url, 'userpictureurl' => $user_picture_url,
'userprofileurl' => $user_profile_url, 'userprofileurl' => $user_profile_url,
'habilitar_destaque' => $habilitar_destaque,
'imagem_destaque' => $imagem_destaque,
'curso_destaque' => $curso_destaque
]; ];
@ -100,7 +109,10 @@ if (isloggedin()) {
'output' => $OUTPUT, 'output' => $OUTPUT,
'bodyattributes' => $bodyattributes, 'bodyattributes' => $bodyattributes,
'moodle_url' => $CFG->wwwroot, 'moodle_url' => $CFG->wwwroot,
'logintoken' => s(\core\session\manager::get_login_token()) 'logintoken' => s(\core\session\manager::get_login_token()),
'habilitar_destaque' => $habilitar_destaque,
'imagem_destaque' => $imagem_destaque,
'curso_destaque' => $curso_destaque
]; ];
} }

BIN
pix/engitec.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

86
settings.php

@ -23,74 +23,22 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) { if ($ADMIN->fulltree) {
$settings = new theme_ilb_admin_settingspage_tabs('themesettingilb', get_string('configtitle', 'theme_ilb'));
$page = new admin_settingpage('theme_ilb_general', get_string('generalsettings', 'theme_ilb'));
// Preset. // Habilitar destaque
$name = 'theme_ilb/preset'; $setting = new admin_setting_configcheckbox('theme_ilb/habilitar_destaque',
$title = get_string('preset', 'theme_ilb'); 'Habilitar destaque',
$description = get_string('preset_desc', 'theme_ilb'); 'Indica se deve ser exibido destaque na página inicial', 0);
$default = 'default.scss'; $settings->add($setting);
$context = context_system::instance(); // Imagem destaque
$fs = get_file_storage(); $setting = new admin_setting_configtext('theme_ilb/imagem_destaque',
$files = $fs->get_area_files($context->id, 'theme_ilb', 'preset', 0, 'itemid, filepath, filename', false); 'Imagem de destaque',
'Imagem a ser exibida como destaque', '', PARAM_TEXT, 50);
$choices = []; $settings->add($setting);
foreach ($files as $file) {
$choices[$file->get_filename()] = $file->get_filename(); // Curso de destaque
} $setting = new admin_setting_configtext('theme_ilb/curso_destaque',
// These are the built in presets. 'Curso de destaque',
$choices['default.scss'] = 'default.scss'; 'ID do curso acessado ao clicar na imagem de destaque', '', PARAM_TEXT, 4);
$choices['plain.scss'] = 'plain.scss'; $settings->add($setting);
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Preset files setting.
$name = 'theme_ilb/presetfiles';
$title = get_string('presetfiles','theme_ilb');
$description = get_string('presetfiles_desc', 'theme_ilb');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
array('maxfiles' => 20, 'accepted_types' => array('.scss')));
$page->add($setting);
// Background image setting.
$name = 'theme_ilb/backgroundimage';
$title = get_string('backgroundimage', 'theme_ilb');
$description = get_string('backgroundimage_desc', 'theme_ilb');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $body-color.
// We use an empty default value because the default colour should come from the preset.
$name = 'theme_ilb/brandcolor';
$title = get_string('brandcolor', 'theme_ilb');
$description = get_string('brandcolor_desc', 'theme_ilb');
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Must add the page after definiting all the settings!
$settings->add($page);
// Advanced settings.
$page = new admin_settingpage('theme_ilb_advanced', get_string('advancedsettings', 'theme_ilb'));
// Raw SCSS to include before the content.
$setting = new admin_setting_scsscode('theme_ilb/scsspre',
get_string('rawscsspre', 'theme_ilb'), get_string('rawscsspre_desc', 'theme_ilb'), '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Raw SCSS to include after the content.
$setting = new admin_setting_scsscode('theme_ilb/scss', get_string('rawscss', 'theme_ilb'),
get_string('rawscss_desc', 'theme_ilb'), '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
$settings->add($page);
} }

12
templates/frontpage_ilb.mustache

@ -705,7 +705,16 @@
</div> </div>
<!-- logotipo e texto --> <!-- logotipo e texto -->
{{#habilitar_destaque}}
<div class="col-xs-12 col-md-4 text-center lessPaddingResponsible"> <div class="col-xs-12 col-md-4 text-center lessPaddingResponsible">
<a href='{{{moodle_url}}}/course/view.php?id={{{curso_destaque}}}'>
<img src='{{{imagem_destaque}}}' style="padding: 0 !important" class="col-xs-12 text-center lessPaddingResponsible"/>
</a>
</div>
{{/habilitar_destaque}}
{{^habilitar_destaque}}
<div class="col-xs-12 col-md-4 text-center lessPaddingResponsible">
<div style="background-color: #F7F7F7; border: 1px solid #E6E6E6; border-bottom: 0; padding: 11% 0 12% 0;"> <div style="background-color: #F7F7F7; border: 1px solid #E6E6E6; border-bottom: 0; padding: 11% 0 12% 0;">
<img src='{{{logo_saberes_xl}}}' width='48%' height='48%' /> <img src='{{{logo_saberes_xl}}}' width='48%' height='48%' />
</div> </div>
@ -717,6 +726,9 @@
</div> </div>
</div> </div>
</div> </div>
{{/habilitar_destaque}}
<div class="col-xs-12 hidden-md hidden-lg"> <div class="col-xs-12 hidden-md hidden-lg">
<br /> <br />
</div> </div>

2
version.php

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2019050200; $plugin->version = 2019081401;
$plugin->requires = 2018112800; $plugin->requires = 2018112800;
$plugin->component = 'theme_ilb'; $plugin->component = 'theme_ilb';

Loading…
Cancel
Save