function plugin_xoopsblock_convert() { if ($this->root->module['platform'] !== "xoops") { return ''; } static $css_show = FALSE; list($tgt, $option1, $option2) = array_pad(func_get_args(), 3, ""); $tgt_bids = array(); if (!$tgt || $tgt === "?") { $tgt = "?"; } else { foreach (explode(",", $tgt) as $_bid) { if (preg_match("/^\\d+\$/", $_bid) && $_bid > 0) { $tgt_bids[] = $_bid; } } } $align = "left"; $around = false; $width = ""; $arg = array(); if (preg_match("/^(left|center|right)\$/i", $option2, $arg)) { $align = $arg[1]; } if (preg_match("/^(left|center|right)\$/i", $option1, $arg)) { $align = $arg[1]; } if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option2, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = "width:" . $width . ";"; } if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option1, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = "width:" . $width . ";"; } if ($align === 'center') { if (!$width) { $width = 'width:auto;'; } $style = ' style="margin-left:auto;margin-right:auto;' . $width . '"'; $around = false; } else { $style = ' style="float:' . $align . ';' . $width . '"'; } $clear = $around ? '' : '<div style="clear:both;"></div>'; global $xoopsUser; $xoopsblock = new XoopsBlock(); $xoopsgroup = new XoopsGroup(); $arr = array(); $side = null; if ($this->root->userinfo['admin']) { $arr = $xoopsblock->getAllBlocks(); } else { if ($xoopsUser) { $arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->groups()); } else { $arr = $xoopsblock->getAllBlocksByGroup($this->plugin_xoopsblock_getByType("Anonymous")); } } $ret = ""; if ($tgt == "?") { foreach ($arr as $myblock) { $block = array(); $block_type = @$myblock->getVar("type") ? $myblock->getVar("type") : $myblock->getVar("block_type"); $name = @$myblock->getVar("title") ? $myblock->getVar("title") : $myblock->getVar("name"); $bid = $myblock->getVar('bid'); $ret .= "<li>(" . $bid . ")" . $name . "</li>"; } } else { global $xoopsTpl; require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); if (is_object($xoopsUser)) { $xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUser->isAdmin())); } $xoopsTpl->assign('xoops_requesturi', htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES)); foreach ($tgt_bids as $bid) { $myblock = new XoopsBlock($bid); $_bid = $myblock->getVar('bid'); if (!empty($_bid)) { $bcachetime = $myblock->getVar('bcachetime'); // Only a guest enable cache. by nao-pon //if (empty($bcachetime)) { if ($bcachetime % 10 == 1) { $bcachetime_guest = TRUE; $bcachetime = $bcachetime - 1; } else { $bcachetime_guest = FALSE; } if (empty($bcachetime) || is_object($xoopsUser) && $bcachetime_guest) { //if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $myblock->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl, 'blk_' . $myblock->getVar('bid'))) { //$xoopsLogger->addBlock($myblock->getVar('name')); $bresult = $myblock->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $myblock->getVar('bid')); $xoopsTpl->clear_assign('block'); } else { //$xoopsLogger->addBlock($myblock->getVar('name'), true, $bcachetime); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $myblock->getVar('bid')); } } else { //$bid = $myblock->getVar('bid'); if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { //$xoopsLogger->addBlock($myblock->getVar('name')); $bresult = $myblock->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']); $bcontent = $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); $xoopsTpl->clear_assign('block'); } else { //$xoopsLogger->addBlock($myblock->getVar('name'), true, $bcachetime); $bcontent = $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); } } $btitle = $myblock->getVar('title'); } else { $btitle = "Block({$bid})"; $bcontent = "Block({$bid}) is not found."; } if ($bcontent) { $ret .= "<h5>" . $btitle . "</h5>\n"; $ret .= $bcontent; foreach (explode("\n", $xoopsTpl->get_template_vars('xoops_block_header')) as $str) { $this->root->head_tags[] = rtrim($str); } foreach (explode("\n", $xoopsTpl->get_template_vars('xoops_module_header')) as $str) { $this->root->head_tags[] = rtrim($str); } $this->root->head_tags = array_unique($this->root->head_tags); } } unset($myblock); } if (!$css_show) { $css_show = true; $this->root->head_pre_tags[] = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" . XOOPS_URL . "/xoops.css\" />"; } if ($tgt == "?") { $ret = "<ul>{$ret}</ul>"; } unset($xoopsblock, $xoopsgroup); return "<div{$style}>{$ret}</div>{$clear}"; }
foreach (array_keys($block_arr) as $i) { $bcachetime = $block_arr[$i]->getVar('bcachetime'); if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $block_arr[$i]->getVar('template') != '' ? $block_arr[$i]->getVar('template') : "system_block_dummy.html"; if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid'))) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent =& $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid')); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent =& $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid')); } switch ($block_arr[$i]->getVar('side')) { case XOOPS_SIDEBLOCK_LEFT: if (!isset($show_lblock)) { $xoopsTpl->assign('xoops_showlblock', 1); $show_lblock = 1; } $xoopsTpl->append('xoops_lblocks', array('title' => $block_arr[$i]->getVar('title'), 'content' => $bcontent)); break; case XOOPS_CENTERBLOCK_LEFT:
function make_cblock() { global $xoopsUser, $xoopsOption; $xoopsblock = new XoopsBlock(); $cc_block = $cl_block = $cr_block = ""; $arr = array(); if ($xoopsOption['theme_use_smarty'] == 0) { if (!isset($GLOBALS['xoopsTpl']) || !is_object($GLOBALS['xoopsTpl'])) { include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); } else { $xoopsTpl =& $GLOBALS['xoopsTpl']; } if (is_object($xoopsUser)) { $block_arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->getGroups(), true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE); } else { $block_arr = $xoopsblock->getAllBlocksByGroup(XOOPS_GROUP_ANONYMOUS, true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE); } $block_count = count($block_arr); $xoopsLogger =& XoopsLogger::instance(); for ($i = 0; $i < $block_count; $i++) { $bcachetime = intval($block_arr[$i]->getVar('bcachetime')); if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $block_arr[$i]->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl)) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent =& $xoopsTpl->fetch('db:' . $btpl); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent =& $xoopsTpl->fetch('db:' . $btpl); } } else { $bid = $block_arr[$i]->getVar('bid'); if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']); $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); } } $title = $block_arr[$i]->getVar('title'); switch ($block_arr[$i]->getVar('side')) { case XOOPS_CENTERBLOCK_CENTER: if ($title != "") { $cc_block .= '<tr valign="top"><td colspan="2"><strong>' . $title . '</strong><hr />' . $bcontent . '<br /><br /></td></tr>' . "\n"; } else { $cc_block .= '<tr><td colspan="2">' . $bcontent . '<br /><br /></td></tr>' . "\n"; } break; case XOOPS_CENTERBLOCK_LEFT: if ($title != "") { $cl_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n"; } else { $cl_block .= '<p>' . $bcontent . '</p>' . "\n"; } break; case XOOPS_CENTERBLOCK_RIGHT: if ($title != "") { $cr_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n"; } else { $cr_block .= '<p>' . $bcontent . '</p>' . "\n"; } break; default: break; } unset($bcontent, $title); } echo '<table width="100%">' . $cc_block . '<tr valign="top"><td width="50%">' . $cl_block . '</td><td width="50%">' . $cr_block . '</td></tr></table>' . "\n"; } }
/** * Render the page * * The theme engine builds pages from 2 templates: canvas and content. * * A module can call this method directly and specify what templates the theme engine must use. * If render() hasn't been called before, the theme defaults will be used for the canvas and * page template (and xoopsOption['template_main'] for the content). * * @param string $canvasTpl The canvas template, if different from the theme default * @param string $pageTpl The page template, if different from the theme default (unsupported, 2.3+ only) * @param string $contentTpl The content template * @param array $vars Template variables to send to the template engine * * @return bool */ public function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array()) { if ($this->renderCount) { return false; } $xoopsLogger = XoopsLogger::getInstance(); $xoopsLogger->startTime('Page rendering'); xoops_load('xoopscache'); $cache = XoopsCache::getInstance(); //Get meta information for cached pages if ($this->contentCacheLifetime && $this->contentCacheId && ($content = $cache->read($this->contentCacheId))) { //we need to merge metas set by blocks ) with the module cached meta $this->htmlHeadStrings = array_merge($this->htmlHeadStrings, $content['htmlHeadStrings']); foreach ($content['metas'] as $type => $value) { $this->metas[$type] = array_merge($this->metas[$type], $content['metas'][$type]); } $GLOBALS['xoopsOption']['xoops_pagetitle'] = $content['xoops_pagetitle']; $GLOBALS['xoopsOption']['xoops_module_header'] = $content['header']; } if (!empty($GLOBALS['xoopsOption']['xoops_pagetitle'])) { $this->template->assign('xoops_pagetitle', $GLOBALS['xoopsOption']['xoops_pagetitle']); } $header = empty($GLOBALS['xoopsOption']['xoops_module_header']) ? $this->template->get_template_vars('xoops_module_header') : $GLOBALS['xoopsOption']['xoops_module_header']; //save meta information of cached pages if ($this->contentCacheLifetime && $this->contentCacheId && !$contentTpl) { $content['htmlHeadStrings'] = $this->htmlHeadStrings; $content['metas'] = $this->metas; $content['xoops_pagetitle'] =& $this->template->get_template_vars('xoops_pagetitle'); $content['header'] = $header; $cache->write($this->contentCacheId, $content); } // @internal : Lame fix to ensure the metas specified in the xoops config page don't appear twice $old = array('robots', 'keywords', 'description', 'rating', 'author', 'copyright'); foreach ($this->metas['meta'] as $name => $value) { if (in_array($name, $old)) { $this->template->assign("xoops_meta_{$name}", htmlspecialchars($value, ENT_QUOTES)); unset($this->metas['meta'][$name]); } } // We assume no overlap between $GLOBALS['xoopsOption']['xoops_module_header'] and $this->template->get_template_vars( 'xoops_module_header' ) ? $this->template->assign('xoops_module_header', $this->renderMetas(null, true) . "\n" . $header); if ($canvasTpl) { $this->canvasTemplate = $canvasTpl; } if ($contentTpl) { $this->contentTemplate = $contentTpl; } if (!empty($vars)) { $this->template->assign($vars); } if ($this->contentTemplate) { $this->content = $this->template->fetch($this->contentTemplate, $this->contentCacheId); } if ($this->bufferOutput) { $this->content .= ob_get_contents(); ob_end_clean(); } $this->template->assign_by_ref('xoops_contents', $this->content); // Do not cache the main (theme.html) template output $this->template->caching = 0; //mb ------------------------- // $this->template->display($this->path . '/' . $this->canvasTemplate); if (file_exists($this->path . '/' . $this->canvasTemplate)) { $this->template->display($this->path . '/' . $this->canvasTemplate); } else { $this->template->display($this->path . '/theme.tpl'); } //mb ------------------------- $this->renderCount++; $xoopsLogger->stopTime('Page rendering'); return true; }
/** * Render the page * * The theme engine builds pages from 2 templates: canvas and content. * * A module can call this method directly and specify what templates the theme engine must use. * If render() hasn't been called before, the theme defaults will be used for the canvas and * page template (and xoopsOption['template_main'] for the content). * * @param string $canvasTpl The canvas template, if different from the theme default * @param string $pageTpl The page template, if different from the theme default (unsupported, 2.3+ only) * @param string $contentTpl The content template * @param array $vars Template variables to send to the template engine */ function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array()) { if ($this->renderCount) { return false; } $xoopsLogger =& XoopsLogger::getInstance(); $xoopsLogger->startTime('Page rendering'); // @internal : Lame fix to ensure the metas specified in the xoops config page don't appear twice $old = array('robots', 'keywords', 'description', 'rating', 'author', 'copyright'); foreach ($this->metas['meta'] as $name => $value) { if (in_array($name, $old)) { $this->template->assign("xoops_meta_{$name}", htmlspecialchars($value, ENT_QUOTES)); unset($this->metas['meta'][$name]); } } if ($canvasTpl) { $this->canvasTemplate = $canvasTpl; } if ($contentTpl) { $this->contentTemplate = $contentTpl; } if (!empty($vars)) { $this->template->assign($vars); } if ($this->contentTemplate) { $this->content = $this->template->fetch($this->contentTemplate, $this->contentCacheId); } if ($this->bufferOutput) { $this->content .= ob_get_contents(); ob_end_clean(); } $this->template->assign_by_ref('xoops_contents', $this->content); // We assume no overlap between $GLOBALS['xoopsOption']['xoops_module_header'] and $this->template->get_template_vars( 'xoops_module_header' ) ? $header = empty($GLOBALS['xoopsOption']['xoops_module_header']) ? $this->template->get_template_vars('xoops_module_header') : $GLOBALS['xoopsOption']['xoops_module_header']; $this->template->assign('xoops_module_header', $this->renderMetas(null, true) . "\n" . $header); if (!empty($GLOBALS['xoopsOption']['xoops_pagetitle'])) { $this->template->assign('xoops_pagetitle', $GLOBALS['xoopsOption']['xoops_pagetitle']); } // Do not cache the main (theme.html) template output $this->template->caching = 0; $this->template->display($this->path . '/' . $this->canvasTemplate); $this->renderCount++; $xoopsLogger->stopTime('Page rendering'); }
$xml->setVar("descriptionHtmlSyndicated", true); $xml->setVar("link", $xml_link); $xml->setVar("syndicationURL", XOOPS_URL . "/" . xoops_getenv("PHP_SELF")); $xml->setVar("webmaster", checkEmail($xoopsConfig["adminmail"], true)); $xml->setVar("editor", checkEmail($xoopsConfig["adminmail"], true)); $xml->setVar("category", $xoopsModule->getVar("name"), true); $xml->setVar("generator", $xoopsModule->getInfo("version")); $xml->setVar("language", _LANGCODE); $dimention = @getimagesize(XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/" . $xoopsModule->getInfo("image")); $image = array("width" => @$dimention[0], "height" => @$dimention[1], "title" => $xoopsConfig["sitename"] . " :: " . $pagetitle, "url" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/" . $xoopsModule->getInfo("image"), "link" => XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/", "description" => $rssdesc); $xml->setImage($image); /* $item = array( "title" => $datatitle, "link" => $dataurl, "description" => $datadesc, "descriptionHtmlSyndicated" => true, "date" => $datadate, "source" => $datasource, "author" => $dataauthor ); */ $xml->addItems($items); //$dummy_content = $xml_handler->display($xml, XOOPS_CACHE_PATH."/".$GLOBALS["artdirname"].".xml.tmp"); $dummy_content = $xml_handler->display($xml); $tpl->assign_by_ref('dummy_content', $dummy_content); } //$content = ob_get_contents(); ob_end_clean(); header('Content-Type:text/xml; charset=' . $xml_charset); $tpl->display('db:system_dummy.html', $xoopsCachedTemplateId);
$bcachetime = $block_arr[$i]->getVar('bcachetime'); if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $block_arr[$i]->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid'))) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid')); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $block_arr[$i]->getVar('bid')); } } else { $bid = $block_arr[$i]->getVar('bid'); if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']);