function none_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // not implemented for uid specifications //if ! empty($userid)) { //return array(); //} $chandler =& xoops_gethandler('config'); $config =& $chandler->getConfigsByDirname($mydirname); $config['dirname'] = $mydirname; if (empty($config['search_comment'])) { $config = array(); } $tpl = new Legacy_XoopsTpl(); $tpl->assign('config', $config); $content = strip_tags($tpl->fetch("db:{$mydirname}_index.tpl")); if (!is_array($keywords)) { $keywords = array(); } if (strtolower($andor) === 'exact') { $keyword = current($keywords); if (false !== mb_stripos($content, $keyword)) { $found = true; } else { $found = false; } } else { $found = 0; foreach ($keywords as $keyword) { if (false !== mb_stripos($content, $keyword)) { $found++; } } if ($found > 0) { if (strtolower($andor) === 'or') { $found = true; } else if ((strtolower($andor) === 'and') and ($found == count($keywords))) { $found = true; } else { $found = false; } } else { $found = false; } } // get time from tpl_lastmodified. if ($found) { $db =& Database::getInstance(); $sql = <<<SQL_DESU SELECT tpl_lastmodified FROM {$db->prefix('tplfile')} WHERE tpl_file = '{$mydirname}_index.tpl' ORDER BY tpl_lastmodified DESC SQL_DESU; $result = $db->query($sql, 1); $time = array_pop(array_values($db->fetchRow($result))); unset($result); } if (empty($time)) { $time = null; } // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? false : true; if ($showcontext && $found) { $context = str_replace(array("\r", "\t", "\f"), ' ', $content); $context = trim(preg_replace('/\n\s*\n/', "\n", $context)); $context = search_make_context($context, $keywords); } else { $context = ''; } $ret = array( array( 'link' => 'index.php', 'title' => $mydirname, 'time' => $time, 'uid' => null, 'context' => $context, ) ); return $found ? $ret : array(); }
function b_none_show($options) { $mydirname = empty($options[0]) ? basename(dirname(__FILE__)) : $options[0]; $mytrustdirname = basename(dirname(__FILE__)); $this_template = empty($options[1]) ? 'db:' . $mydirname . '_block_none.tpl' : trim($options[1]); // prepare $root =& XCube_Root::getSingleton(); $context =& $root->getContext(); $textFilter =& $root->getTextFilter(); $moduleHandler =& xoops_gethandler('module'); $configHandler =& xoops_gethandler('config'); $tpl = new Legacy_XoopsTpl(); // setup block contents $myconfig =& $configHandler->getConfigsByDirname($mydirname); $myconfig['dirname'] = $mydirname; $block = array( 'mydirname' => $mydirname, 'mytrustdirname' => $mytrustdirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'config' => $myconfig, 'content' => '' ); $tpl->assign('block', $block); // assign like themes $tpl->assign(array('xoops_requesturi' => htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES),)); $tpl->assign('xoops_sitename', $textFilter->toShow($context->getAttribute('legacy_sitename'))); $tpl->assign('xoops_pagetitle', $textFilter->toShow($context->getAttribute('legacy_pagetitle'))); $tpl->assign('xoops_slogan', $textFilter->toShow($context->getAttribute('legacy_slogan'))); // meta, etc... $legacyRender =& $moduleHandler->getByDirname('legacyRender'); if (is_object($legacyRender)) { $configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid')); $tpl->assign('xoops_meta_keywords', $textFilter->toShow($configs['meta_keywords'])); $tpl->assign('xoops_meta_description', $textFilter->toShow($configs['meta_description'])); $tpl->assign('xoops_meta_robots', $textFilter->toShow($configs['meta_robots'])); $tpl->assign('xoops_meta_rating', $textFilter->toShow($configs['meta_rating'])); $tpl->assign('xoops_meta_author', $textFilter->toShow($configs['meta_author'])); $tpl->assign('xoops_meta_copyright', $textFilter->toShow($configs['meta_copyright'])); $tpl->assign('xoops_footer', $configs['footer']); // footer may be raw HTML text. $tpl->assign('xoops_banner',' '); } // user $arr = null; if (is_object($context->mXoopsUser)) { $arr = array( 'xoops_isadmin' => $context->mUser->isInRole('Site.Administrator'), 'xoops_isuser' => true, 'xoops_userid' => $context->mXoopsUser->getShow('uid'), 'xoops_uname' => $context->mXoopsUser->getShow('uname') ); } else { $arr = array('xoops_isuser' => false); } $tpl->assign($arr); // theme $tpl->assign('xoops_theme', $context->mXoopsConfig['theme_set']); $tpl->assign('xoops_imageurl', XOOPS_THEME_URL . DIRECTORY_SEPARATOR . $context->mXoopsConfig['theme_set']); // legacy $tpl->assign('legacy_buffertype', 'block'); $contextModule =& $root->mContext->mModule; if (!is_null($contextModule)) { $tpl->assign('legacy_module', $contextModule->mXoopsModule->get('dirname')); $tpl->assign('xoops_dirname', $contextModule->mXoopsModule->get('dirname')); $tpl->assign('xoops_modulename', $contextModule->mXoopsModule->get('name')); } // render and return $ret = array(); $ret['content'] = $tpl->fetch($this_template); unset($tpl); return $ret; }
/** * Prepend HTML to xoops_module_header * @param Legacy_XoopsTpl $xoopsTpl * @param string $html */ protected function _prependToXoopsModuleHeader(Legacy_XoopsTpl $xoopsTpl, $html) { $xoopsTpl->assign('xoops_module_header', $html . $xoopsTpl->get_template_vars('xoops_module_header')); }