예제 #1
0
 /**
  * XoopsThemeBlocksPlugin::buildBlock()
  *
  * @param XoopsBlock $xobject
  * @param XoopsTpl $template
  * @return array|bool
  */
 public function buildBlock($xobject, &$template)
 {
     $xoops = Xoops::getInstance();
     // The lame type workaround will change
     // bid is added temporarily as workaround for specific block manipulation
     $dirname = $xobject->getVar('dirname');
     $block = array('id' => $xobject->getVar('bid'), 'module' => $dirname, 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
     $bcachetime = (int) $xobject->getVar('bcachetime');
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($dirname);
     $tplName = ($tplName = $xobject->getVar('template')) ? "block:{$dirname}/{$tplName}" : "module:system/system_block_dummy.tpl";
     //$tplName = str_replace('.html', '.tpl', $tplName);
     $cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
     $xoops->preload()->triggerEvent('core.themeblocks.buildblock.start', array($xobject, $template->isCached($tplName, $cacheid)));
     if (!$bcachetime || !$template->isCached($tplName, $cacheid)) {
         //Get theme metas
         $old = array();
         if ($this->theme && $bcachetime) {
             foreach ($this->theme->metas as $type => $value) {
                 $old[$type] = $this->theme->metas[$type];
             }
         }
         //build block
         if ($bresult = $xobject->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
         //check if theme added new metas
         if ($this->theme && $bcachetime) {
             $metas = array();
             foreach ($this->theme->metas as $type => $value) {
                 $dif = Xoops_Utils::arrayRecursiveDiff($this->theme->metas[$type], $old[$type]);
                 if (count($dif)) {
                     $metas[$type] = $dif;
                 }
             }
             if (count($metas)) {
                 Xoops_Cache::write($cacheid, $metas);
             }
         }
     } else {
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     //add block cached metas
     if ($this->theme && $bcachetime) {
         if ($metas = Xoops_Cache::read($cacheid)) {
             foreach ($metas as $type => $value) {
                 $this->theme->metas[$type] = array_merge($this->theme->metas[$type], $metas[$type]);
             }
         }
     }
     $template->setCompileId();
     return $block;
 }
예제 #2
0
    include __DIR__ . '/mainfile.php';
} else {
    include '../../' . '/mainfile.php';
}
$xoops = Xoops::getInstance();
$xoops->disableErrorReporting();
$xoops_url = \XoopsBaseConfig::get('url');
if (function_exists('mb_http_output')) {
    mb_http_output('pass');
}
header('Content-Type:text/xml; charset=utf-8');
$dirname = $xoops->isModule() ? $xoops->module->getVar('dirname') : 'system';
$tpl = new XoopsTpl();
$tpl->caching = 2;
$tpl->cache_lifetime = 3600;
if (!$tpl->isCached('module:' . $dirname . '/system_rss.tpl')) {
    $tpl->assign('channel_title', XoopsLocale::convert_encoding(htmlspecialchars($xoops->getConfig('sitename'), ENT_QUOTES)));
    $tpl->assign('channel_link', $xoops_url . '/');
    $tpl->assign('channel_desc', XoopsLocale::convert_encoding(htmlspecialchars($xoops->getConfig('slogan'), ENT_QUOTES)));
    $tpl->assign('channel_lastbuild', XoopsLocale::formatTimestamp(time(), 'rss'));
    $tpl->assign('channel_webmaster', $xoops->checkEmail($xoops->getConfig('adminmail'), true));
    $tpl->assign('channel_editor', $xoops->checkEmail($xoops->getConfig('adminmail'), true));
    $tpl->assign('channel_category', 'News');
    $tpl->assign('channel_generator', 'XOOPS');
    $tpl->assign('channel_language', XoopsLocale::getLangCode());
    $xoTheme = $xoops->theme();
    $imgPath = $xoTheme->resourcePath('/images/logo.png');
    $tpl->assign('image_url', $xoops->url($imgPath));
    $dimension = getimagesize($xoops->path($imgPath));
    $tpl->assign('image_width', $dimension[0]);
    $tpl->assign('image_height', $dimension[1]);
예제 #3
0
$xoops = Xoops::getInstance();
$xoops->disableErrorReporting();
if (function_exists('mb_http_output')) {
    mb_http_output('pass');
}
$categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : -1;
if ($categoryid != -1) {
    /* @var $categoryObj PublisherCategory */
    $categoryObj = $publisher->getCategoryHandler()->get($categoryid);
}
header('Content-Type:text/xml; charset=' . XoopsLocale::getCharset());
$tpl = new XoopsTpl();
$tpl->caching = 2;
$tpl->cache_lifetime = 0;
$myts = MyTextSanitizer::getInstance();
if (!$tpl->isCached('module:publisher/publisher_rss.tpl')) {
    $channel_category = $publisher->getModule()->getVar('name');
    $tpl->assign('channel_charset', XoopsLocale::getCharset());
    $tpl->assign('channel_title', htmlspecialchars($xoops->getConfig('sitename'), ENT_QUOTES));
    $tpl->assign('channel_link', PUBLISHER_URL);
    $tpl->assign('channel_desc', htmlspecialchars($xoops->getConfig('slogan'), ENT_QUOTES));
    $tpl->assign('channel_lastbuild', XoopsLocale::formatTimestamp(time(), 'rss'));
    $tpl->assign('channel_webmaster', $xoops->getConfig('adminmail'));
    $tpl->assign('channel_editor', $xoops->getConfig('adminmail'));
    if ($categoryid != -1) {
        $channel_category .= " > " . $categoryObj->getVar('name');
    }
    $tpl->assign('channel_category', htmlspecialchars($channel_category));
    $tpl->assign('channel_generator', $publisher->getModule()->getVar('name'));
    $tpl->assign('channel_language', XoopsLocale::getLangCode());
    $tpl->assign('image_url', \XoopsBaseConfig::get('url') . '/images/logo.gif');
예제 #4
0
 /**
  * XoopsTheme::checkCache()
  *
  * @return bool
  */
 public function checkCache()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST' && $this->contentCacheLifetime) {
         $template = $this->contentTemplate ? $this->contentTemplate : 'module:system/system_dummy.tpl';
         $this->template->caching = 2;
         $this->template->cache_lifetime = $this->contentCacheLifetime;
         $uri = str_replace(\XoopsBaseConfig::get('url'), '', $_SERVER['REQUEST_URI']);
         // Clean uri by removing session id
         if (defined('SID') && SID && strpos($uri, SID)) {
             $uri = preg_replace("/([\\?&])(" . SID . "\$|" . SID . "&)/", "\\1", $uri);
         }
         $this->contentCacheId = $this->generateCacheId('page_' . substr(md5($uri), 0, 8));
         if ($this->template->isCached($template, $this->contentCacheId)) {
             Xoops::getInstance()->events()->triggerEvent('core.theme.checkcache.success', array($template, $this));
             $this->render(null, null, $template);
             return true;
         }
     }
     return false;
 }