Почему раскрывающееся меню моего администратора не отображается, когда я пытаюсь создать свои собственные настройки для настраиваемой темы Moodle css? - PullRequest
0 голосов
/ 15 февраля 2019

Я создаю новую тему Moodle, которую нужно настроить в CSS.Под «настраиваемым» я подразумеваю, что со страницы администратора вы можете, например, редактировать цвет вашего фона.

Я следовал учебному пособию из https://docs.moodle.org/dev/Themes,, что здорово, но должно быть, из моегомнение, о той же родительской теме для каждой ее части.

Моя страница хорошо отображается за исключением моего выпадающего меню администратора (поэтому я не вижу свою страницу редактирования темы).Все было хорошо, прежде чем я попытался настроить свои собственные настройки, как в учебнике.

Я предполагаю, что, возможно, допустил ошибку, адаптировав свою тему из учебника, но сейчас я полностью потерян.

Мы находимся здесь в каталоге 'theme / mytheme'.

Файл 'settings.php':

<?php

defined('MOODLE_INTERNAL') || die();

$name = 'theme_mytheme/backcolor';
$title = get_string('backcolor', 'theme_mytheme');
$desc = get_string('backcolor_desc', 'theme_mytheme');
$setting = new admin_setting_configcolourpicker($name, $title, $desc, '#ffffff');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

?>

Файл 'lib.php':

<?php

 defined('MOODLE_INTERNAL') || die;

 function theme_mytheme_process_css($css, $theme) {

    // Set custom CSS.
    if (!empty($theme->settings->customcss)) {
        $customcss = $theme->settings->customcss;
    } else {
        $customcss = null;
    }
    $css = theme_mytheme_set_customcss($css, $customcss);
    $defaults = array(
        '[[setting:backcolor]]' => '#FFFFFF',
    );

    foreach ($theme->settings as $key => $val) {
        if (array_key_exists('[[setting:'.$key.']]', $defaults) && !empty($val)) {
            $defaults['[[setting:'.$key.']]'] = $val;
        }
    }

    $homebkg = '';
    if (!empty($theme->settings->homebk)) {
        $homebkg = $theme->setting_file_url('homebk', 'homebk');
        $homebkg = 'background-image: url("' . $homebkg . '");';
    }
    $defaults['[[setting:homebkg]]'] = $homebkg;

    // Replace the CSS with values from the $defaults array.
    $css = strtr($css, $defaults);
    if (empty($theme->settings->tilesshowallcontacts) || $theme->settings->tilesshowallcontacts == false) {
        $css = theme_mytheme_set_tilesshowallcontacts($css, false);
    } else {
        $css = theme_mytheme_set_tilesshowallcontacts($css, true);
    }
    return $css;
}


function theme_mytheme_set_customcss($css, $customcss) {
    $tag = '[[setting:customcss]]';
    $replacement = $customcss;
    if (is_null($replacement)) {
        $replacement = '';
    }

    $css = str_replace($tag, $replacement, $css);

    return $css;
}

function theme_mytheme_set_tilesshowallcontacts($css, $display) {
    $tag = '[[setting:tilesshowallcontacts]]';
    if ($display) {
        $replacement = 'block';
    } else {
        $replacement = 'none';
    }
    $css = str_replace($tag, $replacement, $css);
    return $css;
}

function theme_mytheme_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
    if ($context->contextlevel == CONTEXT_SYSTEM &&
    ($filearea === 'logo' || $filearea === 'smalllogo' || $filearea === 'backgroundimage')) {
        $theme = theme_config::load('mytheme');
        // By default, theme files must be cache-able by both browsers and proxies.
        if (!array_key_exists('cacheability', $options)) {
            $options['cacheability'] = 'public';
        }
        return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
    } else {
        send_file_not_found();
    }
}
?>

Файл 'config.php':

<?php

defined('MOODLE_INTERNAL') || die();

$THEME->name = 'mytheme';
$THEME->sheets = array('styles');
$THEME->editor_sheets = array();
$THEME->parents = array('base');
$THEME->yuicssmodules = array();

$THEME->scss = function($theme) {
    return theme_mytheme_get_pre_scss($theme);
};

$THEME->layouts = array(
    // Most backwards compatible layout without the blocks - this is the layout used by default
    'base' => array(
        'theme' => 'mytheme',
        'file' => 'standard.php',
        'regions' => array(),
    ),
    'standard' => array(
        'theme' => 'mytheme',
        'file' => 'standard.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
    ),
    'frontpage' => array(
        'theme' => 'mytheme',
        'file' => 'standard.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-post'
    )
);

$THEME->csspostprocess = 'theme_mytheme_process_css';

?>

Мне жаль, что я передаю свои полные файлы, но это не может быть уместно, если я не ...

...