Пример #1
0
 /**
  * Format string and media url for notification
  *
  * @param   array $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
  *
  * @return string/array     format notification as $params['format'] request
  */
 function format_like_notifications($params)
 {
     $action = $params['action'];
     $post_id = intval($params['post_id']);
     if ($this->component_action . $post_id === $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $rtmedia_id = rtmedia_id($post_id);
         $liked_list = $this->fetch_media_like_stats($rtmedia_id);
         $liked_by = bp_core_get_username($liked_list[0]->user_id);
         $like_count = get_rtmedia_like($post_id);
         $link = esc_url(get_rtmedia_permalink($rtmedia_id));
         $media_type = rtmedia_type($rtmedia_id);
         $text = null;
         if (0 === intval($like_count)) {
             $this->delete_notification_by_item_id($initiator_id, $post_id);
         } elseif (1 === intval($like_count)) {
             $text = $liked_by . ' ' . __('liked your', 'buddypress-media') . ' ' . $media_type;
         } elseif (2 === intval($like_count)) {
             $text = $liked_by . ' ' . __('and one more friend liked your', 'buddypress-media') . ' ' . $media_type;
         } else {
             $count = $like_count - 1;
             $text = $liked_by . ' ' . __('and', 'buddypress-media') . ' ' . $count . ' ' . __('other friends liked your', 'buddypress-media') . ' ' . $media_type;
         }
         $return = apply_filters('rtmedia_before_like_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         if ('string' === $format) {
             return '<a href="' . esc_url($return['link']) . '">' . esc_html($return['text']) . '</a>';
         } else {
             return $return;
         }
     }
 }
 /**
  * format the new notification in String or array
  * @param array         $params
  * @return array/string  As per $format 
  */
 function format_comment_notifications($params)
 {
     $action = $params['action'];
     $post_id = $params['post_id'];
     if ($this->component_action . $post_id == $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $comment_author = bp_core_get_username($initiator_id);
         $media_url = get_rtmedia_permalink(rtmedia_id($post_id));
         $media_type = rtmedia_type(rtmedia_id($post_id));
         if ($total_items == 1) {
             $text = $comment_author . ' ' . __('commented on your', 'buddypress-media') . ' ' . $media_type;
         } else {
             $text = $total_items . ' ' . __('new comments on your', 'buddypress-media') . ' ' . $media_type;
         }
         $link = $media_url;
         if ($format == 'string') {
             $return = apply_filters('rtmedia_before_comment_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
         } else {
             $return = apply_filters('rtmedia_before_comment_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         }
         return $return;
     }
 }
Пример #3
0
 /**
  * Format string and media url for notification
  * 
  * @param   array           $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
  * @return string/array     format notification as $params['format'] request
  */
 function format_like_notifications($params)
 {
     $action = $params['action'];
     $post_id = $params['post_id'];
     if ($this->component_action . $post_id == $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $liked_list = $this->fetch_media_like_stats(rtmedia_id($post_id));
         $liked_by = bp_core_get_username($liked_list[0]->user_id);
         $like_count = get_rtmedia_like($post_id);
         $link = get_rtmedia_permalink(rtmedia_id($post_id));
         $media_type = rtmedia_type(rtmedia_id($post_id));
         if ($like_count == 0) {
             $this->delete_notification_by_item_id($initiator_id, $post_id);
         } elseif ($like_count == 1) {
             $text = $liked_by . ' ' . __('liked your', 'rtmedia') . ' ' . $media_type;
         } elseif ($like_count == 2) {
             $text = $liked_by . ' ' . __('and one more friend liked your', 'rtmedia') . ' ' . $media_type;
         } else {
             $count = $like_count - 1;
             $text = $liked_by . ' ' . __('and', 'rtmedia') . ' ' . $count . ' ' . __('other friends liked your', 'rtmedia') . ' ' . $media_type;
         }
         if ($format == 'string') {
             $return = apply_filters('rtmedia_before_like_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
         } else {
             $return = apply_filters('rtmedia_before_like_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         }
         return $return;
     }
 }
Пример #4
0
 function add($attr)
 {
     do_action('rtmedia_before_add_comment', $attr);
     $defaults = array('user_id' => $this->get_current_id(), 'comment_author' => $this->get_current_author(), 'comment_date' => current_time('mysql'));
     $params = wp_parse_args($attr, $defaults);
     $id = $this->rtmedia_comment_model->insert($params);
     global $rtmedia_points_media_id;
     $rtmedia_points_media_id = rtmedia_id($params['comment_post_ID']);
     do_action('rtmedia_after_add_comment', $params);
     return $id;
 }
Пример #5
0
function button_rtmedia_for_cover($media_id)
{
    global $rtmedia_media, $rtmedia, $bp;
    $user_id = bp_loggedin_user_id();
    $media_id = rtmedia_id();
    if (isset($rtmedia_media->media_type)) {
        $author_id = $rtmedia_media->media_author;
        if ($rtmedia_media->media_type == 'photo') {
            if (bp_displayed_user_id()) {
                if ($user_id == $author_id) {
                    echo '<a href="#" class="rtmcover" title="' . __("Select", "bp-cover") . '" onclick="select_pic_rtmedia_for_cover(\'' . $media_id . '\', \'' . admin_url('admin-ajax.php') . '\'); return false;">
					' . __("Set Cover", "bp-cover") . '</a>';
                }
            } else {
                if (bp_is_group()) {
                    if (is_admin() || $bp->is_item_admin) {
                        echo '<a href="#" class="rtmcover" title="' . __("Select", "bp-cover") . '" onclick="select_pic_rtmedia_for_cover_group(\'' . $media_id . '\', \'' . admin_url('admin-ajax.php') . '\'); return false;">
					' . __("Set Cover group", "bp-cover") . '</a>';
                    }
                }
            }
        }
    }
}
Пример #6
0
    esc_html_e('Title : ', 'buddypress-media');
    ?>
</label>
							<?php 
    rtmedia_title_input();
    ?>
						</div>

						<div class="rtmedia-editor-description rtm-field-wrap">
							<label for='description'><?php 
    esc_html_e('Description: ', 'buddypress-media');
    ?>
</label>
							<?php 
    rtmedia_description_input($editor = false, true);
    RTMediaMedia::media_nonce_generator(rtmedia_id(), true);
    ?>
						</div>

						<?php 
    do_action('rtmedia_album_edit_fields', 'album-edit');
    ?>

						<div>
							<input type="submit" name="submit" class='rtmedia-save-album'
							       value="<?php 
    esc_attr_e('Save Changes', 'buddypress-media');
    ?>
"/>
							<a class="button rtm-button rtm-button-back"
							   href="<?php 
Пример #7
0
 function modify_medialibrary_permalink($action, $post, $detached)
 {
     $rtm_id = rtmedia_id($post->ID);
     if ($rtm_id) {
         $link = get_rtmedia_permalink($rtm_id);
         $title = _draft_or_post_title($post->post_parent);
         $action['view'] = '<a href="' . $link . '" title="' . esc_attr(sprintf(esc_html__('View &#8220;%s&#8221;', 'buddypress-media'), $title)) . '" rel="permalink">' . esc_html__('View', 'buddypress-media') . '</a>';
     }
     return $action;
 }
function get_rtmedia_date_gmt($rtmedia_id = false)
{
    $media = get_post(rtmedia_media_id(rtmedia_id($rtmedia_id)));
    $date_time = "";
    if (isset($media->post_date_gmt) && $media->post_date_gmt != "") {
        $date_time = rtmedia_convert_date($media->post_date_gmt);
    }
    $date_time = apply_filters('rtmedia_comment_date_format', $date_time, null);
    return '<span>' . $date_time . '</span>';
}
Пример #9
0
    } else {
        // else for if ( $rt_ajax_request )
        ?>

					<div class="rtmedia-item-actions rtm-single-actions rtm-item-actions clearfix">
						<?php 
        do_action('rtmedia_actions_without_lightbox');
        ?>
						<?php 
        rtmedia_actions();
        ?>
					</div>

					<div class="rtmedia-actions-before-description clearfix">
						<?php 
        do_action('rtmedia_actions_before_description', rtmedia_id());
        ?>
					</div>

					<div class="rtmedia-media-description more">
						<?php 
        rtmedia_description();
        ?>
					</div>

					<?php 
        if (rtmedia_comments_enabled()) {
            ?>
						<div class="rtmedia-item-comments">
							<div class="rtmedia-actions-before-comments clearfix">
								<?php 
/** That's all, stop editing from here * */
global $rtmedia_backbone;
$rtmedia_backbone = array('backbone' => false, 'is_album' => false, 'is_edit_allowed' => false);
if (isset($_POST['backbone'])) {
    $rtmedia_backbone['backbone'] = $_POST['backbone'];
}
if (isset($_POST['is_album'])) {
    $rtmedia_backbone['is_album'] = $_POST['is_album'][0];
}
if (isset($_POST['is_edit_allowed'])) {
    $rtmedia_backbone['is_edit_allowed'] = $_POST['is_edit_allowed'][0];
}
?>
<li class="rtmedia-list-item" id="<?php 
echo rtmedia_id();
?>
">
	<?php 
do_action('rtmedia_before_item');
?>
	<a href ="<?php 
rtmedia_permalink();
?>
" title="<?php 
echo rtmedia_title();
?>
">
		<div class="rtmedia-item-thumbnail">

            <img src="<?php 
function get_rtmedia_date_gmt($rtmedia_id = false)
{
    $media = get_post(rtmedia_media_id(rtmedia_id($rtmedia_id)));
    $date_time = "";
    if (isset($media->post_date_gmt) && $media->post_date_gmt != "") {
        $date_time = rtmedia_convert_date($media->post_date_gmt);
    }
    return $date_time;
}
Пример #12
0
 /**
  * Move a media from one album to another
  *
  * @global type $wpdb
  *
  * @param type  $media_id
  * @param type  $album_id
  *
  * @return boolean
  */
 function move($media_id, $album_id)
 {
     global $wpdb;
     /* update the post_parent value in wp_post table */
     $status = $wpdb->update($wpdb->posts, array('post_parent' => $album_id), array('ID' => $media_id));
     if (is_wp_error($status) || $status == 0) {
         return false;
     } else {
         $id = rtmedia_id($media_id);
         /* update album_id, context, context_id and privacy in rtMedia context */
         $album_data = $this->model->get(array('media_id' => $media_id));
         $data = array('album_id' => $album_id, 'context' => $album_data->context, 'context_id' => $album_data->context_id, 'privacy' => $album_data->privacy);
         return $this->update($id, $data, $media_id);
     }
 }
Пример #13
0
/**
 * Function to edit attachment for media
 *
 * @param  string $permalink  attachment permalink
 * @param  array $post_id  return attachment post id
 *
 * @return string attachment post permalink
 */
function rtmedia_attachment_link_callback($permalink, $post_id)
{
    $rtmedia_media_id = rtmedia_id($post_id);
    if (is_admin() && !empty($rtmedia_media_id)) {
        $permalink = esc_url(get_rtmedia_permalink(rtmedia_id($post_id))) . '#rtmedia_comment_ul';
    }
    return $permalink;
}
    /**
     *
     * Outputs the HTML code of this widget.
     *
     * @param array An array of standard parameters for widgets in this theme
     * @param array An array of settings for this widget instance
     * @return void
     *
     **/
    function widget($args, $instance)
    {
        global $bp;
        global $rtmedia_query, $rtmedia_interaction, $rtmedia_media;
        global $rtmedia_backbone;
        $cache = get_transient(md5($this->id));
        $data_source_type = '';
        // the part with the title and widget wrappers cannot be cached!
        // in order to avoid problems with the calculating columns
        //
        extract($args, EXTR_SKIP);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Latest Photos', GKTPLNAME) : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        echo $before_title;
        echo $title;
        echo $after_title;
        if ($cache) {
            echo $cache;
            echo $after_widget;
            return;
        }
        ob_start();
        //
        $user_id = empty($instance['user_id']) ? '' : $instance['user_id'];
        $offset = empty($instance['offset']) ? 0 : $instance['offset'];
        $columns = empty($instance['columns']) ? 5 : $instance['columns'];
        $rows = empty($instance['rows']) ? 2 : $instance['rows'];
        $cache = empty($instance['cache']) ? 60 : $instance['cache'];
        if (!is_numeric($offset)) {
            $offset = 0;
        } else {
            $offset = intval($offset);
        }
        if (!is_numeric($rows)) {
            $rows = 0;
        } else {
            $rows = intval($rows);
        }
        if (!is_numeric($columns)) {
            $columns = 0;
        } else {
            $columns = intval($columns);
        }
        $model = new RTMediaModel();
        if ($data_source_type == 'user') {
            $media = $model->get_media(array('media_type' => 'photo', 'media_author' => $user_id), $offset, $columns * $rows);
        } else {
            $media = $model->get_media(array('media_type' => 'photo'), $offset, $columns * $rows);
        }
        if ($media == null) {
            echo __('There has been no recent activity.', GKTPLNAME);
        } else {
            ?>
			<div class="gk-bp-latest-photos" data-cols="<?php 
            echo $columns;
            ?>
">
				<div>
					<?php 
            foreach ($media as $img) {
                ?>
					<a href ="<?php 
                echo get_rtmedia_permalink(rtmedia_id($img->media_id));
                ?>
">
						<img src="<?php 
                rtmedia_image("rt_media_thumbnail", rtmedia_id($img->media_id));
                ?>
" alt="<?php 
                _e('View full image', GKTPLNAME);
                ?>
" />
					</a>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
        // save the cache results
        $cache_output = ob_get_flush();
        if (is_numeric($cache) && $cache > 0) {
            set_transient(md5($this->id), $cache_output, 60 * $cache);
        } else {
            delete_transient(md5($this->id));
        }
        //
        echo $after_widget;
    }
    /**
     *
     * Outputs the HTML code of this widget.
     *
     * @param array An array of standard parameters for widgets in this theme
     * @param array An array of settings for this widget instance
     * @return void
     *
     **/
    function widget($args, $instance)
    {
        global $bp;
        global $rtmedia_query, $rtmedia_interaction, $rtmedia_media;
        global $rtmedia_backbone;
        $cache = get_transient(md5($this->id));
        // the part with the title and widget wrappers cannot be cached!
        // in order to avoid problems with the calculating columns
        //
        extract($args, EXTR_SKIP);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('BuddyPress Activity', GKTPLNAME) : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        echo $before_title;
        echo $title;
        echo $after_title;
        if ($cache) {
            echo $cache;
            echo $after_widget;
            return;
        }
        ob_start();
        //
        $data_source_type = empty($instance['data_source_type']) ? 'latest' : $instance['data_source_type'];
        $user_id = empty($instance['user_id']) ? '' : $instance['user_id'];
        $total_amount = empty($instance['total_amount']) ? 8 : $instance['total_amount'];
        $show_username = empty($instance['show_username']) ? 'enable' : $instance['show_username'];
        $show_readmore = empty($instance['show_readmore']) ? 'enable' : $instance['show_readmore'];
        $amount_page = empty($instance['amount_page']) ? 4 : $instance['amount_page'];
        $autoanimation = empty($instance['autoanimation']) ? 'disable' : $instance['autoanimation'];
        $photo_width = empty($instance['photo_width']) ? 310 : $instance['photo_width'];
        $offset = empty($instance['offset']) ? 0 : $instance['offset'];
        if (!is_numeric($offset)) {
            $offset = 0;
        } else {
            $offset = intval($offset);
        }
        if (!is_numeric($total_amount)) {
            $total_amount = 0;
        } else {
            $total_amount = intval($total_amount);
        }
        $width = 3000;
        $new_width = $total_amount * $photo_width;
        if ($new_width > 3000) {
            $width = $new_width;
        }
        $model = new RTMediaModel();
        if ($data_source_type == 'user') {
            $media = $model->get_media(array('media_type' => 'photo', 'media_author' => $user_id), $offset, $total_amount);
        } else {
            $media = $model->get_media(array('media_type' => 'photo'), $offset, $total_amount);
        }
        ?>
		
		<div data-cols="<?php 
        echo $amount_page;
        ?>
" style="width: <?php 
        echo $width;
        ?>
px" <?php 
        if ($autoanimation == 'enabled') {
            echo 'class="animate"';
        }
        ?>
>
		
		<?php 
        if ($media == null) {
            ?>
 
			<h4> <?php 
            echo __('GK BuddyPress Gallery: There has been no recent activity.', GKTPLNAME);
            ?>
</h4>
		<?php 
        } else {
            ?>
		
			<?php 
            foreach ($media as $img) {
                ?>
			<figure style="width: <?php 
                echo $photo_width;
                ?>
px">
				<img src="<?php 
                rtmedia_image("rt_media_activity_image", rtmedia_id($img->media_id));
                ?>
" alt="<?php 
                _e('View full image', GKTPLNAME);
                ?>
" />
				<figcaption>
					<?php 
                if ($show_username == 'enabled') {
                    ?>
						<small><?php 
                    echo rtmedia_get_author_name($img->media_author);
                    ?>
</small>
					<?php 
                }
                ?>
					
					<p><?php 
                echo $this->activity_text($this->gk_activity_content($img->activity_id), 15, false);
                ?>
</p>
					
					<?php 
                if ($show_readmore == 'enabled') {
                    ?>
						<a href ="<?php 
                    echo get_rtmedia_permalink(rtmedia_id($img->media_id));
                    ?>
"><?php 
                    _e('Read more...', GKTPLNAME);
                    ?>
</a>
					<?php 
                }
                ?>
				</figcaption>
			</figure>
			<?php 
            }
            ?>
		
		<?php 
        }
        ?>
		</div>
 
		
		<?php 
        // save the cache results
        $cache_output = ob_get_flush();
        set_transient(md5($this->id), $cache_output, 3 * 60 * 60);
        //
        echo $after_widget;
    }
Пример #16
0
/**
 * HTML markup for displaying Media Count of album in album list gallery
 */
function rtm_album_media_count()
{
    $rtmedia_album_count_status = array('status' => true, 'before_string' => '', 'after_string' => '');
    /**
     * rtmedia_string_album_count Filter to update album count status, add string before/after count.
     *
     * @since 4.8
     *
     * @param array $rtmedia_album_count_status status, before_string, after_string
     *
     */
    $rtmedia_album_count_status = apply_filters('rtmedia_string_album_count', $rtmedia_album_count_status);
    if (isset($rtmedia_album_count_status) && $rtmedia_album_count_status['status']) {
        ?>
		<div class="rtmedia-album-media-count" title="<?php 
        echo rtm_get_album_media_count(rtmedia_id()) . RTMEDIA_MEDIA_LABEL;
        ?>
"><?php 
        echo esc_html($rtmedia_album_count_status['before_string']) . rtm_get_album_media_count(rtmedia_id()) . esc_html($rtmedia_album_count_status['after_string']);
        ?>
</div>
		<?php 
    }
    ?>
	<?php 
}