bp_nouveau_document_localize_scripts( array $params = array() )

Localize the strings needed for the messages UI

Description

Parameters

$params

(Optional) Associative array containing the JS Strings needed by scripts.

Default value: array()

Return

(array) The same array with specific strings for the messages UI if needed.

Source

File: bp-templates/bp-nouveau/includes/document/functions.php

function bp_nouveau_document_localize_scripts( $params = array() ) {

	$extensions     = array();
	$mime_types     = array();
	$all_extensions = bp_document_extensions_list();
	foreach ( $all_extensions as $extension ) {
		if ( isset( $extension['is_active'] ) && true === (bool) $extension['is_active'] ) {
			$mime_types[] = $extension['mime_type'];
			$extensions[] = $extension['extension'];
		}
	}

	$folder_id        = 0;
	$type             = '';
	$user_id          = bp_loggedin_user_id();
	$group_id         = 0;
	$move_to_id_popup = $user_id;
	if ( bp_is_group_document() || bp_is_group_folders() ) {
		$folder_id        = (int) bp_action_variable( 1 );
		$type             = 'group';
		$group_id         = ( bp_get_current_group_id() ) ? bp_get_current_group_id() : '';
		$move_to_id_popup = $group_id;
	} elseif ( bp_is_user_document() || bp_is_user_folders() ) {
		$folder_id        = (int) bp_action_variable( 0 );
		$type             = 'profile';
		$move_to_id_popup = $user_id;
	} elseif ( bp_is_document_directory() ) {
		$folder_id = 0;
		$type      = 'profile';
	}

	$exclude = array_merge( $mime_types, $extensions );
	$document_params = array(
		'profile_document'                => bp_is_profile_document_support_enabled(),
		'group_document'                  => bp_is_group_document_support_enabled(),
		'messages_document'               => bp_is_messages_document_support_enabled(),
		'document_type'                   => implode( ',', array_unique( $exclude ) ),
		'empty_document_type'             => __( 'Empty documents will not be uploaded.', 'buddyboss' ),
		'current_folder'                  => $folder_id,
		'current_type'                    => $type,
		'move_to_id_popup'                => $move_to_id_popup,
		'current_user_id'                 => $user_id,
		'current_group_id'                => $group_id,
		'target_text'                     => __( 'Documents', 'buddyboss' ),
		'create_folder_error_title'       => __( 'Please enter title of folder', 'buddyboss' ),
		'invalid_file_type'                => __( 'Unable to upload the file', 'buddyboss' ),
		'document_select_error'           => __( 'Please upload only the following file types: ', 'buddyboss' ) . '<br /><div class="bb-allowed-file-types">' . implode( ', ', array_unique( $extensions ) ) . '</div>',
		'dropzone_document_message'       => __( 'Drop files here to upload', 'buddyboss' ),
		'is_document_directory'           => ( bp_is_document_directory() ) ? 'yes' : 'no',
		'document_preview_error'          => __( 'Sorry! something went wrong we are not able to preview.', 'buddyboss' ),
		'move_to_folder'                  => __( 'Move folder to...', 'buddyboss' ),
		'move_to_file'                     => __( 'Move document to...', 'buddyboss' ),
		'copy_to_clip_board_text'         => __( 'Copied to Clipboard', 'buddyboss' ),
		'download_button'                 => __( 'Download', 'buddyboss' ),
		'document_size_error_header'      => __( 'File too large ', 'buddyboss' ),
		'document_size_error_description' => __( 'This file type is too large.', 'buddyboss' ),
		'sidebar_download_text'           => __( 'Download', 'buddyboss' ),
		'sidebar_view_text'               => __( 'View', 'buddyboss' ),
		'create_folder'                   => __( 'Create Folder', 'buddyboss' ),
	);

	$document_options = array(
		'dictInvalidFileType'       => __( 'Please upload only the following file types: ', 'buddyboss' ) . '<br /><div class="bb-allowed-file-types">' . implode( ', ', array_unique( $extensions ) ) . '</div>',
		'max_upload_size'           => bp_document_file_upload_max_size( false, 'MB' ),
		'maxFiles'                  => apply_filters( 'bp_document_upload_chunk_limit', 10 ),
		'mp3_preview_extension'     => implode( ',', bp_get_document_preview_music_extensions() )
	);

	$params['document'] = $document_options;

	$old_media = $params['media'];

	$params['media'] = array_merge( $old_media, $document_params );

	if ( bp_is_single_folder() ) {
		$params['media']['folder_id'] = (int) bp_action_variable( 0 );
	}

	if ( bp_is_group_single() && bp_is_group_folders() ) {
		$params['media']['folder_id'] = (int) bp_action_variable( 1 );
	}

	$document_i18n_strings = array(
		'folder_delete_confirm'   => __( 'Are you sure you want to delete this folder? Documents in this folder will also be deleted?', 'buddyboss' ),
		'document_delete_confirm' => __( 'Are you sure you want to delete this document?', 'buddyboss' ),
		'folder_delete_error'     => __( 'There was a problem deleting the folder.', 'buddyboss' ),
		'folder_move_error'       => __( 'Please select destination folder.', 'buddyboss' ),
	);

	$old_i18n_strings = $params['media']['i18n_strings'];

	$params['media']['i18n_strings'] = array_merge( $old_i18n_strings, $document_i18n_strings );

	return $params;
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.