예제 #1
0
 public function test_addBreadcrumbLink()
 {
     $level = ob_get_level();
     $xoops = Xoops::getInstance();
     $theme_factory = new \Xoops\Core\Theme\Factory();
     $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);
 }
예제 #2
0
파일: Xoops.php 프로젝트: elitet/XoopsCore
 /**
  * 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 \Xoops\Core\Theme\Factory();
     $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, '?') ? '?' : '&amp;';
         $url .= $joiner . 'xoops_redirect=' . urlencode($_SERVER['REQUEST_URI']);
     }
     $url = preg_replace("/&amp;/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;
 }
예제 #3
0
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 \Xoops\Core\Theme\Factory();
    $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() : '&nbsp;', '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');