Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:13:42 PM (11 years ago)
Author:
tw2113
Message:

More documentation cleanup for part of BP-Core component.

See #6398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-attachment-cover-image.php

    r10194 r10355  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
    … …  
    1919class BP_Attachment_Cover_Image extends BP_Attachment {
    2020        /**
    21          * The constuctor
     21         * The constuctor.
    2222         *
    2323         * @since 2.4.0
    2424         */
    2525        public function __construct() {
    26                 // Allowed cover image types & upload size
     26                // Allowed cover image types & upload size.
    2727                $allowed_types        = bp_attachments_get_allowed_types( 'cover_image' );
    2828                $max_upload_file_size = bp_attachments_get_max_upload_file_size( 'cover_image' );
    … …  
    3535                        'required_wp_files'     => array( 'file', 'image' ),
    3636
    37                         // Specific errors for cover images
     37                        // Specific errors for cover images.
    3838                        'upload_error_strings'  => array(
    3939                                11  => sprintf( __( 'That image is too big. Please upload one smaller than %s', 'buddypress' ), size_format( $max_upload_file_size ) ),
    … …  
    4949         *
    5050         * @param array $allowed_types Array of allowed cover image types.
    51          *
    52          * @return string comma separated list of allowed cover image types.
     51         * @return string $value Comma-separated list of allowed cover image types.
    5352         */
    5453        public static function get_cover_image_types( $allowed_types = array() ) {
    … …  
    6665         * @since 2.4.0
    6766         *
    68          * @param  array $file the temporary file attributes (before it has been moved).
    69          *
    70          * @return array the file with extra errors if needed.
     67         * @param array $file The temporary file attributes (before it has been moved).
     68         * @return array $file The file with extra errors if needed.
    7169         */
    7270        public function validate_upload( $file = array() ) {
    73                 // Bail if already an error
     71                // Bail if already an error.
    7472                if ( ! empty( $file['error'] ) ) {
    7573                        return $file;
    7674                }
    7775
    78                 // File size is too big
     76                // File size is too big.
    7977                if ( $file['size'] > $this->original_max_filesize ) {
    8078                        $file['error'] = 11;
    8179
    82                 // File is of invalid type
     80                // File is of invalid type.
    8381                } elseif ( ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
    8482                        $file['error'] = 12;
    8583                }
    8684
    87                 // Return with error code attached
     85                // Return with error code attached.
    8886                return $file;
    8987        }
    9088
    9189        /**
    92          * Set the directory when uploading a file
    93          *
    94          * @since 2.4.0
    95          *
    96          * @param  array $upload_dir The original Uploads dir.
    97          * @return array upload data (path, url, basedir...)
     90         * Set the directory when uploading a file.
     91         *
     92         * @since 2.4.0
     93         *
     94         * @param array $upload_dir The original Uploads dir.
     95         * @return array $value Upload data (path, url, basedir...).
    9896         */
    9997        public function upload_dir_filter( $upload_dir = array() ) {
    100                 // Default values are for profiles
     98                // Default values are for profiles.
    10199                $object_id = bp_displayed_user_id();
    102100
    … …  
    107105                $object_directory = 'members';
    108106
    109                 // We're in a group, edit default values
     107                // We're in a group, edit default values.
    110108                if ( bp_is_group() || bp_is_group_create() ) {
    111109                        $object_id        = bp_get_current_group_id();
    … …  
    113111                }
    114112
    115                 // Set the subdir
     113                // Set the subdir.
    116114                $subdir  = '/' . $object_directory . '/' . $object_id . '/cover-image';
    117115
    … …  
    121119                 * @since 2.4.0
    122120                 *
    123                  * @param array $value       Array containing the path, URL, and other helpful settings.
     121                 * @param array $value      Array containing the path, URL, and other helpful settings.
    124122                 * @param array $upload_dir The original Uploads dir.
    125123                 */
    … …  
    139137         * @since 2.4.0
    140138         *
    141          * @param string $file the absolute path to the file.
     139         * @param string $file       The absolute path to the file.
     140         * @param array  $dimensions Array of dimensions for the cover image.
    142141         * @return mixed
    143142         */
    … …  
    147146                }
    148147
    149                 // Get image size
     148                // Get image size.
    150149                $cover_data = parent::get_image_data( $file );
    151150
    152                 // Init the edit args
     151                // Init the edit args.
    153152                $edit_args = array();
    154153
    155                 // Do we need to resize the image ?
     154                // Do we need to resize the image?
    156155                if ( ( isset( $cover_data['width'] ) && $cover_data['width'] > $dimensions['width'] ) ||
    157156                ( isset( $cover_data['height'] ) && $cover_data['height'] > $dimensions['height'] ) ) {
    … …  
    163162                }
    164163
    165                 // Do we need to rotate the image ?
     164                // Do we need to rotate the image?
    166165                $angles = array(
    167166                        3 => 180,
    … …  
    174173                }
    175174
    176                 // No need to edit the avatar, original file will be used
     175                // No need to edit the avatar, original file will be used.
    177176                if ( empty( $edit_args ) ) {
    178177                        return false;
    179178
    180                 // Add the file to the edit arguments
     179                // Add the file to the edit arguments.
    181180                } else {
    182181                        $edit_args = array_merge( $edit_args, array( 'file' => $file, 'save' => false ) );
    183182                }
    184183
    185                 // Get the editor so that we can use a specific save method
     184                // Get the editor so that we can use a specific save method.
    186185                $editor = parent::edit_image( 'cover_image', $edit_args );
    187186
    … …  
    192191                }
    193192
    194                 // Save the new image file
     193                // Save the new image file.
    195194                return $editor->save( $this->generate_filename( $file ) );
    196195        }
    197196
    198197        /**
    199          * Generate a filename for the cover image
    200          *
    201          * @since 2.4.0
    202          *
    203          * @param  string $file the absolute path to the file.
    204          * @return string       the absolute path to the new file name
     198         * Generate a filename for the cover image.
     199         *
     200         * @since 2.4.0
     201         *
     202         * @param string $file The absolute path to the file.
     203         * @return string $value The absolute path to the new file name.
    205204         */
    206205        public function generate_filename( $file = '' ) {
    … …  
    218217
    219218        /**
    220          * Build script datas for the Uploader UI
    221          *
    222          * @since 2.4.0
    223          *
    224          * @return array the javascript localization data
     219         * Build script datas for the Uploader UI.
     220         *
     221         * @since 2.4.0
     222         *
     223         * @return array The javascript localization data
    225224         */
    226225        public function script_data() {
    227                 // Get default script data
     226                // Get default script data.
    228227                $script_data = parent::script_data();
    229228
    … …  
    240239                        );
    241240
    242                         // Set feedback messages
     241                        // Set feedback messages.
    243242                        $script_data['feedback_messages'] = array(
    244243                                1 => __( 'Your new cover image was uploaded successfully.', 'buddypress' ),
    … …  
    258257                        );
    259258
    260                         // Set feedback messages
     259                        // Set feedback messages.
    261260                        $script_data['feedback_messages'] = array(
    262261                                1 => __( 'The group cover image was uploaded successfully.', 'buddypress' ),
    … …  
    265264                        );
    266265                } else {
     266
    267267                        /**
    268                          * Use this filter to include specific BuddyPress params for your object.
     268                         * Filters the cover image params to include specific BuddyPress params for your object.
    269269                         * e.g. Cover image for blogs single item.
    270270                         *
    … …  
    276276                }
    277277
    278                 // Include our specific js & css
     278                // Include our specific js & css.
    279279                $script_data['extra_js']  = array( 'bp-cover-image' );
    280280                $script_data['extra_css'] = array( 'bp-avatar' );
    281281
     282                /**
     283                 * Filters the cover image script data.
     284                 *
     285                 * @since 2.4.0
     286                 *
     287                 * @param array $script_data Array of data for the cover image.
     288                 */
    282289                return apply_filters( 'bp_attachments_cover_image_script_data', $script_data );
    283290        }
Note: See TracChangeset for help on using the changeset viewer.