예제 #1
0
/**
 * Edit album option
 *
 * @global      RTMediaQuery    $rtmedia_query
 *
 * @param       array           $options
 *
 * @return      array|void
 */
function rtmedia_album_edit($options)
{
    if (!is_rtmedia_album() || !is_user_logged_in()) {
        return;
    }
    if (!is_rtmedia_album_enable()) {
        return;
    }
    global $rtmedia_query;
    if (isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && !in_array(intval($rtmedia_query->media_query['album_id']), array_map('intval', rtmedia_get_site_option('rtmedia-global-albums')), true)) {
        if (rtmedia_is_album_editable() || is_rt_admin()) {
            $options[] = "<a href='edit/' class='rtmedia-edit' title='" . esc_attr__('Edit Album', 'buddypress-media') . "' ><i class='rtmicon dashicons dashicons-edit'></i>" . esc_html__('Edit Album', 'buddypress-media') . '</a>';
            $options[] = '<form method="post" class="album-delete-form rtmedia-inline" action="delete/">' . wp_nonce_field('rtmedia_delete_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_delete_album_nonce') . '<button type="submit" name="album-delete" class="rtmedia-delete-album" title="' . esc_attr__('Delete Album', 'buddypress-media') . '"><i class="dashicons dashicons-trash rtmicon"></i>' . esc_html__('Delete Album', 'buddypress-media') . '</button></form>';
            if (is_rtmedia_group_album()) {
                $album_list = rtmedia_group_album_list();
            } else {
                $album_list = rtmedia_user_album_list();
            }
            if ($album_list) {
                $options[] = '<a href="#rtmedia-merge" class="rtmedia-reveal-modal rtmedia-modal-link" title="' . esc_attr__('Merge Album', 'buddypress-media') . '"><i class="dashicons dashicons-randomize"></i>' . esc_html__('Merge Album', 'buddypress-media') . '</a>';
            }
        }
    }
    return $options;
}
    /**
     * Render the uploader shortcode and attach the uploader panel
     *
     * @param type $template_name
     */
    public function render($template_name)
    {
        global $rtmedia_query;
        $album = '';
        if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album()) {
            $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />';
        } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') {
                $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>';
            }
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                $album = '<span> <label> <i class="rtmicon-picture-o"></i>' . __('Album', 'rtmedia') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>';
            }
        }
        $up_privacy = $privacy = "";
        //uploader privacy dropdown for uploader under rtMedia Media tab.
        if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false)) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                // if the context is group, then set the media privacy to public
                $privacy = "<input type='hidden' name='privacy' value='0'/>";
            } else {
                $up_privacy = new RTMediaPrivacy();
                $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy');
                if ($up_privacy) {
                    $privacy = "<span><i class='rtmicon-eye'></i> <label for='privacy'> " . __('Privacy: ', 'rtmedia') . "</label>" . $up_privacy . "</span>";
                }
            }
        }
        $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop row">' . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", "rtmedia") . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'rtmedia') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'rtmedia') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'rtmedia') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="row">' . wp_nonce_field('rtmedia_' . get_current_user_id(), 'rtmedia_media_delete_nonce') . '<table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'rtmedia'), 'content' => '<div class="rtmedia-container"><div id="rtmedia-action-update"><button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update"><i class="rtmicon-plus-circle"></i>' . apply_filters('rtmedia_attach_file_message', __('Attach Files', 'rtmedia')) . '</button>' . $up_privacy . '</div><div id="rtmedia-whts-new-upload-container"><div id="rtm-upload-start-notice"><span>' . __('Upload will start only after you enter content and click Post Update.', 'rtmedia') . '</span></div><table id="rtMedia-queue-list" class="rtMedia-queue-list"><tbody></tbody></table></div></div>')), 'link_input' => array('title' => __('Insert from URL', 'rtmedia'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />'));
        $tabs = apply_filters('rtmedia_upload_tabs', $tabs);
        $attr = $this->attributes;
        $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload';
        if ($attr && is_array($attr)) {
            foreach ($attr as $key => $val) {
                ?>
                <input type='hidden' id="rt_upload_hf_<?php 
                echo sanitize_key($key);
                ?>
" value='<?php 
                echo $val;
                ?>
' name ='<?php 
                echo $key;
                ?>
' />
                <?php 
            }
        }
        $upload_type = 'default';
        if (isset($attr['activity']) && $attr['activity']) {
            $upload_type = 'activity';
        }
        $uploadHelper = new RTMediaUploadHelper();
        include $this->locate_template($template_name);
    }
예제 #3
0
 function create_album()
 {
     $nonce = filter_input(INPUT_POST, 'create_album_nonce', FILTER_SANITIZE_STRING);
     $_name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
     $return['error'] = false;
     if (wp_verify_nonce($nonce, 'rtmedia_create_album_nonce') && isset($_name) && $_name && is_rtmedia_album_enable()) {
         $_context = filter_input(INPUT_POST, 'context', FILTER_SANITIZE_STRING);
         $_context_id = filter_input(INPUT_POST, 'context_id', FILTER_SANITIZE_NUMBER_INT);
         if (!empty($_context) && 'group' === $_context) {
             $group_id = !empty($_context_id) ? $_context_id : '';
             if (false === can_user_create_album_in_group($group_id)) {
                 $return['error'] = esc_html__('You can not create album in this group.', 'buddypress-media');
             }
         }
         $create_album = apply_filters('rtm_is_album_create_enable', true);
         if (!$create_album) {
             $return['error'] = esc_html__('You can not create album.', 'buddypress-media');
         }
         $create_album = apply_filters('rtm_display_create_album_button', true, $_context_id);
         if (!$create_album) {
             $return['error'] = esc_html__('You can not create more albums, you exceed your album limit.', 'buddypress-media');
         }
         if (false !== $return['error']) {
             wp_send_json($return);
         }
         $album = new RTMediaAlbum();
         // setup context values
         $context = $_context;
         if ('profile' === $context) {
             $context_id = get_current_user_id();
         } else {
             $context_id = !empty($_context_id) ? $_context_id : 0;
         }
         // setup new album data
         $album_data = apply_filters('rtmedia_create_album_data', array('title' => $_name, 'author' => get_current_user_id(), 'new' => true, 'post_id' => false, 'context' => $context, 'context_id' => $context_id));
         $rtmedia_id = $album->add($album_data['title'], $album_data['author'], $album_data['new'], $album_data['post_id'], $album_data['context'], $album_data['context_id']);
         $rtmedia_nav = new RTMediaNav();
         if ('group' === $_context) {
             $rtmedia_nav->refresh_counts($_context_id, array('context' => $_context, 'context_id' => $_context_id));
         } else {
             $rtmedia_nav->refresh_counts(get_current_user_id(), array('context' => 'profile', 'media_author' => get_current_user_id()));
         }
         if ($rtmedia_id) {
             $return['album'] = apply_filters('rtmedia_create_album_response', $rtmedia_id);
             wp_send_json($return);
         } else {
             echo false;
         }
     } else {
         $return['error'] = esc_html__('Data mismatch, Please insert data properly.', 'buddypress-media');
         wp_send_json($return);
     }
     wp_die();
 }
예제 #4
0
 function create_album()
 {
     $nonce = $_POST['create_album_nonce'];
     $return['error'] = false;
     if (wp_verify_nonce($nonce, 'rtmedia_create_album_nonce') && isset($_POST['name']) && $_POST['name'] && is_rtmedia_album_enable()) {
         if (isset($_POST['context']) && $_POST['context'] == "group") {
             $group_id = !empty($_POST['context_id']) ? $_POST['context_id'] : '';
             if (can_user_create_album_in_group($group_id) == false) {
                 $return['error'] = __('You can not create album in this group.', 'buddypress-media');
             }
         }
         $create_album = apply_filters("rtm_is_album_create_enable", true);
         if (!$create_album) {
             $return['error'] = __('You can not create album.', 'buddypress-media');
         }
         $create_album = apply_filters("rtm_display_create_album_button", true, $_POST['context_id']);
         if (!$create_album) {
             $return['error'] = __('You can not create more albums, you exceed your album limit.', 'buddypress-media');
         }
         if ($return['error'] !== false) {
             echo json_encode($return);
             wp_die();
         }
         $album = new RTMediaAlbum();
         // setup context values
         $context = $_POST['context'];
         if ($context == 'profile') {
             $context_id = get_current_user_id();
         } else {
             $context_id = isset($_POST['context_id']) ? $_POST['context_id'] : 0;
         }
         // setup new album data
         $album_data = apply_filters('rtmedia_create_album_data', array('title' => $_POST['name'], 'author' => get_current_user_id(), 'new' => true, 'post_id' => false, 'context' => $context, 'context_id' => $context_id));
         $rtmedia_id = $album->add($album_data['title'], $album_data['author'], $album_data['new'], $album_data['post_id'], $album_data['context'], $album_data['context_id']);
         $rtMediaNav = new RTMediaNav();
         if ($_POST['context'] == "group") {
             $rtMediaNav->refresh_counts($_POST['context_id'], array("context" => $_POST['context'], 'context_id' => $_POST['context_id']));
         } else {
             $rtMediaNav->refresh_counts(get_current_user_id(), array("context" => "profile", 'media_author' => get_current_user_id()));
         }
         if ($rtmedia_id) {
             $return['album'] = apply_filters('rtmedia_create_album_response', $rtmedia_id);
             echo json_encode($return);
         } else {
             echo esc_attr(false);
         }
     } else {
         $return['error'] = __('Data mismatch, Please insert data properly.', 'buddypress-media');
         echo json_encode($return);
     }
     wp_die();
 }
예제 #5
0
 function create_album()
 {
     $nonce = $_POST['create_album_nonce'];
     if (wp_verify_nonce($nonce, 'rtmedia_create_album_nonce') && isset($_POST['name']) && $_POST['name'] && is_rtmedia_album_enable()) {
         if (isset($_POST['context']) && $_POST['context'] == "group") {
             $group_id = !empty($_POST['context_id']) ? $_POST['context_id'] : '';
             if (can_user_create_album_in_group($group_id) == false) {
                 echo false;
                 wp_die();
             }
         }
         $create_album = apply_filters("rtm_is_album_create_enable", true);
         if (!$create_album) {
             echo false;
             wp_die();
         }
         $create_album = apply_filters("rtm_display_create_album_button", true, $_POST['context_id']);
         if (!$create_album) {
             echo false;
             wp_die();
         }
         $album = new RTMediaAlbum();
         $rtmedia_id = $album->add($_POST['name'], get_current_user_id(), true, false, $_POST['context'], $_POST['context_id']);
         $rtMediaNav = new RTMediaNav();
         if ($_POST['context'] == "group") {
             $rtMediaNav->refresh_counts($_POST['context_id'], array("context" => $_POST['context'], 'context_id' => $_POST['context_id']));
         } else {
             $rtMediaNav->refresh_counts(get_current_user_id(), array("context" => "profile", 'media_author' => get_current_user_id()));
         }
         if ($rtmedia_id) {
             echo $rtmedia_id;
         } else {
             echo false;
         }
     } else {
         echo false;
     }
     wp_die();
 }
예제 #6
0
 public function sub_nav()
 {
     global $rtmedia, $rtmedia_query;
     if (function_exists('bp_is_group') && bp_is_group()) {
         if (isset($rtmedia->options['buddypress_enableOnGroup']) && $rtmedia->options['buddypress_enableOnGroup'] == '0') {
             return;
         }
         global $bp;
         $counts = $this->actual_counts($bp->groups->current_group->id, "group");
     } else {
         if (class_exists('BuddyPress') && isset($rtmedia->options['buddypress_enableOnProfile']) && $rtmedia->options['buddypress_enableOnProfile'] == '0') {
             return;
         }
         $counts = $this->actual_counts();
     }
     $default = false;
     if (function_exists('bp_is_group') && bp_is_group()) {
         $link = get_rtmedia_group_link(bp_get_group_id());
         $model = new RTMediaModel();
         $other_count = $model->get_other_album_count(bp_get_group_id(), "group");
     } else {
         if (function_exists('bp_displayed_user_id') && bp_displayed_user_id()) {
             $link = get_rtmedia_user_link(bp_displayed_user_id());
         } elseif (get_query_var('author')) {
             $link = get_rtmedia_user_link(get_query_var('author'));
         }
         $model = new RTMediaModel();
         $other_count = $model->get_other_album_count(bp_displayed_user_id(), "profile");
     }
     $all = '';
     if (!isset($rtmedia_query->action_query->media_type)) {
         $all = 'class="current selected"';
     }
     echo apply_filters('rtmedia_sub_nav_all', '<li id="rtmedia-nav-item-all-li" ' . $all . '><a id="rtmedia-nav-item-all" href="' . trailingslashit($link) . RTMEDIA_MEDIA_SLUG . '/">' . __("All", "rtmedia") . '<span>' . (isset($counts['total']['all']) ? $counts['total']['all'] : 0) . '</span>' . '</a></li>');
     if (!isset($rtmedia_query->action_query->action) || empty($rtmedia_query->action_query->action)) {
         $default = true;
     }
     //print_r($rtmedia_query->action_query);
     $global_album = '';
     $albums = '';
     if (isset($rtmedia_query->action_query->media_type) && $rtmedia_query->action_query->media_type == 'album') {
         $albums = 'class="current selected"';
     }
     //$other_count = 0;
     if (is_rtmedia_album_enable()) {
         if (!isset($counts['total']["album"])) {
             $counts['total']["album"] = 0;
         }
         $counts['total']["album"] = $counts['total']["album"] + $other_count;
         $album_label = __(defined('RTMEDIA_ALBUM_PLURAL_LABEL') ? constant('RTMEDIA_ALBUM_PLURAL_LABEL') : 'Albums', 'rtmedia');
         echo apply_filters('rtmedia_sub_nav_albums', '<li id="rtmedia-nav-item-albums-li" ' . $albums . '><a id="rtmedia-nav-item-albums" href="' . trailingslashit($link) . RTMEDIA_MEDIA_SLUG . '/album/">' . $album_label . '<span>' . (isset($counts['total']["album"]) ? $counts['total']["album"] : 0) . '</span>' . '</a></li>');
     }
     foreach ($rtmedia->allowed_types as $type) {
         //print_r($type);
         if (!isset($rtmedia->options['allowedTypes_' . $type['name'] . '_enabled'])) {
             continue;
         }
         if (!$rtmedia->options['allowedTypes_' . $type['name'] . '_enabled']) {
             continue;
         }
         $selected = '';
         if (isset($rtmedia_query->action_query->media_type) && $type['name'] == $rtmedia_query->action_query->media_type) {
             $selected = ' class="current selected"';
         } else {
             $selected = '';
         }
         $context = isset($rtmedia_query->query['context']) ? $rtmedia_query->query['context'] : 'default';
         $context_id = isset($rtmedia_query->query['context_id']) ? $rtmedia_query->query['context_id'] : 0;
         $name = strtoupper($type['name']);
         $is_group = false;
         $profile = self::profile_id();
         if (!$profile) {
             $profile = self::group_id();
             $is_group = true;
         }
         if (!$is_group) {
             $profile_link = trailingslashit(get_rtmedia_user_link($profile));
         } else {
             $profile_link = trailingslashit(get_rtmedia_group_link($profile));
         }
         $type_label = __(defined('RTMEDIA_' . $name . '_PLURAL_LABEL') ? constant('RTMEDIA_' . $name . '_PLURAL_LABEL') : $type['plural_label'], 'rtmedia');
         echo apply_filters('rtmedia_sub_nav_' . $type['name'], '<li id="rtmedia-nav-item-' . $type['name'] . '-' . $context . '-' . $context_id . '-li" ' . $selected . '><a id="rtmedia-nav-item-' . $type['name'] . '" href="' . $profile_link . RTMEDIA_MEDIA_SLUG . '/' . constant('RTMEDIA_' . $name . '_SLUG') . '/' . '">' . $type_label . '<span>' . (isset($counts['total'][$type['name']]) ? $counts['total'][$type['name']] : 0) . '</span>' . '</a></li>', $type['name']);
     }
     do_action("add_extra_sub_nav");
 }
예제 #7
0
 function set_action_query()
 {
     if (isset($this->interaction) && isset($this->interaction->query_vars)) {
         $raw_query = $this->interaction->query_vars;
     } else {
         $raw_query = array();
     }
     if (isset($raw_query) && is_array($raw_query) && count($raw_query) > 1) {
         if (empty($raw_query[0]) && !empty($raw_query[1])) {
             $temp_query = array();
             for ($rtCount = 1; $rtCount < count($raw_query); $rtCount++) {
                 $temp_query[] = $raw_query[$rtCount];
             }
             $raw_query = $temp_query;
         }
     }
     //        if ( isset ( $_SERVER[ "REMOTE_ADDR" ] ) && $_SERVER[ "REMOTE_ADDR" ] == "14.97.170.202" ) {
     //            echo "<pre>";
     //            print_r ( $this );
     //            echo "</pre>";
     //        }
     $bulk = false;
     $action = false;
     $attribute = false;
     $modifier_type = 'default';
     $modifier_value = false;
     $format = '';
     $pageno = 1;
     $attributes = '';
     // The first part of the query /media/{*}/
     if (is_array($raw_query) && count($raw_query) && !empty($raw_query[0])) {
         //set the modifier value beforehand
         $modifier_value = $raw_query[0];
         if ($modifier_value == "album" && !is_rtmedia_album_enable()) {
             include get_404_template();
             die;
         }
         do_action('rtmedia_slug_404_handler');
         // disbale  media type 404 handler
         // requesting nonce /media/nonce/edit/ | /media/nonce/comment
         // | /media/nonce/delete
         if ($modifier_value == 'nonce') {
             $modifier_type = 'nonce';
             // requesting media id /media/{id}/
         } elseif (is_numeric($modifier_value)) {
             $modifier_type = 'id';
             // this block is unnecessary, please delete, asap
             if (isset($_POST['request_action']) && $_POST['request_action'] == 'delete') {
                 $action = 'delete';
             }
             // requesting an upload screen /media/upload/
         } elseif (array_key_exists($modifier_value, $this->actions)) {
             // /media/edit/ | media/delete/ | /media/like/
             $action = $modifier_value;
             $bulk = true;
         } elseif ($modifier_value == 'upload') {
             $modifier_type = 'upload';
             $action = 'upload';
             // /media/pg/2/
         } elseif ($modifier_value == 'pg') {
             //paginating default query
             $modifier_type = 'pg';
         } else {
             // requesting by media type /media/photos | /media/videos/
             $modifier_type = 'media_type';
         }
     }
     $modifier_type = apply_filters("rtmedia_action_query_modifier_type", $modifier_type, $raw_query);
     $modifier_value = apply_filters("rtmedia_action_query_modifier_value", $modifier_value, $raw_query);
     if (isset($raw_query[1])) {
         $second_modifier = $raw_query[1];
         switch ($modifier_type) {
             case 'nonce':
                 // /media/nonce/edit/ | /media/nonce/delete/
                 if (array_key_exists($second_modifier, $this->actions)) {
                     $nonce_type = $second_modifier;
                 }
                 break;
             case 'id':
                 // /media/23/edit/ | media/23/delete/ | /media/23/like/
                 if (array_key_exists($second_modifier, $this->actions)) {
                     $action = $second_modifier;
                 } else {
                     if ($second_modifier == "pg") {
                         if (isset($raw_query[2]) && is_numeric($raw_query[2])) {
                             $pageno = $raw_query[2];
                         }
                     }
                 }
                 break;
             case 'pg':
                 // /media/page/2/ | /media/page/3/
                 if (is_numeric($second_modifier)) {
                     $pageno = $second_modifier;
                 }
                 break;
             case 'media_type':
                 // /media/photos/edit/ | /media/videos/edit/
                 if (array_key_exists($second_modifier, $this->actions)) {
                     $action = $second_modifier;
                     $bulk = true;
                 }
                 // /media/photos/page/2/
                 //elseif($second_modifier=='page'){
                 //$page = $second_modifier;
                 //pagination support
                 //}
                 break;
             default:
                 break;
         }
     }
     //the third part of the query /media/modifier/second_modifier/{*}
     if (isset($raw_query[2])) {
         $third_modifier = $raw_query[2];
         switch ($modifier_type) {
             case 'nonce':
                 // leaving here for more granular nonce, in future, for eg,
                 // /media/nonce/edit/title/
                 break;
             case 'id':
                 // leaving here for more granular editing, in future, for eg,
                 // /media/23/edit/title/
                 break;
             case 'media_type':
                 // /media/photos/edit/ | /media/videos/edit/
                 // leaving here for more granular editing, in future, for eg,
                 // /media/photos/edit/title/
                 // /media/photos/page/2/
                 if ($second_modifier == 'pg' && is_numeric($third_modifier)) {
                     $pageno = $third_modifier;
                 }
                 break;
             case 'pg':
             default:
                 break;
         }
     }
     global $rtmedia;
     //if ( ! $rtmedia->get_option( 'media_end_point_enable' ) )
     //include get_404_template();
     /**
      * set action query object
      * setting parameters in action query object for pagination
      */
     $per_page_media = intval($rtmedia->options['general_perPageMedia']);
     $per_page_media = intval(apply_filters("rtmedia_per_page_media", $per_page_media));
     $this->action_query = (object) array($modifier_type => $modifier_value, 'action' => $action, 'bulk' => $bulk, 'page' => $pageno, 'per_page_media' => $per_page_media, 'attributes' => $attributes);
 }
function rtmedia_album_edit($options)
{
    if (!is_rtmedia_album() || !is_user_logged_in()) {
        return;
    }
    if (!is_rtmedia_album_enable()) {
        return;
    }
    global $rtmedia_query;
    ?>

	<?php 
    if (isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && !in_array($rtmedia_query->media_query['album_id'], rtmedia_get_site_option('rtmedia-global-albums'))) {
        //if ( isset ( $rtmedia_query->media_query[ 'media_author' ] ) && get_current_user_id () == $rtmedia_query->media_query[ 'media_author' ] ) {
        if (rtmedia_is_album_editable() || is_rt_admin()) {
            $options[] = "<a href='edit/' class='rtmedia-edit' title='" . __('Edit Album', 'rtmedia') . "' ><i class='rtmicon-edit rtmicon-fw'></i>" . __('Edit Album', 'rtmedia') . "</a>";
            $options[] = '<form method="post" class="album-delete-form rtmedia-inline" action="delete/">' . wp_nonce_field('rtmedia_delete_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_delete_album_nonce') . '<button type="submit" name="album-delete" class="rtmedia-delete-album" title="' . __('Delete Album', 'rtmedia') . '"><i class="rtmicon-trash-o rtmicon-fw"></i>' . __('Delete Album', 'rtmedia') . '</button></form>';
            if (is_rtmedia_group_album()) {
                $album_list = rtmedia_group_album_list();
            } else {
                $album_list = rtmedia_user_album_list();
            }
            if ($album_list) {
                $options[] = '<a href="#rtmedia-merge" class="rtmedia-reveal-modal rtmedia-modal-link" title="' . __('Merge Album', 'rtmedia') . '"><i class="rtmicon-code-fork rtmicon-fw"></i>' . __('Merge Album', 'rtmedia') . '</a>';
            }
        }
    }
    return $options;
}
예제 #9
0
    /**
     * Render the uploader shortcode and attach the uploader panel
     *
     * @param type $template_name
     */
    public function render($template_name)
    {
        global $rtmedia_query;
        $album = '';
        if (apply_filters('rtmedia_render_select_album_upload', true)) {
            if ($rtmedia_query && isset($rtmedia_query->media_query) && isset($rtmedia_query->media_query['album_id']) && is_rtmedia_album($rtmedia_query->media_query['album_id'])) {
                $album = '<input class="rtmedia-current-album" type="hidden" name="rtmedia-current-album" value="' . $rtmedia_query->media_query['album_id'] . '" />';
            } elseif (is_rtmedia_album_enable() && $rtmedia_query && is_rtmedia_gallery()) {
                if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'profile') {
                    $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_user_album_list() . '</select></span>';
                }
                if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group') {
                    $album = '<span> <label> <i class="dashicons dashicons-format-gallery rtmicon"></i>' . __('Album', 'buddypress-media') . ': </label><select name="album" class="rtmedia-user-album-list">' . rtmedia_group_album_list() . '</select></span>';
                }
            }
        }
        $up_privacy = $privacy = "";
        //uploader privacy dropdown for uploader under rtMedia Media tab.
        if (is_rtmedia_privacy_enable() && (!isset($rtmedia_query->is_upload_shortcode) || $rtmedia_query->is_upload_shortcode === false) || isset($rtmedia_query->is_upload_shortcode) && !isset($this->attributes['privacy'])) {
            if (isset($rtmedia_query->query['context']) && $rtmedia_query->query['context'] == 'group' || function_exists('bp_is_groups_component') && bp_is_groups_component()) {
                // if the context is group, then set the media privacy to public
                $privacy = "<input type='hidden' name='privacy' value='0'/>";
            } else {
                $up_privacy = new RTMediaPrivacy();
                $up_privacy = $up_privacy->select_privacy_ui(false, 'rtSelectPrivacy');
                if ($up_privacy) {
                    $privacy = "<span> <label for='privacy'> <i class='dashicons dashicons-visibility rtmicon'></i> " . __('Privacy: ', 'buddypress-media') . "</label>" . $up_privacy . "</span>";
                }
            }
        }
        $upload_tabs = array('file_upload' => array('title' => __('File Upload', 'buddypress-media'), 'class' => array('rtm-upload-tab', 'active'), 'content' => '<div class="rtm-upload-tab-content" data-id="rtm-upload-tab">' . apply_filters('rtmedia_uploader_before_select_files', "") . '<div class="rtm-select-files"><input id="rtMedia-upload-button" value="' . __("Select your files", 'buddypress-media') . '" type="button" class="rtmedia-upload-input rtmedia-file" />' . '<span class="rtm-seperator">' . __('or', 'buddypress-media') . '</span><span class="drag-drop-info">' . __('Drop your files here', 'buddypress-media') . '</span> <i class="rtm-file-size-limit rtmicon-info-circle rtmicon-fw"></i></div>' . apply_filters('rtmedia_uploader_after_select_files', "") . '</div>'));
        $upload_tabs = apply_filters('rtmedia_uploader_tabs', $upload_tabs);
        if (is_array($upload_tabs) && !empty($upload_tabs)) {
            if (sizeof($upload_tabs) == 1 && isset($upload_tabs['file_upload'])) {
                $upload_tab_html = $upload_tabs['file_upload']['content'];
            } else {
                $upload_tab_html = '<div class="rtm-uploader-main-wrapper"><div class="rtm-uploader-tabs"><ul>';
                foreach ($upload_tabs as $single_tab) {
                    $upload_tab_html .= '<li class="' . implode(' ', $single_tab['class']) . '">' . $single_tab['title'] . '</li>';
                }
                $upload_tab_html .= '</ul></div>';
                foreach ($upload_tabs as $single_tab) {
                    $upload_tab_html .= $single_tab['content'];
                }
                $upload_tab_html .= '</div>';
            }
        } else {
            $upload_tab_html = '';
        }
        $tabs = array('file_upload' => array('default' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div id="rtmedia-upload-container" >' . '<div id="drag-drop-area" class="drag-drop clearfix">' . apply_filters('rtmedia_uploader_before_album_privacy', "") . "<div class='rtm-album-privacy'>" . $album . $privacy . "</div>" . $upload_tab_html . apply_filters('rtmedia_uploader_before_start_upload_button', "") . '<input type="button" class="start-media-upload" value="' . __('Start upload', 'buddypress-media') . '"/>' . apply_filters('rtmedia_uploader_after_start_upload_button', "") . '</div>' . '<div class="clearfix">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist"></ul></div>' . '</div>'), 'activity' => array('title' => __('File Upload', 'buddypress-media'), 'content' => '<div class="rtmedia-plupload-container rtmedia-container clearfix">' . '<div id="rtmedia-action-update" class="clearfix">' . '<div class="rtm-upload-button-wrapper">' . '<div id="rtmedia-whts-new-upload-container">' . '</div>' . '<button type="button" class="rtmedia-add-media-button" id="rtmedia-add-media-button-post-update" title="' . apply_filters('rtmedia_attach_media_button_title', __('Attach Media', 'buddypress-media')) . '">' . '<span class="dashicons dashicons-admin-media"></span>' . apply_filters('rtmedia_attach_file_message', '') . '</button>' . '</div>' . $up_privacy . '</div>' . '</div>' . '<div class="rtmedia-plupload-notice">' . '<ul class="plupload_filelist_content ui-sortable rtm-plupload-list clearfix" id="rtmedia_uploader_filelist">' . '</ul>' . '</div>')), 'link_input' => array('title' => __('Insert from URL', 'buddypress-media'), 'content' => '<input type="url" name="bp-media-url" class="rtmedia-upload-input rtmedia-url" />'));
        $tabs = apply_filters('rtmedia_upload_tabs', $tabs);
        $attr = $this->attributes;
        $mode = isset($_GET['mode']) && array_key_exists($_GET['mode'], $tabs) ? $_GET['mode'] : 'file_upload';
        if ($attr && is_array($attr)) {
            foreach ($attr as $key => $val) {
                ?>
				<input type='hidden' id="rt_upload_hf_<?php 
                echo sanitize_key($key);
                ?>
" value='<?php 
                echo $val;
                ?>
' name ='<?php 
                echo $key;
                ?>
' />
				<?php 
            }
        }
        $upload_type = 'default';
        if (isset($attr['activity']) && $attr['activity']) {
            $upload_type = 'activity';
        }
        $uploadHelper = new RTMediaUploadHelper();
        include $this->locate_template($template_name);
    }
예제 #10
0
 public function sub_nav()
 {
     global $rtmedia, $rtmedia_query;
     if (function_exists('bp_is_group') && bp_is_group()) {
         if (isset($rtmedia->options['buddypress_enableOnGroup']) && 0 === intval($rtmedia->options['buddypress_enableOnGroup'])) {
             return;
         }
         global $bp;
         $counts = $this->actual_counts($bp->groups->current_group->id, 'group');
     } else {
         if (class_exists('BuddyPress') && isset($rtmedia->options['buddypress_enableOnProfile']) && 0 === intval($rtmedia->options['buddypress_enableOnProfile'])) {
             return;
         }
         $counts = $this->actual_counts();
     }
     $default = false;
     if (function_exists('bp_is_group') && bp_is_group()) {
         $link = get_rtmedia_group_link(bp_get_group_id());
         $model = new RTMediaModel();
         $other_count = $model->get_other_album_count(bp_get_group_id(), 'group');
     } else {
         if (function_exists('bp_displayed_user_id') && bp_displayed_user_id()) {
             $link = get_rtmedia_user_link(bp_displayed_user_id());
         } elseif (get_query_var('author')) {
             $link = get_rtmedia_user_link(get_query_var('author'));
         }
         $model = new RTMediaModel();
         $other_count = $model->get_other_album_count(bp_displayed_user_id(), 'profile');
     }
     $all = '';
     if (!isset($rtmedia_query->action_query->media_type) && !isset($rtmedia_query->query['media_type'])) {
         $all = 'current selected';
     }
     echo apply_filters('rtmedia_sub_nav_all', '<li id="rtmedia-nav-item-all-li" class="' . esc_attr($all) . '"><a id="rtmedia-nav-item-all" href="' . esc_url(trailingslashit($link)) . RTMEDIA_MEDIA_SLUG . '/">' . esc_html__('All', 'buddypress-media') . '<span>' . esc_html(isset($counts['total']['all']) ? $counts['total']['all'] : 0) . '</span>' . '</a></li>');
     // @codingStandardsIgnoreLine
     if (!isset($rtmedia_query->action_query->action) || empty($rtmedia_query->action_query->action)) {
         $default = true;
     }
     $albums = '';
     //condition to keep "Album" tab active
     if (array_key_exists('media_type', $rtmedia_query->query) && isset($rtmedia_query->query['media_type']) && 'album' === $rtmedia_query->query['media_type']) {
         $albums = 'current selected';
     } elseif (array_key_exists('media_type', $rtmedia_query->action_query) && isset($rtmedia_query->action_query->media_type) && 'album' === $rtmedia_query->action_query->media_type) {
         $albums = 'current selected';
     }
     if (is_rtmedia_album_enable()) {
         if (!isset($counts['total']['album'])) {
             $counts['total']['album'] = 0;
         }
         $counts['total']['album'] = $counts['total']['album'] + $other_count;
         $album_label = esc_html__(defined('RTMEDIA_ALBUM_PLURAL_LABEL') ? constant('RTMEDIA_ALBUM_PLURAL_LABEL') : 'Albums', 'buddypress-media');
         echo apply_filters('rtmedia_sub_nav_albums', '<li id="rtmedia-nav-item-albums-li" class="' . esc_attr($albums) . '"><a id="rtmedia-nav-item-albums" href="' . esc_url(trailingslashit($link)) . RTMEDIA_MEDIA_SLUG . '/album/">' . esc_html($album_label) . '<span>' . esc_html(isset($counts['total']['album']) ? $counts['total']['album'] : 0) . '</span>' . '</a></li>');
         // @codingStandardsIgnoreLine
     }
     foreach ($rtmedia->allowed_types as $type) {
         if (!isset($rtmedia->options['allowedTypes_' . $type['name'] . '_enabled'])) {
             continue;
         }
         if (!$rtmedia->options['allowedTypes_' . $type['name'] . '_enabled']) {
             continue;
         }
         $selected = '';
         if (isset($rtmedia_query->action_query->media_type) && $type['name'] === $rtmedia_query->action_query->media_type) {
             $selected = ' class="current selected"';
         } else {
             $selected = '';
         }
         $context = isset($rtmedia_query->query['context']) ? $rtmedia_query->query['context'] : 'default';
         $context_id = isset($rtmedia_query->query['context_id']) ? $rtmedia_query->query['context_id'] : 0;
         $name = strtoupper($type['name']);
         $is_group = false;
         $profile = self::profile_id();
         if (!$profile) {
             $profile = self::group_id();
             $is_group = true;
         }
         if (!$is_group) {
             $profile_link = trailingslashit(get_rtmedia_user_link($profile));
         } else {
             $profile_link = trailingslashit(get_rtmedia_group_link($profile));
         }
         $type_label = esc_html__(defined('RTMEDIA_' . $name . '_PLURAL_LABEL') ? constant('RTMEDIA_' . $name . '_PLURAL_LABEL') : $type['plural_label'], 'buddypress-media');
         echo apply_filters('rtmedia_sub_nav_' . $type['name'], '<li id="rtmedia-nav-item-' . esc_attr($type['name']) . '-' . esc_attr($context) . '-' . esc_attr($context_id) . '-li" ' . $selected . '><a id="rtmedia-nav-item-' . esc_attr($type['name']) . '" href="' . esc_url($profile_link . RTMEDIA_MEDIA_SLUG . '/' . constant('RTMEDIA_' . $name . '_SLUG') . '/') . '">' . $type_label . '<span>' . esc_html(isset($counts['total'][$type['name']]) ? $counts['total'][$type['name']] : 0) . '</span>' . '</a></li>', $type['name']);
     }
     do_action('add_extra_sub_nav');
 }
예제 #11
0
/**
 * Rendering merge album markup
 *
 * @global      RTMediaQuery    $rtmedia_query
 */
function rtmedia_merge_album_modal()
{
    if (!is_rtmedia_album() || !is_user_logged_in()) {
        return;
    }
    if (!is_rtmedia_album_enable()) {
        return;
    }
    global $rtmedia_query;
    if (is_rtmedia_group_album()) {
        $album_list = rtmedia_group_album_list();
    } else {
        $album_list = rtmedia_user_album_list();
    }
    if ($album_list && !empty($rtmedia_query->media_query['album_id'])) {
        ?>
		<div class="rtmedia-merge-container rtmedia-popup mfp-hide" id="rtmedia-merge">
			<div id="rtm-modal-container">
				<h2 class="rtm-modal-title"><?php 
        esc_html_e('Merge Album', 'buddypress-media');
        ?>
</h2>
				<form method="post" class="album-merge-form" action="merge/">
					<p>
						<span><?php 
        esc_html_e('Select Album to merge with : ', 'buddypress-media');
        ?>
</span>
						<?php 
        echo '<select name="album" class="rtmedia-merge-user-album-list">' . $album_list . '</select>';
        // @codingStandardsIgnoreLine
        ?>
					</p>
					<?php 
        wp_nonce_field('rtmedia_merge_album_' . $rtmedia_query->media_query['album_id'], 'rtmedia_merge_album_nonce');
        ?>
					<input type="submit" class="rtmedia-merge-selected" name="merge-album" value="<?php 
        esc_html_e('Merge Album', 'buddypress-media');
        ?>
"/>
				</form>
			</div>
		</div>
		<?php 
    }
}