Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/12/2015 12:49:36 AM (9 years ago)
Author:
tw2113
Message:

First pass at BP-Core docs cleanup.

See #6398.

File:
1 edited

Legend:

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

    r9874 r10012  
    1111
    1212/**
    13  * BP Attachment class
     13 * BP Attachment class.
    1414 *
    1515 * Extend it to manage your component's uploads.
     
    2222
    2323    /**
    24      * The file being uploaded
     24     * The file being uploaded.
    2525     *
    2626     * @var array
     
    3030    /**
    3131     * The default args to be merged with the
    32      * ones passed by the child class
     32     * ones passed by the child class.
    3333     *
    3434     * @var array
     
    4545
    4646    /**
    47      * Construct Upload parameters
    48      *
    49      * @since BuddyPress (2.3.0)
    50      *
    51      * @param array $args {
     47     * Construct Upload parameters.
     48     *
     49     * @since BuddyPress (2.3.0)
     50     *
     51     * @param array|string $args {
    5252     *     @type int    $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings.
    5353     *     @type array  $allowed_mime_types    List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
    54      *                                         Defaults to WordPress allowed mime types
    55      *     @type string $base_dir              Component's upload base directory. Defaults to WordPress 'uploads'
     54     *                                         Defaults to WordPress allowed mime types.
     55     *     @type string $base_dir              Component's upload base directory. Defaults to WordPress 'uploads'.
    5656     *     @type string $action                The upload action used when uploading a file, $_POST['action'] must be set
    57      *                                         and its value must equal $action {@link wp_handle_upload()} (required)
    58      *     @type string $file_input            The name attribute used in the file input. (required)
     57     *                                         and its value must equal $action {@link wp_handle_upload()} (required).
     58     *     @type string $file_input            The name attribute used in the file input. (required).
    5959     *     @type array  $upload_error_strings  A list of specific error messages (optional).
    60      *     @type array  $required_wp_files     The list of required WordPress core files. Default: array( 'file' );
     60     *     @type array  $required_wp_files     The list of required WordPress core files. Default: array( 'file' ).
    6161     * }
    6262     * @uses  sanitize_key()
     
    107107     * @since BuddyPress (2.3.0)
    108108     *
    109      * @uses  bp_upload_dir()
     109     * @uses bp_upload_dir()
    110110     */
    111111    public function set_upload_dir() {
     
    140140
    141141    /**
    142      * Set Upload error messages
     142     * Set Upload error messages.
    143143     *
    144144     * Used into the $overrides argument of BP_Attachment->upload()
     
    146146     * @since BuddyPress (2.3.0)
    147147     *
    148      * @param array $param a list of error messages to add to BuddyPress core ones
     148     * @param array $param A list of error messages to add to BuddyPress core ones.
     149     *
    149150     * @return array the list of upload errors
    150151     */
     
    176177
    177178    /**
    178      * Include the WordPress core needed files
     179     * Include the WordPress core needed files.
    179180     *
    180181     * @since BuddyPress (2.3.0)
     
    191192
    192193    /**
    193      * Upload the attachment
    194      *
    195      * @since BuddyPress (2.3.0)
    196      *
    197      * @param  array $file               The appropriate entry the from $_FILES superglobal.
    198      * @param  string $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
    199      * @param  string $time              Optional. Time formatted in 'yyyy/mm'. Default null.
     194     * Upload the attachment.
     195     *
     196     * @since BuddyPress (2.3.0)
     197     *
     198     * @param  array       $file              The appropriate entry the from $_FILES superglobal.
     199     * @param  string      $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
     200     * @param  string|null $time              Optional. Time formatted in 'yyyy/mm'. Default null.
     201     *
    200202     * @uses   wp_handle_upload()        To upload the file
    201203     * @uses   add_filter()              To temporarly overrides WordPress uploads data
     
    247249
    248250        /**
    249          * If you need to add some overrides we haven't thought of
     251         * If you need to add some overrides we haven't thought of.
    250252         *
    251          * @var  array $overrides the wp_handle_upload overrides
     253         * @param array $overrides The wp_handle_upload overrides
    252254         */
    253255        $overrides = apply_filters( 'bp_attachment_upload_overrides', $overrides );
     
    286288
    287289    /**
    288      * Validate the allowed mime types using WordPress allowed mime types
     290     * Validate the allowed mime types using WordPress allowed mime types.
    289291     *
    290292     * In case of a multisite, the mime types are already restricted by
     
    312314
    313315    /**
    314      * Specific upload rules
     316     * Specific upload rules.
    315317     *
    316318     * Override this function from your child class to build your specific rules
     
    322324     * @since BuddyPress (2.3.0)
    323325     *
    324      * @param  array $file the temporary file attributes (before it has been moved)
    325      * @return array the file
     326     * @param  array $file The temporary file attributes (before it has been moved).
     327     *
     328     * @return array The file.
    326329     */
    327330    public function validate_upload( $file = array() ) {
     
    340343
    341344    /**
    342      * Default filter to save the attachments
    343      *
    344      * @since BuddyPress (2.3.0)
    345      *
    346      * @uses   apply_filters() call 'bp_attachment_upload_dir' to eventually override the upload location
    347      *                         regarding to context
    348      * @return array the upload directory data
     345     * Default filter to save the attachments.
     346     *
     347     * @since BuddyPress (2.3.0)
     348     *
     349     * @uses apply_filters() call 'bp_attachment_upload_dir' to eventually override the upload location
     350     *       regarding to context
     351     *
     352     * @return array The upload directory data.
    349353     */
    350354    public function upload_dir_filter() {
     355
    351356        /**
    352357         * Filters the component's upload directory.
     
    367372
    368373    /**
    369      * Create the custom base directory for the component uploads
    370      *
    371      * Override this function in your child class to run specific actions
     374     * Create the custom base directory for the component uploads.
     375     *
     376     * Override this function in your child class to run specific actions.
    372377     * (eg: add an .htaccess file)
    373378     *
    374379     * @since BuddyPress (2.3.0)
    375380     *
    376      * @uses   wp_mkdir_p()
     381     * @uses wp_mkdir_p()
    377382     */
    378383    public function create_dir() {
     
    396401
    397402    /**
    398      * Crop an image file
     403     * Crop an image file.
    399404     *
    400405     * @since BuddyPress (2.3.0)
     
    402407     * @param array $args {
    403408     *     @type string $original_file The source file (absolute path) for the Attachment.
    404      *     @type int    $crop_x The start x position to crop from.
    405      *     @type int    $crop_y The start y position to crop from.
    406      *     @type int    $crop_w The width to crop.
    407      *     @type int    $crop_h The height to crop.
    408      *     @type int    $dst_w The destination width.
    409      *     @type int    $dst_h The destination height.
    410      *     @type int    $src_abs Optional. If the source crop points are absolute.
    411      *     @type string $dst_file Optional. The destination file to write to.
     409     *     @type int    $crop_x        The start x position to crop from.
     410     *     @type int    $crop_y        The start y position to crop from.
     411     *     @type int    $crop_w        The width to crop.
     412     *     @type int    $crop_h        The height to crop.
     413     *     @type int    $dst_w         The destination width.
     414     *     @type int    $dst_h         The destination height.
     415     *     @type int    $src_abs       Optional. If the source crop points are absolute.
     416     *     @type string $dst_file      Optional. The destination file to write to.
    412417     * }
    413418     * @uses wp_crop_image()
     419     *
    414420     * @return string|WP_Error New filepath on success, WP_Error on failure.
    415421     */
     
    495501
    496502    /**
    497      * Build script datas for the Uploader UI
    498      *
    499      * Override this method from your child class to build the script datas
    500      *
    501      * @since BuddyPress (2.3.0)
    502      *
    503      * @return array the javascript localization data
     503     * Build script datas for the Uploader UI.
     504     *
     505     * Override this method from your child class to build the script datas.
     506     *
     507     * @since BuddyPress (2.3.0)
     508     *
     509     * @return array The javascript localization data.
    504510     */
    505511    public function script_data() {
Note: See TracChangeset for help on using the changeset viewer.