function onActivityContentDisplay($args) { $model =& CFactory::getModel('Wall'); $wall =& JTable::getInstance('Wall', 'CTable'); $my = CFactory::getUser(); if (empty($args->content)) { return ''; } $wall->load($args->cid); CFactory::load('libraries', 'privacy'); CFactory::load('libraries', 'comment'); $comment = CComment::stripCommentData($wall->comment); $config = CFactory::getConfig(); $commentcut = false; if (strlen($comment) > $config->getInt('streamcontentlength')) { $origcomment = $comment; $comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...'; $commentcut = true; } if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) { CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'wall'); $videoContent = ''; $params = new CParameter($args->params); $videoLink = $params->get('videolink'); $image = $params->get('url'); // For older activities that does not have videoLink , we need to process it the old way. if (!$videoLink) { $html = CWallLibrary::_processWallContent($comment); $tmpl = new CTemplate(); $html = CStringHelper::escape($html); if ($commentcut) { //add read more/less link for content $html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>'; $html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>'; $html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>'; } $tmpl->set('comment', $html); $html = $tmpl->fetch('activity.wall.post'); } else { $html = '<ul class ="cDetailList clrfix">'; $html .= '<li>'; $image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image; $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->'; $videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300'); $comment = CString::str_ireplace($videoLink, '', $comment); $html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->'; if (!empty($videoPlayer)) { $html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>'; } $html .= '</li>'; $html .= '</ul>'; } return $html; } }
/** * Return formatted comment given the wall item */ public static function formatComment($wall) { $config = CFactory::getConfig(); $my = CFactory::getUser(); $actModel = CFactory::getModel('activities'); $like = new CLike(); $likeCount = $like->getLikeCount('comment', $wall->id); $isLiked = $like->userLiked('comment', $wall->id, $my->id); $user = CFactory::getUser($wall->post_by); // Censor if the user is banned if ($user->block) { $wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED'); } else { // strip out the comment data $CComment = new CComment(); $wall->comment = $CComment->stripCommentData($wall->comment); // Need to perform basic formatting here // 1. support nl to br, // 2. auto-link text $CTemplate = new CTemplate(); $wall->comment = $origComment = $CTemplate->escape($wall->comment); $wall->comment = CStringHelper::autoLink($wall->comment); } $commentsHTML = ''; $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>'; $date = new JDate($wall->date); $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> '; $commentsHTML .= $wall->comment; $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date); $cid = isset($wall->contentid) ? $wall->contentid : null; $activity = $actModel->getActivity($cid); $ownPost = $my->id == $wall->post_by; $allowRemove = $my->authorise('community.delete', 'walls', $wall); $canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin(); // only poster can edit if ($allowRemove) { $commentsHTML .= ' <span class="wall-coc-remove-link">• <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>'; } $commentsHTML .= '</span>'; $commentsHTML .= '</div>'; $editHTML = ''; if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) { $editHTML .= '<a href="javascript:" class="joms-button--edit">'; $editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>'; $editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>'; $editHTML .= '</a>'; } $removeHTML = ''; if ($allowRemove) { $removeHTML .= '<a href="javascript:" class="joms-button--remove">'; $removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>'; $removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>'; $removeHTML .= '</a>'; } $removeTagHTML = ''; if (CActivitiesHelper::hasTag($my->id, $wall->comment)) { $removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>'; } /* user deleted */ if ($user->guest == 1) { $userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> '; } else { $userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> '; } $params = $wall->params; $paramsHTML = ''; $image = (array) $params->get('image'); $photoThumbnail = false; if ($params->get('attached_photo_id') > 0) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); $paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>'; } else { if ($params->get('title')) { $video = self::detectVideo($params->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-relative joms-js--comment-preview">'; if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) { $paramsHTML .= '<span class="joms-media__remove" data-action="remove-preview" onClick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="#joms-icon-remove"></use></svg></span>'; } if ($params->get('image')) { $paramsHTML .= $params->get('link'); $paramsHTML .= '<div class="joms-media__thumbnail">'; $paramsHTML .= '<a href="' . $params->get('link') ? $params->get('link') : '#' . '">'; $paramsHTML .= '<img src="' . array_shift($image) . '" />'; $paramsHTML .= '</a>'; $paramsHTML .= '</div>'; } $url = $params->get('url') ? $params->get('url') : '#'; $paramsHTML .= '<div class="joms-media__body">'; $paramsHTML .= '<a href="' . $url . '">'; $paramsHTML .= '<h4 class="joms-media__title">' . $params->get('title') . '</h4>'; $paramsHTML .= '<p class="joms-media__desc reset-gap">' . CStringHelper::trim_words($params->get('description')) . '</p>'; if ($params->get('link')) { $paramsHTML .= '<span class="joms-text--light"><small>' . preg_replace('#^https?://#', '', $params->get('link')) . '</small></span>'; } $paramsHTML .= '</a></div></div>'; } } } if (!$params->get('title') && $params->get('url')) { $paramsHTML .= '<div class="joms-gap"></div>'; $paramsHTML .= '<div class="joms-media--album">'; $paramsHTML .= '<a href="' . $params->get('url') . '">'; $paramsHTML .= '<img class="joms-stream-thumb" src="' . $params->get('url') . '" />'; $paramsHTML .= '</a>'; $paramsHTML .= '</div>'; } $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 $template = new CTemplate(); $template->set('wall', $wall)->set('originalComment', $origComment)->set('date', $date)->set('isLiked', $isLiked)->set('likeCount', $likeCount)->set('canRemove', $allowRemove)->set('canEdit', $canEdit)->set('canRemove', $allowRemove)->set('user', $user)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML); $commentsHTML = $template->fetch('stream/single-comment'); return $commentsHTML; }
/** * Fetches the wall content template and returns the wall data in HTML format * * @param appType The application type to load the walls from * @param uniqueId The unique id for the specific application * @param isOwner Boolean value if the current browser is owner of the specific app or profile * @param limit The limit to display the walls * @param templateFile The template file to use. **/ function getWallContents($appType, $uniqueId, $isOwner, $limit = 0, $limitstart = 0, $templateFile = 'wall.content', $processFunc = '', $param = null) { CError::assert($appType, '', '!empty', __FILE__, __LINE__); CError::assert($uniqueId, '', '!empty', __FILE__, __LINE__); $config = CFactory::getConfig(); $html = '<div id="wall-containter">'; $model = CFactory::getModel('wall'); //@rule: If limit is not set, then we need to use Joomla's limit if ($limit == 0) { $jConfig =& JFactory::getConfig(); $limit = $jConfig->getValue('list_limit'); } // Special 'discussions' $order = 'DESC'; //if($appType == 'discussions'){ //$order = $config->get('group_discuss_order'); //$discussionsTrigger = true; //} $walls = $model->getPost($appType, $uniqueId, $limit, $limitstart, $order); // Special 'discussions' $discussionsTrigger = false; $order = $config->get('group_discuss_order'); if ($appType == 'discussions' && $order == 'ASC') { $walls = array_reverse($walls); $discussionsTrigger = true; } if ($walls) { //Process wall comments CFactory::load('libraries', 'comment'); $wallComments = array(); $comment = new CComment(); for ($i = 0; $i < count($walls); $i++) { $wall = $walls[$i]; $wallComments[] = $wall->comment; $wall->comment = $comment->stripCommentData($wall->comment); } // Trigger the wall applications / plugins CWall::triggerWallComments($walls); for ($i = 0; $i < count($walls); $i++) { $html .= CWallLibrary::_getWallHTML($walls[$i], $wallComments[$i], $appType, $isOwner, $processFunc, $templateFile); } if ($appType == 'discussions') { $wallCount = CWallLibrary::getWallCount('discussions', $uniqueId); $limitStart = $limitstart + $limit; //$limitStart = $wallCount - $limit; //$limitStart = $limit; if ($wallCount > $limitStart) { $groupId = JRequest::getInt('groupid'); $groupId = empty($groupId) ? $param : $groupId; if ($discussionsTrigger) { $html = CWall::_getOlderWallsHTML($groupId, $uniqueId, $limitStart) . $html; } else { $html .= CWall::_getOlderWallsHTML($groupId, $uniqueId, $limitStart); } } } } $html .= '</div>'; return $html; }
public function ajaxeditComment($id, $value, $photoId = 0) { $config = CFactory::getConfig(); $my = CFactory::getUser(); $actModel = CFactory::getModel('activities'); $objResponse = new JAXResponse(); $json = array(); if ($my->id == 0) { $this->blockUnregister(); } $wall = JTable::getInstance('wall', 'CTable'); $wall->load($id); $cid = isset($wall->contentid) ? $wall->contentid : null; $activity = $actModel->getActivity($cid); $ownPost = $my->id == $wall->post_by; $targetPost = $activity->target == $my->id; $allowEdit = COwnerHelper::isCommunityAdmin() || ($ownPost || $targetPost) && !empty($my->id); $value = trim($value); if (empty($value)) { $json['error'] = JText::_('COM_COMMUNITY_CANNOT_EDIT_COMMENT_ERROR'); } else { if ($config->get('wallediting') && $allowEdit) { $params = new CParameter($wall->params); //if photo id is not 0, this wall is appended with a picture if ($photoId > 0 && $params->get('attached_photo_id') != $photoId) { //lets check if the photo belongs to the uploader $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); if ($photo->creator == $my->id && $photo->albumid == '-1') { $params->set('attached_photo_id', $photoId); //sets the status to ready so that it wont be deleted on cron run $photo->status = 'ready'; $photo->store(); } } else { if ($photoId == -1) { //if there is nothing, remove the param if applicable //delete from db and files $photoModel = CFactory::getModel('photos'); $photoTable = $photoModel->getPhoto($params->get('attached_photo_id')); $photoTable->delete(); $params->set('attached_photo_id', 0); } } $wall->params = $params->toString(); $wall->comment = $value; $wall->store(); $CComment = new CComment(); $value = $CComment->stripCommentData($value); // Need to perform basic formatting here // 1. support nl to br, // 2. auto-link text $CTemplate = new CTemplate(); $value = $origValue = $CTemplate->escape($value); $value = CStringHelper::autoLink($value); $value = nl2br($value); $value = CUserHelper::replaceAliasURL($value); $value = CStringHelper::getEmoticon($value); $json['comment'] = $value; $json['originalComment'] = $origValue; // $objResponse->addScriptCall("joms.jQuery('div[data-commentid=" . $id . "] .cStream-Content span.comment').html", $value); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").val', $origValue); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").removeData', 'initialized'); // if ($photoId == -1) { // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "none").attr("data-no_thumb", 1);'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail").html', '<img/>'); // } else if ($photoId != 0) { // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-fetch-wrapper").remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-content] .cStream-Meta").before', '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . JUri::root(true) ."/". $photo->thumbnail . '" /></div>'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "block").removeAttr("data-no_thumb");'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail img").attr("src", "' . JUri::root(true) ."/". $photo->thumbnail . '").attr("data-photo_id", "0").data("photo_id", 0);'); // } } else { $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT'); } } if (!isset($json['error'])) { $json['success'] = true; } die(json_encode($json)); }
//$key indicates the group id foreach ($groups as $key => $groupPost) { $groupId = $key; $groupname = CStringHelper::escape($groupPost[0]->groupname); $grouplink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId); ?> <h4><?php echo $groupname; ?> </h4> <?php foreach ($groupPost as $post_info) { $user = CFactory::getUser($post_info->actor); $comment = CComment::stripCommentData($post_info->title); $comment = JString::substr($comment, 0, $charactersCount); $comment .= $charactersCount > JString::strlen($comment) ? '' : '...'; $comment = CUserHelper::replaceAliasURL($comment); ?> <div class="joms-stream__header wide "> <div class= "joms-avatar--stream"> <a title="<?php echo $user->getDisplayName(); ?> " href="<?php echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); ?> "> <img src="<?php echo $user->getThumbAvatar();
public static function getActivityContentHTML($act) { // Ok, the activity could be an upload OR a wall comment. In the future, the content should // indicate which is which $html = ''; $param = new CParameter($act->params); $action = $param->get('action', false); $config = CFactory::getConfig(); $groupModel = CFactory::getModel('groups'); if ($action == CGroupsAction::DISCUSSION_CREATE) { // Old discussion might not have 'action', and we can't display their // discussion summary $topicId = $param->get('topic_id', false); if ($topicId) { $group = JTable::getInstance('Group', 'CTable'); $discussion = JTable::getInstance('Discussion', 'CTable'); $group->load($act->cid); $discussion->load($topicId); $discussion->message = strip_tags($discussion->message); $topic = CStringHelper::escape($discussion->message); $tmpl = new CTemplate(); $tmpl->set('comment', JString::substr($topic, 0, $config->getInt('streamcontentlength'))); $html = $tmpl->fetch('activity.groups.discussion.create'); } return $html; } else { if ($action == CGroupsAction::WALLPOST_CREATE) { // a new wall post for group // @since 1.8 $group = JTable::getInstance('Group', 'CTable'); $group->load($act->cid); $wallModel = CFactory::getModel('Wall'); $wall = JTable::getInstance('Wall', 'CTable'); $my = CFactory::getUser(); // make sure the group is a public group or current use is // a member of the group if ($group->approvals == 0 || $group->isMember($my->id)) { //CFactory::load( 'libraries' , 'comment' ); $wall->load($param->get('wallid')); $comment = strip_tags($wall->comment, '<comment>'); $comment = CComment::stripCommentData($comment); $tmpl = new CTemplate(); $tmpl->set('comment', JString::substr($comment, 0, $config->getInt('streamcontentlength'))); $html = $tmpl->fetch('activity.groups.wall.create'); } return $html; } else { if ($action == CGroupsAction::DISCUSSION_REPLY) { // @since 1.8 $group = JTable::getInstance('Group', 'CTable'); $group->load($act->cid); $wallModel = CFactory::getModel('Wall'); $wall = JTable::getInstance('Wall', 'CTable'); $my = CFactory::getUser(); // make sure the group is a public group or current use is // a member of the group if ($group->approvals == 0 || $group->isMember($my->id)) { $wallid = $param->get('wallid'); //CFactory::load( 'libraries' , 'wall' ); $html = CWallLibrary::getWallContentSummary($wallid); } return $html; } else { if ($action == CGroupsAction::CREATE) { $group = JTable::getInstance('Group', 'CTable'); $group->load($act->cid); $tmpl = new CTemplate(); $tmpl->set('group', $group); $html = $tmpl->fetch('activity.groups.create'); } } } } return $html; }
/** * Return formatted comment given the wall item */ public static function formatComment($wall) { CFactory::load('helpers', 'owner'); $my = CFactory::getUser(); // Save processing time if (!$wall->comment) { return ''; } // strip out the comment data CFactory::load('libraries', 'comment'); $wall->comment = CComment::stripCommentData($wall->comment); // Need to perform basic formatting here // 1. support nl to br, // 2. auto-link text CFactory::load('helpers', 'linkgenerator'); $wall->comment = CTemplate::escape($wall->comment); $wall->comment = CLinkGeneratorHelper::replaceURL($wall->comment); $wall->comment = nl2br($wall->comment); CFactory::load('helpers', 'time'); $user = CFactory::getUser($wall->post_by); $commentsHTML = ''; $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>'; $date = new JDate($wall->date); $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> '; $commentsHTML .= $wall->comment; $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date); // Only site admin, or wall author can remove it // @todo: the target stream activity should also be able to delete it if (COwnerHelper::isCommunityAdmin() || $my->id == $wall->post_by) { $commentsHTML .= ' <span class="wall-coc-remove-link">• <a onclick="joms.miniwall.remove(' . $wall->id . ');" href="#removeThisComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>'; } $commentsHTML .= '</span>'; $commentsHTML .= '</div>'; return $commentsHTML; }
public function ajaxEditWall($wallId, $editableFunc) { $objResponse = new JAXResponse(); $wall =& JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); CFactory::load('libraries', 'wall'); $isEditable = CWall::isEditable($editableFunc, $wall->id); if (!$isEditable) { $objResponse->addAlert(JText::_('CC NOT ALLOWED TO EDIT')); return $objResponse->sendResponse(); } CFactory::load('libraries', 'comment'); $tmpl = new CTemplate(); $message = CComment::stripCommentData($wall->comment); $tmpl->set('message', $message); $tmpl->set('editableFunc', $editableFunc); $tmpl->set('id', $wall->id); $content = $tmpl->fetch('wall.edit'); $objResponse->addScriptCall('joms.jQuery("#wall_' . $wallId . ' div.loading").hide();'); $objResponse->addAssign('wall-edit-container-' . $wallId, 'innerHTML', $content); return $objResponse->sendResponse(); }