/** * 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; }