本文整理汇总了PHP中NewsModel::setParseDate方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::setParseDate方法的具体用法?PHP NewsModel::setParseDate怎么用?PHP NewsModel::setParseDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsModel
的用法示例。
在下文中一共展示了NewsModel::setParseDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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>";
}
}