本文整理汇总了PHP中TextCleaner::clearText方法的典型用法代码示例。如果您正苦于以下问题:PHP TextCleaner::clearText方法的具体用法?PHP TextCleaner::clearText怎么用?PHP TextCleaner::clearText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextCleaner
的用法示例。
在下文中一共展示了TextCleaner::clearText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Gets news with some Id
*
* @param int $id Id of news
* @return mixed Associated array with news data
* @throws APIException
*/
public function get($id)
{
$element = umiHierarchy::getInstance()->getElement($id);
if (!$element) {
throw new APIException("Can't find news with id " . $id);
}
$images = array();
$mainImage = $element->getValue("anons_pic");
if ($mainImage) {
$mainImage = "http://" . $_SERVER['HTTP_HOST'] . $mainImage;
$images[] = $mainImage;
}
$cleaner = new TextCleaner();
$text = $element->getValue("content");
$text = $cleaner->clearText($text);
$imagesFromText = $cleaner->getPhotos($text);
$images = array_merge($images, $imagesFromText);
$item = array("id" => $id, "header" => $element->getValue("h1"), "text" => $text, "images" => $images, "date" => $element->getValue("publish_time")->getFormattedDate("d.m.Y"), "original_link" => "http://" . $_SERVER['HTTP_HOST'] . umiHierarchy::getInstance()->getPathById($id));
return $item;
}