getAllPublished(false, $minEditDate); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true)); $result = array(); foreach ($points as $point) { $tempPoint['id'] = $point->id; $tempPoint['name'] = $point->name; $tempPoint['lat'] = $point->lat; $tempPoint['lng'] = $point->lng; $tempPoint['categoryId'] = $point->categoryId; $tempPoint['status'] = $point->status; $result[] = $tempPoint; } return array('status' => 'success','data' => $result); } /** * Точка */ static private function getPoint($data) { $id = isset($data['id']) ? intval($data['id']) : NULL; if (!$id) { self::error('Broken request!'); } $point = Point::model()->getByPK($id); if (!$point) { self::error('Unknown point!'); } $point->descriptionHtml = nl2br($point->description); $point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml, 'js'); $point->name = htmlspecialchars($point->name); $imgs = $point->photos; $photosCount = 1; if ($point->img == '' && !empty($imgs)) { $img = array_shift($imgs); $point->img = $img->name; } $imgs = $point->photos; if (!empty($imgs)) { $tmp = array(); $photosCount = count($imgs); foreach ($imgs as $img) { $tmp[] = $img->name; } $point->images = $tmp; } $extraParams = $point->getExtraParams(); if (!empty($extraParams)) { $tmp = array(); foreach ($extraParams as $extraParam) { $tmp[] = array($extraParam->name, $extraParam->value); } $point->extraParams = $tmp; } $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true)); $point->categoryIcon = $categories[$point->categoryId]['icon']; $point->categoryName = $categories[$point->categoryId]['name']; $point->photosCount = $photosCount; $point->inFavorites = Favorite::model()->checkIsMy($id); $point->iLike = Like::model()->checkIsMy($id); return array('status' => 'success','data' => $point->getValues()); } /** * Категории */ static private function getCategories() { $categories = Category::model()->getAll(array('order' => 'ord DESC', 'asArray' => true, 'noKeys' => true)); $categories[] = array( "id" => "0", "name" => "Все точки", "icon" => "/ico/all.png", "ord" => "0" ); $categories = array_reverse($categories); return array('status' => 'success','data' => $categories); } static private function error($message = FALSE) { $answer = array('status' => 'error'); if ($message) { $answer['message'] = $message; } self::renderPartial('json.php', $answer); } }