Exemplo n.º 1
0
 public function index($arguments)
 {
     Layout::set('title', 'Search');
     if (empty($_POST['query'])) {
         return Error::set('No search query found.');
     }
     $query = substr(trim(htmlentities($_POST['query'], ENT_QUOTES, 'ISO8859-1', false)), 0, 250);
     $results = Search::query($query);
     if ($results['hits']['total'] == 0) {
         return Error::set('No results found.');
     }
     $this->view['results'] = array();
     $news = new news(ConnectionFactory::get('mongo'));
     $articles = new articles(ConnectionFactory::get('mongo'));
     $lectures = new lectures(ConnectionFactory::get('mongo'));
     $i = 1;
     if (empty($results['hits']['hits'])) {
         return;
     }
     foreach ($results['hits']['hits'] as $result) {
         $entry = $result['_source'];
         switch ($entry['type']) {
             case 'news':
                 $post = $news->get($result['_id'], false, true);
                 if (empty($post)) {
                     continue;
                 }
                 $post['type'] = 'news';
                 array_push($this->view['results'], $post);
                 break;
             case 'article':
                 $article = $articles->get($result['_id'], false, true);
                 if (empty($article)) {
                     continue;
                 }
                 $article['type'] = 'article';
                 array_push($this->view['results'], $article);
                 break;
             case 'lecture':
                 $lecture = $lectures->get($result['_id'], false, true);
                 if (empty($lecture)) {
                     continue;
                 }
                 $lecture['type'] = 'lecture';
                 array_push($this->view['results'], $lecture);
                 break;
         }
         if ($i == 5) {
             break;
         }
         ++$i;
     }
 }
Exemplo n.º 2
0
 public function vote($arguments)
 {
     if (!CheckAcl::can('voteOnNews')) {
         return Error::set('You can not vote on news posts.');
     }
     if (empty($arguments[0]) || empty($arguments[1])) {
         return Error::set('Vote or news id not found.');
     }
     $news = new news(ConnectionFactory::get('mongo'));
     $result = $news->castVote($arguments[0], $arguments[1]);
     $post = $news->get($arguments[0], false, true);
     if (is_string($result)) {
         return Error::set($result, false, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
     }
     Error::set('Vote cast!', true, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
 }
Exemplo n.º 3
0
<?php

include "function.php";
$index = new index();
//获取首页置顶消息
$index_msg = $index->getIndexMsg();
//获取首页置顶消息
$index_top_msg = $index->getTopMsg();
//获取首页置顶消息
$index_slide_images = $index->getIndexSlideImages(10);
//检查是否登陆
$isLogin = login::isLogin();
$news = new news();
$newsList = $news->get(3);
$newsList2 = $news->get(4, 2);
$newsTypeList = $news->getNewsType();
//
$user = user::getUserSession();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
//导入meta数据及js库
echo $systemHead["meta"] . $systemHead["title"] . CSS_BASE . JS_JQUERY;
?>


<script>
var index_msg = <?php 
echo json_encode($index_msg);
Exemplo n.º 4
0
<?php

require_once 'class.news.php';
setlocale(LC_ALL, 'en_EN');
$news = new news();
$list = $news->get(3);
foreach ($list as $new) {
    if (($new = $news->read_content($new)) !== NULL) {
        $n = $new['content'];
        $link = "p.php?p=news/show&l=" . $news->lang . "&news_id={$new['id']}";
        $pos = strpos($n, '<!-- cut -->');
        if ($pos != FALSE) {
            $before = substr($n, 0, $pos);
            $before .= "<div align='right' class='news-more'><a href='{$link}'>more &raquo;</a></div>";
        } else {
            $before = $n;
        }
        echo "<p class='news-latest-title'><a href='{$link}'>" . $new['title'] . "</a><br />";
        echo "<em class='news-latest-date'>" . $new['date'] . "</em></p>";
        echo "<div class='news-latest-body'>" . $before . "</div>\n";
    }
}
echo '<p align="right"><a href="/p.php?p=news&amp;l=' . $news->lang . '" title="News">Archives</a></p>';
echo '<p align="right"><a href="/rss.php?p=news&amp;l=' . $news->lang . '">RSS 2.0 updates&nbsp;<img src="/i/feed-icon-14x14.png" alt="rss" border="0" /></a></p>';
?>

Exemplo n.º 5
0
<?php

include "function.php";
$index = new index();
//获取首页置顶消息
$index_msg = $index->getIndexMsg();
//获取首页置顶消息
$index_top_msg = $index->getTopMsg();
//获取首页置顶消息
$index_slide_images = $index->getIndexSlideImages(10);
//检查是否登陆
$isLogin = login::isLogin();
$news = new news();
$newsList = $news->get(10);
$newsTypeList = $news->getNewsType();
//
$user = user::getUserSession();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
//导入meta数据及js库
echo $systemHead["meta"] . $systemHead["title"] . CSS_BASE;
?>


<script>
var index_msg = <?php 
echo json_encode($index_msg);
?>