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


PHP NewsModel::addNews方法代码示例

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


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

示例1: add

 /**
  *
  */
 public function add()
 {
     $view = new View();
     $view->header = "Добавить новость";
     $view->render('addnews.html');
     //        include __DIR__ . '/../views/addnews.html';
     if (isset($_POST['title']) && !empty($_POST['title'])) {
         if (isset($_POST['text']) && !empty($_POST['text'])) {
             $title = $_POST['title'];
             $text = $_POST['text'];
             NewsModel::addNews($title, $text);
         }
     }
 }
开发者ID:aufimtsev,项目名称:FunFramework,代码行数:17,代码来源:AdminController.php

示例2: CronNewsAction

 /**
  * ADD News by cron
  * */
 public function CronNewsAction()
 {
     ini_set('max_execution_time', 0);
     $newsModel = new NewsModel();
     $sec_to_delete_news_from_feeds = $this->getParam("SEC_TO_DELETE_NEWS_FROM_FEEDS");
     $newsModel->deleteOldNews(date("Y-m-d H:i:s", time() - $sec_to_delete_news_from_feeds));
     $lastRSS = new lastRSS();
     $lastRSS->cache_dir = './rss_cache';
     $lastRSS->cache_time = 3600;
     // one hour
     $aNewsTreeFeeds = $newsModel->getAllNewsTreeFeeds("", true, true, true);
     foreach ($aNewsTreeFeeds as $newsTreeFeeds) {
         echo $newsTreeFeeds['url'];
         echo "<br>";
         $aFeeds = $lastRSS->Get($newsTreeFeeds['url']);
         echo "<pre>";
         //print_r($aFeeds);
         //print_r($newsTreeFeeds);
         //echo $newsTreeFeeds['last_parse_date']."<br>";
         $n = 0;
         if (is_array($aFeeds) && count($aFeeds) > 0 && is_array($aFeeds['items'])) {
             foreach ($aFeeds['items'] as $item) {
                 //print_r($item); echo "<hr>";
                 $pubDate = isset($item['pubDate']) ? $item['pubDate'] : date("Y-m-d H:i:s");
                 $title = isset($item['title']) ? $item['title'] : "";
                 $link = isset($item['link']) ? $item['link'] : "";
                 $description = isset($item['description']) ? $item['description'] : "";
                 $category = isset($item['category']) ? $item['category'] : "";
                 $enclosure = isset($item['enclosure']) ? $item['enclosure'] : "";
                 $enclosure_type = isset($item['enclosure_type']) ? $item['enclosure_type'] : "";
                 if (strtoupper($aFeeds['encoding']) != 'UTF-8') {
                     $title = iconv(strtoupper($aFeeds['encoding']), 'UTF-8', $title);
                     $description = iconv(strtoupper($aFeeds['encoding']), 'UTF-8', $description);
                     $category = iconv(strtoupper($aFeeds['encoding']), 'UTF-8', $category);
                     $enclosure = iconv(strtoupper($aFeeds['encoding']), 'UTF-8', $enclosure);
                 }
                 $short_text = $newsModel->getNWordsFromText($description, 40);
                 $pub_date = date("Y-m-d H:i:s", strtotime($pubDate));
                 if (!$newsTreeFeeds['category_tag'] || strtoupper($newsTreeFeeds['category_tag']) == strtoupper($category)) {
                     // if RSS-feeds have different categories => it should be same as in item
                     $pub_date_in_sec = strtotime($pub_date);
                     if ((!$newsTreeFeeds['last_parse_date'] || $newsTreeFeeds['last_parse_date'] < $pub_date) && time() - $sec_to_delete_news_from_feeds < $pub_date_in_sec) {
                         // not parsed yet
                         $n++;
                         $newsModel->addNews($newsTreeFeeds['id'], $title, $link, $short_text, $description, $category, $pub_date, $enclosure, $enclosure_type, 0, 0, 0, $newsTreeFeeds['text_parse_type']);
                         $newsModel->setParseDate($newsTreeFeeds['feed_id'], date("Y-m-d H:i:s"));
                     }
                 }
             }
         }
         echo "Added " . $n . " News";
         echo "</pre>";
         echo "<hr>";
     }
 }
开发者ID:amanai,项目名称:next24,代码行数:58,代码来源:NewsController.php


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