public function getFieldHTML($field, $required, $isDropDown = true) { $class = $field->required == 1 ? ' required' : ''; $class .= !empty($field->tips) ? ' jomNameTips tipRight' : ''; $optionSize = 1; // the default 'select below' if (!empty($field->options)) { $optionSize += count($field->options); } $dropDown = $isDropDown ? '' : ' size="' . $optionSize . '"'; CFactory::load('helpers', 'string'); $html = '<select id="field' . $field->id . '" name="field' . $field->id . '"' . $dropDown . ' class="select' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '" style="' . $this->getStyle() . '" size="' . $this->params->get('size') . '">'; $defaultSelected = ''; //@rule: If there is no value, we need to default to a default value if (empty($field->value)) { $defaultSelected .= ' selected="selected"'; } if ($isDropDown) { $html .= '<option value="" ' . $defaultSelected . '>' . JText::_('COM_COMMUNITY_SELECT_BELOW') . '</option>'; } if (!empty($field->options)) { $selectedElement = 0; CFactory::load('libraries', 'template'); foreach ($field->options as $option) { $selected = $option == $field->value ? ' selected="selected"' : ''; if (!empty($selected)) { $selectedElement++; } $html .= '<option value="' . CTemplate::escape($option) . '"' . $selected . '>' . JText::_($option) . '</option>'; } if ($selectedElement == 0) { //if nothing is selected, we default the 1st option to be selected. $eleName = 'field' . $field->id; $html .= <<<HTML \t\t\t\t\t <script type='text/javascript'> \t\t\t\t\t\t var slt = document.getElementById('{$eleName}'); \t\t\t\t\t\t if(slt != null) \t\t\t\t\t\t { \t\t\t\t\t\t slt.options[0].selected = true; \t\t\t\t\t\t } \t\t\t\t\t </script> HTML; } } $html .= '</select>'; $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>'; return $html; }
public static function _getLatestVideosHTML($userid, $limit, $limitstart, $row, $total) { $config = CFactory::getConfig(); $video = JTable::getInstance('Video', 'CTable'); $isVideoModal = $config->get('video_mode') == 1; ob_start(); if (!empty($row)) { ?> <ul class="joms-list--half clearfix"> <?php $i = 1; foreach ($row as $data) { if ($i > $limit) { break; } $i++; $video->load($data->id); $thumbnail = $video->getThumbnail(); if ($isVideoModal) { $link = 'javascript:" onclick="joms.api.videoOpen(\'' . $video->id . '\');'; } else { $link = plgCommunityMyVideos::buildLink($data->id); } ?> <li class="joms-list__item"> <a href="<?php echo $link; ?> "> <img title="<?php echo CTemplate::escape($video->getTitle()); ?> " src="<?php echo $thumbnail; ?> "/> <span class="joms-video__duration"><?php echo $video->getDurationInHMS(); ?> </span> </a> </li> <?php } ?> </ul> <?php if ($i <= $total) { ?> <div class="joms-gap"></div> <a href="<?php echo CRoute::_('index.php?option=com_community&view=videos&task=myvideos&userid=' . $userid); ?> "> <span><?php echo JText::_('PLG_MYVIDEOS_VIEWALL_VIDEOS'); ?> </span> <span>(<?php echo $total; ?> )</span> </a> <?php } ?> <?php } else { ?> <div><?php echo JText::_('PLG_MYVIDEOS_NO_VIDEOS'); ?> </div> <?php } ?> <?php $contents = ob_get_contents(); @ob_end_clean(); $html = $contents; 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; }
/** * Add reply via ajax * @todo: check permission and message ownership */ public function ajaxAddReply($msgId, $reply, $photoId = 0) { $filter = JFilterInput::getInstance(); $msgId = $filter->clean($msgId, 'int'); //$reply = $filter->clean($reply, 'string'); $photoId = $filter->clean($photoId, 'int'); $my = CFactory::getUser(); $model = $this->getModel('inbox'); $message = $model->getMessage($msgId); $messageRecipient = $model->getParticipantsID($msgId, $my->id); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } // Block users $getBlockStatus = new blockUser(); $userModel = CFactory::getModel('User'); $bannedList = $userModel->getBannedUser(); $newRecipient = array(); foreach ($messageRecipient as $recipient) { if ($getBlockStatus->isUserBlocked($recipient, 'inbox')) { continue; } $newRecipient[] = $recipient; } $messageRecipient = $newRecipient; // @rule: Spam checks if ($this->_isSpam($my, $reply)) { $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM')); die(json_encode($json)); } if (empty($reply) && $photoId == 0) { $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_BE_EMPTY')); die(json_encode($json)); } if (empty($messageRecipient)) { $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_FIND_RECIPIENT')); die(json_encode($json)); } // make sure we can only reply to message that belogn to current user if (!$model->canReply($my->id, $msgId)) { $json = array('error' => JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING')); die(json_encode($json)); } if (in_array($messageRecipient[0], $bannedList)) { $json = array('error' => JText::_('COM_COMMUNITY_USER_BANNED')); die(json_encode($json)); } $date = JFactory::getDate(); //get the time without any offset! $obj = new stdClass(); $obj->id = null; $obj->from = $my->id; $obj->posted_on = $date->toSql(); $obj->from_name = $my->name; $obj->subject = 'RE:' . $message->subject; $obj->body = $reply; $body = new JRegistry(); $body->set('content', $obj->body); // photo attachment if ($photoId > 0) { //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') { $body->set('attached_photo_id', $photoId); //sets the status to ready so that it wont be deleted on cron run $photo->status = 'ready'; $photo->store(); } } /** * @since 3.2.1 * Message URL fetching */ if (preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $obj->body)) { $graphObject = CParsers::linkFetch($obj->body); if ($graphObject) { $graphObject->merge($body); $obj->body = $graphObject->toString(); } } else { $obj->body = $body->toString(); } $model->sendReply($obj, $msgId); $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $obj->id); $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id); //add user points CUserPoints::assignPoint('inbox.message.reply'); // Add notification foreach ($messageRecipient as $row) { $params = new CParameter(''); $params->set('message', $reply); $params->set('title', $obj->subject); $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgId); $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgId); $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE')); $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE')); CNotificationLibrary::add('inbox_create_message', $my->id, $row, JText::_('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params); } // onMessageDisplay Event trigger $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(); $args[] = $obj; $appsLib->triggerEvent('onMessageDisplay', $args); $params = new JRegistry($obj->body); // Escape content $content = $originalContent = $params->get('content'); $content = CTemplate::escape($content); $content = CStringHelper::autoLink($content); $content = nl2br($content); $content = CStringHelper::getEmoticon($content); $content = CStringHelper::converttagtolink($content); //get thumbnail if available $photoThumbnail = ''; if ($params->get('attached_photo_id')) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); } $tmpl = new CTemplate(); $tmpl->set('user', CFactory::getUser($obj->from)); $tmpl->set('msg', $obj); $tmpl->set('originalContent', $originalContent); $tmpl->set('content', $content); $tmpl->set('params', $params); $tmpl->set('removeLink', $deleteLink); $tmpl->set('authorLink', $authorLink); $tmpl->set('photoThumbnail', $photoThumbnail); $html = $tmpl->fetch('inbox.message'); $json = array('success' => true, 'html' => $html); die(json_encode($json)); }
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)); }
/** * Show the message reading window */ public function read($data) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (!$this->accessAllowed('registered')) { return; } $config = CFactory::getConfig(); if (!$config->get('enablepm')) { echo JText::_('COM_COMMUNITY_PRIVATE_MESSAGING_DISABLED'); return; } //page title $document = JFactory::getDocument(); $inboxModel = CFactory::getModel('inbox'); $my = CFactory::getUser(); $msgid = $jinput->request->get('msgid', 0, 'INT'); if (!$inboxModel->canRead($my->id, $msgid)) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'), 'error'); return; } $pathway = $mainframe->getPathway(); $pathway->addItem($this->escape(JText::_('COM_COMMUNITY_INBOX_TITLE')), CRoute::_('index.php?option=com_community&view=inbox')); $parentData = ''; $html = ''; $messageHeading = ''; $recipient = array(); $parentData = $inboxModel->getMessage($msgid); if (!empty($data->messages)) { $document = JFactory::getDocument(); $pathway->addItem($this->escape(htmlspecialchars_decode($parentData->subject))); $document->setTitle(htmlspecialchars_decode($parentData->subject)); require_once COMMUNITY_COM_PATH . '/libraries/apps.php'; $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $config = CFactory::getConfig(); $pagination = intval($config->get('stream_default_comments', 5)); $count = count($data->messages); $hide = true; foreach ($data->messages as $row) { $count--; if ($count < $pagination) { $hide = false; } // onMessageDisplay Event trigger $args = array(); $originalBodyContent = $row->body; $row->body = new JRegistry($row->body); if ($row->body == '{}') { //backward compatibility, save the old data into content parameter if needed $newParam = new CParameter(); $newParam->set('content', $originalBodyContent); $table = JTable::getInstance('Message', 'CTable'); $table->load($row->id); $table->body = $newParam->toString(); $table->store(); $row->body = new CParameter($table->body); } // Escape content $content = $originalContent = $row->body->get('content'); $content = CTemplate::escape($content); $content = CStringHelper::autoLink($content); $content = nl2br($content); $content = CStringHelper::getEmoticon($content); $content = CStringHelper::converttagtolink($content); $content = CUserHelper::replaceAliasURL($content); $params = $row->body; $args[] = $row; $appsLib->triggerEvent('onMessageDisplay', $args); $user = CFactory::getUser($row->from); //construct the delete link $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $row->id); $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); //get thumbnail if available $photoThumbnail = ''; if ($params->get('attached_photo_id')) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); } $tmpl = new CTemplate(); $html .= $tmpl->set('user', $user)->set('msg', $row)->set('hide', $hide)->set('originalContent', $originalContent)->set('content', $content)->set('params', $params)->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('photoThumbnail', $photoThumbnail)->fetch('inbox.message'); } $myLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id); $recipient = $inboxModel->getRecepientMessage($msgid); $recepientCount = count($recipient); $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR'; $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount)); } else { $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>'; } //end if $tmplMain = new CTemplate(); echo $tmplMain->set('messageHeading', $messageHeading)->set('recipient', $recipient)->set('limit', $pagination)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $html)->set('my', $my)->set('submenu', $this->showSubmenu(false))->fetch('inbox.read'); }
?> </a> </span> <span class="joms-stream__time"> <small> <?php echo $discussion['created_interval']; ?> </small> </span> </div> </div> <div class="joms-stream__body"> <?php // Escape content $discussion['comment'] = CTemplate::escape($discussion['comment']); $discussion['comment'] = CStringHelper::autoLink($discussion['comment']); $discussion['comment'] = nl2br($discussion['comment']); $discussion['comment'] = CStringHelper::getEmoticon($discussion['comment']); $discussion['comment'] = CStringHelper::converttagtolink($discussion['comment']); $discussion['comment'] = CUserHelper::replaceAliasURL($discussion['comment']); echo substr($discussion['comment'], 0, 250); if (strlen($discussion['comment']) > 250) { echo ' ...'; } // @TODO: DRY $video = JTable::getInstance('Video', 'CTable'); if ($video->init($params->get('url'))) { $video->isValid(); } else { $video = false;
/** * 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; }
/** * * @param type $userid * @param type $limit * @param type $limitstart * @param type $row * @param type $total * @return type */ public static function _getLatestPhotoHTML($userid, $limit, $limitstart, $row, $total) { $config = CFactory::getConfig(); $photo = JTable::getInstance('Photo', 'CTable'); $isPhotoModal = $config->get('album_mode') == 1; ob_start(); if (!empty($row)) { ?> <ul class="joms-list--thumbnail"> <?php $i = 0; foreach ($row as $data) { $photo->load($data->id); if ($isPhotoModal) { $link = 'javascript:" onclick="joms.api.photoOpen(\'' . $photo->albumid . '\', \'' . $photo->id . '\');'; } else { $link = plgCommunityMyLatestPhotos::buildLink($photo->albumid, $data->id); } $thumbnail = $photo->getThumbURI(); ?> <li class="joms-list__item"> <a href="<?php echo $link; ?> "> <img title="<?php echo CTemplate::escape($photo->caption); ?> " src="<?php echo $thumbnail; ?> "> </a> </li> <?php } // end foreach ?> </ul> <?php } else { ?> <div><?php echo JText::_('PLG_COMMUNITY_MYLATESTPHOTOS_NO_PHOTO'); ?> </div> <?php } ?> <?php $contents = ob_get_contents(); @ob_end_clean(); $html = $contents; return $html; }
/** * * */ public function ajaxAddTag($element, $id, $tagString) { $filter = JFilterInput::getInstance(); $id = $filter->clean($id, 'int'); $tagString = $filter->clean($tagString, 'string'); $element = $filter->clean($element, 'string'); $objResponse = new JAXResponse(); // @todo: make sure user has the permission CFactory::load('libraries', 'tags'); $tags = new CTags(); $tagString = JString::trim($tagString); // If there is only 1 word, add a space so thet the next 'explode' call works $tagStrings = explode(',', $tagString); // @todo: limit string lenght foreach ($tagStrings as $row) { // Need to trim unwanted char $row = JString::trim($row, " ,;:"); // For each tag, we ucwords them for consistency $row = ucwords($row); // @todo: Send out warning or error message that the string is too short if (JString::strlen($row) >= CTags::MIN_LENGTH) { // Only add to the tag list if add is successful if ($tags->add($element, $id, $row)) { // @todo: get last tag id inserted $tagid = $tags->lastInsertId(); // urlescape the string $row = CTemplate::escape($row); $objResponse->addScriptCall("joms.jQuery('#tag-list').append", "<li id=\"tag-" . $tagid . "\"><span class=\"tag-token\"><a href=\"javascript:void(0);\" onclick=\"joms.tag.list('" . $row . "')\">{$row}</a><a href=\"javascript:void(0);\" style=\"display:block\" class=\"tag-delete\" onclick=\"joms.tag.remove('" . $tagid . "')\">x</a></span></li>"); } } } $objResponse->addScriptCall('joms.jQuery(\'#tag-addbox\').val', ''); return $objResponse->sendResponse(); }