本文整理汇总了PHP中theme_config::load方法的典型用法代码示例。如果您正苦于以下问题:PHP theme_config::load方法的具体用法?PHP theme_config::load怎么用?PHP theme_config::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theme_config
的用法示例。
在下文中一共展示了theme_config::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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();
}
}
示例5: 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;
}
示例6: 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();
}
}
示例7: __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;
}
示例8: 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;
}
示例9: 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();
}
}
示例10: 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;
}
示例11: 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();
}
}
示例12: 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);
}
}
示例13: 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();
}
}
示例14: test_svg_image_use
/**
* This function will test directives used to serve SVG images to make sure
* this are making the right decisions.
*/
public function test_svg_image_use()
{
global $CFG;
$this->resetAfterTest();
// The two required tests.
$this->assertTrue(file_exists($CFG->dirroot . '/pix/i/test.svg'));
$this->assertTrue(file_exists($CFG->dirroot . '/pix/i/test.png'));
$theme = theme_config::load(theme_config::DEFAULT_THEME);
// First up test the forced setting.
$imagefile = $theme->resolve_image_location('i/test', 'moodle', true);
$this->assertSame('test.svg', basename($imagefile));
$imagefile = $theme->resolve_image_location('i/test', 'moodle', false);
$this->assertSame('test.png', basename($imagefile));
// Now test the use of the svgicons config setting.
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$CFG->svgicons = true;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
$this->assertSame('test.svg', basename($imagefile));
$CFG->svgicons = false;
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
$this->assertSame('test.png', basename($imagefile));
unset($CFG->svgicons);
// Finally test a few user agents.
$useragents = array('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)' => false, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' => false, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)' => false, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)' => false, 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)' => false, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)' => true, 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)' => true, 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Chrome/11.0.652.0 Safari/534.17' => true, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1' => true, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1' => true, 'Mozilla/5.0 (Windows NT 6.1; rv:1.9) Gecko/20100101 Firefox/4.0' => true, 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0.1' => true, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1' => true, 'Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.10.289 Version/12.02' => false, 'Mozilla/5.0 (Linux; U; Android 0.5; en-us) AppleWebKit/522+ (KHTML, like Gecko) Safari/419.3' => false, 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => false, 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13' => true, 'Mozilla/5.0 (Linux; Android 4.3; it-it; SAMSUNG GT-I9505/I9505XXUEMJ7 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36' => true);
foreach ($useragents as $agent => $expected) {
core_useragent::instance(true, $agent);
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
if ($expected) {
$this->assertSame('test.svg', basename($imagefile), 'Incorrect image returned for user agent `' . $agent . '`');
} else {
$this->assertSame('test.png', basename($imagefile), 'Incorrect image returned for user agent `' . $agent . '`');
}
}
}
示例15: theme_bcu_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_bcu_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
static $theme;
if (empty($theme)) {
$theme = theme_config::load('bcu');
}
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 === 'pagebackground') {
return $theme->setting_file_serve('pagebackground', $args, $forcedownload, $options);
} else {
if (preg_match("/p[1-9][0-9]/", $filearea) !== false) {
return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
} else {
if (substr($filearea, 0, 9) === 'marketing' && substr($filearea, 10, 5) === 'image') {
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 {
if ($filearea === 'fontfilettfheading') {
return $theme->setting_file_serve('fontfilettfheading', $args, $forcedownload, $options);
} else {
if ($filearea === 'fontfilettfbody') {
return $theme->setting_file_serve('fontfilettfbody', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
}
}
}
}
}
}
}
}
}
}
} else {
send_file_not_found();
}
}