当前位置: 首页>>代码示例>>PHP>>正文


PHP news::get方法代码示例

本文整理汇总了PHP中news::get方法的典型用法代码示例。如果您正苦于以下问题:PHP news::get方法的具体用法?PHP news::get怎么用?PHP news::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在news的用法示例。


在下文中一共展示了news::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 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;
     }
 }
开发者ID:Zandemmer,项目名称:HackThisSite-Old,代码行数:53,代码来源:search.php

示例2: vote

 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'))));
 }
开发者ID:Zandemmer,项目名称:HackThisSite-Old,代码行数:16,代码来源:news.php

示例3: json_encode

<?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);
开发者ID:lincong1987,项目名称:lanbowang,代码行数:31,代码来源:index.php

示例4: news

<?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>';
?>

开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:25,代码来源:latestnews.php

示例5: json_encode

<?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);
?>
开发者ID:lincong1987,项目名称:lanbowang,代码行数:31,代码来源:index1.php


注:本文中的news::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。