本文整理汇总了PHP中ThemeUtil::getAllThemes方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemeUtil::getAllThemes方法的具体用法?PHP ThemeUtil::getAllThemes怎么用?PHP ThemeUtil::getAllThemes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThemeUtil
的用法示例。
在下文中一共展示了ThemeUtil::getAllThemes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_html_select_themes
/**
* Zikula_View function to display a drop down list of themes.
*
* Available parameters:
* - name: Name for the control (optional) if not present then only the option tags are output
* - id: ID for the control
* - selected: Selected value
* - filter: Filter themes use (possible values: ThemeUtil::FILTER_ALL (default) ThemeUtil::FILTER_USER, ThemeUtil::FILTER_SYSTEM, ThemeUtil::FILTER_ADMIN
* - state: Filter themes by state (possible values: ThemeUtil::STATE_ALL (default), ThemeUtil::STATE_ACTIVE, ThemeUtil::STATE_INACTIVE
* - type: Filter themes by type (possible values: ThemeUtil::TYPE_ALL (default), ThemeUtil::TYPE_XANTHIA3
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Examples
*
* {html_select_themes name=mytheme selected=mythemechoice}
*
* <select name="mytheme">
* <option value="">{ml name=_DEFAULT}</option>
* {html_select_themes selected=$mythemechoice}
* </select>
*
* @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 value of the last status message posted, or void if no status message exists.
*/
function smarty_function_html_select_themes($params, Zikula_View $view)
{
if (!isset($params['filter']) || !defined($params['filter'])) {
$filter = ThemeUtil::FILTER_ALL;
} else {
$filter = constant($params['filter']);
}
if (!isset($params['state']) || !defined($params['state'])) {
$state = ThemeUtil::STATE_ALL;
} else {
$state = constant($params['state']);
}
if (!isset($params['type']) || !defined($params['type'])) {
$type = ThemeUtil::TYPE_ALL;
} else {
$type = constant($params['type']);
}
$themelist = array();
$themes = ThemeUtil::getAllThemes($filter, $state, $type);
if (!empty($themes)) {
foreach ($themes as $theme) {
$themelist[$theme['name']] = $theme['displayname'];
}
}
natcasesort($themelist);
require_once $view->_get_plugin_filepath('function', 'html_options');
$output = smarty_function_html_options(array('options' => $themelist, 'selected' => isset($params['selected']) ? $params['selected'] : null, 'name' => isset($params['name']) ? $params['name'] : null, 'id' => isset($params['id']) ? $params['id'] : null), $view);
if (isset($params['assign'])) {
$view->assign($params['assign'], $output);
} else {
return $output;
}
}
示例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: handler
/**
* Event handler here.
*
* @param Zikula_Event $event Event handler.
*
* @return void
*/
public function handler(Zikula_Event $event)
{
// check if this is for this handler
$subject = $event->getSubject();
if (!($event['method'] == 'extensions' && $subject instanceof Users_Controller_Admin)) {
return;
}
if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Zikula Modules and Themes versions
$view = Zikula_View::getInstance('Users');
$view->assign('mods', ModuleUtil::getModules());
$view->assign('themes', ThemeUtil::getAllThemes());
$event->setData($view->fetch('users_admin_extensions.tpl'));
$event->stop();
}
示例4: handler
/**
* Event handler here.
*
* @param GenericEvent $event Event handler.
*
* @return void
*/
public function handler(GenericEvent $event)
{
// check if this is for this handler
$subject = $event->getSubject();
if (!($event['method'] == 'extensions' && $subject instanceof \Users\Controller\AdminController)) {
return;
}
if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) {
throw new \Zikula\Framework\Exception\ForbiddenException();
}
// Zikula Modules and Themes versions
$view = Zikula_View::getInstance('Users');
$view->assign('mods', ModUtil::getModules());
$view->assign('themes', ThemeUtil::getAllThemes());
$event->setData($view->fetch('users_admin_extensions.tpl'));
$event->stopPropagation();
}
示例5: getStylesheets
public static function getStylesheets()
{
$stylesheets = array();
$styles = array();
// restricted stylesheets, array for possible future changes
$sysStyles = array('system/Blocks/style/menutree/adminstyle.css', 'system/Blocks/style/menutree/contextmenu.css', 'system/Blocks/style/menutree/tree.css');
// module stylesheets
$modulesStyles = FileUtil::getFiles('system/Blocks/style/menutree', false, false, 'css', false);
$configStyles = FileUtil::getFiles('config/style/Blocks/menutree', false, false, 'css', false);
$styles['modules'] = array_merge($modulesStyles, $configStyles);
// themes stylesheets - get user and admin themes
$userThemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);
$adminThemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_ADMIN);
$themesStyles = array();
foreach ($userThemes as $ut) {
$themesStyles[$ut['name']] = FileUtil::getFiles('themes/' . $ut['name'] . '/style/Blocks/menutree', false, false, 'css', false);
}
foreach ($adminThemes as $at) {
if (!array_key_exists($at['name'], $themesStyles)) {
$themesStyles[$at['name']] = FileUtil::getFiles('themes/' . $at['name'] . '/style/Blocks/menutree', false, false, 'css', false);
}
}
// get stylesheets which exist in every theme
$styles['themes']['all'] = call_user_func_array('array_intersect', $themesStyles);
// get stylesheets which exist in some themes
$styles['themes']['some'] = array_unique(call_user_func_array('array_merge', $themesStyles));
$styles['themes']['some'] = array_diff($styles['themes']['some'], $styles['themes']['all'], $styles['modules'], $sysStyles);
$stylesheets = array_unique(array_merge($styles['modules'], $styles['themes']['all']));
$stylesheets = array_diff($stylesheets, $sysStyles);
sort($stylesheets);
// fill array keys using values
$stylesheets = array_combine($stylesheets, $stylesheets);
$someThemes = __('Only in some themes');
if (!empty($styles['themes']['some'])) {
sort($styles['themes']['some']);
$stylesheets[$someThemes] = array_combine($styles['themes']['some'], $styles['themes']['some']);
}
return self::normalize($stylesheets);
}
示例6: 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);
}
示例7: clear_cacheid_allthemes
/**
* Clears the cache for a specific cache_id's in all active themes.
*
* @param string $cache_ids Array of given cache ID's for which to clear theme cache.
* @param string $themes Array of theme objects for which to clear theme cache, defaults to all active themes.
*
* @return boolean True on success.
*/
public function clear_cacheid_allthemes($cache_ids, $themes = null)
{
if ($cache_ids) {
if (!is_array($cache_ids)) {
$cache_ids = array($cache_ids);
}
if (!$themes) {
$themes = ThemeUtil::getAllThemes();
}
$theme = Zikula_View_Theme::getInstance();
foreach ($themes as $themearr) {
foreach ($cache_ids as $cache_id) {
$theme->clear_cache(null, $cache_id, null, null, $themearr['directory']);
}
}
}
return true;
}
示例8: clear_cache
/**
* Clear theme engine cached templates
*
* Using this function, the admin can clear all theme engine cached
* templates for the system.
*/
public function clear_cache()
{
$csrftoken = FormUtil::getPassedValue('csrftoken');
$this->checkCsrfToken($csrftoken);
// Security check
if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
$cacheid = FormUtil::getPassedValue('cacheid');
$theme = Zikula_View_Theme::getInstance();
if ($cacheid) {
// clear cache for all active themes
$themesarr = ThemeUtil::getAllThemes();
foreach ($themesarr as $themearr) {
$themedir = $themearr['directory'];
$res = $theme->clear_cache(null, $cacheid, null, null, $themedir);
if ($res) {
LogUtil::registerStatus($this->__('Done! Deleted theme engine cached templates.').' '.$cacheid.', '.$themedir);
} else {
LogUtil::registerError($this->__('Error! Failed to clear theme engine cached templates.').' '.$cacheid.', '.$themedir);
}
}
} else {
// this clear all cache for all themes
$res = $theme->clear_all_cache();
if ($res) {
LogUtil::registerStatus($this->__('Done! Deleted theme engine cached templates.'));
} else {
LogUtil::registerError($this->__('Error! Failed to clear theme engine cached templates.'));
}
}
$this->redirect(ModUtil::url('Theme', 'admin', 'modifyconfig'));
}
示例9: pnThemeGetAllThemes
/**
* pnThemeGetAllThemes
*
* list all available themes
*
* possible values of filter are
* PNTHEME_FILTER_ALL - get all themes (default)
* PNTHEME_FILTER_USER - get user themes
* PNTHEME_FILTER_SYSTEM - get system themes
* PNTHEME_FILTER_ADMIN - get admin themes
*
* @param filter - filter list of returned themes by type
* @return array of available themes
**/
function pnThemeGetAllThemes($filter = PNTHEME_FILTER_ALL, $state = PNTHEME_STATE_ACTIVE, $type = PNTHEME_TYPE_ALL)
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array('pnThemeGetAllThemes()', 'ThemeUtil::getAllThemes()')), E_USER_DEPRECATED);
return ThemeUtil::getAllThemes($filter, $state, $type);
}