示例#1
0
文件: galleries.php 项目: anqh/anqh
 /**
  * Get notification as HTML.
  *
  * @static
  * @param   Model_Notification
  * @return  string
  */
 public static function get(Model_Notification $notification)
 {
     $text = '';
     switch ($notification->type) {
         case self::TYPE_IMAGE_COMMENT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user commented your :photo: <em>:comment</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':comment' => Text::smileys(Text::auto_link_urls(HTML::chars($notification->text)))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_NOTE:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user tagged you to a :photo', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable'))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_REPORT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user reported a :photo: <em>:reason</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':reason' => $notification->text ? HTML::chars($notification->text) : __('No reason')));
             } else {
                 $notification->delete();
             }
             break;
     }
     return $text;
 }
示例#2
0
文件: user.php 项目: anqh/anqh
 /**
  * Get notification as HTML.
  *
  * @static
  * @param   Model_Notification
  * @return  string
  */
 public static function get(Model_Notification $notification)
 {
     $text = '';
     switch ($notification->type) {
         case self::TYPE_FRIEND:
             $friend = Model_User::find_user($notification->user_id);
             if ($friend->loaded()) {
                 $text = __(':friend added you as a friend', array(':friend' => HTML::user($friend)));
             } else {
                 $notification->delete();
             }
             break;
     }
     return $text;
 }