/** * Get favorites. * * @return array */ public function actions() { // Clickable favorites if (Permission::has($this->event, Model_Event::PERMISSION_FAVORITE)) { if ($this->event->is_favorite(Visitor::$user)) { // Favorite event, click to unfavorite return array(HTML::anchor(Route::model($this->event, 'unfavorite') . '?token=' . Security::csrf(), $this->event->favorite_count . ' <i class="fa fa-heart"></i>', array('title' => __('Remove favorite'), 'class' => 'ajaxify btn btn-xs btn-lovely'))); } else { // Non-favorite event, click to favorite if ($this->event->favorite_count > 1) { return array(HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), $this->event->favorite_count . ' <i class="fa fa-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-xs btn-default'))); } else { return array(HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="fa fa-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-xs btn-default text-muted'))); } } } return $this->event->favorite_count ? array('<span class="btn btn-xs btn-default disabled"><i class="fa fa-heart"></i> ' . $this->event->favorite_count . '</span>') : null; }
/** * Render favorites. * * @return string */ public function favorites() { // Clickable favorites if (Permission::has($this->event, Model_Event::PERMISSION_FAVORITE, self::$_user)) { if ($this->event->is_favorite(self::$_user)) { // Favorite event, click to unfavorite return HTML::anchor(Route::model($this->event, 'unfavorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Remove favorite'), 'class' => 'ajaxify btn btn-small btn-lovely active')); } else { // Non-favorite event, click to favorite if ($this->event->favorite_count) { return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active')); } else { return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active')); } } } return $this->event->favorite_count ? '<span class="btn btn-small btn-inverse disabled"><i class="icon-heart icon-white"></i> ' . $this->event->favorite_count . '</a>' : ''; }