示例#1
0
$p->limit(appconf('limit'));
$p->offset($cgi->offset);
$list = $p->getThread($cgi->post);
if (!empty($cgi->highlight)) {
    $highlight = '?highlight=' . $cgi->highlight;
} else {
    $highlight = '?highlight=';
}
$pg = new Pager($cgi->offset, appconf('limit'), $p->total);
$pg->setUrl(site_prefix() . '/index/siteforum-list-action/post.%s' . $highlight, $cgi->post);
$pg->getInfo();
if (!$cgi->topic) {
    $cgi->topic = $list[0]->topic_id;
}
$t = new SiteForum_Topic();
$topic = $t->getTitle($cgi->topic);
$subject = $list[0]->subject;
if (!empty($cgi->highlight)) {
    loader_import('saf.Misc.Search');
    echo search_bar($cgi->highlight, '/index/sitesearch-app?ctype=siteforum_post&show_types=yes');
    $queries = search_split_query($cgi->highlight);
    foreach (array_keys($list) as $key) {
        $list[$key]->body = search_highlight($list[$key]->body, $queries);
    }
}
page_title($subject);
template_simple_register('pager', $pg);
echo template_simple('message_list.spt', array('forum_name' => appconf('forum_name'), 'topic' => $topic, 'subject' => $subject, 'list' => $list, 'sitesearch' => @file_exists('inc/app/sitesearch/data/sitesearch.pid')));
if (appconf('template')) {
    page_template(appconf('template'));
}
示例#2
0
<?php

global $cgi;
loader_import('news.Story');
loader_import('news.Functions');
$story = new NewsStory();
if (!empty($parameters['story'])) {
    // view story
    $obj = $story->get($parameters['story']);
    if (!$obj) {
        echo template_simple('not_found.spt', array('error' => $story->error));
        return;
    }
    if (!empty($parameters['highlight'])) {
        loader_import('saf.Misc.Search');
        $obj->body = search_bar($parameters['highlight'], '/index/news-search-action') . search_highlight($obj->body, $parameters['highlight']);
        $obj->highlight = $parameters['highlight'];
    }
    $pages = news_page_split($obj->body);
    if (!$cgi->pagenum) {
        $cgi->pagenum = 1;
    }
    $obj->body = news_page_nav($pages, $cgi->pagenum, $obj->id, $parameters['highlight']);
    $obj->pagenum = $cgi->pagenum;
    if (appconf('comments')) {
        $obj->comments = true;
        loader_import('news.Comment');
        $c = new NewsComment();
        $c->orderBy('ts asc');
        $obj->commentList = $c->find($obj->id);
        if (!$obj->commentList) {
示例#3
0
/**
 * If you would like search terms to be automatically highlighted in your
 * web pages, add 'filter 1 = "body: saf.Misc.Search"' to the modes.php file
 * in your template set, under the appropriate output mode.
 *
 * @param string
 * @return string
 * @package Misc
 */
function saf_misc_search_content_filter($body)
{
    global $cgi;
    if (!empty($cgi->highlight)) {
        return search_bar($cgi->highlight) . search_highlight($body, $cgi->highlight);
    } else {
        if (isset($_SERVER['HTTP_REFERER']) and $_SERVER['HTTP_REFERER'] != '') {
            $keywords = get_searchengine_keywords($_SERVER['HTTP_REFERER']);
            if ($keywords) {
                return search_bar(implode(' ', $keywords)) . search_highlight($body, $keywords);
            }
        }
    }
    return $body;
}