public function test_addBreadcrumbLink() { $level = ob_get_level(); $xoops = Xoops::getInstance(); $theme_factory = new XoopsThemeFactory(); $theme = $theme_factory->createInstance(); $xoops->setTheme($theme); $template = new XoopsTpl(); $xoops->setTpl($template); $instance = new $this->myClass(); $instance->addBreadcrumbLink(); $x = $instance->renderBreadcrumb(); while (ob_get_level() > $level) { @ob_end_flush(); } $x = str_replace("\r\n", "\n", $x); $this->assertSame("<ul class=\"breadcrumb\">\n </ul>", $x); }
if ($xoops->isUser()) { foreach ($xoops->user->getGroups() as $group) { if (in_array($group, $xoops->getConfig('closesite_okgrp')) || FixedGroups::ADMIN == $group) { $allowed = true; break; } } } else { if (!empty($_POST['xoops_login'])) { include_once $xoops->path('include/checklogin.php'); exit; } } if (!$allowed) { $xoopsThemeFactory = null; $xoopsThemeFactory = new XoopsThemeFactory(); $xoopsThemeFactory->allowedThemes = $xoops->getConfig('theme_set_allowed'); $xoopsThemeFactory->defaultTheme = $xoops->getConfig('theme_set'); $xoops->setTheme($xoopsThemeFactory->createInstance(array('plugins' => array()))); unset($xoopsThemeFactory); $xoops->theme()->addScript('/include/xoops.js', array('type' => 'text/javascript')); $xoops->setTpl($xoops->theme()->template); $xoops->tpl()->assign(array('xoops_theme' => $xoops->getConfig('theme_set'), 'xoops_imageurl' => \XoopsBaseConfig::get('themes-url') . '/' . $xoops->getConfig('theme_set') . '/', 'xoops_themecss' => $xoops->getCss($xoops->getConfig('theme_set')), 'xoops_requesturi' => htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES), 'xoops_sitename' => htmlspecialchars($xoops->getConfig('sitename'), ENT_QUOTES), 'xoops_slogan' => htmlspecialchars($xoops->getConfig('slogan'), ENT_QUOTES), 'xoops_dirname' => $xoops->isModule() ? $xoops->module->getVar('dirname') : 'system', 'xoops_banner' => $xoops->getConfig('banners') ? $xoops->getBanner() : ' ', 'xoops_pagetitle' => $xoops->isModule() ? $xoops->module->getVar('name') : htmlspecialchars($xoops->getConfig('slogan'), ENT_QUOTES), 'lang_login' => XoopsLocale::A_LOGIN, 'lang_username' => XoopsLocale::C_USERNAME, 'lang_password' => XoopsLocale::C_PASSWORD, 'lang_siteclosemsg' => $xoops->getConfig('closesite_text'))); //todo check if we can use $xoops->getConfig() instead $config_handler = $xoops->getHandlerConfig(); $criteria = new CriteriaCompo(new Criteria('conf_modid', 1)); $criteria->add(new Criteria('conf_catid')); $config = $config_handler->getConfigs($criteria, true); foreach (array_keys($config) as $i) { $name = $config[$i]->getVar('conf_name', 'n'); $value = $config[$i]->getVar('conf_value', 'n');
/** * Function to redirect a user to certain pages * * @param string $url URL to redirect to * @param int $time time to wait (to allow reading message display) * @param string $message message to display * @param bool $addredirect add xoops_redirect parameter with current URL to the redirect * URL - used for return from login redirect * @param bool $allowExternalLink allow redirect to external URL * * @return void */ public function redirect($url, $time = 3, $message = '', $addredirect = true, $allowExternalLink = false) { $this->events()->triggerEvent('core.redirect.start', array($url, $time, $message, $addredirect, $allowExternalLink)); // if conditions are right, system preloads will exit on this call // so don't use it if you want to be called, use start version above. $this->events()->triggerEvent('core.include.functions.redirectheader', array($url, $time, $message, $addredirect, $allowExternalLink)); $xoops_url = \XoopsBaseConfig::get('url'); if (preg_match("/[\\0-\\31]|about:|script:/i", $url)) { if (!preg_match('/^\\b(java)?script:([\\s]*)history\\.go\\(-[0-9]*\\)([\\s]*[;]*[\\s]*)$/si', $url)) { $url = $xoops_url; } } if (!$allowExternalLink && ($pos = strpos($url, '://'))) { $xoopsLocation = substr($xoops_url, strpos($xoops_url, '://') + 3); if (strcasecmp(substr($url, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) { $url = $xoops_url; } } if (!defined('XOOPS_CPFUNC_LOADED')) { $theme = 'default'; } else { $theme = $this->getConfig('theme_set'); } $xoopsThemeFactory = null; $xoopsThemeFactory = new XoopsThemeFactory(); $xoopsThemeFactory->allowedThemes = $this->getConfig('theme_set_allowed'); $xoopsThemeFactory->defaultTheme = $theme; $this->setTheme($xoopsThemeFactory->createInstance(array("plugins" => array(), "renderBanner" => false))); $this->setTpl($this->theme()->template); $this->tpl()->assign(array('xoops_theme' => $theme, 'xoops_imageurl' => \XoopsBaseConfig::get('themes-url') . '/' . $theme . '/', 'xoops_themecss' => $this->getCss($theme), 'xoops_requesturi' => htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES), 'xoops_sitename' => htmlspecialchars($this->getConfig('sitename'), ENT_QUOTES), 'xoops_slogan' => htmlspecialchars($this->getConfig('slogan'), ENT_QUOTES), 'xoops_dirname' => $this->isModule() ? $this->module->getVar('dirname') : 'system', 'xoops_pagetitle' => $this->isModule() ? $this->module->getVar('name') : htmlspecialchars($this->getConfig('slogan'), ENT_QUOTES))); $this->tpl()->assign('time', (int) $time); if (!empty($_SERVER['REQUEST_URI']) && $addredirect && strstr($url, 'user.php')) { $joiner = false === strpos($url, '?') ? '?' : '&'; $url .= $joiner . 'xoops_redirect=' . urlencode($_SERVER['REQUEST_URI']); } $url = preg_replace("/&/i", '&', htmlspecialchars($url, ENT_QUOTES)); $this->tpl()->assign('url', $url); $message = trim($message) != '' ? $message : XoopsLocale::E_TAKING_YOU_BACK; $this->tpl()->assign('message', $message); $this->tpl()->assign('lang_ifnotreload', sprintf(XoopsLocale::F_IF_PAGE_NOT_RELOAD_CLICK_HERE, $url)); $this->events()->triggerEvent('core.include.functions.redirectheader.end'); $this->tpl()->display('module:system/system_redirect.tpl'); exit; }
public function createInstance($options = array()) { $xoops = \Xoops::getInstance(); $options["plugins"] = array(); $options['renderBanner'] = false; $inst = parent::createInstance($options); $inst->path = \XoopsBaseConfig::get('adminthemes-path') . '/' . $inst->folderName; $inst->url = \XoopsBaseConfig::get('adminthemes-url') . '/' . $inst->folderName; $inst->template->assign(array('theme_path' => $inst->path, 'theme_tpl' => $inst->path . '/xotpl', 'theme_url' => $inst->url, 'theme_img' => $inst->url . '/img', 'theme_icons' => $inst->url . '/icons', 'theme_css' => $inst->url . '/css', 'theme_js' => $inst->url . '/js', 'theme_lang' => $inst->url . '/language')); return $inst; }