本文整理汇总了PHP中ThemeUtil::getInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeUtil::getInfo方法的具体用法?PHP ThemeUtil::getInfo怎么用?PHP ThemeUtil::getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThemeUtil
的用法示例。
在下文中一共展示了ThemeUtil::getInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_previewimage
/**
* Zikula_View function to display a preview image from a theme
*
* Available parameters:
* - name name of the theme to display the preview image for
* - name if set, the id assigned to the image
* - size if set, the size of the image to use from small, medium, large (optional: default 'medium')
* - assign if set, the title will be assigned to this variable
*
* Example
* {previewimage name=andreas08 size=large}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.title.php::smarty_function_previewimage()
*
* @return string The markup to display the theme image.
*/
function smarty_function_previewimage($params, Zikula_View $view)
{
if (!isset($params['name'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('previewimage', 'name')));
return false;
}
if (!isset($params['size']) || !in_array($params['size'], array('large', 'medium', 'small'))) {
$params['size'] = 'medium';
}
$idstring = '';
if (isset($params['id'])) {
$idstring = " id=\"{$params['id']}\"";
}
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($params['name']));
$theme = ThemeUtil::getTheme($themeinfo['name']);
$themePath = null === $theme ? "themes/{$themeinfo['directory']}/images" : $theme->getRelativePath() . '/Resources/public/images';
if (file_exists("{$themePath}/preview_{$params['size']}.png")) {
$filesrc = "{$themePath}/preview_{$params['size']}.png";
} else {
$filesrc = "system/ThemeModule/Resources/public/images/preview_{$params['size']}.png";
}
$markup = "<img{$idstring} src=\"{$filesrc}\" alt=\"\" />";
if (isset($params['assign'])) {
$view->assign($params['assign'], $markup);
} else {
return $markup;
}
}
示例2: main
/**
* display theme changing user interface
*/
public function main()
{
// check if theme switching is allowed
if (!System::getVar('theme_change')) {
LogUtil::registerError($this->__('Notice: Theme switching is currently disabled.'));
$this->redirect(ModUtil::url('Users', 'user', 'main'));
}
if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_COMMENT)) {
return LogUtil::registerPermissionError();
}
// get our input
$startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : 1, 'GET');
// we need this value multiple times, so we keep it
$itemsperpage = $this->getVar('itemsperpage');
// get some use information about our environment
$currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
// get all themes in our environment
$allthemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);
$previewthemes = array();
$currentthemepic = null;
foreach ($allthemes as $key => $themeinfo) {
$themename = $themeinfo['name'];
if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_medium.png')) {
$themeinfo['previewImage'] = $themepic;
$themeinfo['largeImage'] = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_large.png';
} else {
$themeinfo['previewImage'] = 'system/Theme/images/preview_medium.png';
$themeinfo['largeImage'] = 'system/Theme/images/preview_large.png';
}
if ($themename == $currenttheme['name']) {
$currentthemepic = $themepic;
unset($allthemes[$key]);
} else {
$previewthemes[$themename] = $themeinfo;
}
}
$previewthemes = array_slice($previewthemes, $startnum-1, $itemsperpage);
$this->view->setCaching(Zikula_View::CACHE_DISABLED);
$this->view->assign('currentthemepic', $currentthemepic)
->assign('currenttheme', $currenttheme)
->assign('themes', $previewthemes)
->assign('defaulttheme', ThemeUtil::getInfo(ThemeUtil::getIDFromName(System::getVar('Default_Theme'))));
// assign the values for the pager plugin
$this->view->assign('pager', array('numitems' => sizeof($allthemes),
'itemsperpage' => $itemsperpage));
// Return the output that has been generated by this function
return $this->view->fetch('theme_user_main.tpl');
}
示例3: _getpurifierdefaultconfig
/**
* Retrieves default configuration array for HTML Purifier.
*
* @return array HTML Purifier default configuration settings.
*/
private static function _getpurifierdefaultconfig()
{
$purifierDefaultConfig = HTMLPurifier_Config::createDefault();
$purifierDefaultConfigValues = $purifierDefaultConfig->def->defaults;
$config = array();
foreach ($purifierDefaultConfigValues as $key => $val) {
$keys = explode(".", $key, 2);
$config[$keys[0]][$keys[1]] = $val;
}
$charset = ZLanguage::getEncoding();
if (strtolower($charset) != 'utf-8') {
// set a different character encoding with iconv
$config['Core']['Encoding'] = $charset;
// Note that HTML Purifier's support for non-Unicode encodings is crippled by the
// fact that any character not supported by that encoding will be silently
// dropped, EVEN if it is ampersand escaped. If you want to work around
// this, you are welcome to read docs/enduser-utf8.html in the full package for a fix,
// but please be cognizant of the issues the "solution" creates (for this
// reason, I do not include the solution in this document).
}
// determine doctype of current theme
// supported doctypes include:
//
// HTML 4.01 Strict
// HTML 4.01 Transitional
// XHTML 1.0 Strict
// XHTML 1.0 Transitional (default)
// XHTML 1.1
//
// TODO - we need a new theme field for doctype declaration
// for now we will use non-strict modes
$currentThemeID = ThemeUtil::getIDFromName(UserUtil::getTheme());
$themeInfo = ThemeUtil::getInfo($currentThemeID);
$useXHTML = (isset($themeInfo['xhtml']) && $themeInfo['xhtml']) ? true : false;
// as XHTML 1.0 Transitional is the default, we only set HTML (for now)
if (!$useXHTML) {
$config['HTML']['Doctype'] = 'HTML 4.01 Transitional';
}
// allow nofollow and imageviewer to be used as document relationships in the rel attribute
// see http://htmlpurifier.org/live/configdoc/plain.html#Attr.AllowedRel
$config['Attr']['AllowedRel'] = array('nofollow' => true, 'imageviewer' => true, 'lightbox' => true);
// allow Youtube by default
$config['Filter']['YouTube'] = false; // technically deprecated in favour of HTML.SafeEmbed and HTML.Object
// general enable for embeds and objects
$config['HTML']['SafeObject'] = true;
$config['Output']['FlashCompat'] = true;
$config['HTML']['SafeEmbed'] = true;
return $config;
}
示例4: smarty_function_themeinfo
/**
* Smarty function to display the theme info
*
* Example
* {themeinfo}
*
* @see function.themeinfo.php::smarty_function_themeinfo()
* @param array $params All attributes passed to this function from the template
* @param object $smarty Reference to the Smarty object
* @return string the themeinfo
*/
function smarty_function_themeinfo($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('themeinfo', '$themeinfo')), E_USER_DEPRECATED);
$thistheme = UserUtil::getTheme();
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($thistheme));
$themecredits = '<!-- ' . __f('Theme: %1$s by %2$s - %3$s', array(DataUtil::formatForDisplay($themeinfo['display']), DataUtil::formatForDisplay($themeinfo['author']), DataUtil::formatForDisplay($themeinfo['contact']))) . ' -->';
return $themecredits;
}
示例5: __construct
/**
* Constructor.
*
* @param Zikula_ServiceManager $serviceManager ServiceManager.
* @param string $themeName Theme name.
*/
public function __construct(Zikula_ServiceManager $serviceManager, $themeName)
{
// store our theme information
$this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themeName));
// prevents any case mismatch
$themeName = $this->themeinfo['name'];
foreach (array('name', 'directory', 'version', 'state', 'xhtml') as $key) {
$this->{$key} = $this->themeinfo[$key];
}
parent::__construct($serviceManager);
if ($this->themeinfo['i18n']) {
ZLanguage::bindThemeDomain($this->name);
// property for {gt} template plugin to detect language domain
$this->domain = ZLanguage::getThemeDomain($this->name);
} else {
$this->domain = null;
}
EventUtil::attachCustomHandlers("themes/{$themeName}/EventHandlers");
EventUtil::attachCustomHandlers("themes/{$themeName}/lib/{$themeName}/EventHandlers");
$event = new \Zikula\Core\Event\GenericEvent($this);
$this->eventManager->dispatch('theme.preinit', $event);
// change some base settings from our parent class
// template compilation
$this->compile_dir = CacheUtil::getLocalDir('Theme_compiled');
$this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'compile_check');
$this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'force_compile');
// template caching
$this->cache_dir = CacheUtil::getLocalDir('Theme_cache');
$this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'enablecache');
//if ($this->caching) {
// $this->cache_modified_check = true;
//}
// if caching and is not an admin controller
if ($this->caching && strpos($this->type, 'admin') !== 0) {
$modulesnocache = array_filter(explode(',', ModUtil::getVar('ZikulaThemeModule', 'modulesnocache')));
if (in_array($this->toplevelmodule, $modulesnocache)) {
$this->caching = Zikula_View::CACHE_DISABLED;
}
} else {
$this->caching = Zikula_View::CACHE_DISABLED;
}
// halt caching for write operations to prevent strange things happening
if (isset($_POST) && count($_POST) != 0) {
$this->caching = Zikula_View::CACHE_DISABLED;
}
// and also for GET operations with csrftoken/authkey
if (isset($_GET['csrftoken']) || isset($_GET['authkey'])) {
$this->caching = Zikula_View::CACHE_DISABLED;
}
$this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'cache_lifetime');
if (!$this->homepage) {
$this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'cache_lifetime_mods');
}
// assign all our base template variables
$this->_base_vars();
// define the plugin directories
$this->_plugin_dirs();
// load the theme configuration
$this->load_config();
// check for cached output
// turn on caching, check for cached output and then disable caching
// to prevent blocks from being cached
if ($this->caching && $this->is_cached($this->themeconfig['page'], $this->cache_id)) {
$this->display($this->themeconfig['page'], $this->cache_id);
System::shutdown();
}
// register page vars output filter
$this->load_filter('output', 'pagevars');
// register short urls output filter
if (System::getVar('shorturls')) {
$this->load_filter('output', 'shorturls');
}
// register trim whitespace output filter if requried
if (ModUtil::getVar('ZikulaThemeModule', 'trimwhitespace')) {
$this->load_filter('output', 'trimwhitespace');
}
$this->load_filter('output', 'asseturls');
$event = new \Zikula\Core\Event\GenericEvent($this);
$this->eventManager->dispatch('theme.init', $event);
$this->startOutputBuffering();
}
示例6: __construct
/**
* Constructor.
*
* @param Zikula_ServiceManager $serviceManager ServiceManager.
* @param string $moduleName Module name ("zikula" for system plugins).
* @param integer|null $caching Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
*/
public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
{
$this->serviceManager = $serviceManager;
$this->eventManager = $this->serviceManager->get('event_dispatcher');
$this->request = \ServiceUtil::get('request');
// set the error reporting level
$this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
$this->error_reporting &= ~E_USER_DEPRECATED;
$this->allow_php_tag = true;
// get variables from input
$module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
$type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
$func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
// set vars based on the module structures
$this->homepage = PageUtil::isHomepage();
$this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
$this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
// Initialize the module property with the name of
// the topmost module. For Hooks, Blocks, API Functions and others
// you need to set this property to the name of the respective module!
$this->toplevelmodule = ModUtil::getName();
if (!$moduleName) {
$moduleName = $this->toplevelmodule;
}
$this->modinfo = ModUtil::getInfoFromName($moduleName);
$this->module = array($moduleName => $this->modinfo);
// initialise environment vars
$this->language = ZLanguage::getLanguageCode();
$this->baseurl = System::getBaseUrl();
$this->baseuri = System::getBaseUri();
// system info
$this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$this->theme = $theme = $this->themeinfo['directory'];
$themeBundle = ThemeUtil::getTheme($this->themeinfo['name']);
//---- Plugins handling -----------------------------------------------
// add plugin paths
switch ($this->modinfo['type']) {
case ModUtil::TYPE_MODULE:
$mpluginPathNew = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
$mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
break;
case ModUtil::TYPE_SYSTEM:
$mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
$mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
break;
default:
$mpluginPathNew = "system/" . $this->modinfo['directory'] . "/Resources/views/plugins";
$mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
}
// add standard plugin search path
$this->plugins_dir = array();
$this->addPluginDir('config/plugins');
// Official override
$this->addPluginDir('lib/legacy/viewplugins');
// Core plugins
$this->addPluginDir(isset($themeBundle) ? $themeBundle->getRelativePath() . '/plugins' : "themes/{$theme}/plugins");
// Theme plugins
$this->addPluginDir('plugins');
// Smarty core plugins
$this->addPluginDir($mpluginPathNew);
// Plugins for current module
$this->addPluginDir($mpluginPath);
// Plugins for current module
// check if the 'type' parameter in the URL is admin or adminplugin
$legacyControllerType = FormUtil::getPassedValue('lct', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
if ($type === 'admin' || $type === 'adminplugin' || $legacyControllerType === 'admin') {
// include plugins of the Admin module to the plugins_dir array
if (!$this instanceof Zikula_View_Theme) {
$this->addPluginDir('system/AdminModule/Resources/views/plugins');
} else {
$this->load_filter('output', 'admintitle');
}
}
// theme plugins module overrides
$themePluginsPath = isset($themeBundle) ? $themeBundle->getRelativePath() . '/modules/$moduleName/plugins' : "themes/{$theme}/templates/modules/{$moduleName}/plugins";
$this->addPluginDir($themePluginsPath);
//---- Cache handling -------------------------------------------------
if ($caching && in_array((int) $caching, array(0, 1, 2))) {
$this->caching = (int) $caching;
} else {
$this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'render_cache');
}
$this->compile_id = '';
$this->cache_id = '';
// template compilation
$this->compile_dir = CacheUtil::getLocalDir('view_compiled');
$this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'render_compile_check');
$this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'render_force_compile');
// template caching
$this->cache_dir = CacheUtil::getLocalDir('view_cache');
$this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'render_lifetime');
$this->expose_template = ModUtil::getVar('ZikulaThemeModule', 'render_expose_template') == true ? true : false;
// register resource type 'z' this defines the way templates are searched
//.........这里部分代码省略.........
示例7: queryStringDecode
//.........这里部分代码省略.........
if (ZLanguage::getLangUrlRule() && $lang) {
// and redirect then
self::redirect(self::getCurrentUrl() . "/{$lang}", array(), 302, true);
self::shutDown();
}
} else {
// check the existing shortURL parameters
// validation of the first parameter as language code
if (ZLanguage::isLangParam($args[0]) && in_array($args[0], ZLanguage::getInstalledLanguages())) {
// checks if the language is not enforced and this url is passing the default lang
if (!ZLanguage::getLangUrlRule() && $lang == $args[0]) {
// redirects the passed arguments without the default site language
array_shift($args);
foreach ($args as $k => $v) {
$args[$k] = urlencode($v);
}
self::redirect(self::getBaseUrl() . $frontController . ($args ? implode('/', $args) : ''), array(), 302, true);
self::shutDown();
}
self::queryStringSetVar('lang', $args[0], $request);
array_shift($args);
} elseif (ZLanguage::getLangUrlRule()) {
// if the lang is forced, redirects the passed arguments plus the lang
foreach ($args as $k => $v) {
$args[$k] = urlencode($v);
}
$langTheme = isset($_GET['theme']) ? "{$lang}/{$_GET['theme']}" : $lang;
self::redirect(self::getBaseUrl() . $frontController . $langTheme . '/' . implode('/', $args), array(), 302, true);
self::shutDown();
}
// check if there are remaining arguments
if ($args) {
// try the first argument as a module
$modinfo = ModUtil::getInfoFromName($args[0]);
if ($modinfo) {
array_shift($args);
}
}
// if that fails maybe it's a theme
if ($args && !$modinfo) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($args[0]));
if ($themeinfo) {
self::queryStringSetVar('theme', $themeinfo['name'], $request);
$request->attributes->set('_theme', $themeinfo['name']);
// now shift the vars and continue as before
array_shift($args);
if ($args) {
$modinfo = ModUtil::getInfoFromName($args[0]);
if ($modinfo) {
array_shift($args);
}
}
}
}
// if there are parameters (not homepage)
// try to see if there's a default shortURLs module
if ($args && !$modinfo) {
// add the default module handler into the code
$modinfo = ModUtil::getInfoFromName(self::getVar('shorturlsdefaultmodule'));
}
}
// check if there is a module and a custom url handler for it
// if not decode the url using the default handler
if ($modinfo && $modinfo['type'] != 0) {
// prepare the arguments to the module handler
array_unshift($args, '');
示例8: delete
/**
* delete a theme
*
*/
public function delete($args)
{
$themename = FormUtil::getPassedValue('themename', isset($args['themename']) ? $args['themename'] : null, 'REQUEST');
$objectid = FormUtil::getPassedValue('objectid', isset($args['objectid']) ? $args['objectid'] : null, 'REQUEST');
$confirmation = FormUtil::getPassedValue('confirmation', null, 'POST');
if (!empty($objectid)) {
$mid = $objectid;
}
// Get the theme info
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themename));
if ($themeinfo == false) {
return LogUtil::registerError($this->__('Sorry! No such theme found.'), 404);
}
// Security check
if (!SecurityUtil::checkPermission('Theme::', "$themename::", ACCESS_DELETE)) {
return LogUtil::registerPermissionError();
}
// Check for confirmation.
if (empty($confirmation)) {
// No confirmation yet
// Add the message id
$this->view->assign($themeinfo);
// Return the output that has been generated by this function
return $this->view->fetch('theme_admin_delete.tpl');
}
// If we get here it means that the user has confirmed the action
$this->checkCsrfToken();
$deletefiles = FormUtil::getPassedValue('deletefiles', 0, 'POST');
// Delete the admin message
// The return value of the function is checked
if (ModUtil::apiFunc('Theme', 'admin', 'delete', array('themename' => $themename, 'deletefiles' => $deletefiles))) {
// Success
LogUtil::registerStatus($this->__('Done! Deleted it.'));
}
// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
$this->redirect(ModUtil::url('Theme', 'admin', 'view'));
}
示例9: __construct
/**
* Constructor.
*
* @param ContainerBuilder $container ServiceManager.
* @param string $moduleName Module name ("zikula" for system plugins).
* @param integer|null $caching Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
*/
public function __construct(ContainerBuilder $container, $moduleName = '', $caching = null)
{
$this->container = $container;
$this->dispatcher = $this->container->get('event_dispatcher');
$this->request = $this->container->get('request');
// set the error reporting level
$this->error_reporting = isset($container['error_reporting']) ? $container['error_reporting'] : E_ALL;
$this->allow_php_tag = true;
// get variables from input
$module = $this->request->attributes->get('_module', null);
$type = $this->request->attributes->get('_controller', 'user');
$func = $this->request->attributes->get('_action', 'index');
// set vars based on the module structures
$this->homepage = empty($module) ? true : false;
$this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
$this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
// Initialize the module property with the name of
// the topmost module. For Hooks, Blocks, API Functions and others
// you need to set this property to the name of the respective module!
$this->toplevelmodule = ModUtil::getName();
if (!$moduleName) {
$moduleName = $this->toplevelmodule;
}
$this->modinfo = ModUtil::getInfoFromName($moduleName);
$this->module = array($moduleName => $this->modinfo);
// initialise environment vars
$this->language = ZLanguage::getLanguageCode();
$this->baseurl = System::getBaseUrl();
$this->baseuri = System::getBaseUri();
// system info
$this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$this->theme = $this->themeinfo['directory'];
//---- Plugins handling -----------------------------------------------
// add plugin paths
switch ($this->modinfo['type']) {
case ModUtil::TYPE_MODULE:
$mpluginPath = "modules/" . $this->modinfo['directory'] . "/Resources/views/plugins";
break;
case ModUtil::TYPE_SYSTEM:
$mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
break;
default:
$mpluginPath = "system/" . $this->modinfo['directory'] . "/Rsources/views/plugins";
}
// add standard plugin search path
$this->plugins_dir = array();
$this->addPluginDir('config/Resources/plugins');
// Official override
$this->addPluginDir('config/plugins');
// Official override
$this->addPluginDir(ZIKULA_ROOT . '/../src/legacy/viewplugins');
// Core plugins
$this->addPluginDir("themes/{$this->theme}/Resources/views/plugins");
// Theme plugins
$this->addPluginDir(SMARTY_DIR . 'plugins');
// Smarty core plugins
$this->addPluginDir($mpluginPath);
// Plugins for current module
// check if the 'type' parameter in the URL is admin and if yes,
// include system/Admin/templates/plugins to the plugins_dir array
if ($type === 'admin') {
if (!$this instanceof Zikula_View_Theme) {
$this->addPluginDir('system/AdminModule/Resources/views/plugins');
} else {
$this->load_filter('output', 'admintitle');
}
}
//---- Cache handling -------------------------------------------------
if ($caching && in_array((int) $caching, array(0, 1, 2))) {
$this->caching = (int) $caching;
} else {
$this->caching = (int) ModUtil::getVar('Theme', 'render_cache');
}
$this->compile_id = '';
$this->cache_id = '';
// template compilation
$this->compile_dir = CacheUtil::getLocalDir('view_compiled');
$this->compile_check = ModUtil::getVar('Theme', 'render_compile_check');
$this->force_compile = ModUtil::getVar('Theme', 'render_force_compile');
// template caching
$this->cache_dir = CacheUtil::getLocalDir('view_cache');
$this->cache_lifetime = ModUtil::getVar('Theme', 'render_lifetime');
$this->expose_template = ModUtil::getVar('Theme', 'render_expose_template') == true ? true : false;
// register resource type 'z' this defines the way templates are searched
// during {include file='my_template.tpl'} this enables us to store selected module
// templates in the theme while others can be kept in the module itself.
$this->register_resource('z', array('Zikula_View_Resource', 'z_get_template', 'z_get_timestamp', 'z_get_secure', 'z_get_trusted'));
// set 'z' as default resource type
$this->default_resource_type = 'z';
// process some plugins specially when Render cache is enabled
if (!$this instanceof Zikula_View_Theme && $this->caching) {
$this->register_nocache_plugins();
}
//.........这里部分代码省略.........
示例10: display
public function display($blockinfo)
{
// check if the module is available
if (!ModUtil::available('Theme')) {
return;
}
// check if theme switching is allowed
if (!System::getVar('theme_change')) {
return;
}
// security check
if (!SecurityUtil::checkPermission( "Themeswitcherblock::", "$blockinfo[title]::", ACCESS_READ)) {
return;
}
// Get variables from content block
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// Defaults
if (empty($vars['format'])) {
$vars['format'] = 1;
}
// get some use information about our environment
$currenttheme = UserUtil::getTheme();
// get all themes in our environment
$themes = ThemeUtil::getAllThemes();
// get some use information about our environment
$currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
// get all themes in our environment
$themes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);
$previewthemes = array();
$currentthemepic = null;
foreach ($themes as $themeinfo) {
$themename = $themeinfo['name'];
if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_small.png')) {
$themeinfo['previewImage'] = $themepic;
} else {
$themeinfo['previewImage'] = 'system/Theme/images/preview_small.png';
}
$previewthemes[$themename] = $themeinfo;
if ($themename == $currenttheme['name']) {
$currentthemepic = $themeinfo['previewImage'];
}
}
$this->view->assign($vars)
->assign('currentthemepic', $currentthemepic)
->assign('currenttheme', $currenttheme)
->assign('themes', $previewthemes);
$blockinfo['content'] = $this->view->fetch('theme_block_themeswitcher.tpl');
return BlockUtil::themeBlock($blockinfo);
}
示例11: themeBlock
/**
* Display a block based on the current theme.
*
* @param array $blockinfo Block info.
*
* @return string The rendered output.
*/
public static function themeBlock($blockinfo)
{
static $themeinfo, $themedir, $upb, $downb;
if (!isset($blockinfo['bid'])) {
$blockinfo['bid'] = '';
}
if (!isset($blockinfo['title'])) {
$blockinfo['title'] = '';
}
if (UserUtil::isLoggedIn() && ModUtil::getVar('Blocks', 'collapseable') == 1 && isset($blockinfo['collapsable']) && ($blockinfo['collapsable'] == '1')) {
if (!isset($themeinfo)) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$themedir = DataUtil::formatForOS($themeinfo['directory']);
}
// check for collapsable menus being enabled, and setup the collapsable menu image.
if (!isset($upb)) {
if (file_exists('themes/' . $themedir . '/images/upb.png')) {
$upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />';
} elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) {
$upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />';
} else {
$upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />';
}
}
if (!isset($downb)) {
if (file_exists('themes/' . $themedir . '/images/downb.png')) {
$downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />';
} elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) {
$downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />';
} else {
$downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />';
}
}
if (self::checkUserBlock($blockinfo) == '1') {
if (!empty($blockinfo['title'])) {
$blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>';
}
} else {
$blockinfo['content'] = '';
if (!empty($blockinfo['title'])) {
$blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Blocks', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>';
}
}
// end collapseable menu config
} else {
$blockinfo['minbox'] = '';
}
return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
}
示例12: themeBlock
/**
* Display a block based on the current theme.
*
* @param array $blockinfo Block info.
*
* @return string The rendered output.
*/
public static function themeBlock($blockinfo)
{
static $themeinfo, $themedir, $upb, $downb;
if (!isset($blockinfo['bid'])) {
$blockinfo['bid'] = '';
}
if (!isset($blockinfo['title'])) {
$blockinfo['title'] = '';
}
if (UserUtil::isLoggedIn() && ModUtil::getVar('ZikulaBlocksModule', 'collapseable') == 1 && isset($blockinfo['collapsable']) && $blockinfo['collapsable'] == '1') {
if (!isset($themeinfo)) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$themedir = DataUtil::formatForOS($themeinfo['directory']);
}
// check for collapsable menus being enabled, and setup the collapsable menu image.
if (!isset($upb)) {
if (file_exists('themes/' . $themedir . '/images/upb.png')) {
$upb = '<img src="themes/' . $themedir . '/images/upb.png" alt="-" />';
} elseif (file_exists('themes/' . $themedir . '/images/14_layer_raiselayer.png')) {
$upb = '<img src="themes/' . $themedir . '/images/14_layer_raiselayer.png" alt="-" />';
} else {
$upb = '<img src="images/icons/extrasmall/14_layer_raiselayer.png" alt="-" />';
}
}
if (!isset($downb)) {
if (file_exists('themes/' . $themedir . '/images/downb.png')) {
$downb = '<img src="themes/' . $themedir . '/images/downb.png" alt="+" />';
} elseif (file_exists('themes/' . $themedir . '/images/14_layer_lowerlayer.png')) {
$downb = '<img src="themes/' . $themedir . '/images/14_layer_lowerlayer.png" alt="+" />';
} else {
$downb = '<img src="images/icons/extrasmall/14_layer_lowerlayer.png" alt="+" />';
}
}
$checkUserBlock = self::checkUserBlock($blockinfo);
if ($checkUserBlock) {
if (!empty($blockinfo['title'])) {
$blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $upb . '</a>';
}
} else {
$blockinfo['content'] = '';
if (!empty($blockinfo['title'])) {
$blockinfo['minbox'] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('ZikulaBlocksModule', 'user', 'changestatus', array('bid' => $blockinfo['bid']))) . '">' . $downb . '</a>';
}
}
// end collapseable menu config
} else {
$blockinfo['minbox'] = '';
}
// try twig theme first (note: theme is already set by this point)
$container = ServiceUtil::getManager();
$twigBasedThemeBlock = $container->get('zikula_core.common.theme_engine')->wrapBcBlockInTheme($blockinfo);
if ($twigBasedThemeBlock) {
return $twigBasedThemeBlock;
}
// theme is not twig based revert to smarty
return Zikula_View_Theme::getInstance()->themesidebox($blockinfo);
}
示例13: __construct
/**
* Constructor.
*
* @param Zikula_ServiceManager $serviceManager ServiceManager.
* @param string $moduleName Module name ("zikula" for system plugins).
* @param integer|null $caching Whether or not to cache (Zikula_View::CACHE_*) or use config variable (null).
*/
public function __construct(Zikula_ServiceManager $serviceManager, $moduleName = '', $caching = null)
{
$this->serviceManager = $serviceManager;
$this->eventManager = $this->serviceManager->getService('zikula.eventmanager');
$this->request = $this->serviceManager->getService('request');
// set the error reporting level
$this->error_reporting = isset($GLOBALS['ZConfig']['Debug']['error_reporting']) ? $GLOBALS['ZConfig']['Debug']['error_reporting'] : E_ALL;
$this->allow_php_tag = true;
// get variables from input
$module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
$type = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
$func = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
// set vars based on the module structures
$this->homepage = empty($module) ? true : false;
$this->type = strtolower(!$this->homepage ? $type : System::getVar('starttype'));
$this->func = strtolower(!$this->homepage ? $func : System::getVar('startfunc'));
// Initialize the module property with the name of
// the topmost module. For Hooks, Blocks, API Functions and others
// you need to set this property to the name of the respective module!
$this->toplevelmodule = ModUtil::getName();
if (!$moduleName) {
$moduleName = $this->toplevelmodule;
}
$this->modinfo = ModUtil::getInfoFromName($moduleName);
$this->module = array($moduleName => $this->modinfo);
// initialise environment vars
$this->language = ZLanguage::getLanguageCode();
$this->baseurl = System::getBaseUrl();
$this->baseuri = System::getBaseUri();
// system info
$this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$this->theme = $theme = $this->themeinfo['directory'];
//---- Plugins handling -----------------------------------------------
// add plugin paths
switch ($this->modinfo['type'])
{
case ModUtil::TYPE_MODULE :
$mpluginPath = "modules/" . $this->modinfo['directory'] . "/templates/plugins";
$mpluginPathOld = "modules/" . $this->modinfo['directory'] . "/pntemplates/plugins";
break;
case ModUtil::TYPE_SYSTEM :
$mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
$mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
break;
default:
$mpluginPath = "system/" . $this->modinfo['directory'] . "/templates/plugins";
$mpluginPathOld = "system/" . $this->modinfo['directory'] . "/pntemplates/plugins";
}
// add standard plugin search path
$this->plugins_dir = array();
$this->addPluginDir('config/plugins'); // Official override
$this->addPluginDir('lib/viewplugins'); // Core plugins
$this->addPluginDir("themes/$theme/plugins"); // Theme plugins
$this->addPluginDir('plugins'); // Smarty core plugins
$this->addPluginDir($mpluginPath); // Plugins for current module
// check if the 'type' parameter in the URL is admin and if yes,
// include system/Admin/templates/plugins to the plugins_dir array
if ($type === 'admin') {
if (!$this instanceof Zikula_View_Theme) {
$this->addPluginDir('system/Admin/templates/plugins');
} else {
$this->load_filter('output', 'admintitle');
}
}
// adds legacy plugin paths if needed
if (System::isLegacyMode()) {
$this->addPluginDir('lib/legacy/plugins'); // Core legacy plugins
$this->addPluginDir($mpluginPathOld); // Module plugins (legacy paths)
$this->addPluginDir("themes/$theme/templates/modules/$moduleName/plugins"); // Module override in themes
}
//---- Cache handling -------------------------------------------------
if ($caching && in_array((int)$caching, array(0, 1, 2))) {
$this->caching = (int)$caching;
} else {
$this->caching = (int)ModUtil::getVar('Theme', 'render_cache');
}
// write actions should not be cached or weird things happen
if (isset($_POST) && count($_POST) != 0) {
$this->caching = Zikula_View::CACHE_DISABLED;
}
//.........这里部分代码省略.........
示例14: pnThemeGetInfo
/**
* pnThemeGetInfo
*
* Returns information about a theme.
*
* @author Mark West
* @param string $themeid Id of the theme
* @return array the theme information
**/
function pnThemeGetInfo($themeid)
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array('pnThemeGetInfo()', 'ThemeUtil::getInfo()')), E_USER_DEPRECATED);
return ThemeUtil::getInfo($themeid);
}
示例15: smarty_outputfilter_pagevars
/**
* Zikula_View outputfilter to add page variables and additional header global into page header
*
* By default this output filter places page variable output immediately prior to the closing
* head tag (</head>). The output can, optionally, be placed anywhere in the template by adding
* the HTML comment <!-- pagevars --> to the page template. Note that this must always be in
* the header for the output to function correctly.
*
* @param string $source Output source.
* @param Zikula_View $view Reference to Zikula_View instance.
*
* @return string
*/
function smarty_outputfilter_pagevars($source, $view)
{
$return = '';
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));
$cssjscombine = ModUtil::getVar('ZikulaThemeModule', 'cssjscombine', false);
$type = $view->getRequest()->get('type');
$zkType = $view->getRequest()->attributes->get('_zkType');
$isAdminController = $type == 'admin' || $zkType == 'admin';
// get list of stylesheets and scripts from JCSSUtil
$jcss = JCSSUtil::prepareJCSS($cssjscombine, $view->cache_dir, $themeinfo, $isAdminController);
if (is_array($jcss['stylesheets']) && !empty($jcss['stylesheets'])) {
foreach ($jcss['stylesheets'] as $stylesheet) {
if (empty($stylesheet)) {
continue;
}
// check if the stylesheets is in the additional_header array
if ($themeinfo['xhtml']) {
$return .= '<link rel="stylesheet" href="' . DataUtil::formatForDisplay($stylesheet) . '" type="text/css" />' . "\n";
} else {
$return .= '<link rel="stylesheet" href="' . DataUtil::formatForDisplay($stylesheet) . '" type="text/css">' . "\n";
}
}
}
// get inline js config and print it just before any script tag
$jsConfig = JCSSUtil::getJSConfig();
if (!empty($jsConfig)) {
$return .= $jsConfig;
}
if (is_array($jcss['javascripts']) && !empty($jcss['javascripts'])) {
foreach ($jcss['javascripts'] as $j => $javascript) {
if (empty($javascript)) {
unset($jcss['javascripts'][$j]);
continue;
}
// check if the javascript is in the additional_header array
$return .= '<script type="text/javascript" src="' . DataUtil::formatForDisplay($javascript) . '"></script>' . "\n";
}
}
$headerContent = PageUtil::getVar('header');
if (is_array($headerContent) && !empty($headerContent)) {
$return .= implode("\n", $headerContent) . "\n";
}
// if we've got some page vars to add the header wrap the output in
// suitable identifying comments when in development mode
$return = trim($return);
if (!empty($return) && System::getVar('development') != 0) {
$return = "<!-- zikula pagevars -->\n" . $return . "\n<!-- /zikula pagevars -->";
}
// get any body page vars
$bodyvars = PageUtil::getVar('body');
if (!empty($bodyvars)) {
$bodyattribs = '<body ' . @implode(' ', $bodyvars) . '>';
$source = str_replace('<body>', $bodyattribs, $source);
}
// get any footer page vars
$footervars = PageUtil::getVar('footer');
if (!empty($footervars)) {
$footersource = @implode("\n", $footervars) . "\n</body>";
$source = str_replace('</body>', $footersource, $source);
}
// replace the string in the template source
if (stripos($source, '<!-- pagevars -->')) {
$source = str_replace('<!-- pagevars -->', $return, $source);
} else {
$headPos = stripos($source, '</head>');
if ($headPos !== false) {
if ($headPos == strripos($source, '</head>')) {
// Position of the first </head> matches the last </head> so str_replace is safe
$source = str_replace('</head>', $return . "\n</head>", $source);
} else {
// Position of the first </head> does not match the last </head> so str_replace is NOT safe
// There was probably a {zdebug} tag opening a _dbgconsole.
// Need to use preg_replace so we can limit to the first.
preg_replace('#</head>#i', $return . "\n</head>", $source, 1);
}
}
}
// return the modified source
return $source;
}