/** * @param ActivityTable $row * @param Activity $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin * @return null|string */ static public function showAttachments( $row, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; if ( ! $stream->get( 'links', 1 ) ) { return null; } $links = $row->attachments(); $_PLUGINS->trigger( 'activity_onDisplayActivityAttachments', array( &$row, &$links, $stream, $output ) ); if ( ! $links ) { return null; } $cbModerator = CBActivity::isModerator( (int) $viewer->get( 'id' ) ); $isStatus = ( ( $row->get( 'type' ) == 'status' ) || ( $row->get( 'subtype' ) == 'status' ) ); $rowOwner = ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ); $count = count( $links ); $return = '<div class="streamItemScroll">' . '<div class="streamItemScrollLeft' . ( $count > 1 ? null : ' hidden' ) . '">' . '<table>' . '<tr>' . '<td>' . '<span class="streamItemScrollLeftIcon fa fa-chevron-left"></span>' . '</td>' . '</tr>' . '</table>' . '</div>'; foreach ( $links as $i => $link ) { $hasMedia = ( ( $link['type'] == 'custom' ) || ( ( $link['type'] != 'url' ) && $link['media']['url'] ) || ( ( $link['type'] == 'url' ) && $link['media']['url'] && $link['thumbnail'] ) ); $return .= '<div class="activityContainerAttachment streamItemScrollContent ' . ( $link['type'] == 'url' ? 'streamMedia media' : 'streamPanel panel' ) . ( $i != 0 ? ' hidden' : null ) . '">'; if ( $hasMedia ) { $return .= '<div class="activityContainerAttachmentMedia ' . ( $link['type'] == 'url' ? 'streamMediaLeft media-left' : 'streamPanelBody panel-body' ) . ' text-center">'; switch ( $link['type'] ) { case 'custom': $return .= $link['media']['custom']; break; case 'video': $return .= '<video width="640" height="360" style="width: 100%; height: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemVideo" preload="none" controls></video>'; break; case 'audio': $return .= '<audio width="640" style="width: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemAudio" preload="none" controls></audio>'; break; case 'image': $return .= '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . '<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />' . '</a>'; break; case 'url': default: $return .= '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . '<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />' . '</a>'; break; } $return .= '</div>'; } if ( $link['title'] || $link['description'] || ( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ) || ( $count > 1 ) ) { $hypertext = ( $link['text'] ? CBTxt::T( $link['text'] ) : $link['url'] ); $return .= '<div class="streamPanelFooter streamItemDisplay activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . '">' . '<div class="cbMoreLess">' . '<div class="cbMoreLessContent">' . ( $link['title'] ? '<div><strong><a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( CBTxt::T( $link['title'] ) ) : CBTxt::T( $link['title'] ) ) . '</a></strong></div>' : null ) . ( $isStatus ? htmlspecialchars( CBTxt::T( $link['description'] ) ) : CBTxt::T( $link['description'] ) ) . '</div>' . '<div class="activityContainerAttachmentUrl small">' . ( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ? '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( $hypertext ) : $hypertext ) . '</a>' : null ) . ( $count > 1 ? '<div class="activityContainerAttachmentCount text-muted">' . ( $i + 1 ) . ' - ' . $count . '</div>' : null ) . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>'; } if ( $isStatus && ( $cbModerator || $rowOwner ) ) { $return .= '<div class="streamPanelFooter streamItemEdit activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . ' hidden">' . '<input type="text" id="' . $stream->id() . '_links_title_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][title]" value="' . htmlspecialchars( $link['title'] ) . '" class="streamInput streamInputLinkTitle form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Title' ) ) . '" />' . '<textarea id="' . $stream->id() . '_links_description_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][description]" rows="1" class="streamInput streamInputAutosize streamInputLinkDescription form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Description' ) ) . '">' . htmlspecialchars( $link['description'] ) . '</textarea>'; if ( $link['type'] == 'url' ) { $return .= '<div class="streamInput">' . '<label class="checkbox-inline">' . '<input type="checkbox" id="' . $stream->id() . '_links_thumbnail_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][thumbnail]" value="0"' . ( ! $link['thumbnail'] ? ' checked="checked"' : null ) . '> ' . CBTxt::T( 'Do not display thumbnail' ) . '</label>' . '</div>'; } $return .= '</div>'; } $return .= '</div>'; } $return .= '<div class="streamItemScrollRight' . ( $count > 1 ? null : ' hidden' ) . '">' . '<table>' . '<tr>' . '<td>' . '<span class="streamItemScrollRightIcon fa fa-chevron-right"></span>' . '</td>' . '</tr>' . '</table>' . '</div>' . '</div>'; return $return; }
/** * Displays activity stream * * @param int $id * @param Activity $stream * @param int $output * @param bool $data * @param UserTable $user * @param UserTable $viewer */ private function showActivity( $id, $stream, $output, $data, $user, $viewer ) { CBActivity::getTemplate( 'activity', false, false ); if ( $id ) { $stream->set( 'id', $id ); $stream->set( 'limitstart', 0 ); $stream->set( 'limit', 0 ); $stream->set( 'paging', 0 ); $rows = $stream->data(); } else { if ( $data ) { $count = $stream->data( true ); if ( ! $count ) { $rows = array(); } else { $rows = $stream->data(); if ( $count <= ( $stream->get( 'limitstart' ) + $stream->get( 'limit' ) ) ) { $stream->set( 'paging', 0 ); } } } else { $rows = array(); } } if ( $rows ) { if ( $stream->get( 'comments', 1 ) ) { CBActivity::preFetchComments( $rows, 'activity' ); } if ( $stream->get( 'tags', 1 ) ) { CBActivity::preFetchTags( $rows, 'activity' ); } CBActivity::preFetchUsers( $rows ); } echo HTML_cbactivityActivity::showActivity( $rows, $stream, $output, $user, $viewer, $this ); }