当前位置: 首页>>代码示例>>PHP>>正文


PHP theme_config类代码示例

本文整理汇总了PHP中theme_config的典型用法代码示例。如果您正苦于以下问题:PHP theme_config类的具体用法?PHP theme_config怎么用?PHP theme_config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了theme_config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: css_store_css

/**
 * Stores CSS in a file at the given path.
 *
 * This function either succeeds or throws an exception.
 *
 * @param theme_config $theme The theme that the CSS belongs to.
 * @param string $csspath The path to store the CSS at.
 * @param array $cssfiles The CSS files to store.
 */
function css_store_css(theme_config $theme, $csspath, array $cssfiles) {
    global $CFG;

    // Check if both the CSS optimiser is enabled and the theme supports it.
    if (!empty($CFG->enablecssoptimiser) && $theme->supportscssoptimisation) {
        // This is an experimental feature introduced in Moodle 2.3
        // The CSS optimiser organises the CSS in order to reduce the overall number
        // of rules and styles being sent to the client. It does this by collating
        // the CSS before it is cached removing excess styles and rules and stripping
        // out any extraneous content such as comments and empty rules.
        $optimiser = new css_optimiser;
        $css = '';
        foreach ($cssfiles as $file) {
            $css .= file_get_contents($file)."\n";
        }
        $css = $theme->post_process($css);
        $css = $optimiser->process($css);

        // If cssoptimisestats is set then stats from the optimisation are collected
        // and output at the beginning of the CSS
        if (!empty($CFG->cssoptimiserstats)) {
            $css = $optimiser->output_stats_css().$css;
        }
    } else {
        // This is the default behaviour.
        // The cssoptimise setting was introduced in Moodle 2.3 and will hopefully
        // in the future be changed from an experimental setting to the default.
        // The css_minify_css will method will use the Minify library remove
        // comments, additional whitespace and other minor measures to reduce the
        // the overall CSS being sent.
        // However it has the distinct disadvantage of having to minify the CSS
        // before running the post process functions. Potentially things may break
        // here if theme designers try to push things with CSS post processing.
        $css = $theme->post_process(css_minify_css($cssfiles));
    }

    clearstatcache();
    if (!file_exists(dirname($csspath))) {
        @mkdir(dirname($csspath), $CFG->directorypermissions, true);
    }

    // Prevent serving of incomplete file from concurrent request,
    // the rename() should be more atomic than fwrite().
    ignore_user_abort(true);
    if ($fp = fopen($csspath.'.tmp', 'xb')) {
        fwrite($fp, $css);
        fclose($fp);
        rename($csspath.'.tmp', $csspath);
        @chmod($csspath, $CFG->filepermissions);
        @unlink($csspath.'.tmp'); // just in case anything fails
    }
    ignore_user_abort(false);
    if (connection_aborted()) {
        die;
    }
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:65,代码来源:csslib.php

示例2: get_filter_options

 /**
  * Retrieve the list of available filter options.
  *
  * @return  array                   An array whose keys are the valid options
  *                                  And whose values are the values to display
  */
 public static function get_filter_options()
 {
     $manager = \core_plugin_manager::instance();
     $themes = $manager->get_installed_plugins('theme');
     $options = [];
     foreach (array_keys($themes) as $themename) {
         try {
             $theme = \theme_config::load($themename);
         } catch (Exception $e) {
             // Bad theme, just skip it for now.
             continue;
         }
         if ($themename !== $theme->name) {
             // Obsoleted or broken theme, just skip for now.
             continue;
         }
         if ($theme->hidefromselector) {
             // The theme doesn't want to be shown in the theme selector and as theme
             // designer mode is switched off we will respect that decision.
             continue;
         }
         $options[$theme->name] = get_string('pluginname', "theme_{$theme->name}");
     }
     return $options;
 }
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:theme.php

示例3: get_template_directories_for_component

 /**
  * Helper function for getting a list of valid template directories for a specific component.
  *
  * @param string $component The component to search
  * @param string $themename The current theme name
  * @return string[] List of valid directories for templates for this compoonent. Directories are not checked for existence.
  */
 public static function get_template_directories_for_component($component, $themename = '')
 {
     global $CFG, $PAGE;
     // Default the param.
     if ($themename == '') {
         $themename = $PAGE->theme->name;
     }
     // Clean params for safety.
     $component = clean_param($component, PARAM_COMPONENT);
     $themename = clean_param($themename, PARAM_COMPONENT);
     // Validate the component.
     $dirs = array();
     $compdirectory = core_component::get_component_directory($component);
     if (!$compdirectory) {
         throw new coding_exception("Component was not valid: " . s($component));
     }
     // Find the parent themes.
     $parents = array();
     if ($themename === $PAGE->theme->name) {
         $parents = $PAGE->theme->parents;
     } else {
         $themeconfig = theme_config::load($themename);
         $parents = $themeconfig->parents;
     }
     // First check the theme.
     $dirs[] = $CFG->dirroot . '/theme/' . $themename . '/templates/' . $component . '/';
     // Now check the parent themes.
     // Search each of the parent themes second.
     foreach ($parents as $parent) {
         $dirs[] = $CFG->dirroot . '/theme/' . $parent . '/templates/' . $component . '/';
     }
     $dirs[] = $compdirectory . '/templates/';
     return $dirs;
 }
开发者ID:zaintq,项目名称:Extensions-for-Open-Courseware,代码行数:41,代码来源:mustache_template_finder.php

示例4: theme_essentials_process_css

/**
 * Essentials is a basic child theme of Essential to help you as a theme
 * developer create your own child theme of Essential.
 *
 * @package     theme_essentials
 * @copyright   2015 Gareth J Barnard
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function theme_essentials_process_css($css, $theme)
{
    /* Change to 'true' if you want to use Essential's settings after removing the '$THEME->parents_exclude_sheets' in config.php.
       Then to get the alternive colours back, renove the overridden method 'custom_menu_themecolours' in the 'theme_essentials_core_renderer'
       class in the 'core_renderer.php' file in the 'classes' folder. */
    $usingessentialsettings = false;
    if ($usingessentialsettings) {
        if (file_exists("{$CFG->dirroot}/theme/essential/lib.php")) {
            require_once "{$CFG->dirroot}/theme/essential/lib.php";
        } else {
            if (!empty($CFG->themedir) and file_exists("{$CFG->themedir}/essential/lib.php")) {
                require_once "{$CFG->themedir}/essential/lib.php";
            }
        }
        // else will just fail when cannot find theme_essential_process_css!
        static $parenttheme;
        if (empty($parenttheme)) {
            $parenttheme = theme_config::load('essential');
        }
        $css = theme_essential_process_css($css, $parenttheme);
    }
    // If you have your own settings, then add them here.
    // Finally return processed CSS
    return $css;
}
开发者ID:RobsonTK,项目名称:Moodle,代码行数:33,代码来源:lib.php

示例5: theme_clean_pluginfile

function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
    if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
        $theme = theme_config::load('clean');
        return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
    } else {
        send_file_not_found();
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:8,代码来源:lib.php

示例6: list_templates

 /**
  * Return a list of details about installed templates.
  *
  * @param string $component Filter the list to a single component.
  * @param string $search Search string to optionally filter the list of templates.
  * @param string $themename The name of the current theme.
  * @return array[string] Where each template is in the form "component/templatename".
  */
 public static function list_templates($component = '', $search = '', $themename = '')
 {
     global $CFG, $PAGE;
     if (empty($themename)) {
         $themename = $PAGE->theme->name;
     }
     $themeconfig = \theme_config::load($themename);
     $templatedirs = array();
     $results = array();
     if ($component !== '') {
         // Just look at one component for templates.
         $dirs = mustache_template_finder::get_template_directories_for_component($component, $themename);
         $templatedirs[$component] = $dirs;
     } else {
         // Look at all the templates dirs for core.
         $templatedirs['core'] = mustache_template_finder::get_template_directories_for_component('core', $themename);
         // Look at all the templates dirs for subsystems.
         $subsystems = core_component::get_core_subsystems();
         foreach ($subsystems as $subsystem => $dir) {
             $dir .= '/templates';
             if (is_dir($dir)) {
                 $dirs = mustache_template_finder::get_template_directories_for_component('core_' . $subsystem, $themename);
                 $templatedirs['core_' . $subsystem] = $dirs;
             }
         }
         // Look at all the templates dirs for plugins.
         $plugintypes = core_component::get_plugin_types();
         foreach ($plugintypes as $type => $dir) {
             $plugins = core_component::get_plugin_list_with_file($type, 'templates', false);
             foreach ($plugins as $plugin => $dir) {
                 if ($type == 'theme' && $plugin != $themename && !in_array($plugin, $themeconfig->parents)) {
                     continue;
                 }
                 if (!empty($dir) && is_dir($dir)) {
                     $pluginname = $type . '_' . $plugin;
                     $dirs = mustache_template_finder::get_template_directories_for_component($pluginname, $themename);
                     $templatedirs[$pluginname] = $dirs;
                 }
             }
         }
     }
     foreach ($templatedirs as $templatecomponent => $dirs) {
         foreach ($dirs as $dir) {
             // List it.
             $files = glob($dir . '/*.mustache');
             foreach ($files as $file) {
                 $templatename = basename($file, '.mustache');
                 if ($search == '' || strpos($templatename, $search) !== false) {
                     $results[$templatecomponent . '/' . $templatename] = 1;
                 }
             }
         }
     }
     $results = array_keys($results);
     sort($results);
     return $results;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:65,代码来源:api.php

示例7: theme_essential_pluginfile

/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course.
 * @param stdClass $cm.
 * @param context $context.
 * @param string $filearea.
 * @param array $args.
 * @param bool $forcedownload.
 * @param array $options.
 * @return bool.
 */
function theme_essential_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    static $theme;
    if (empty($theme)) {
        $theme = theme_config::load('essential');
    }
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        if ($filearea === 'logo') {
            return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else {
            if ($filearea === 'style') {
                theme_essential_serve_css($args[1]);
            } else {
                if ($filearea === 'headerbackground') {
                    return $theme->setting_file_serve('headerbackground', $args, $forcedownload, $options);
                } else {
                    if ($filearea === 'pagebackground') {
                        return $theme->setting_file_serve('pagebackground', $args, $forcedownload, $options);
                    } else {
                        if ($filearea === 'favicon') {
                            return $theme->setting_file_serve('favicon', $args, $forcedownload, $options);
                        } else {
                            if (preg_match("/^fontfile(eot|otf|svg|ttf|woff|woff2)(heading|body)\$/", $filearea)) {
                                // http://www.regexr.com/.
                                return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
                            } else {
                                if (preg_match("/^(marketing|slide)[1-9][0-9]*image\$/", $filearea)) {
                                    return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
                                } else {
                                    if ($filearea === 'iphoneicon') {
                                        return $theme->setting_file_serve('iphoneicon', $args, $forcedownload, $options);
                                    } else {
                                        if ($filearea === 'iphoneretinaicon') {
                                            return $theme->setting_file_serve('iphoneretinaicon', $args, $forcedownload, $options);
                                        } else {
                                            if ($filearea === 'ipadicon') {
                                                return $theme->setting_file_serve('ipadicon', $args, $forcedownload, $options);
                                            } else {
                                                if ($filearea === 'ipadretinaicon') {
                                                    return $theme->setting_file_serve('ipadretinaicon', $args, $forcedownload, $options);
                                                } else {
                                                    send_file_not_found();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        send_file_not_found();
    }
}
开发者ID:nadavkav,项目名称:moodle-accessibility,代码行数:69,代码来源:lib.php

示例8: __construct

 public function __construct(moodle_page $page, $target)
 {
     parent::__construct($page, $target);
     static $theme;
     if (empty($theme)) {
         $theme = theme_config::load('essential');
     }
     $this->enablecategoryicon = !empty($theme->settings->enablecategoryicon) ? $theme->settings->enablecategoryicon : false;
 }
开发者ID:ging,项目名称:moodle-theme_essential,代码行数:9,代码来源:core_course_renderer.php

示例9: get_child_theme_config

 private static function get_child_theme_config()
 {
     if (!self::$checkedchildtheme) {
         global $PAGE;
         if (in_array('essential', $PAGE->theme->parents)) {
             $themename = $PAGE->theme->name;
             self::$childtheme = \theme_config::load($themename);
             self::$checkedchildtheme = true;
         }
     }
     return self::$childtheme;
 }
开发者ID:nadavkav,项目名称:moodle-accessibility,代码行数:12,代码来源:toolbox.php

示例10: theme_clean_pluginfile

/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course
 * @param stdClass $cm
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @param array $options
 * @return bool
 */
function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo' || $filearea === 'smalllogo') {
        $theme = theme_config::load('clean');
        // 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();
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:25,代码来源:lib.php

示例11: css_store_css

/**
 * Stores CSS in a file at the given path.
 *
 * This function either succeeds or throws an exception.
 *
 * @param theme_config $theme The theme that the CSS belongs to.
 * @param string $csspath The path to store the CSS at.
 * @param array $cssfiles The CSS files to store.
 */
function css_store_css(theme_config $theme, $csspath, array $cssfiles)
{
    global $CFG;
    if (!empty($CFG->enablecssoptimiser)) {
        // This is an experimental feature introduced in Moodle 2.3
        // The CSS optimiser organises the CSS in order to reduce the overall number
        // of rules and styles being sent to the client. It does this by collating
        // the CSS before it is cached removing excess styles and rules and stripping
        // out any extraneous content such as comments and empty rules.
        $optimiser = new css_optimiser();
        $css = '';
        foreach ($cssfiles as $file) {
            $css .= file_get_contents($file) . "\n";
        }
        $css = $theme->post_process($css);
        $css = $optimiser->process($css);
        // If cssoptimisestats is set then stats from the optimisation are collected
        // and output at the beginning of the CSS
        if (!empty($CFG->cssoptimiserstats)) {
            $css = $optimiser->output_stats_css() . $css;
        }
    } else {
        // This is the default behaviour.
        // The cssoptimise setting was introduced in Moodle 2.3 and will hopefully
        // in the future be changed from an experimental setting to the default.
        // The css_minify_css will method will use the Minify library remove
        // comments, additional whitespace and other minor measures to reduce the
        // the overall CSS being sent.
        // However it has the distinct disadvantage of having to minify the CSS
        // before running the post process functions. Potentially things may break
        // here if theme designers try to push things with CSS post processing.
        $css = $theme->post_process(css_minify_css($cssfiles));
    }
    check_dir_exists(dirname($csspath));
    $fp = fopen($csspath, 'w');
    fwrite($fp, $css);
    fclose($fp);
}
开发者ID:numbas,项目名称:moodle,代码行数:47,代码来源:csslib.php

示例12: theme_essentials_process_css

/**
 * Essentials is a basic child theme of Essential to help you as a theme
 * developer create your own child theme of Essential.
 *
 * @package     theme_essentials
 * @copyright   2015 Gareth J Barnard
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function theme_essentials_process_css($css, $theme)
{
    // Change to 'true' if you want to use Essential's settings after removing the '$THEME->parents_exclude_sheets' in config.php.
    $usingessentialsettings = false;
    if ($usingessentialsettings) {
        require_once dirname(__FILE__) . '/../essential/lib.php';
        static $parenttheme;
        if (empty($parenttheme)) {
            $parenttheme = theme_config::load('essential');
        }
        $css = theme_essential_process_css($css, $parenttheme);
    }
    // If you have your own settings, then add them here.
    // Finally return processed CSS
    return $css;
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:24,代码来源:lib.php

示例13: theme_essentials_pluginfile

/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course.
 * @param stdClass $cm.
 * @param context $context.
 * @param string $filearea.
 * @param array $args.
 * @param bool $forcedownload.
 * @param array $options.
 * @return bool.
 */
function theme_essentials_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    static $theme;
    if (empty($theme)) {
        $theme = theme_config::load('essentials');
    }
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        if ($filearea === 'logo') {
            return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else {
            send_file_not_found();
        }
    } else {
        send_file_not_found();
    }
}
开发者ID:nadavkav,项目名称:moodle-accessibility,代码行数:28,代码来源:lib.php

示例14: get_setting

    /**
     * Returns settings as formatted text
     *
     * @param string $setting
     * @param string $format = false
     * @param string $theme = null
     * @return string
     */
    public function get_setting($setting, $format = false, $theme = null) {
        if (empty($theme)) {
            $theme = theme_config::load('adaptable');
        }

        if (empty($theme->settings->$setting)) {
            return false;
        } else if (!$format) {
            return $theme->settings->$setting;
        } else if ($format === 'format_text') {
            return format_text($theme->settings->$setting, FORMAT_PLAIN);
        } else if ($format === 'format_html') {
            return format_text($theme->settings->$setting, FORMAT_HTML, array('trusted' => true));
        } else {
            return format_string($theme->settings->$setting);
        }
    }
开发者ID:educacionbe,项目名称:campus,代码行数:25,代码来源:renderers.php

示例15: theme_lambda_pluginfile

function theme_lambda_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        $theme = theme_config::load('lambda');
        if ($filearea === 'logo') {
            return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else {
            if ($filearea === 'pagebackground') {
                return $theme->setting_file_serve('pagebackground', $args, $forcedownload, $options);
            } else {
                if ($filearea === 'slide1image') {
                    return $theme->setting_file_serve('slide1image', $args, $forcedownload, $options);
                } else {
                    if ($filearea === 'slide2image') {
                        return $theme->setting_file_serve('slide2image', $args, $forcedownload, $options);
                    } else {
                        if ($filearea === 'slide3image') {
                            return $theme->setting_file_serve('slide3image', $args, $forcedownload, $options);
                        } else {
                            if ($filearea === 'slide4image') {
                                return $theme->setting_file_serve('slide4image', $args, $forcedownload, $options);
                            } else {
                                if ($filearea === 'slide5image') {
                                    return $theme->setting_file_serve('slide5image', $args, $forcedownload, $options);
                                } else {
                                    if (substr($filearea, 0, 15) === 'carousel_image_') {
                                        return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
                                    } else {
                                        send_file_not_found();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        send_file_not_found();
    }
}
开发者ID:sirromas,项目名称:medical,代码行数:41,代码来源:lib.php


注:本文中的theme_config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。