示例#1
0
 public static function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile, $banned = 0)
 {
     $my = CFactory::getUser();
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     $commentsHTML = '';
     $comment = new CComment();
     /*
      * @todo 3.3 revise what is this code about
      */
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         if ($banned == 1) {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, false);
         } else {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
         }
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     // Change '->created to lapse format if stream uses lapse format'
     if ($config->get('activitydateformat') == 'lapse') {
         $wall->created = CTimeHelper::timeLapse($date);
     } else {
         $wall->created = $date->Format(JText::_('DATE_FORMAT_LC2'), true);
     }
     $wallParam = new CParameter($wall->params);
     $photoThumbnail = '';
     $paramsHTML = '';
     $image = (array) $wallParam->get('image');
     if ($wallParam->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($wallParam->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
     } else {
         if ($wallParam->get('title')) {
             $video = self::detectVideo($wallParam->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-js--comment-preview">';
                 if ($isOwner) {
                     $paramsHTML .= '<span data-action="remove-preview" class="joms-fetched-close" style="top:0;right:0;left:auto" onclick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><i class="joms-icon-remove"></i></span>';
                 }
                 if ($wallParam->get('image')) {
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $wallParam->get('link') ? $wallParam->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $wallParam->get('url') ? $wallParam->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title"><a href="' . $url . '">' . $wallParam->get('title') . '</a></h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . CStringHelper::trim_words($wallParam->get('description')) . '</p>';
                 if ($wallParam->get('link')) {
                     $paramsHTML .= '<cite>' . preg_replace('#^https?://#', '', $wallParam->get('link')) . '</cite>';
                 }
                 $paramsHTML .= '</div></div>';
             }
         }
     }
     $CComment = new CComment();
     $wall->originalComment = $wall->comment;
     $wall->comment = $CComment->stripCommentData($wall->comment);
     $CTemplate = new CTemplate();
     $wall->comment = CStringHelper::autoLink($wall->comment);
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $canDelete = $my->authorise('community.delete', 'walls', $wall);
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id) == COMMUNITY_LIKE;
     // Create new instance of the template
     $tmpl = new CTemplate();
     return $tmpl->set('id', $wall->id)->set('author', $user->getDisplayName())->set('avatarHTML', $avatarHTML)->set('authorLink', CUrlHelper::userLink($user->id))->set('created', $wall->created)->set('content', $wall->comment)->set('commentsHTML', $commentsHTML)->set('avatar', $user->getThumbAvatar())->set('isMine', $isOwner)->set('canDelete', $canDelete)->set('isEditable', $isEditable)->set('processFunc', $processFunc)->set('config', $config)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML)->set('wall', $wall)->set('likeCount', $likeCount)->set('isLiked', $isLiked)->fetch($templateFile);
 }
示例#2
0
文件: wall.php 项目: bizanto/Hooked
 function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile)
 {
     CFactory::load('helpers', 'url');
     CFactory::load('helpers', 'user');
     CFactory::load('helpers', 'videos');
     CFactory::load('libraries', 'comment');
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     // Apply any post processing on the content
     $wall->comment = CWallLibrary::_processWallContent($wall->comment);
     $commentsHTML = '';
     $comment = new CComment();
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     //var_dump($avatarHTML);exit;
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = COMMUNITY_WALLS_EDIT_INTERVAL - abs($interval);
     $editInterval = round($interval / 60);
     // Create new instance of the template
     $tmpl = new CTemplate();
     $tmpl->set('id', $wall->id);
     $tmpl->set('author', $user->getDisplayName());
     $tmpl->set('avatarHTML', $avatarHTML);
     $tmpl->set('authorLink', CUrlHelper::userLink($user->id));
     $tmpl->set('created', $date->toFormat(JText::_('DATE_FORMAT_LC2')));
     $tmpl->set('content', $wall->comment);
     $tmpl->set('commentsHTML', $commentsHTML);
     $tmpl->set('avatar', $user->getThumbAvatar());
     $tmpl->set('isMine', $isOwner);
     $tmpl->set('isEditable', $isEditable);
     $tmpl->set('editInterval', $editInterval);
     $tmpl->set('processFunc', $processFunc);
     $tmpl->set('config', $config);
     return $tmpl->fetch($templateFile);
 }