function &get_template_vars($name = null) { $root =& XCube_Root::getSingleton(); if (!isset($name)) { foreach ($this->_mContextReserve as $t_key => $t_value) { if (isset($this->_mContextReserve[$t_value])) { $this->_tpl_vars[$t_key] = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$t_value]), ENT_QUOTES); } } $value =& parent::get_template_vars($name); } elseif (isset($this->_mContextReserve[$name])) { $value = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$name]), ENT_QUOTES); } else { $value =& parent::get_template_vars($name); } return $value; }
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}"; }
function xnpbookGetEditBlock($item_id) { $textutil =& xoonips_getutility('text'); $formdata =& xoonips_getutility('formdata'); // get BasicInformation / Preview / index block $basic = xnpGetBasicInformationEditBlock($item_id); $index = xnpGetIndexEditBlock($item_id); $attachment = xnpGetAttachmentEditBlock($item_id, 'book_pdf'); // get DetailInformation $detail = xnpbookGetDetailInformation($item_id); // override values if post form request foreach (_xnpbook_get_detail_request(true) as $key => $val) { if ($val !== null) { $detail[$key]['value'] = $val; } } // html special chars for each value foreach ($detail as $key => $val) { $detail[$key]['value'] = $textutil->html_special_chars($detail[$key]['value']); } // check amazon access key and secret access key $mydirname = basename(dirname(dirname(__FILE__))); $mhandler =& xoops_gethandler('module'); $module =& $mhandler->getByDirname($mydirname); $chandler =& xoops_gethandler('config'); $mconfig = $chandler->getConfigsByCat(false, $module->mid()); $amazon_key_exist = true; if (empty($mconfig['AccessKey']) || empty($mconfig['SecretAccessKey']) || empty($mconfig['AssociateTag'])) { $amazon_key_exist = false; } // set to template global $xoopsTpl; $tpl = new XoopsTpl(); // copy variables in $xoopsTpl to $tpl $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('index', $index); $tpl->assign('attachment', $attachment); $tpl->assign('attachment_dl_limit', xnpGetDownloadLimitationOptionEditBlock('xnpbook', xnpbookGetAttachmentDownloadLimitOption($item_id))); $tpl->assign('attachment_dl_notify', xnpGetDownloadNotificationOptionEditBlock('xnpbook', xnpbookGetAttachmentDownloadNotifyOption($item_id))); $tpl->assign('detail', $detail); $tpl->assign('system_message', $tpl->get_template_vars('system_message')); $tpl->assign('is_register', false); $tpl->assign('myurl', XOOPS_URL . '/modules/xoonips/edit.php'); $formdata =& xoonips_getutility('formdata'); if (!$formdata->getValue('get', 'post_id', 's', false)) { $detail_handler =& xoonips_getormhandler('xnpbook', 'item_detail'); $detail_orm =& $detail_handler->get($item_id); $tpl->assign('xnpbook_author', xoonips_get_multiple_field_template_vars($detail_orm->getAuthors(), 'xnpbook', 'author')); } else { $tpl->assign('xnpbook_author', xoonips_get_multiple_field_template_vars(xoonips_get_orm_from_post('xnpbook', 'author'), 'xnpbook', 'author')); } $tpl->assign('amazon_key_exist', $amazon_key_exist); // return as HTML return $tpl->fetch('db:xnpbook_register_block.html'); }
/** * ブロックが準備されているかを返す * @returns bool 準備されていればTRUE, そうでなければFALSE */ protected function _isBlockPrepared(XoopsTpl $xoopsTpl) { return $xoopsTpl->get_template_vars('xoops_showlblock') !== null; }
/** * 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; }
} include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp']; eval("\$body = " . $modname . "GetDetailBlock( \$item_id );"); $xoopsTpl->assign('body', $body); $func = $modname . "GetDownloadConfirmationBlock"; if (function_exists($func)) { $xoopsTpl->assign('download_confirmation', $func($item_id, $download_file_id)); } else { $xoopsTpl->assign('download_file_id', $download_file_id); } $xoonips_module_header = '<link rel="stylesheet" type="text/css" href="style.css" />'; $func = $modname . 'GetHeadMeta'; if (function_exists($func)) { eval('$xoonips_module_header .= "\\n".' . $func . '($item_id);'); } $xoonips_module_header .= "\n" . $xoopsTpl->get_template_vars('xoops_module_header'); $xoopsTpl->assign('xoops_module_header', $xoonips_module_header); // Record events(view item) $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log'); $eventlog_handler->recordViewItemEvent($item_id); $basic = xnpGetBasicInformationArray($item_id); $xoopsTpl->assign('xoops_pagetitle', $textutil->html_special_chars($basic['titles'][0])); // get item viewed count $ranking_handler =& xoonips_gethandler('xoonips', 'ranking'); $ranking_handler->update(); $viewed_count = $ranking_handler->get_count_viewed_item($item_id); $xoopsTpl->assign('viewed_count', $viewed_count); //start of item comment function $comconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $com_dir_name = $comconfig_handler->getValue('item_comment_dirname'); $com_forum_id = $comconfig_handler->getValue('item_comment_forum_id');
/** * 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'); }
case XOOPS_SIDEBLOCK_RIGHT: if (!isset($show_rblock)) { $xoopsTpl->assign('xoops_showrblock', 1); $show_rblock = 1; } $xoopsTpl->append('xoops_rblocks', array('title' => $block_arr[$i]->getVar('title'), 'content' => $bcontent, 'weight' => $block_arr[$i]->getVar('weight'))); break; } unset($bcontent); } // FALLBACK inserting admin_menu_block in admin side if (!$adminmenublock_exists) { require_once XOOPS_ROOT_PATH . '/modules/altsys/blocks/blocks.php'; $admin_menu_block = array(b_altsys_admin_menu_show(array('altsys'))); $admin_menu_block[0]['title'] = 'Admin Menu'; $lblocks = $xoopsTpl->get_template_vars('xoops_lblocks'); if (!is_array($lblocks)) { $lblocks = array(); } $xoopsTpl->assign('xoops_lblocks', array_merge($admin_menu_block, $lblocks)); } //unset($block_arr); if (!isset($show_lblock)) { $xoopsTpl->assign('xoops_showlblock', 0); } if (!isset($show_rblock)) { $xoopsTpl->assign('xoops_showrblock', 0); } if (!isset($show_cblock)) { $xoopsTpl->assign('xoops_showcblock', 0); }
function xnpsimulatorGetConfirmBlock($item_id) { $textutil =& xoonips_getutility('text'); $formdata =& xoonips_getutility('formdata'); $developer_handler =& xoonips_getormhandler('xnpsimulator', 'developer'); $developer_objs =& $formdata->getObjectArray('post', $developer_handler->getTableName(), $developer_handler, false); // retrive detail information $detail = array(); $simulator_type = $formdata->getValue('post', 'simulator_type', 's', false); if ($simulator_type !== false) { $simulator_types = xnpsimulator_get_type_array(); $detail['simulator_type'] = array('value' => $textutil->html_special_chars($simulator_type), 'display_value' => $textutil->html_special_chars($simulator_types[$simulator_type])); } // retrieve blocks of BasicInformation / Preview / index block $basic = xnpGetBasicInformationConfirmBlock($item_id); xnpConfirmHtml($detail, 'xnpsimulator_item_detail', array_keys($detail), _CHARSET); $preview = xnpGetPreviewConfirmBlock($item_id); $attachment = xnpGetAttachmentConfirmBlock($item_id, 'simulator_data'); $index = xnpGetIndexConfirmBlock($item_id); $lengths = xnpGetColumnLengths('xnpsimulator_item_detail'); $readme = xnpGetTextFileConfirmBlock($item_id, 'readme', $lengths['readme']); $rights = xnpGetRightsConfirmBlock($item_id, $lengths['rights']); if (xnpHasWithout($basic) || xnpHasWithout($detail) || xnpHasWithout($preview) || xnpHasWithout($attachment) || xnpHasWithout($readme) || xnpHasWithout($rights) || xoonips_is_multiple_field_too_long($developer_objs, 'xnpsimulator', 'developer')) { global $system_message; $system_message = $system_message . "\n<br /><font color='#ff0000'>" . _MD_XOONIPS_ITEM_WARNING_FIELD_TRIM . '</font><br />'; } // assign to template global $xoopsTpl; $tpl = new XoopsTpl(); // variables assigned to xoopsTpl are copied to tpl $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('preview', $preview); $tpl->assign('index', $index); $tpl->assign('attachment', $attachment); $tpl->assign('attachment_dl_limit', xnpGetDownloadLimitationOptionConfirmBlock('xnpsimulator')); $tpl->assign('attachment_dl_notify', xnpGetDownloadNotificationOptionConfirmBlock('xnpsimulator')); $tpl->assign('detail', $detail); $tpl->assign('readme', $readme); $tpl->assign('rights', $rights); if (isset($simulator_date)) { $tpl->assign('simulator_date', $simulator_date); if ($simulator_date['Date_Year']) { $tpl->assign('system_message', $tpl->get_template_vars('system_message') . '<br/><font color=\'#ff0000\'>' . _MD_XOONIPS_ITEM_TITLE_REQUIRED . '</font>'); } } $tpl->assign('xnpsimulator_developer', xoonips_get_multiple_field_template_vars($developer_objs, 'xnpsimulator', 'developer')); // return HTML content return $tpl->fetch('db:xnpsimulator_confirm_block.html'); }