/** * 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; } }
/** * 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'); }
/** * 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(); }
/** * 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(); }
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); }
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); }
/** * 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; }
/** * 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')); }
/** * 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); }