/** * Tests the JHtmlString::abridge method. * * @param string $text The text to truncate. * @param integer $length The maximum length of the text. * @param integer $intro The maximum length of the intro text. * @param string $expected The expected result. * * @return void * * @dataProvider getTestAbridgeData * @since 11.3 */ public function testAbridge($text, $length, $intro, $expected) { $this->assertThat(JHtmlString::abridge($text, $length, $intro), $this->equalTo($expected)); }
?> " /> <?php } ?> </div> <div class="file-list-meta"> <a class="file-title" data-filename="<?php echo StreamTemplate::escape($fullFilename); ?> " href="<?php echo JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $row->id); ?> "><?php echo StreamTemplate::escape(JHtmlString::abridge($row->filename, 32, 25)); ?> </a> <span class="small"> <?php $fext = strtolower(substr($row->filename, -4)); if ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled()) { if (in_array($fext, array('.doc', 'docx', '.pdf', '.ppt', 'pptx'))) { echo ' <a href="javascript:void(0);" class="meta-preview small" data-message_id="' . $row->stream_id . '" data-filename="' . StreamTemplate::escape($row->filename) . '" data-file_id="' . $row->id . '" onclick="S.preview.show(this);">' . JText::_('COM_STREAM_LABEL_PREVIEW') . '</a>'; } } ?> (<?php echo StreamMessage::formatBytes($row->filesize); ?> )
/** * Tests the JHtmlString::abridge method. * * @param string $text The text to truncate. * @param integer $length The maximum length of the text. * @param integer $intro The maximum length of the intro text. * @param string $expected The expected result. * * @return void * * @since 3.1 * @dataProvider getTestAbridgeData */ public function testAbridge($text, $length, $intro, $expected) { $this->assertEquals($expected, JHtmlString::abridge($text, $length, $intro)); }
<ul id="edit-attachment-list" class="edit-attachment"> <!-- show attachement to allow file deletion --> <?php if (!empty($files)) { foreach ($files as $file) { ?> <li style="list-style: none outside none;margin-left:0px;padding-left: 8px;" class="qq-upload-success"> <div data-filename="<?php echo $file->filename; ?> " class="message-content-file" file_id="<?php echo $file->id; ?> "> <?php echo StreamTemplate::escape(JHtmlString::abridge($file->filename, 24)); ?> <span class="small hint">(<?php echo StreamMessage::formatBytes($file->filesize, 1); ?> )</span> <a file_id="<?php echo $file->id; ?> " href="#unlinkAttachment" class="meta-edit">Remove</a> <input type="hidden" value="<?php echo $file->id; ?> " name="attachment[]"> </div> </li>
/** * Return attachment view for the given stream */ public static function getAttachmentHTML($stream) { $my = JXFactory::getUser(); $data = json_decode($stream->raw); $html = ''; if (!function_exists('whoMakesAction')) { /** * Call this function to retrieve the item/message viewer * @param JTable $stream the current StreamTable * @param int $item_id the owner of the item (for example: id of the file or id of a message contains a link) * @param String $type type of the item (since tracking is done by id, being specific is safer. eg: file_220, link_220) */ function whoMakesAction($stream, $item_id = 0, $type = NULL) { // get list of avatar who viewed the stream $whoMakesAction = $stream->whoMakesAction($item_id, $type); $avatarListWhoMakeAction = ''; if ($whoMakesAction && count($whoMakesAction) > 0) { // Do rename the variable if its too long or easily mistyped $avatarListWhoMakeAction .= '<div class="user-horizontal-list message-reader-list">'; if ($type == 'video') { // change language from READ to SEEN if its a video $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_SEEN_BY') . ' '; } else { $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_READ_BY') . ' '; } /* $avatarListWhoMakeAction .= count($whoMakesAction) . ' reader'; */ $avatarListWhoMakeAction .= '<a href="#showReaders" data-content="<ul>'; foreach ($whoMakesAction as $user_id) { // there will be 0 as user which in return will load current user if ($user_id != 0 && $user_id != NULL) { $user = JXFactory::getUser($user_id); $avatarListWhoMakeAction .= StreamTemplate::escape('<li><a href="' . $user->getURL() . '">' . $user->name . '</a></li>'); } } $avatarListWhoMakeAction .= '</ul>">'; $label = count($whoMakesAction) > 1 ? JText::_('COM_STREAM_LABEL_USERS') : JText::_('COM_STREAM_LABEL_USER'); $avatarListWhoMakeAction .= count($whoMakesAction) . " {$label}</a>"; $avatarListWhoMakeAction .= '</span></div>'; } return $avatarListWhoMakeAction; } } // Attachment $jxConfig = new JXConfig(); $files = $stream->getFiles(); $hasPreview = false; $numPreview = 0; // Sort the files, photos at the bottom usort($files, array('StreamMessage', 'sortAttachment')); $imgHtml = '<div class="message-content-attachment">'; foreach ($files as $file) { // only show if the file does exist // @todo: templatize this ? $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Show file name only if preview doesn't exist // Otherwise, just show the preview. People can click on the preview and download it from tehre if (!$file->getParam('has_preview')) { // Show preview link, of if the filename is doc, docx, pdf, ppt, pptx $fext = strtolower(substr($file->filename, -4)); $html .= '<div data-filename="' . $file->filename . '" ' . 'data-message_id=' . $stream->id . ' class="message-content-file ">'; $html .= '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::abridge($file->filename, 20, 13)) . '</a>'; $html .= ' <span class="small hint">(' . StreamMessage::formatBytes($file->filesize, 1) . ')</span>'; // append to file container only once if ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled()) { if (in_array($fext, array('.doc', 'docx', '.pdf', '.ppt', 'pptx'))) { $html .= ' <a href="#preview" class="meta-preview small" data-filename="' . StreamTemplate::escape($file->filename) . '" data-file_id="' . $file->id . '" onclick="return S.preview.show(this);">' . JText::_('COM_STREAM_LABEL_PREVIEW') . '</a>'; } } $html .= whoMakesAction($stream, $file->id, 'file'); $html .= '<div class="clear"></div>'; $html .= '</div>'; /* // File can only be remove in 'edit' view if( $my->authorise('stream.message.edit', $stream) ){ $html .= '<a class="meta-edit" href="#removeAttachment" file_id="'.$file->id.'">'. JText::_('COM_STREAM_LABEL_REMOVE').'</a>'; } */ } if ($file->getParam('has_preview')) { $randId = 'preview_' . rand(1000, 9999); $path = str_replace(DS, '/', $file->getParam('thumb_path')); $imgHtml .= '<div class="message-content-preview"><img rel="#' . $randId . '" src="' . JURI::root() . $path . '" /></div>'; // Attach overlay code $width = $file->getParam('width'); $height = $file->getParam('height'); if (!empty($width) && !empty($height)) { if ($width > 640) { $height = 640 / $width * $height; $width = 640; } if ($height > 640) { $width = 640 / $height * $width; $height = 640; } $viewLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id . '&display=1'); $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Replace all <show_next> tag, since the previous one is clearly not the last one $imgHtml = str_replace('<show_next>', '<div class="image_next btn btn-large" onclick="$(\'[rel=\\\'#' . $randId . '\\\']\').click();">→</div>', $imgHtml); $imgHtml .= ' <div id="' . $randId . '" class="apple_overlay" style="width:' . $width . 'px">'; // IF this is NOT the first preview, add the 'PREV' button if ($numPreview != 0) { $imgHtml .= '<div class="image_prev btn btn-large" onclick="$(\'[rel=\\\'#' . $prevRandId . '\\\']\').click();">←</div>'; } $imgSrc = $dlLink; if ($file->getParam('preview_path')) { $imgSrc = str_replace(DS, '/', $file->getParam('preview_path')); $imgSrc = JURI::root() . $imgSrc; } $imgHtml .= '<show_next> <a class="close"></a> <img width="' . $width . '" height="' . $height . '" src="' . $imgSrc . '" /> <div> <a href="' . $viewLink . '" target="_blank">View full-size image</a> • <a href="' . $dlLink . '">Download</a></div> </div>'; $prevRandId = $randId; $hasPreview = true; $numPreview++; } } } $imgHtml .= '</div>'; // If there is no attachement at all, remove the div $imgHtml = str_replace('<div class="message-content-attachment"></div>', '', $imgHtml); $html .= $imgHtml; // If we have added the preview, which is left floated, we need to add a clearing div // the sorting function above will make sure that preview'ed would be the last attachment if ($hasPreview) { // Get rid of all the <show_next> marker $html = str_replace('<show_next>', '', $html); $html .= '<div class="clear"></div>'; } // Videos if (!empty($data->video)) { foreach ($data->video as $videoid) { $video = JTable::getInstance('Video', 'StreamTable'); if ($video->load($videoid)) { $html .= '<div class="message-content-video" id="video-' . $videoid . '"> <img class="message-content-video-thumbnail interactive" src="' . $video->thumb . '" embed_id="' . $videoid . '" embed_type="videos"/> <span class="video-duration">' . StreamMessage::formatDuration($video->duration) . '</span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($video->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($video->description, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $video->id, 'video') . ' <div class="clear"></div> </div>'; } } } // Slideshare if (!empty($data->slideshare)) { foreach ($data->slideshare as $slideshareid) { $slideshare = JTable::getInstance('Slideshare', 'StreamTable'); if ($slideshare->load($slideshareid)) { $ss = json_decode($slideshare->response); $html .= '<div class="message-content-video slideshare" id="video-' . $slideshareid . '"> <img src="' . $ss->thumbnail . '" embed_id="' . $slideshareid . '" embed_type="slideshare"/> <span class="video-duration"></span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($ss->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($ss->author_name, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $slideshareid, 'slideshare') . ' <div class="clear"></div> </div>'; } } } /* Link service * Certain link will able to store excerpt from the linked page */ $params = json_decode($stream->params); /* refetch if the link is not grab yet */ $url = self::getLinks($stream->message); if (!empty($url[0])) { $linkTable = JTable::getInstance('Link', 'StreamTable'); if ($linkTable->load(array('link' => $url[0]))) { $linkParam = StreamLinks::format($linkTable->params); if (!empty($linkParam) && strlen($linkParam->text) > 0) { $html .= '<div class="stream-message-links-in-post">'; if ($linkParam->media_type && $linkParam->media_link) { if (strlen($linkParam->media_type == 'image' && $linkParam->media_link) > 0) { $html .= '<div class="stream-links-image-container"> <span> <img class="stream-message-links-image" src="' . StreamLinks::imageAssetThumbnailPath($linkParam->media_link) . '" /> </span> </div>'; } } $html .= '<div class="stream-links-container"> <div class="stream-message-links-title">' . $linkParam->title . '</div> <div class="stream-message-links-url">' . $linkParam->url . '</div> <div class="stream-message-links-content">' . $linkParam->text . '</div>' . '</div><div class="clear"></div>' . whoMakesAction($stream, $stream->id, 'link') . ' <div class="clear"></div> </div>'; } } } return $html; }
foreach ($readBy as $recipientId) { $readByUsers[] = JXFactory::getUser($recipientId)->name; } echo implode(', ', $readByUsers); ?> <?php } ?> </span> </div> </li> <li class="inbox-delete"> <a href="" class="close">×</a> </li> <?php if (!empty($attachments)) { echo '<li style="border-top: 1px solid #EFEFEF; width: 540px; margin-left: 40px;">'; foreach ($attachments as $attachment) { $dlLink = JRoute::_('index.php?option=com_messaging&task=download&file_id=' . $attachment->id); $html = '<div class="message-content-file ">'; $html .= '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::abridge($attachment->filename, 16)) . '</a>'; $html .= ' <span class="small hint">(' . StreamMessage::formatBytes($attachment->filesize, 1) . ')</span>'; $html .= '</div>'; echo $html; } echo '</li>'; } ?> </ul> </li>