/** * 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; } }
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; }
/** * 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; } }
/** * 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)); }
/** * 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'); }
/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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); }
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")); } }
/** * 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; } }
/** * 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; }
/** * 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(); }
/** * 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(); }
/** * 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'); }
/** * bbsmiles * returns a html snippet with buttons for inserting bbsmiles into a text * * @param $args['textfieldid'] id of the textfield for inserting smilies */ public function bbsmiles($args) { if (!isset($args['textfieldid']) || empty($args['textfieldid'])) { return LogUtil::registerArgsError(); } // if we have more than one textarea we need to distinguish them, so we simply use // a counter stored in a session var until we find a better solution $counter = SessionUtil::getVar('bbsmile_counter', 0); $counter++; SessionUtil::setVar('bbsmile_counter', $counter); $this->view->assign('counter', $counter); $this->view->assign('textfieldid', $args['textfieldid']); PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('BBSmile')); $templatefile = DataUtil::formatForOS(ModUtil::getName()) . '.tpl'; if ($this->view->template_exists($templatefile)) { return $this->view->fetch($templatefile); } $this->view->add_core_data(); return $this->view->fetch('bbsmile_user_bbsmiles.tpl'); }
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); }
/** * Configure a theme's variables based on provided .yml definitions for each field. * @Route("/admin/var/{themeName}") * @todo change route name to /admin/variable/{themeName} when similar named is removed? * @Theme("admin") * * @param Request $request * @param string $themeName * @return mixed * @throws \InvalidArgumentException if theme type is not twig-based */ public function varAction(Request $request, $themeName) { $themeBundle = \ThemeUtil::getTheme($themeName); if (!$themeBundle->isTwigBased()) { throw new NotFoundHttpException('Theme type must be twig-based in ' . __FILE__ . ' at line ' . __LINE__ . '.'); } $themeVarsPath = $themeBundle->getConfigPath() . '/variables.yml'; if (!file_exists($themeVarsPath)) { $this->addFlash('warning', $this->__f('%theme% has no configuration.', array('%theme%' => $themeName))); return $this->redirect($this->generateUrl('zikulathememodule_admin_view')); } $variableDefinitions = Yaml::parse(file_get_contents($themeVarsPath)); /** @var \Symfony\Component\Form\FormBuilder $formBuilder */ $formBuilder = $this->createFormBuilder($themeBundle->getThemeVars()); foreach ($variableDefinitions as $fieldName => $definitions) { $options = isset($definitions['options']) ? $definitions['options'] : []; if (isset($definitions['type'])) { $formBuilder->add($fieldName, $definitions['type'], $options); } } $formBuilder->add('save', 'submit', array('label' => $this->__('Save'), 'icon' => 'fa-check fa-lg', 'attr' => array('class' => "btn btn-success")))->add('toDefault', 'submit', array('label' => $this->__('Set to defaults'), 'icon' => 'fa-refresh fa-lg', 'attr' => array('class' => "btn btn-primary")))->add('cancel', 'submit', array('label' => $this->__('Cancel'), 'icon' => 'fa-times fa-lg', 'attr' => array('class' => "btn btn-danger"))); $form = $formBuilder->getForm(); $form->handleRequest($request); if ($form->isValid()) { if ($form->get('save')->isClicked()) { // pseudo-hack to save theme vars in to modvars table \ModUtil::setVars($themeName, $form->getData()); $this->addFlash('status', $this->__('Done! Theme configuration updated.')); } elseif ($form->get('toDefault')->isClicked()) { \ModUtil::setVars($themeName, $themeBundle->getDefaultThemeVars()); $this->addFlash('status', $this->__('Done! Theme configuration updated to default values.')); } elseif ($form->get('cancel')->isClicked()) { $this->addFlash('status', $this->__('Operation cancelled.')); } return $this->redirect($this->generateUrl('zikulathememodule_admin_view')); } return $this->render('ZikulaThemeModule:Admin:var.html.twig', ['themeName' => $themeName, 'form' => $form->createView()]); }
static function setupPersonality() { $persona = self::getPersonality(); if (!isset($persona) || trim($persona) == '') { return; } ThemeUtil::printStyleSheetLink("personality/{$persona}/styles.css", "persona", true); $validBanner = ThemeUtil::exists("/personality/" . $persona . "/banner.png"); $validFooter = ThemeUtil::exists("/personality/" . $persona . "/footer.png"); echo "<!-- setting up persona: {$persona} : {$validFooter} ; {$validBanner} -->"; if ($validFooter || $validBanner) { echo "<style>\n"; if ($validBanner) { $banner = WEBPATH . "/themes/" . basename(dirname(dirname(__FILE__))) . "/personality/" . $persona . "/banner.png"; echo "#banner {\t\n" . "\tbackground: transparent url({$banner}) no-repeat 0 -10px; \n" . "} \n"; } if ($validFooter) { $footer = WEBPATH . "/themes/" . basename(dirname(dirname(__FILE__))) . "/personality/" . $persona . "/footer.png"; echo "#footer {\t\n" . "\tbackground: transparent url({$footer}) no-repeat 0 -10px; \n" . "} \n"; } echo "</style> \n"; } }
public function initialize(Zikula_Form_View $view) { if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission()); } // Include categories only when 2nd category enabled in settings $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => array('checkActive' => false, 'expandedPageIds' => SessionUtil::getVar('contentExpandedPageIds', array())), 'enableEscape' => true, 'translate' => false, 'includeLanguages' => true, 'includeCategories' => $this->getVar('categoryUsage') < 3, 'orderBy' => 'setLeft')); if ($pages === false) { return $this->view->registerError(null); } // Get categories names if enabled if ($this->getVar('$categoryUsage') < 4) { $lang = ZLanguage::getLanguageCode(); $categories = array(); foreach ($pages as $page) { $cat = CategoryUtil::getCategoryByID($page['categoryId']); $categories[$page['id']] = array(); $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name']; if (isset($page['categories']) && is_array($page['categories'])) { foreach ($page['categories'] as $pageCat) { $cat = CategoryUtil::getCategoryByID($pageCat['categoryId']); $categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name']; } } } $this->view->assign('categories', $categories); } PageUtil::setVar('title', $this->__('Page list and content structure')); $csssrc = ThemeUtil::getModuleStylesheet('admin', 'admin.css'); PageUtil::addVar('stylesheet', $csssrc); $this->view->assign('pages', $pages); $this->view->assign('multilingual', ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual')); $this->view->assign('enableVersioning', $this->getVar('enableVersioning')); $this->view->assign('language', ZLanguage::getLanguageCode()); Content_Util::contentAddAccess($this->view, null); return true; }
<div class='date' day="<?php echo zpFormattedDate('%e', $dt); ?> " month="<?php echo zpFormattedDate('%b', $dt); ?> " year="<?php echo zpFormattedDate('%Y', $dt); ?> "/> <div class='content'><?php echo getNewsContent(); ?> </div> <div class='categories'><?php echo ThemeUtil::clean(NewsUtil::printNewsCategories(',', false, false), FALSE); ?> </div> <div class='preview'><?php echo ThemeUtil::clean(getNewsContent(), FALSE, 120, FALSE); ?> </div> </div> <?php $u++; } ?> </div>
/** * Decode the path string into a set of variable/value pairs. * * This API works in conjunction with the new short urls * system to extract a path based variable set into the Get, Post * and request superglobals. * A sample path is /modname/function/var1:value1. * * @return void */ public static function queryStringDecode() { if (self::isInstalling()) { return; } // get our base parameters to work out if we need to decode the url $module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING); $func = FormUtil::getPassedValue('func', null, 'GETPOST', FILTER_SANITIZE_STRING); $type = FormUtil::getPassedValue('type', null, 'GETPOST', FILTER_SANITIZE_STRING); // check if we need to decode the url if (self::getVar('shorturls') && (empty($module) && empty($type) && empty($func))) { // user language is not set at this stage $lang = System::getVar('language_i18n', ''); $customentrypoint = self::getVar('entrypoint'); $expectEntrypoint = !self::getVar('shorturlsstripentrypoint'); $root = empty($customentrypoint) ? 'index.php' : $customentrypoint; // check if we hit baseurl, e.g. domain.com/ and if we require the language URL // then we should redirect to the language URL. if (ZLanguage::isRequiredLangParam() && self::getCurrentUrl() == self::getBaseUrl()) { $uri = $expectEntrypoint ? "{$root}/{$lang}" : "{$lang}"; self::redirect(self::getBaseUrl() . $uri); self::shutDown(); } // check if entry point is part of the URL expectation. If so throw error if it's not present // since this URL is technically invalid. if ($expectEntrypoint && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) !== 0) { $protocol = System::serverGetVar('SERVER_PROTOCOL'); header("{$protocol} 404 Not Found"); echo __('The requested URL cannot be found'); system::shutDown(); } if (!$expectEntrypoint && self::getCurrentUrl() == self::getBaseUrl() . $root) { self::redirect(self::getHomepageUrl()); self::shutDown(); } if (!$expectEntrypoint && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) === 0) { $protocol = System::serverGetVar('SERVER_PROTOCOL'); header("{$protocol} 404 Not Found"); echo __('The requested URL cannot be found'); system::shutDown(); } // get base path to work out our current url $parsedURL = parse_url(self::getCurrentUri()); // strip any unwanted content from the provided URL $tobestripped = array(self::getBaseUri(), "{$root}"); $path = str_replace($tobestripped, '', $parsedURL['path']); $path = trim($path, '/'); // split the path into a set of argument strings $args = explode('/', rtrim($path, '/')); // ensure that each argument is properly decoded foreach ($args as $k => $v) { $args[$k] = urldecode($v); } $modinfo = null; $frontController = $expectEntrypoint ? "{$root}/" : ''; // if no arguments present if (!$args[0] && !isset($_GET['lang']) && !isset($_GET['theme'])) { // we are in the homepage, checks if language code is forced if (ZLanguage::getLangUrlRule() && $lang) { // and redirect then $response = new RedirectResponse(self::getCurrentUrl() . "/{$lang}"); $respose->send(); System::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); } $response = new RedirectResponse(self::getBaseUrl() . $frontController . ($args ? implode('/', $args) : '')); $respose->send(); System::shutDown(); } self::queryStringSetVar('lang', $args[0]); 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; $response = new RedirectResponse(self::getBaseUrl() . $frontController . $langTheme . '/' . implode('/', $args)); $response->send(); System::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']); // 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, ''); // support for 1.2- empty parameter due the initial explode array_unshift($args, $modinfo['url']); // set the REQUEST parameters self::queryStringSetVar('module', $modinfo['name']); // the user.function name can be the second argument string, set a default // later the custom module handler (if exists) must setup a new one if needed self::queryStringSetVar('type', 'user'); if (isset($args[2])) { self::queryStringSetVar('func', $args[2]); } else { self::queryStringSetVar('func', 'index'); } if (!ModUtil::apiFunc($modinfo['name'], 'user', 'decodeurl', array('vars' => $args))) { // any remaining arguments are specific to the module $argscount = count($args); for ($i = 3; $i < $argscount; $i = $i + 2) { if (isset($args[$i]) && isset($args[$i + 1])) { self::queryStringSetVar($args[$i], urldecode($args[$i + 1])); } } } } } }
function render(&$render) { $dom = ZLanguage::getModuleDomain('mediashare'); PageUtil::AddVar('javascript', 'javascript/ajax/prototype.js'); PageUtil::AddVar('javascript', 'javascript/ajax/scriptaculous.js'); PageUtil::AddVar('javascript', 'javascript/ajax/pnajax.js'); PageUtil::AddVar('javascript', 'javascript/ajax/lightbox.js'); PageUtil::AddVar('stylesheet', 'javascript/ajax/lightbox/lightbox.css'); PageUtil::AddVar('javascript', 'modules/mediashare/pnjavascript/finditem.js'); PageUtil::AddVar('stylesheet', ThemeUtil::getModuleStylesheet('mediashare')); $thumbnailSize = (int) pnModGetVar('mediashare', 'thumbnailSize') + 10; $html = "<div class=\"mediashareItemSelector\">\n<table><tr>\n"; $mediadir = pnModAPIFunc('mediashare', 'user', 'getRelativeMediadir'); if (!($albums = pnModAPIFunc('mediashare', 'user', 'getAllAlbums', array('albumId' => 1)))) { return false; } if ($this->selectedItemId != null) { $mediaItem = pnModAPIFunc('mediashare', 'user', 'getMediaItem', array('mediaId' => $this->selectedItemId)); if ($mediaItem === false) { return false; } $selectedMediaId = $mediaItem['id']; $selectedAlbumId = $mediaItem['parentAlbumId']; } else { $mediaItem = null; $selectedMediaId = null; $selectedAlbumId = count($albums) > 0 ? $albums[0]['id'] : null; } $imgSrc = null; $itemOptionsHtml = ''; if ($selectedAlbumId != null) { $items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => $selectedAlbumId)); foreach ($items as $item) { if ($selectedMediaId == null) { $selectedMediaId = $item['id']; } if ($selectedMediaId == $item['id']) { $imgSrc = $mediadir . $item['thumbnailRef']; $selected = ' selected="selected"'; } else { $selected = ''; } $itemOptionsHtml .= "<option value=\"{$item['id']}\"{$selected}>" . DataUtil::formatForDisplay($item['title']) . "</option>\n"; } } $html .= "<td class=\"img\" style=\"height: {$thumbnailSize}px; width: {$thumbnailSize}px;\">\n"; if ($imgSrc != null) { $imgStyle = ''; } else { $imgStyle = ' style="display: none"'; } $html .= "<img id=\"{$this->id}_img\" src=\"{$imgSrc}\" alt=\"\"{$imgStyle}/><br/>\n"; $html .= "</td>\n"; $html .= "<td class=\"selector\">\n"; $html .= "<label for=\"{$this->id}_album\">" . __('Album', $dom) . "</label><br/>"; $html .= "<select id=\"{$this->id}_album\" name=\"{$this->inputName}_album\" onchange=\"mediashare.itemSelector.albumChanged(this,'{$this->id}', '" . $mediadir . "')\">\n"; foreach ($albums as $album) { $title = ''; for ($i = 1, $cou = (int) $album['nestedSetLevel']; $i < $cou; ++$i) { $title .= '+ '; } if ($selectedAlbumId == $album['id']) { $selected = ' selected="selected"'; } else { $selected = ''; } $html .= "<option value=\"{$album['id']}\"{$selected}>" . $title . DataUtil::formatForDisplay($album['title']) . "</option>\n"; } $html .= "</select><br/>\n"; $html .= "<label for=\"{$this->id}_item\">" . __('Media item', $dom) . "</label><br/> "; $html .= "<select id=\"{$this->id}_item\" name=\"{$this->inputName}\" onchange=\"mediashare.itemSelector.itemChanged(this,'{$this->id}', '" . $mediadir . "')\">\n"; if ($selectedAlbumId != null) { $items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => $selectedAlbumId)); $html .= $itemOptionsHtml; } $html .= "</select>"; $html .= "</td></tr>\n"; if ($this->enableUpload) { $html .= "<tr><td colspan=\"2\"><a href=\"javascript:void(0)\" id=\"mediashare_upload_collapse\">" . __('Upload', $dom) . "</a><div id=\"mediashare_upload\">\n"; $html .= __('Select an item or upload a file directly', $dom) . '<br/>'; $html .= "<label for=\"{$this->id}_upload\">" . __('Upload', $dom) . "</label>\n"; $html .= "<input type=\"file\" id=\"{$this->id}_upload\" name=\"{$this->inputName}_upload\" class=\"file\"/>\n"; if ($this->enableAddAlbum) { $html .= '<br/>' . __('Optional name of a new album to place the upload in', $dom) . '<br/>'; $html .= "<label for=\"{$this->id}_newalbum\">" . __('Album', $dom) . "</label>\n"; $html .= "<input type=\"text\" id=\"{$this->id}_newalbum\" name=\"{$this->inputName}_newalbum\"/>\n"; } $html .= "</div></td></tr>\n"; } $html .= "</table>\n"; $html .= "<script type=\"text/javascript\">Event.observe(window,'load',function(){mediashare.itemSelector.onLoad('{$this->id}');});\n</script>\n"; $html .= "</div>\n"; return $html; }
public static function getWebPath() { return null === ThemeUtil::getThemeDir() ? null : ThemeUtil::getThemeDir(); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_READ)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // template to use if (empty($vars['template'])) { $vars['template'] = 'blocks_block_extmenu.tpl'; } // stylesheet to use if (empty($vars['stylesheet'])) { $vars['stylesheet'] = 'extmenu.css'; } // add the stylesheet to the header PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Blocks', $vars['stylesheet'])); // if cache is enabled, checks for a cached output if ($this->view->getCaching()) { // set the cache id $this->view->setCacheId($blockinfo['bkey'] . '/bid' . $blockinfo['bid'] . '/' . UserUtil::getGidCacheString()); // check out if the contents are cached if ($this->view->is_cached($vars['template'])) { $blockinfo['content'] = $this->view->fetch($vars['template']); return BlockUtil::themeBlock($blockinfo); } } // create default block variables if (!isset($vars['blocktitles'])) { $vars['blocktitles'] = array(); } if (!isset($vars['links'])) { $vars['links'] = array(); } if (!isset($vars['stylesheet'])) { $vars['stylesheet'] = ''; } if (!isset($vars['menuid'])) { $vars['menuid'] = 0; } // get language and default to en $thislang = ZLanguage::getLanguageCode(); if (!array_key_exists($thislang, $vars['links'])) { $thislang = 'en'; } // if specific blocktitle for selected language exists, use it if (array_key_exists($thislang, $vars['blocktitles']) && !empty($vars['blocktitles'][$thislang])) { $blockinfo['title'] = $vars['blocktitles'][$thislang]; } // Content $menuitems = array(); if (!empty($vars['links'][$thislang])) { $blocked = array(); foreach ($vars['links'][$thislang] as $linkid => $link) { $link['parentid'] = isset($link['parentid']) ? $link['parentid'] : null; $denied = !SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . ':' . $linkid . ':', ACCESS_READ); if ($denied || !is_null($link['parentid']) && in_array($link['parentid'], $blocked)) { $blocked[] = $linkid; } elseif (!isset($link['active']) || $link['active'] != '1') { $blocked[] = $linkid; } else { // pre zk1.2 check if (!isset($link['id'])) { $link['id'] = $linkid; } $link['url'] = ModUtil::apiFunc('Blocks', 'user', 'encodebracketurl', $link['url']); // check for multiple options in image $this->checkImage($link); $menuitems[] = $link; } } } // Modules if (!empty($vars['displaymodules'])) { $newmods = ModUtil::getUserMods(); $mods = array(); foreach ($newmods as $module) { if (!preg_match('#(?:error|blocks)#', strtolower($module['name']))) { $mods[] = $module; } } // Separate from current content, if any if (count($menuitems) > 0) { $menuitems[] = array('name' => ' ', 'url' => '', 'title' => '', 'level' => 0, 'parentid' => null, 'image' => ''); if (SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_ADMIN)) { $menuitems[] = array('name' => $this->__('--Installed modules--'), 'url' => ModUtil::url('Blocks', 'admin', 'modify', array('bid' => $blockinfo['bid'])), 'title' => '', 'level' => 0, 'parentid' => null, 'image' => ''); } } foreach ($mods as $mod) { // prepare image if (SecurityUtil::checkPermission("{$mod['name']}::", '::', ACCESS_OVERVIEW)) { $menuitems[] = array('name' => $mod['displayname'], 'url' => ModUtil::url($mod['name'], 'user', 'main'), 'title' => $mod['description'], 'level' => 0, 'parentid' => null, 'image' => ''); } } } // check for any empty result set if (empty($menuitems)) { return; } $currenturi = urlencode(str_replace(System::getBaseUri() . '/', '', System::getCurrentUri())); // assign the items $this->view->assign('menuitems', $menuitems)->assign('blockinfo', $blockinfo)->assign('currenturi', $currenturi)->assign('access_edit', Securityutil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_EDIT)); // get the block content $blockinfo['content'] = $this->view->fetch($vars['template']); // pass the block array back to the theme for display return BlockUtil::themeBlock($blockinfo); }
/** * Get the user's theme. * * This function will return the current theme for the user. * Order of theme priority: * - page-specific * - category * - user * - system * * @param boolean $force True to ignore the cache. * * @return string the name of the user's theme * @throws RuntimeException If this function was unable to calculate theme name. */ public static function getTheme($force = false) { static $theme; if (isset($theme) && !$force) { return $theme; } // Page-specific theme $request = ServiceUtil::get('request'); $pagetheme = $request->get('theme', null); $type = $request->attributes->get('_controller', null); if (!empty($pagetheme)) { $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($pagetheme)); if ($themeinfo['state'] == ThemeUtil::STATE_ACTIVE && ($themeinfo['user'] || $themeinfo['system'] || $themeinfo['admin'] && $type == 'admin') && is_dir(ZIKULA_ROOT . '/themes/' . DataUtil::formatForOS($themeinfo['directory']))) { return self::_getThemeFilterEvent($themeinfo['name'], 'page-specific'); } } // check for an admin theme if (($type == 'admin' || $type == 'adminplugin') && SecurityUtil::checkPermission('::', '::', ACCESS_EDIT)) { $admintheme = ModUtil::getVar('Admin', 'admintheme'); if (!empty($admintheme)) { $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($admintheme)); if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir(ZIKULA_ROOT . '/themes/' . DataUtil::formatForOS($themeinfo['directory']))) { return self::_getThemeFilterEvent($themeinfo['name'], 'admin-theme'); } } } // set a new theme for the user $session = $request->getSession(); $newtheme = $request->get('newtheme'); if (!empty($newtheme) && System::getVar('theme_change')) { $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($newtheme)); if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir(ZIKULA_ROOT . '/themes/' . DataUtil::formatForOS($themeinfo['directory']))) { if (self::isLoggedIn()) { self::setVar('theme', $newtheme); } else { $session->set('theme', $newtheme); } return self::_getThemeFilterEvent($themeinfo['name'], 'new-theme'); } } // User theme if (System::getVar('theme_change') || SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) { if (self::isLoggedIn()) { $usertheme = self::getVar('theme'); } else { $usertheme = $session->get('theme'); } $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($usertheme)); if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir(ZIKULA_ROOT . '/themes/' . DataUtil::formatForOS($themeinfo['directory']))) { return self::_getThemeFilterEvent($themeinfo['name'], 'user-theme'); } } // default site theme $defaulttheme = System::getVar('Default_Theme'); $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($defaulttheme)); if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir(ZIKULA_ROOT . '/themes/' . DataUtil::formatForOS($themeinfo['directory']))) { return self::_getThemeFilterEvent($themeinfo['name'], 'default-theme'); } if (!System::isInstalling()) { throw new RuntimeException(__('UserUtil::getTheme() is unable to calculate theme name.')); } }
?> found </div> <?php echo $prevNext['prev']; ?> <div id="image-thumb-container"> <?php $u = 0; while (next_image()) { $imageTitle = getImageTitle(); $size = getSizeCustomImage(NULL, 383); $desc = getImageDesc(); if (!empty($desc)) { $desc = ThemeUtil::clean($desc); } else { $desc = ''; } ThemeUtil::$script .= "images.push({" . " title: '{$imageTitle}', \n" . " description: '{$desc}', \n" . " location: '" . getCustomImageURL(NULL, 383) . "', \n" . " url: '" . getFullImageURL() . "',\n" . " width: " . $size[0] . ",\n" . " height: " . $size[1] . "\n" . "});\n"; if (isset($_highlight_image) && $_highlight_image == $_zp_current_image->filename) { ThemeUtil::$script .= "initialImageThumbSelection = {$u}; \n"; } ?> <div class="image-thumb left opa60 <?php echo $u % 2 == 0 ? 'even' : 'odd'; ?> "> <img index="<?php echo $u;
echo getRandomImages()->getCustomImage(NULL, 192, 48, 192, 48, NULL, null, false); ?> " width="195" height="48"/> </div> </div> <div id="page-date" class="opa60"> <?php echo NewsUtil::printPageLastChangeDate(); ?> </div> <?php $codeBlock = getCodeblock(2); if (isset($codeBlock) && ThemeUtil::clean($codeBlock, false) != '') { ?> <div id="album-description" class="page opa60"> <?php printCodeBlock(2); ?> </div> <?php } ?> <div id="page-filler" class="opa20"> </div> </div>
/** * Zikula_View function to provide easy access to an image * * This function provides an easy way to include an image. The function will return the * full source path to the image. It will as well provite the width and height attributes * if none are set. * * Available parameters: * - src The file name of the image * - modname The well-known name of a module (default: the current module) * - modplugin The name of the plugin in the passed module * - sysplugin The name of the system plugin * - width, height If set, they will be passed. If none is set, they are obtained from the image * - alt If not set, an empty string is being assigned * - title If set it will be passed as a title attribute * - assign If set, the results are assigned to the corresponding variable instead of printed out * - optional If set then the plugin will not return an error if an image is not found * - default If set then a default image is used should the requested image not be found (Note: full path required) * - set If modname is 'core' then the set parameter is set to define the directory in /images/ * - nostoponerror If set and error ocurs (image not found or src is no image), do not trigger_error, but return false * - retval If set indicated the field to return instead the array of values (src, width, etc.) * - fqurl If set the image path is absolute, if not relative * - all remaining parameters are passed to the image tag * * Example: {img src='heading.png'} * Output: <img src="modules/Example/images/en/heading.png" alt="" width="261" height="69" /> * * Example: {img src='heading.png' width='100' border='1' __alt='foobar'} * Output: <img src="modules/Example/images/en/heading.png" width="100" border="1" alt="foobar" /> * * Example: {img src='xhtml11.png' modname='core' set='powered'} * Output: <img src="themes/Theme/images/powered/xhtml11.png" alt="" width="88" height="31" /> * * Example: {img src='iconX.png' modname='ModName' modplugin='Plug1' set='icons'} * Output: <img src="modules/ModName/plugins/Plug1/images/icons/iconX.png" alt="" width="16" height="16" /> * * Example: {img src='iconY.png' sysplugin='Plug2' set='icons/small'} * Output: <img src="plugins/Plug2/images/icons/small/iconY.png" alt="" width="16" height="16" /> * * If the parameter assign is set, the results are assigned as an array. The components of * this array are the same as the attributes of the img tag; additionally an entry 'imgtag' is * set to the complete image tag. * * Example: * {img src="heading.png" assign="myvar"} * {$myvar.src} * {$myvar.width} * {$myvar.imgtag} * * Output: * modules/Example/images/en/heading.gif * 261 * <img src="modules/Example/images/en/heading.gif" alt="" width="261" height="69" /> * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string|void The img tag, null if $params['nostoponerror'] true and there is an error. */ function smarty_function_img($params, Zikula_View $view) { $nostoponerror = isset($params['nostoponerror']) && $params['nostoponerror'] ? true : false; if (!isset($params['src']) || !$params['src']) { if (!$nostoponerror) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'src'))); return; } else { return false; } } // process the image location $modname = isset($params['modname']) ? $params['modname'] : $view->toplevelmodule; $modplugin = isset($params['modplugin']) ? $params['modplugin'] : null; $sysplugin = isset($params['sysplugin']) ? $params['sysplugin'] : null; // process the image set $set = isset($params['set']) ? $params['set'] : null; $osset = DataUtil::formatForOS($set); // if the module name is 'core' if ($modname == 'core') { if (System::isLegacyMode() && (strpos($osset, 'icons/') !== false || strpos($osset, 'global/') !== false) && strpos($params['src'], '.gif')) { LogUtil::log(__f('Core image %s does not exist, please use the png format (called from %s).', array($params['src'], $view->getTemplatePath())), E_USER_DEPRECATED); $params['src'] = str_replace('.gif', '.png', $params['src']); } } // 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 $imgsrc = ''; foreach ($paths as $path) { $fullpath = $path . ($osset ? "/{$osset}/" : '/') . $ossrc; if (is_readable($fullpath)) { $imgsrc = $fullpath; break; } } if ($imgsrc == '' && isset($params['default'])) { $imgsrc = $params['default']; } // default for the optional flag $optional = isset($params['optional']) ? $params['optional'] : true; if ($imgsrc == '') { if ($optional) { if (!$nostoponerror) { $view->trigger_error(__f("%s: Image '%s' not found", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src'])))); return; } else { return false; } } return; } // If neither width nor height is set, get these parameters. // If one of them is set, we do NOT obtain the real dimensions. // This way it is easy to scale the image to a certain dimension. if (!isset($params['width']) && !isset($params['height'])) { if (!($_image_data = @getimagesize($imgsrc))) { if (!$nostoponerror) { $view->trigger_error(__f("%s: Image '%s' is not a valid image file", array('img', DataUtil::formatForDisplay(($set ? "{$set}/" : '') . $params['src'])))); return; } else { return false; } } $params['width'] = $_image_data[0]; $params['height'] = $_image_data[1]; } $basepath = isset($params['fqurl']) && $params['fqurl'] ? System::getBaseUrl() : System::getBaseUri(); $params['src'] = $basepath . '/' . $imgsrc; $retval = isset($params['retval']) ? $params['retval'] : null; $assign = isset($params['assign']) ? $params['assign'] : null; unset($params['modname']); unset($params['retval']); unset($params['assign']); if (isset($params['altml'])) { // legacy unset($params['altml']); } if (isset($params['titleml'])) { // legacy unset($params['titleml']); } unset($params['optional']); unset($params['default']); unset($params['set']); unset($params['nostoponerror']); unset($params['fqurl']); $imgtag = '<img '; foreach ($params as $key => $value) { $imgtag .= $key . '="' . $value . '" '; } $imgtag .= '/>'; if (!empty($retval) && isset($params[$retval])) { return $params[$retval]; } elseif (!empty($assign)) { $params['imgtag'] = $imgtag; $view->assign($assign, $params); } else { return $imgtag; } }
/** * Run a module function. * * @param string $modname The name of the module. * @param string $type The type of function to run. * @param string $func The specific function to run. * @param array $args The arguments to pass to the function. * @param boolean $api Whether or not to execute an API (or regular) function. * @param string $instanceof Perform instanceof checking of target class. * * @throws Zikula_Exception_NotFound If method was not found. * @throws InvalidArgumentException If the controller is not an instance of the class specified in $instanceof. * * @return mixed. */ public static function exec($modname, $type = 'user', $func = 'main', $args = array(), $api = false, $instanceof = null) { // define input, all numbers and booleans to strings $modname = isset($modname) ? (string) $modname : ''; $ftype = $api ? 'api' : ''; $loadfunc = $api ? 'ModUtil::loadApi' : 'ModUtil::load'; // validate if (!System::varValidate($modname, 'mod')) { return null; } // Remove from 1.4 if (System::isLegacyMode() && $modname == 'Modules') { LogUtil::log(__('Warning! "Modules" module has been renamed to "Extensions". Please update your ModUtil::func() and ModUtil::apiFunc() calls.')); $modname = 'Extensions'; } $modinfo = self::getInfo(self::getIDFromName($modname)); $path = $modinfo['type'] == self::TYPE_SYSTEM ? 'system' : 'modules'; $controller = null; $modfunc = null; $loaded = call_user_func_array($loadfunc, array($modname, $type)); if (self::isOO($modname)) { $result = self::getCallable($modname, $type, $func, $api); if ($result) { $modfunc = $result['callable']; $controller = $modfunc[0]; if (!is_null($instanceof)) { if (!$controller instanceof $instanceof) { throw new InvalidArgumentException(__f('%1$s must be an instance of $2$s', array(get_class($controller), $instanceof))); } } } } $modfunc = $modfunc ? $modfunc : "{$modname}_{$type}{$ftype}_{$func}"; $eventManager = EventUtil::getManager(); if ($loaded) { $preExecuteEvent = new Zikula_Event('module_dispatch.preexecute', $controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); $postExecuteEvent = new Zikula_Event('module_dispatch.postexecute', $controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); if (is_callable($modfunc)) { $eventManager->notify($preExecuteEvent); // Check $modfunc is an object instance (OO) or a function (old) if (is_array($modfunc)) { if ($modfunc[0] instanceof Zikula_AbstractController) { $reflection = call_user_func(array($modfunc[0], 'getReflection')); $subclassOfReflection = new ReflectionClass($reflection->getParentClass()); if ($subclassOfReflection->hasMethod($modfunc[1])) { // Don't allow front controller to access any public methods inside the controller's parents throw new Zikula_Exception_NotFound(); } $modfunc[0]->preDispatch(); } $postExecuteEvent->setData(call_user_func($modfunc, $args)); if ($modfunc[0] instanceof Zikula_AbstractController) { $modfunc[0]->postDispatch(); } } else { $postExecuteEvent->setData($modfunc($args)); } return $eventManager->notify($postExecuteEvent)->getData(); } // get the theme if (ServiceUtil::getManager()->getService('zikula')->getStage() & Zikula_Core::STAGE_THEME) { $theme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); if (file_exists($file = 'themes/' . $theme['directory'] . '/functions/' . $modname . "/{$type}{$ftype}/{$func}.php") || file_exists($file = 'themes/' . $theme['directory'] . '/functions/' . $modname . "/pn{$type}{$ftype}/{$func}.php")) { include_once $file; if (function_exists($modfunc)) { EventUtil::notify($preExecuteEvent); $postExecuteEvent->setData($modfunc($args)); return EventUtil::notify($postExecuteEvent)->getData(); } } } if (file_exists($file = "config/functions/{$modname}/{$type}{$ftype}/{$func}.php") || file_exists($file = "config/functions/{$modname}/pn{$type}{$ftype}/{$func}.php")) { include_once $file; if (is_callable($modfunc)) { $eventManager->notify($preExecuteEvent); $postExecuteEvent->setData($modfunc($args)); return $eventManager->notify($postExecuteEvent)->getData(); } } if (file_exists($file = "{$path}/{$modname}/{$type}{$ftype}/{$func}.php") || file_exists($file = "{$path}/{$modname}/pn{$type}{$ftype}/{$func}.php")) { include_once $file; if (is_callable($modfunc)) { $eventManager->notify($preExecuteEvent); $postExecuteEvent->setData($modfunc($args)); return $eventManager->notify($postExecuteEvent)->getData(); } } // try to load plugin // This kind of eventhandler should // 1. Check $event['modfunc'] to see if it should run else exit silently. // 2. Do something like $result = {$event['modfunc']}({$event['args'}); // 3. Save the result $event->setData($result). // 4. $event->setNotify(). // return void // This event means that no $type was found $event = new Zikula_Event('module_dispatch.type_not_found', null, array('modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), false); $eventManager->notify($event); if ($preExecuteEvent->isStopped()) { return $preExecuteEvent->getData(); } return false; } // Issue not found exception for controller requests if (!System::isLegacyMode() && !$api) { throw new Zikula_Exception_NotFound(__f('The requested controller action %s_Controller_%s::%s() could not be found', array($modname, $type, $func))); } }