本文整理汇总了PHP中ThemeUtil类的典型用法代码示例。如果您正苦于以下问题:PHP ThemeUtil类的具体用法?PHP ThemeUtil怎么用?PHP ThemeUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThemeUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: pageLock
public function pageLock($args)
{
$lockName = $args['lockName'];
$returnUrl = (array_key_exists('returnUrl', $args) ? $args['returnUrl'] : null);
$ignoreEmptyLock = (array_key_exists('ignoreEmptyLock', $args) ? $args['ignoreEmptyLock'] : false);
$uname = UserUtil::getVar('uname');
$lockedHtml = '';
if (!empty($lockName) || !$ignoreEmptyLock) {
PageUtil::AddVar('javascript', 'zikula.ui');
PageUtil::AddVar('javascript', 'system/PageLock/javascript/pagelock.js');
PageUtil::AddVar('stylesheet', ThemeUtil::getModuleStylesheet('pagelock'));
$lockInfo = ModUtil::apiFunc('pagelock', 'user', 'requireLock',
array('lockName' => $lockName,
'lockedByTitle' => $uname,
'lockedByIPNo' => $_SERVER['REMOTE_ADDR']));
$hasLock = $lockInfo['hasLock'];
if (!$hasLock) {
$view = Zikula_View::getInstance('pagelock');
$view->assign('lockedBy', $lockInfo['lockedBy']);
$lockedHtml = $view->fetch('PageLock_lockedwindow.tpl');
}
} else {
$hasLock = true;
}
$html = "<script type=\"text/javascript\">/* <![CDATA[ */ \n";
if (!empty($lockName)) {
if ($hasLock) {
$html .= "document.observe('dom:loaded', PageLock.UnlockedPage);\n";
} else {
$html .= "document.observe('dom:loaded', PageLock.LockedPage);\n";
}
}
$lockedHtml = str_replace("\n", "", $lockedHtml);
$lockedHtml = str_replace("\r", "", $lockedHtml);
// Use "PageLockLifetime*2/3" to add a good margin to lock timeout when pinging
// disabled due to #2556 and #2745
// $returnUrl = DataUtil::formatForDisplayHTML($returnUrl);
$html .= "
PageLock.LockName = '$lockName';
PageLock.ReturnUrl = '$returnUrl';
PageLock.PingTime = " . (PageLockLifetime*2/3) . ";
PageLock.LockedHTML = '" . $lockedHtml . "';
/* ]]> */</script>";
PageUtil::addVar('header', $html);
return true;
}
示例3: 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;
}
}
示例4: smarty_function_admincategorymenu
/**
* Smarty function to display the category menu for admin links. This also adds the
* navtabs.css to the page vars array for stylesheets.
*
* Admin
* {admincategorymenu}
*
* @see function.admincategorymenu.php::smarty_function_admincategoreymenu()
* @param array $params All attributes passed to this function from the template
* @param object $view Reference to the Zikula_View object
* @return string the results of the module function
*/
function smarty_function_admincategorymenu($params, $view)
{
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Admin'));
$modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
$acid = ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
return ModUtil::func('AdminModule', 'admin', 'categorymenu', array('acid' => $acid));
}
示例5: 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');
}
示例6: _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;
}
示例7: 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;
}
示例8: smarty_function_admincategorymenu
/**
* Smarty function to display the category menu for admin links. This also adds the
* navtabs.css to the page vars array for stylesheets.
*
* Admin
* {admincategorymenu}
*
* @see function.admincategorymenu.php::smarty_function_admincategorymenu()
* @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 results of the module function
*/
function smarty_function_admincategorymenu($params, \Zikula_View $view)
{
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('ZikulaAdminModule'));
$modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
$acid = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
$path = array('_controller' => 'ZikulaAdminModule:Admin:categorymenu', 'acid' => $acid);
$subRequest = $view->getRequest()->duplicate(array(), null, $path);
return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
示例9: smarty_function_themesetvar
/**
* Plugin to set a variable on the theme
*
* This function set the corresponding value on a theme variable
*
* Available parameters:
* - name: Name of the variable
* - value: The value to set on the variable
*
* Example
* {themesetvar name='master' value='1col'} for Andreas08
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return mixed
*/
function smarty_function_themesetvar($params, Zikula_View $view)
{
$name = isset($params['name']) ? $params['name'] : null;
$value = isset($params['value']) ? $params['value'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('themegetvar', 'name')));
return false;
}
ThemeUtil::setVar($name, $value);
}
示例10: __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"));
}
}
示例11: smarty_function_themegetvar
/**
* Plugin to get a variable from the theme
*
* This function returns the corresponding value set on the theme
*
* Available parameters:
* - name: Name of the variable
* - default: If set, the default value to return if the variable is not set
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Example
* {themegetvar name='themepath'}
* {themegetvar name='scriptpath' assign='scriptpath'}
*
* @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 colour definition.
*/
function smarty_function_themegetvar($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$name = isset($params['name']) ? $params['name'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('themegetvar', 'name')));
return false;
}
$result = ThemeUtil::getVar($name, $default);
if ($assign) {
$view->assign($assign, $result);
} else {
return $result;
}
}
示例12: smarty_function_cotypeEditor
/**
* CoType
*
* @copyright (C) 2007, Jorn Wildt
* @link http://www.elfisk.dk
* @version $Id$
* @license See license.txt
*/
function smarty_function_cotypeEditor($params, &$render)
{
$inputId = $params['inputId'];
$documentId = (int) $params['documentId'];
static $firstTime = true;
if ($firstTime) {
PageUtil::AddVar('javascript', 'javascript/ajax/prototype.js');
$moduleStylesheet = '../../../../' . ThemeUtil::getModuleStylesheet('cotype', 'editor.css');
$url = System::getBaseUrl();
$head = "<script type=\"text/javascript\">\nCoTypeStylesheet = '{$moduleStylesheet}';\nCoTypeDocumentId = {$documentId};\n</script>";
PageUtil::AddVar('header', $head);
}
$firstTime = false;
$html = "";
return $html;
}
示例13: 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();
}
示例14: 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();
}
示例15: render
/**
* Render event handler.
*
* @param Zikula_Form_View $view Reference to Zikula_Form_View object.
*
* @return string The rendered output
*/
public function render(Zikula_Form_View $view)
{
static $firstTime = true;
if ($firstTime) {
PageUtil::addVar('javascript', 'prototype');
PageUtil::addVar('javascript', 'Zikula.UI');
// imageviewer
PageUtil::addVar('javascript', 'modules/Reviews/javascript/Reviews_finder.js');
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Reviews'));
}
$firstTime = false;
if (!SecurityUtil::checkPermission('Reviews:' . ucwords($this->objectType) . ':', '::', ACCESS_COMMENT)) {
return false;
}
$categorisableObjectTypes = array('review');
$catIds = array();
if (in_array($this->objectType, $categorisableObjectTypes)) {
// fetch selected categories to reselect them in the output
// the actual filtering is done inside the repository class
$catIds = ModUtil::apiFunc('Reviews', 'category', 'retrieveCategoriesFromRequest', array('ot' => $this->objectType));
}
$this->selectedItemId = $this->text;
$entityClass = 'Reviews_Entity_' . ucwords($this->objectType);
$serviceManager = ServiceUtil::getManager();
$entityManager = $serviceManager->getService('doctrine.entitymanager');
$repository = $entityManager->getRepository($entityClass);
$sort = $repository->getDefaultSortingField();
$sdir = 'asc';
// convenience vars to make code clearer
$where = '';
$sortParam = $sort . ' ' . $sdir;
$entities = $repository->selectWhere($where, $sortParam);
$view = Zikula_View::getInstance('Reviews', false);
$view->assign('objectType', $this->objectType)->assign('items', $entities)->assign('selectedId', $this->selectedItemId);
// assign category properties
$properties = null;
if (in_array($this->objectType, $categorisableObjectTypes)) {
$properties = ModUtil::apiFunc('Reviews', 'category', 'getAllProperties', array('ot' => $this->objectType));
}
$view->assign('properties', $properties)->assign('catIds', $catIds);
return $view->fetch('external/' . $this->objectType . '/select.tpl');
}