-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRJ-58 - Added template for media/video/document activity display
- Loading branch information
1 parent
1257d3f
commit d932a1d
Showing
8 changed files
with
677 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/bp-templates/bp-nouveau/readylaunch/document/activity-document-actions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document actions | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
global $document_template; | ||
$document_id = bp_get_document_id(); | ||
$document_attachment_id = bp_get_document_attachment_id(); | ||
$download_url = bp_document_download_link( $document_attachment_id, $document_id ); | ||
$document_privacy = bb_media_user_can_access( $document_id, 'document' ); | ||
$can_download_btn = true === (bool) $document_privacy['can_download']; | ||
$can_view = true === (bool) $document_privacy['can_view']; | ||
$can_move = true === (bool) $document_privacy['can_move']; | ||
$can_add = true === (bool) $document_privacy['can_add']; | ||
$can_delete = true === (bool) $document_privacy['can_delete']; | ||
$db_privacy = bp_get_db_document_privacy(); | ||
$is_comment_doc = bp_document_is_activity_comment_document( $document_template->document ); | ||
$document_user_id = bp_get_document_user_id(); | ||
|
||
$group_id = bp_get_document_group_id(); | ||
if ( $group_id > 0 ) { | ||
$move_id = $group_id; | ||
$move_type = 'group'; | ||
} else { | ||
$move_id = $document_user_id; | ||
$move_type = 'profile'; | ||
} | ||
?> | ||
<div class="document-action-wrap"> | ||
<a href="#" class="document-action_collapse" data-balloon-pos="up" data-tooltip-collapse="<?php esc_attr_e( 'Collapse', 'buddyboss' ); ?>" data-balloon="<?php esc_attr_e( 'Expand', 'buddyboss' ); ?>"><i class="bb-icon-merge bb-icon-l document-icon-collapse"></i></a> | ||
<a href="<?php echo esc_url( $download_url ); ?>" class="document-action_download" data-id="<?php echo esc_attr( $document_id ); ?>" data-activity-id="<?php bp_document_activity_id(); ?>" data-balloon-pos="up" data-balloon="<?php esc_attr_e( 'Download', 'buddyboss' ); ?>"> | ||
<i class="bb-icon-l bb-icon-download"></i> | ||
</a> | ||
|
||
<a href="#" target="_blank" class="document-action_more" data-balloon-pos="up" data-balloon="<?php esc_attr_e( 'More actions', 'buddyboss' ); ?>"> | ||
<i class="bb-icon-f bb-icon-ellipsis-h"></i> | ||
</a> | ||
<div class="document-action_list bb_more_dropdown"> | ||
<?php bp_get_template_part( 'common/more-options-view' ); ?> | ||
<ul class="conflict-activity-ul-li-comment"> | ||
<?php | ||
if ( $can_download_btn ) { | ||
?> | ||
<li class="copy_download_file_url document-action-class"> | ||
<a href="<?php echo esc_url( $download_url ); ?>"><?php esc_attr_e( 'Copy Download Link', 'buddyboss' ); ?></a> | ||
</li> | ||
<?php | ||
} | ||
if ( $can_move || bp_loggedin_user_id() === $document_user_id || bp_current_user_can( 'bp_moderate' ) ) { | ||
if ( ! in_array( $db_privacy, array( 'forums', 'message' ), true ) ) { | ||
if ( $is_comment_doc ) { | ||
?> | ||
<li class="move_file document-action-class move-disabled" data-balloon-pos="down" data-balloon="<?php esc_attr_e( 'Document inherits activity privacy in comment. You are not allowed to move.', 'buddyboss' ); ?>"> | ||
<a href="#"><?php esc_attr_e( 'Move', 'buddyboss' ); ?></a> | ||
</li> | ||
<?php | ||
} else { | ||
if ( $can_move ) { | ||
?> | ||
<li class="move_file document-action-class"> | ||
<a href="#" data-action="document" data-type="<?php echo esc_attr( $move_type ); ?>" id="<?php echo esc_attr( $move_id ); ?>" class="ac-document-move"><?php esc_attr_e( 'Move', 'buddyboss' ); ?></a> | ||
</li> | ||
<?php | ||
} | ||
} | ||
} | ||
$item_id = 0; | ||
if ( bp_is_active( 'activity' ) ) { | ||
$activity_comment_id = bp_get_activity_comment_id(); | ||
$item_id = ( $activity_comment_id ) ? $activity_comment_id : bp_get_activity_id(); | ||
} | ||
if ( $can_delete ) { | ||
?> | ||
<li class="delete_file document-action-class"> | ||
<a class="document-file-delete" data-item-activity-id="<?php echo esc_attr( $item_id ); ?>" data-item-from="activity" data-item-preview-attachment-id="<?php echo esc_attr( bp_get_document_preview_attachment_id() ); ?>" data-item-attachment-id="<?php echo esc_attr( $document_attachment_id ); ?>" data-item-id="<?php echo esc_attr( $document_id ); ?>" data-type="<?php echo esc_attr( 'document' ); ?>" href="#"><?php esc_attr_e( 'Delete', 'buddyboss' ); ?></a> | ||
</li> | ||
<?php | ||
} | ||
} | ||
?> | ||
</ul> | ||
</div> | ||
<div class="bb_more_dropdown_overlay"></div> | ||
</div> |
14 changes: 14 additions & 0 deletions
14
src/bp-templates/bp-nouveau/readylaunch/document/activity-document-preview.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document preview main. | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
// Doc/PDF/image extension files preview. | ||
bp_get_template_part( 'document/doc-preview' ); | ||
|
||
// Audio extension files preview. | ||
bp_get_template_part( 'document/audio-preview' ); |
113 changes: 113 additions & 0 deletions
113
src/bp-templates/bp-nouveau/readylaunch/document/activity-entry.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document entry. | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
$document_id = bp_get_document_id(); | ||
$attachment_id = bp_get_document_attachment_id(); | ||
$extension = bp_get_document_extension(); | ||
$db_privacy = bp_get_db_document_privacy(); | ||
$doc_activity_id = bp_get_document_activity_id(); | ||
$doc_parent_activity_id = bp_get_document_parent_activity_id(); | ||
$doc_user_id = bp_get_document_user_id(); | ||
$doc_folder_id = bp_get_document_folder_id(); | ||
$doc_group_id = bp_get_document_group_id(); | ||
$doc_attachment_url = bp_get_document_attachment_url(); | ||
$svg_icon = bp_document_svg_icon( $extension, $attachment_id ); | ||
$svg_icon_download = bp_document_svg_icon( 'download' ); | ||
$url = wp_get_attachment_url( $attachment_id ); | ||
$filename = basename( get_attached_file( $attachment_id ) ); | ||
$size = is_file( get_attached_file( $attachment_id ) ) ? bp_document_size_format( filesize( get_attached_file( $attachment_id ) ) ) : 0; | ||
$download_url = bp_document_download_link( $attachment_id, $document_id ); | ||
$document_privacy = bb_media_user_can_access( $document_id, 'document' ); | ||
$can_download_btn = true === (bool) $document_privacy['can_download']; | ||
$can_edit_btn = true === (bool) $document_privacy['can_edit']; | ||
$can_view = true === (bool) $document_privacy['can_view']; | ||
$can_add = true === (bool) $document_privacy['can_add']; | ||
$can_move = true === (bool) $document_privacy['can_move']; | ||
$can_delete = true === (bool) $document_privacy['can_delete']; | ||
$extension_lists = bp_document_extensions_list(); | ||
$attachment_url = ''; | ||
$mirror_text = ''; | ||
|
||
if ( $attachment_id ) { | ||
$text_attachment_url = wp_get_attachment_url( $attachment_id ); | ||
$mirror_text = bp_document_mirror_text( $attachment_id ); | ||
} | ||
|
||
$class_theatre = apply_filters( 'bp_document_activity_theater_class', 'bb-open-document-theatre' ); | ||
$class_popup = apply_filters( 'bp_document_activity_theater_description_class', 'document-detail-wrap-description-popup' ); | ||
$click_text = apply_filters( 'bp_document_activity_click_to_view_text', __( ' view', 'buddyboss' ) ); | ||
$video_url = bb_document_video_get_symlink( $document_id ); | ||
$user_can_edit = bp_document_user_can_edit( $document_id ); | ||
?> | ||
|
||
<div class="bb-activity-media-elem document-activity <?php echo esc_attr( $document_id ); ?> <?php echo wp_is_mobile() ? 'is-mobile' : ''; ?>" data-id="<?php echo esc_attr( $document_id ); ?>" data-parent-id="<?php bp_document_parent_id(); ?>"> | ||
<?php bp_get_template_part( 'document/activity-document-preview' ); ?> <!-- .bb-code-extension-files-preview. --> | ||
<div class="document-description-wrap"> | ||
<a | ||
href="<?php echo esc_url( $download_url ); ?>" | ||
class="entry-img <?php echo esc_attr( $class_theatre ); ?>" | ||
data-id="<?php echo esc_attr( $document_id ); ?>" | ||
data-attachment-full="" | ||
data-attachment-id="<?php echo esc_attr( $attachment_id ); ?>" | ||
data-privacy="<?php echo esc_attr( $db_privacy ); ?>" | ||
data-extension="<?php echo $extension ? esc_attr( $extension ) : ''; ?>" | ||
data-parent-activity-id="<?php echo esc_attr( $doc_parent_activity_id ); ?>" | ||
data-activity-id="<?php echo esc_attr( $doc_activity_id ); ?>" | ||
data-author="<?php echo esc_attr( $doc_user_id ); ?>" | ||
data-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-full-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-text-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-video-preview="<?php echo $video_url ? esc_url( $video_url ) : ''; ?>" | ||
data-mp3-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-album-id="<?php echo esc_attr( $doc_folder_id ); ?>" | ||
data-group-id="<?php echo esc_attr( $doc_group_id ); ?>" | ||
data-document-title="<?php echo esc_html( $filename ); ?>" | ||
data-mirror-text="<?php echo esc_html( $mirror_text ); ?>" | ||
data-can-edit="<?php echo esc_attr( $user_can_edit ); ?>" | ||
data-icon-class="<?php echo esc_attr( $svg_icon ); ?>"> | ||
<i class="<?php echo esc_attr( $svg_icon ); ?>"></i> | ||
</a> | ||
<a | ||
href="<?php echo esc_url( $download_url ); ?>" | ||
class="document-detail-wrap <?php echo esc_attr( $class_popup ); ?>" | ||
data-id="<?php echo esc_attr( $document_id ); ?>" | ||
data-attachment-id="<?php echo esc_attr( $attachment_id ); ?>" | ||
data-attachment-full="" | ||
data-privacy="<?php echo esc_attr( $db_privacy ); ?>" | ||
data-extension="<?php echo $extension ? esc_attr( $extension ) : ''; ?>" | ||
data-parent-activity-id="<?php echo esc_attr( $doc_parent_activity_id ); ?>" | ||
data-activity-id="<?php echo esc_attr( $doc_activity_id ); ?>" | ||
data-author="<?php echo esc_attr( $doc_user_id ); ?>" | ||
data-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-full-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-text-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-mp3-preview="<?php echo esc_attr( $doc_attachment_url ); ?>" | ||
data-video-preview="<?php echo $video_url ? esc_url( $video_url ) : ''; ?>" | ||
data-album-id="<?php echo esc_attr( $doc_folder_id ); ?>" | ||
data-group-id="<?php echo esc_attr( $doc_group_id ); ?>" | ||
data-document-title="<?php echo esc_html( $filename ); ?>" | ||
data-mirror-text="<?php echo esc_html( $mirror_text ); ?>" | ||
data-can-edit="<?php echo esc_attr( $user_can_edit ); ?>" | ||
data-icon-class="<?php echo esc_attr( $svg_icon ); ?>"> | ||
<span class="document-title"><?php echo esc_html( $filename ); ?></span> | ||
<span class="document-description"><?php echo esc_html( $size ); ?></span> | ||
<span class="document-extension-description"><?php echo esc_html( bp_document_get_extension_description( $extension ) ); ?></span> | ||
<span class="document-helper-text"> <span> - </span><span class="document-helper-text-click"><?php esc_html_e( 'Click to', 'buddyboss' ); ?></span><span class="document-helper-text-inner"><?php echo esc_html( $click_text ); ?></span></span> | ||
</a> | ||
</div> | ||
|
||
<?php | ||
// .bb-activity-document-actions. | ||
bp_get_template_part( 'document/activity-document-actions' ); | ||
|
||
// Code extension files preview. | ||
bp_get_template_part( 'document/code-preview' ); | ||
?> | ||
|
||
</div> <!-- .bb-activity-media-elem --> |
28 changes: 28 additions & 0 deletions
28
src/bp-templates/bp-nouveau/readylaunch/document/audio-preview.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document audio preview. | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
$audio_url = ''; | ||
$doc_extension = bp_get_document_extension(); | ||
$doc_preview_music_extensions = bp_get_document_preview_music_extensions(); | ||
$bp_document_music_preview = apply_filters( 'bp_document_music_preview', true ); | ||
|
||
if ( in_array( $doc_extension, $doc_preview_music_extensions, true ) && $bp_document_music_preview ) { | ||
$audio_url = bp_document_get_preview_audio_url( bp_get_document_id(), bp_get_document_attachment_id(), $doc_extension ); | ||
} | ||
|
||
if ( in_array( $doc_extension, $doc_preview_music_extensions, true ) ) { | ||
?> | ||
<div class="document-audio-wrap"> | ||
<audio controls controlsList="nodownload"> | ||
<source src="<?php echo esc_url( $audio_url ); ?>" type="audio/mpeg"> | ||
<?php esc_html_e( 'Your browser does not support the audio element.', 'buddyboss' ); ?> | ||
</audio> | ||
</div> | ||
<?php | ||
} |
54 changes: 54 additions & 0 deletions
54
src/bp-templates/bp-nouveau/readylaunch/document/code-preview.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document code preview | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @var string $download_url Download Url. | ||
* | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
$attachment_id = bp_get_document_attachment_id(); | ||
$download_url = bp_document_download_link( $attachment_id, bp_get_document_id() ); | ||
$extension = bp_get_document_extension(); | ||
/** | ||
* Filters the document text preview. | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* | ||
* @param bool $retval Whether document text preview. | ||
*/ | ||
$bp_document_text_preview = apply_filters( 'bp_document_text_preview', true ); | ||
$sizes = is_file( get_attached_file( $attachment_id ) ) ? get_attached_file( $attachment_id ) : 0; | ||
|
||
if ( $sizes && filesize( $sizes ) / 1e+6 < 2 && $bp_document_text_preview ) { | ||
if ( in_array( $extension, bp_get_document_preview_code_extensions(), true ) ) { | ||
$data = bp_document_get_preview_text_from_attachment( $attachment_id ); | ||
$file_data = $data['text']; | ||
$more_text = $data['more_text'] | ||
?> | ||
<div class="document-text-wrap"> | ||
<div class="document-text" data-extension="<?php echo esc_attr( $extension ); ?>"> | ||
<textarea class="document-text-file-data-hidden" style="display: none;"><?php echo wp_kses_post( $file_data ); ?></textarea> | ||
</div> | ||
<div class="document-expand"> | ||
<a href="#" class="document-expand-anchor"><i class="bb-icon-l bb-icon-expand document-icon-plus"></i> | ||
<span><?php esc_html_e( 'Expand', 'buddyboss' ); ?></span></a> | ||
</div> | ||
</div> <!-- .document-text-wrap --> | ||
<?php | ||
if ( true === $more_text ) { | ||
|
||
printf( | ||
/* translators: %s: download string */ | ||
'<div class="more_text_view">%s</div>', | ||
sprintf( | ||
/* translators: %s: download url */ | ||
wp_kses_post( 'This file was truncated for preview. Please <a href="%s">download</a> to view the full file.', 'buddyboss' ), | ||
esc_url( $download_url ) | ||
) | ||
); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/bp-templates/bp-nouveau/readylaunch/document/doc-preview.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* ReadyLaunch - The template for activity document doc preview. | ||
* | ||
* @since BuddyBoss [BBVERSION] | ||
* @package BuddyBoss\Core | ||
* @version 1.0.0 | ||
*/ | ||
|
||
$bp_document_image_preview = apply_filters( 'bp_document_image_preview', true ); | ||
$attachment_url = bp_get_document_attachment_image_activity_thumbnail(); | ||
$bp_get_document_extension = bp_get_document_extension(); | ||
if ( | ||
$attachment_url && | ||
$bp_document_image_preview && | ||
! in_array( $bp_get_document_extension, bp_get_document_preview_code_extensions(), true ) && // exclude file extension. | ||
! in_array( $bp_get_document_extension, bp_get_document_preview_music_extensions(), true ) // exclude audio extension. | ||
) { | ||
?> | ||
<div class="document-preview-wrap"> | ||
<img src="<?php echo esc_url( $attachment_url ); ?>" alt="" /> | ||
</div><!-- .document-preview-wrap --> | ||
<?php | ||
} |
Oops, something went wrong.