本文整理汇总了PHP中UserUtil::getTheme方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::getTheme方法的具体用法?PHP UserUtil::getTheme怎么用?PHP UserUtil::getTheme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserUtil
的用法示例。
在下文中一共展示了UserUtil::getTheme方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: _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;
}
示例3: smarty_function_modulejavascript
/**
* Zikula_View function to include module specific javascripts
*
* Available parameters:
* - modname module name (if not set, the current module is assumed)
* if modname="" than we will look into the main javascript folder
* - script name of the external javascript file (mandatory)
* - modonly javascript will only be included when the the current module is $modname
* - onload function to be called with onLoad handler in body tag, makes sense with assign set only, see example #2
* - assign if set, the tag and the script filename are returned
*
* Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 }
* Output: <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js">
*
* Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 onload="dosomething()" assign=myjs }
* Output: nothing, but assigns a variable containing several values:
* $myjs.scriptfile = "modules/foobar/javascript/module_admin_config.js"
* $myjs.tag = "<script type=\"text/javascript\" src=\"modules/foobar/javascript/module_admin_config.js\"></script>"
* $myjs.onload = "onLoad=\"dosomething()\"";
* Possible code in master.tpl would be:
*
* ...
* { $myjs.tag }
* </head>
* <body { $myjs.onload } >
* ...
*
* which results in
*
* ...
* <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js"></script>
* </head>
* <body onLoad="dosomething()" >
* ...
*
* if foobar is the current module.
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The tag.
*/
function smarty_function_modulejavascript($params, Zikula_View $view)
{
// check if script is set (mandatory)
if (!isset($params['script'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modulejavascript', 'script')));
return false;
}
// check if modname is set and if not, if $modonly is set
if (!isset($params['modname'])) {
if (isset($params['modonly'])) {
// error - we want $modonly only with $modname
$view->trigger_error(__f('Error! in %1$s: parameter \'%2$s\' only supported together with \'%3$s\' set.', array('modulejavascript', 'modonly', 'modname')));
return;
}
// we use the current module name
$params['modname'] = ModUtil::getName();
}
if (isset($params['modonly']) && $params['modname'] != ModUtil::getName()) {
// current module is not $modname - do nothing and return silently
return;
}
// if modname is empty, we will search the main javascript folder
if ($params['modname'] == '') {
$searchpaths = array('javascript', 'javascript/ajax');
} else {
// theme directory
$theme = DataUtil::formatForOS(UserUtil::getTheme());
$osmodname = DataUtil::formatForOS($params['modname']);
$themepath = "themes/{$theme}/Resources/public/js/{$osmodname}";
// module directory
$modinfo = ModUtil::getInfoFromName($params['modname']);
$osmoddir = DataUtil::formatForOS($modinfo['directory']);
$modpath = "modules/{$osmoddir}/Resources/public/js";
$syspath = "system/{$osmoddir}/Resources/public/js";
$searchpaths = array($themepath, $modpath, $syspath);
}
$osscript = DataUtil::formatForOS($params['script']);
// search for the javascript
$scriptsrc = '';
foreach ($searchpaths as $path) {
if (is_readable("{$path}/{$osscript}")) {
$scriptsrc = "{$path}/{$osscript}";
break;
}
}
// if no module javascript has been found then return no content
$tag = empty($scriptsrc) ? '' : '<script type="text/javascript" src="' . $scriptsrc . '"></script>';
// onLoad event handler used?
$onload = isset($params['onload']) ? 'onLoad="' . $params['onload'] . '"' : '';
if (isset($params['assign'])) {
$return = array();
$return['scriptfile'] = $scriptsrc;
$return['tag'] = $tag;
$return['onload'] = $onload;
$view->assign($params['assign'], $return);
} else {
return $tag;
}
//.........这里部分代码省略.........
示例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: smarty_function_usergettheme
/**
* Zikula_View function to the current users theme
*
* Available parameters:
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The variables content.
*/
function smarty_function_usergettheme($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$result = UserUtil::getTheme();
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例6: __construct
public function __construct()
{
$themeName = \UserUtil::getTheme();
$theme = \ThemeUtil::getTheme($themeName);
if (null !== $theme && is_readable($path = $theme->getConfigPath() . '/overrides.yml')) {
// bundle type theme
$this->overrideMap = Yaml::parse(file_get_contents($path));
} elseif (is_readable("themes/{$themeName}/templates/overrides.yml")) {
// pre-1.4.0 style theme
$this->_overrideMap = Yaml::parse(file_get_contents("themes/{$themeName}/templates/overrides.yml"));
}
}
示例7: initialize
/**
* Initialize form handler.
*
* This method takes care of all necessary initialisation of our data and form states.
*
* @return boolean False in case of initialization errors, otherwise true.
*/
public function initialize(Zikula_Form_View $view)
{
$this->inlineUsage = UserUtil::getTheme() == 'Printer' ? true : false;
$this->idPrefix = $this->request->getGet()->filter('idp', '', FILTER_SANITIZE_STRING);
// initialise redirect goal
$this->returnTo = $this->request->getGet()->filter('returnTo', null, FILTER_SANITIZE_STRING);
// store current uri for repeated creations
$this->repeatReturnUrl = System::getCurrentURI();
$this->permissionComponent = $this->name . ':' . $this->objectTypeCapital . ':';
$entityClass = $this->name . '_Entity_' . ucfirst($this->objectType);
$objectTemp = new $entityClass();
$this->idFields = $objectTemp->get_idFields();
// retrieve identifier of the object we wish to view
$this->idValues = MUBoard_Util_Controller::retrieveIdentifier($this->request, array(), $this->objectType, $this->idFields);
$hasIdentifier = MUBoard_Util_Controller::isValidIdentifier($this->idValues);
$entity = null;
$this->mode = $hasIdentifier ? 'edit' : 'create';
if ($this->mode == 'edit') {
if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_EDIT)) {
// set an error message and return false
return LogUtil::registerPermissionError();
}
$entity = $this->initEntityForEdit();
if ($this->hasPageLockSupport === true && ModUtil::available('PageLock')) {
// try to guarantee that only one person at a time can be editing this entity
/* ModUtil::apiFunc('PageLock', 'user', 'pageLock',
array('lockName' => $this->name . $this->objectTypeCapital . $this->createCompositeIdentifier(),
'returnUrl' => $this->getRedirectUrl(null, $entity))); */
}
} else {
if (!SecurityUtil::checkPermission($this->permissionComponent, '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
$entity = $this->initEntityForCreation($entityClass);
}
$this->view->assign('mode', $this->mode)->assign('inlineUsage', $this->inlineUsage);
// We set text field to empty if entity class is posting
if ($this->request->query->filter('ot', 'category', FILTER_SANITIZE_STRING) == 'posting' && $this->request->query->filter('func', 'main', FILTER_SANITIZE_STRING) == 'display') {
$entity['text'] = '';
}
$entityData = $entity->toArray();
// assign data to template as array (makes translatable support easier)
$this->view->assign($this->objectTypeLower, $entityData);
// save entity reference for later reuse
$this->entityRef = $entity;
$this->initializeAdditions();
// everything okay, no initialization errors occured
return true;
}
示例8: smarty_function_moduleheader
/**
* Smarty function build module header in user content page.
*
* {moduleheader}
*
* Available parameters:
* modname Module name to display header for (optional, defaults to current module)
* type Type for module links (defaults to 'user')
* title Title to display in header (optional, defaults to module name)
* titlelink Link to attach to title (optional, defaults to none)
* setpagetitle If set to true, {pagesetvar} is used to set page title
* insertstatusmsg If set to true, {insert name='getstatusmsg'} is put in front of template
* menufirst If set to true, menu is first, then title
* putimage If set to true, module image is also displayed next to title
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string A formatted string containing navigation for the module admin panel.
*/
function smarty_function_moduleheader($params, $view)
{
if (!isset($params['modname']) || !ModUtil::available($params['modname'])) {
$params['modname'] = ModUtil::getName();
}
if (empty($params['modname'])) {
return false;
}
$type = isset($params['type']) ? $params['type'] : 'user';
$assign = isset($params['assign']) ? $params['assign'] : null;
$menufirst = isset($params['menufirst']) ? $params['menufirst'] : false;
$putimage = isset($params['putimage']) ? $params['putimage'] : false;
$setpagetitle = isset($params['setpagetitle']) ? $params['setpagetitle'] : false;
$insertstatusmsg = isset($params['insertstatusmsg']) ? $params['insertstatusmsg'] : false;
$cutlenght = isset($params['cutlenght']) ? $params['cutlenght'] : 20;
if ($putimage) {
$image = isset($params['image']) ? $params['image'] : ModUtil::getModuleImagePath($params['modname']);
} else {
$image = '';
}
if (!isset($params['title'])) {
$modinfo = ModUtil::getInfoFromName($params['modname']);
if (isset($modinfo['displayname'])) {
$params['title'] = $modinfo['displayname'];
} else {
$params['title'] = ModUtil::getName();
}
}
$titlelink = isset($params['titlelink']) ? $params['titlelink'] : false;
$renderer = Zikula_View::getInstance('Theme');
$renderer->setCaching(Zikula_View::CACHE_DISABLED);
$renderer->assign('userthemename', UserUtil::getTheme());
$renderer->assign('modname', $params['modname']);
$renderer->assign('type', $params['type']);
$renderer->assign('title', $params['title']);
$renderer->assign('titlelink', $titlelink);
$renderer->assign('truncated', mb_strlen($params['title']) > $cutlenght);
$renderer->assign('titletruncated', mb_substr($params['title'], 0, $cutlenght) . '...');
$renderer->assign('setpagetitle', $setpagetitle);
$renderer->assign('insertstatusmsg', $insertstatusmsg);
$renderer->assign('menufirst', $menufirst);
$renderer->assign('image', $image);
if ($assign) {
$view->assign($assign, $renderer->fetch('moduleheader.tpl'));
} else {
return $renderer->fetch('moduleheader.tpl');
}
}
示例9: save
/**
* Save combined pagevars.
*
* @param array $files Files.
* @param string $ext Extention.
* @param string $cache_dir Cache directory.
*
* @return array Array of file with combined pagevars file and remote files
*/
private static function save($files, $ext, $cache_dir)
{
$themevars = ModUtil::getVar('ZikulaThemeModule');
$lifetime = $themevars['cssjscombine_lifetime'];
$hash = md5(serialize($files) . UserUtil::getTheme());
$cachedFile = "{$cache_dir}/{$hash}_{$ext}.php";
$cachedFileUri = "{$hash}_{$ext}.php";
if (is_readable($cachedFile) && ($lifetime == -1 || filemtime($cachedFile) + $lifetime > time())) {
return System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
}
switch ($ext) {
case 'css':
$ctype = 'text/css';
break;
case 'js':
$ctype = 'text/javascript';
break;
default:
$ctype = 'text/plain';
break;
}
$includedFiles = array();
$outputFiles = array();
$contents = array();
$dest = fopen($cachedFile, 'w');
foreach ($files as $file) {
if (!empty($file)) {
// skip remote files from combining
if (is_file($file)) {
self::readfile($contents, $file, $ext);
$includedFiles[] = $file;
} else {
$outputFiles[] = $file;
}
}
}
array_unshift($contents, "/* --- Combined file written: " . DateUtil::getDateTime() . " */\n\n");
array_unshift($contents, "/* --- Combined files:\n" . implode("\n", $includedFiles) . "\n*/\n\n");
$contents = implode('', $contents);
// optional minify
if ($themevars['cssjsminify'] && $ext == 'css') {
// Remove comments.
$contents = trim(preg_replace('/\\/\\*.*?\\*\\//s', '', $contents));
// Compress whitespace.
$contents = preg_replace('/\\s+/', ' ', $contents);
// Additional whitespace optimisation -- spaces around certain tokens is not required by CSS
$contents = preg_replace('/\\s*(;|\\{|\\}|:|,)\\s*/', '\\1', $contents);
}
global $ZConfig;
$signingKey = md5(serialize($ZConfig['DBInfo']['databases']['default']));
$signature = md5($contents . $ctype . $lifetime . $themevars['cssjscompress'] . $signingKey);
$data = array('contents' => $contents, 'ctype' => $ctype, 'lifetime' => $lifetime, 'gz' => $themevars['cssjscompress'], 'signature' => $signature);
fwrite($dest, serialize($data));
fclose($dest);
$combined = System::getBaseUri() . '/jcss.php?f=' . $cachedFileUri;
array_unshift($outputFiles, $combined);
return $outputFiles;
}
示例10: __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
//.........这里部分代码省略.........
示例11: getModuleStylesheet
/**
* Get the modules stylesheet from several possible sources.
*
* @param string $modname The modules name (optional, defaults to top level module).
* @param string $stylesheet The stylesheet file (optional).
*
* @return string Path of the stylesheet file, relative to PN root folder.
*/
public static function getModuleStylesheet($modname = '', $stylesheet = '')
{
// default for the module
if (empty($modname)) {
$modname = ModUtil::getName();
}
$modname = preg_match('/\\w+Module$/', $modname) ? $modname : $modname . 'Module';
// default for the style sheet
if (empty($stylesheet)) {
$stylesheet = ModUtil::getVar($modname, 'modulestylesheet');
if (empty($stylesheet)) {
$stylesheet = 'style.css';
}
}
$osstylesheet = DataUtil::formatForOS($stylesheet);
$osmodname = DataUtil::formatForOS($modname);
// config directory
$configstyledir = 'config/style';
$configpath = "{$configstyledir}/{$osmodname}";
// theme directory
$theme = DataUtil::formatForOS(UserUtil::getTheme());
$themepath = "themes/{$theme}/Resources/public/css/{$osmodname}";
// module directory
$modinfo = ModUtil::getInfoFromName($modname);
$osmoddir = DataUtil::formatForOS($modinfo['directory']);
$modpath = "modules/{$osmoddir}/Resources/public/css";
$syspath = "system/{$osmoddir}/Resources/public/css";
// search for the style sheet
$csssrc = '';
foreach (array($configpath, $themepath, $modpath, $syspath) as $path) {
if (is_readable("{$path}/{$osstylesheet}")) {
$csssrc = "{$path}/{$osstylesheet}";
break;
}
}
return $csssrc;
}
示例12: getStylesheet
/**
* Get the templateset stylesheet from several possible sources
*
* @access public
* @param string $path the templateset/css path
* @return string path of the stylesheet file, relative to Zikula root folder
*/
public function getStylesheet($args = array())
{
// default for the style sheet
if (!isset($args['path']) || empty($args['path'])) {
$defaultcss = $this->getVar('css', 'style.css');
$args['path'] = 'Standard/' . $defaultcss;
}
$ospath = DataUtil::formatForOS($args['path']);
// config directory
$configpath = "config/templates/EZComments";
// theme directory
$theme = DataUtil::formatForOS(UserUtil::getTheme());
$themepath = "themes/$theme/templates/modules/EZComments";
// module directory
$modpath = "modules/EZComments/templates";
// search for the style sheet
$csssrc = '';
foreach (array($configpath, $themepath, $modpath) as $basepath) {
if (!file_exists("$basepath/$ospath") || !is_readable("$basepath/$ospath")) {
continue;
}
$csssrc = "$basepath/$ospath";
break;
}
return $csssrc;
}
示例13: loader
/**
* Initialise scribite for requested areas.
*
* @param array $args Text area: 'area', Module name: 'modulename'.
*
* @return string
*/
public static function loader($args)
{
$dom = ZLanguage::getModuleDomain('Scribite');
// Argument checks
if (!isset($args['areas'])) {
return LogUtil::registerError(__('Error! Scribite_Api_User::loader() "area" argument was empty.', $dom));
}
if (!isset($args['modulename'])) {
$args['modulename'] = ModUtil::getName();
}
$module = $args['modulename'];
// Security check if user has COMMENT permission for scribite and module
if (!SecurityUtil::checkPermission('Scribite::', "{$module}::", ACCESS_COMMENT)) {
return;
}
// check for editor argument, if none given the default editor will be used
if (!isset($args['editor']) || empty($args['editor'])) {
// get default editor from config
$defaulteditor = ModUtil::getVar('Scribite', 'DefaultEditor');
if ($defaulteditor == '-') {
return;
// return if no default is set and no arg is given
// id given editor doesn't exist use default editor
} else {
$args['editor'] = $defaulteditor;
}
}
// check if editor argument exists, load default if not given
if (ModUtil::apiFunc('Scribite', 'user', 'getEditors', array('editorname' => $args['editor']))) {
// set some general parameters
$zBaseUrl = rtrim(System::getBaseUrl(), '/');
$zikulaThemeBaseURL = "{$zBaseUrl}/themes/" . DataUtil::formatForOS(UserUtil::getTheme());
$zikulaBaseURI = rtrim(System::getBaseUri(), '/');
$zikulaBaseURI = ltrim($zikulaBaseURI, '/');
$zikulaRoot = rtrim($_SERVER['DOCUMENT_ROOT'], '/');
// prepare view instance
$view = Zikula_View::getInstance('Scribite');
$view->setCaching(false);
$view->assign(ModUtil::getVar('Scribite'));
$view->assign('modname', $args['modulename']);
$view->assign('zBaseUrl', $zBaseUrl);
$view->assign('zikulaBaseURI', $zikulaBaseURI);
$view->assign('zikulaRoot', $zikulaRoot);
$view->assign('editor_dir', $args['editor']);
$view->assign('zlang', ZLanguage::getLanguageCode());
// check for modules installed providing plugins and load specific javascripts
if (ModUtil::available('photoshare')) {
PageUtil::AddVar('javascript', 'modules/photoshare/javascript/findimage.js');
}
if (ModUtil::available('mediashare')) {
PageUtil::AddVar('javascript', 'modules/mediashare/javascript/finditem.js');
}
if (ModUtil::available('pagesetter')) {
PageUtil::AddVar('javascript', 'modules/pagesetter/javascript/findpub.js');
}
if (ModUtil::available('folder')) {
PageUtil::AddVar('javascript', 'modules/folder/javascript/selector.js');
}
if (ModUtil::available('MediaAttach')) {
PageUtil::AddVar('javascript', 'modules/MediaAttach/javascript/finditem.js');
}
if (ModUtil::available('Files')) {
PageUtil::AddVar('javascript', 'modules/Files/javascript/getFiles.js');
}
// main switch for choosen editor
switch ($args['editor']) {
case 'xinha':
// get xinha config if editor is active
// get plugins for xinha
$xinha_listplugins = ModUtil::getVar('Scribite', 'xinha_activeplugins');
if ($xinha_listplugins != '') {
$xinha_listplugins = unserialize($xinha_listplugins);
/* if (in_array('ExtendedFileManager', $xinha_listplugins)) {
$view->assign('EFMConfig', true);
} else { */
$view->assign('EFMConfig', false);
//}
$xinha_listplugins = '\'' . DataUtil::formatForDisplay(implode('\', \'', $xinha_listplugins)) . '\'';
}
// prepare areas for xinha
if ($args['areas'][0] == "all") {
$modareas = 'all';
} elseif ($args['areas'][0] == "PagEd") {
$modareas = 'PagEd';
} else {
$modareas = '\'' . DataUtil::formatForDisplay(implode('\', \'', $args['areas'])) . '\'';
}
// load Prototype
PageUtil::AddVar('javascript', 'prototype');
// set parameters
$view->assign('modareas', $modareas);
$view->assign('xinha_listplugins', $xinha_listplugins);
// end xinha
//.........这里部分代码省略.........
示例14: 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);
}
示例15: smarty_function_img
//.........这里部分代码省略.........
}
// always provide an alt attribute.
// if none is set, assign an empty one.
$params['alt'] = isset($params['alt']) ? $params['alt'] : '';
// prevent overwriting surrounding titles (#477)
if (isset($params['title']) && empty($params['title'])) {
unset($params['title']);
}
// language
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
if ($sysplugin) {
$osplugdir = DataUtil::formatForOS($sysplugin);
$pluglangpath = "plugins/{$osplugdir}/images/{$lang}";
$plugpath = "plugins/{$osplugdir}/images";
// form the array of paths
$paths = array($pluglangpath, $plugpath);
} else {
// module directory
if ($modname != 'core') {
$modinfo = ModUtil::getInfoFromName($modname);
$osmoddir = DataUtil::formatForOS($modinfo['directory']);
$moduleDir = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
}
if ($modplugin) {
$osmodplugdir = DataUtil::formatForOS($modplugin);
$modpluglangpath = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/Resources/public/images/{$lang}";
$modplugpath = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/Resources/public/images";
$modpluglangpathOld = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/images/{$lang}";
$modplugpathOld = "{$moduleDir}/{$osmoddir}/plugins/{$osmodplugdir}/images";
// form the array of paths
$paths = array($modpluglangpath, $modplugpath, $modpluglangpathOld, $modplugpathOld);
} else {
// theme directory
$ostheme = DataUtil::formatForOS(UserUtil::getTheme());
$theme = ThemeUtil::getTheme($ostheme);
$themePath = null === $theme ? '' : $theme->getRelativePath() . '/Resources/public/images';
$themepath = $themePath;
$corethemepath = "themes/{$ostheme}/images";
if ($modname == 'core') {
$modpath = "images";
$paths = array($themepath, $corethemepath, $modpath);
} else {
$osmodname = DataUtil::formatForOS($modname);
$themelangpath = "{$themePath}/{$lang}";
$themelangpathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images/{$lang}";
$themepathOld = "themes/{$ostheme}/templates/modules/{$osmodname}/images";
$module = ModUtil::getModule($modinfo['name']);
$moduleBasePath = null === $module ? '' : $module->getRelativePath() . '/Resources/public/images';
$modlangpath = "{$moduleBasePath}/{$lang}";
$modpath = $moduleBasePath;
$modlangpathOld = "{$moduleDir}/{$osmoddir}/images/{$lang}";
$modpathOld = "{$moduleDir}/{$osmoddir}/images";
$modlangpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages/{$lang}";
$modpathOld2 = "{$moduleDir}/{$osmoddir}/pnimages";
// form the array of paths
if (preg_match('/^admin.(png|gif|jpg)$/', $params['src'])) {
// special processing for modules' admin icon
$paths = array($modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
} else {
$paths = array($themelangpath, $themepath, $themelangpathOld, $themepathOld, $corethemepath, $modlangpath, $modpath, $modlangpathOld, $modpathOld, $modlangpathOld2, $modpathOld2);
}
}
}
}
$ossrc = DataUtil::formatForOS($params['src']);
// search for the image