diff --git a/controllers/UserController.php b/controllers/UserController.php index 44c0d86..77dc326 100644 --- a/controllers/UserController.php +++ b/controllers/UserController.php @@ -89,4 +89,20 @@ class UserController extends Controller 'randomPoint' => $randomPoint, )); } + + function actionFavorites() + { + if (!App::$user) { + App::redirect('/'); + } + + $randomPoint = Point::model()->getRandom(); + $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); + $randomPoint->description = Helper::replaceLinks($randomPoint->description); + + self::render('user/favorites.php', array( + 'favorites' => Favorite::model()->getAllMy(), + 'randomPoint' => $randomPoint, + )); + } } diff --git a/models/Category.php b/models/Category.php index f4805b7..a0ca786 100644 --- a/models/Category.php +++ b/models/Category.php @@ -2,6 +2,7 @@ class Category extends Model { + private static $categories = NULL; function __construct($fromArray = array()) { @@ -15,4 +16,13 @@ class Category extends Model return new self(); } + static function getIcoById($id) + { + if (self::$categories === NULL) { + self::$categories = self::model()->getAll(array('asArray'=>true)); + } + + return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL; + } + } diff --git a/views/indexTemplate.php b/views/indexTemplate.php index eae8904..d7026af 100644 --- a/views/indexTemplate.php +++ b/views/indexTemplate.php @@ -109,6 +109,8 @@ if (App::$user) {
+ = mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>…
+