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


PHP FeedItem::saveImages方法代码示例

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


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

示例1: saveFeedItem


//.........这里部分代码省略.........
				}

				if ($filtered) return false;
			}

			if (preg_match('/\((.[^\)]+)\)$/Ui', trim($item['author']), $_matches)) $item['author'] = $_matches[1];
			$item['author']=$db->escape($db->lessen(UTF8::correct($item['author'])));
			$item['permalink']=$db->escape($db->lessen(UTF8::correct($item['permalink'])));
			$item['description']=$db->escape($db->lessen(UTF8::correct(trim($item['description'])),65535));
			
			$enclosures = array();
			foreach($item['enclosures'] as $en) {
				array_push($enclosures, $en['url']);
			}

			$enclosureString=$db->escape($db->lessen(UTF8::correct(implode('|',$enclosures))));				

			$deadLine=0;
			$feedLife = Settings::get('archivePeriod');
			if ($feedLife > 0) $deadLine=gmmktime()-($feedLife*86400);

			requireComponent('Bloglounge.Data.FeedItems');

			$oldTags = null;
			$id = FeedItem::getIdByURL($item['permalink']);
			if($id === false && isset($item['guid'])) {
				$item['guid']=$db->escape($db->lessen(UTF8::correct($item['guid'])));
				$id = FeedItem::getIdByURL($item['guid']);
			}

			$item['author'] = Feed::getAuthor($item, $feedId, $id);
			$item['title'] = Feed::getTitle($item, $feedId, $id);

			$affected = 0;
			$isRebuildData = false;

			$summarySave = Settings::get('summarySave');
			$description = $item['description'];
			if(Validator::getBool($summarySave)) { // summarySave
				$description = func::stripHTML($item['description'].'>');
				if (substr($description, -1) == '>') $description = substr($description, 0, strlen($description) - 1);
				$description = $db->lessen(func::htmltrim($description), 1000, '');
			}
			
			if (preg_match("/^[0-9]+$/",$id)) {
				$baseItem = FeedItem::getFeedItem($id);
			//	$baseItem['title']=$db->escape(UTF8::correct($baseItem['title']));
			//	$baseItem['description']=$db->escape(UTF8::correct(trim($baseItem['description'])));

				if(($baseItem['title']!=$item['title'])) {
					$isRebuildData = true;
					$tags = FeedItem::get($id, 'tags');
					requireComponent('LZ.PHP.Media');
					Media::delete($id);

					$oldTags = func::array_trim(explode(',', $tags));
					$db->execute("UPDATE {$database['prefix']}FeedItems SET author = '{$item['author']}', title = '{$item['title']}', description = '{$description}', tags = '$tagString', enclosure = '$enclosureString', written = {$item['written']} WHERE id = $id");
				}
			} else {
				if ($item['written']==0)
					$item['written']=gmmktime();
				if ($item['written']>$deadLine) {
					$db->execute("INSERT INTO {$database['prefix']}FeedItems (feed, author, permalink, title, description, tags, enclosure, written, feedVisibility) VALUES ($feedId, '{$item['author']}', '{$item['permalink']}', '{$item['title']}', '{$description}', '$tagString', '$enclosureString', {$item['written']},'{$feedVisibility}')");

					$id =$db->insertId();
					$db->execute('UPDATE '.$database['prefix'].'Feeds SET feedCount=feedCount+1 WHERE id="'.$feedId.'"');
					if (isset($this)) $this->updated++;
				}
				$isRebuildData = true;
			}			

			if(Validator::getBool(Settings::get('saveImages'))) {
				if($description = FeedItem::saveImages($feedId, $id, $item)) {
					$db->execute("UPDATE {$database['prefix']}FeedItems SET description = '{$description}' WHERE id = $id");
				}
			}
			
			$item = $event->on('Add.updateFeedItem', array($feedId, $id, $item));
			if(count($item)==3) $item = $item[2];
	
			$result = false;
			if($isRebuildData) {
				requireComponent('Bloglounge.Data.Groups');
				GroupCategory::buildGroupCategory($id, $feedId, $item['tags']);

				Tag::buildTagIndex($id, $item['tags'], $oldTags);
					

				Category::buildCategoryRelations($id, $item['tags'], $oldTags);
				
				$isSaveThumbnail = FeedItem::cacheThumbnail($id, $item);

				// 썸네일 저장 이벤트
				$event->on('Add.thumbnailSave',array($item, $feedId, $id, $isSaveThumbnail));
				
				$result = true;
			}

			return $result;
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:LZ.PHP.Feeder.php


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