Exemplo n.º 1
0
            ?>
								<a id="rtMedia-galary-prev" style='<?php 
            echo esc_attr($display);
            ?>
'
								   href="<?php 
            echo esc_url(rtmedia_pagination_prev_link());
            ?>
"><?php 
            esc_html_e('Prev', 'buddypress-media');
            ?>
</a>

								<?php 
            $display = '';
            if (rtmedia_offset() + rtmedia_per_page_media() < rtmedia_count()) {
                $display = 'display:block;';
            } else {
                $display = 'display:none;';
            }
            ?>
								<a id="rtMedia-galary-next" style="<?php 
            echo esc_attr($display);
            ?>
"
								   href="<?php 
            echo esc_url(rtmedia_pagination_next_link());
            ?>
"><?php 
            esc_html_e('Next', 'buddypress-media');
            ?>
Exemplo n.º 2
0
 function json_output()
 {
     global $rtmedia_query, $rtmedia;
     $options = $rtmedia->options;
     $media_array = array();
     if ($rtmedia_query->media) {
         foreach ($rtmedia_query->media as $key => $media) {
             $media_array[$key] = $media;
             $media_array[$key]->guid = rtmedia_image('rt_media_thumbnail', $media->id, false);
             $media_array[$key]->rt_permalink = get_rtmedia_permalink($media->id);
             $media_array[$key]->duration = rtmedia_duration($media->id);
             $media_array[$key] = apply_filters('rtmedia_media_array_backbone', $media_array[$key]);
         }
     }
     $return_array['data'] = $media_array;
     $return_array['prev'] = rtmedia_page() - 1;
     $return_array['next'] = rtmedia_offset() + rtmedia_per_page_media() < rtmedia_count() ? rtmedia_page() + 1 : -1;
     if (isset($rtmedia->options['general_display_media']) && $options['general_display_media'] == 'pagination') {
         $return_array['pagination'] = rtmedia_get_pagination_values();
     }
     echo json_encode($return_array);
     die;
 }
Exemplo n.º 3
0
/**
 * Render pagination UI
 *
 * @global      RTMedia         $rtmedia
 * @global      RTMediaQuery    $rtmedia_query
 * @global      int             $paged
 *
 * @return      string
 */
function rtmedia_get_pagination_values()
{
    global $rtmedia, $rtmedia_query, $paged;
    $general_options = $rtmedia->options;
    $per_page = $general_options['general_perPageMedia'];
    if (isset($rtmedia_query->query['per_page'])) {
        $per_page = $rtmedia_query->query['per_page'];
    }
    $per_page = intval($per_page);
    $range = 1;
    $showitems = $range * 2 + 1;
    $rtmedia_media_pages = '';
    if (0 === intval(rtmedia_offset())) {
        $paged = 1;
        // @codingStandardsIgnoreLine
    } else {
        if (intval(rtmedia_offset()) === $per_page) {
            $paged = 2;
            // @codingStandardsIgnoreLine
        } else {
            $paged = ceil(rtmedia_offset() / $per_page) + 1;
            // @codingStandardsIgnoreLine
        }
    }
    $pages = ceil(rtmedia_count() / $per_page);
    if (!$pages) {
        $pages = 1;
    }
    $page_base_url = rtmedia_pagination_page_link();
    if (1 !== intval($pages)) {
        $rtmedia_media_pages .= "<div class='rtm-pagination clearfix'>";
        $rtmedia_media_pages .= "<div class='rtmedia-page-no rtm-page-number'>";
        $rtmedia_media_pages .= "<span class='rtm-label'>";
        $rtmedia_media_pages .= esc_html(apply_filters('rtmedia_goto_page_label', esc_html__('Go to page no : ', 'buddypress-media')));
        $rtmedia_media_pages .= '</span>';
        $rtmedia_media_pages .= "<input type='hidden' id='rtmedia_first_page' value='1' />";
        $rtmedia_media_pages .= "<input type='hidden' id='rtmedia_last_page' value='" . esc_attr($pages) . "' />";
        $rtmedia_media_pages .= "<input type='number' value='" . esc_attr($paged) . "' min='1' max='" . esc_attr($pages) . "' class='rtm-go-to-num' id='rtmedia_go_to_num' />";
        $rtmedia_media_pages .= "<a class='rtmedia-page-link button' data-page-type='num' data-page-base-url='" . $page_base_url . "' href='#'>" . esc_html__('Go', 'buddypress-media') . '</a>';
        $rtmedia_media_pages .= "</div><div class='rtm-paginate'>";
        if ($paged > 1 && $showitems < $pages) {
            $page_url = rtmedia_page() - 1 == 1 ? '' : $page_base_url . (rtmedia_page() - 1);
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='prev' href='" . esc_url($page_url) . "'><i class='dashicons dashicons-arrow-left-alt2'></i></a>";
        }
        if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) {
            $page_url = $page_base_url . '1';
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='page' data-page='1' href='" . esc_url($page_url) . "'>1</a>";
            if ($paged > 3) {
                $rtmedia_media_pages .= '<span>...</span>';
            }
        }
        for ($i = 1; $i <= $pages; $i++) {
            if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                $page_url = $page_base_url . $i;
                $rtmedia_media_pages .= $paged == $i ? "<span class='current'>" . esc_html($i) . '</span>' : "<a class='rtmedia-page-link' data-page-type='page' data-page='" . esc_attr($i) . "' href='" . esc_url($page_url) . "' class='inactive' >" . esc_html($i) . '</a>';
            }
        }
        if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) {
            $page_url = $page_base_url . $pages;
            if ($paged + 2 < $pages) {
                $rtmedia_media_pages .= '<span>...</span>';
            }
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='page' data-page='" . esc_attr($pages) . "' href='" . esc_url($page_url) . "'>" . esc_html($pages) . '</a>';
        }
        if ($paged < $pages && $showitems < $pages) {
            $page_url = $page_base_url . (rtmedia_page() + 1);
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='next' href='" . esc_url($page_url) . "'><i class='dashicons dashicons-arrow-right-alt2'></i></a>";
        }
        $rtmedia_media_pages .= "</div></div>\n";
    }
    // End if().
    return $rtmedia_media_pages;
}
function rtmedia_get_pagination_values()
{
    global $rtmedia, $rtmedia_query;
    $general_options = $rtmedia->options;
    $per_page = $general_options['general_perPageMedia'];
    if (isset($rtmedia_query->query['per_page'])) {
        $per_page = $rtmedia_query->query['per_page'];
    }
    $range = 1;
    $showitems = $range * 2 + 1;
    $rtmedia_media_pages = '';
    global $paged;
    if (rtmedia_offset() == 0) {
        $paged = 1;
    } else {
        if (rtmedia_offset() == $per_page) {
            $paged = 2;
        } else {
            $paged = ceil(rtmedia_offset() / $per_page) + 1;
        }
    }
    $pages = ceil(rtmedia_count() / $per_page);
    if (!$pages) {
        $pages = 1;
    }
    if (1 != $pages) {
        $rtmedia_media_pages .= "<div class='rtm-pagination clearfix'>";
        //if( $pages > 100 ) {
        $rtmedia_media_pages .= "<div class='rtmedia-page-no rtm-page-number'>";
        $rtmedia_media_pages .= "<span class='rtm-label'>";
        $rtmedia_media_pages .= apply_filters('rtmedia_goto_page_label', __("Go to page no : ", 'rtmedia'));
        $rtmedia_media_pages .= "</span>";
        $rtmedia_media_pages .= "<input type='hidden' id='rtmedia_first_page' value='1' />";
        $rtmedia_media_pages .= "<input type='hidden' id='rtmedia_last_page' value='" . $pages . "' />";
        $rtmedia_media_pages .= "<input type='number' value='" . $paged . "' min='1' max='" . $pages . "' class='rtm-go-to-num' id='rtmedia_go_to_num' />";
        $rtmedia_media_pages .= "<a class='rtmedia-page-link button' data-page-type='num' href='#'>" . __('Go', 'rtmedia') . "</a>";
        $rtmedia_media_pages .= "</div><div class='rtm-paginate'>";
        //}
        if ($paged > 1 && $showitems < $pages) {
            $page_url = rtmedia_page() - 1 == 1 ? "" : "pg/" . (rtmedia_page() - 1);
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='prev' href='" . $page_url . "'><i class='dashicons dashicons-arrow-left-alt2'></i></a>";
        }
        if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) {
            $page_url = 'pg/1';
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='page' data-page='1' href='" . $page_url . "'>1</a><span>...</span>";
        }
        for ($i = 1; $i <= $pages; $i++) {
            if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                $page_url = 'pg/' . $i;
                $rtmedia_media_pages .= $paged == $i ? "<span class='current'>" . $i . "</span>" : "<a class='rtmedia-page-link' data-page-type='page' data-page='" . $i . "' href='" . $page_url . "' class='inactive' >" . $i . "</a>";
            }
        }
        if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) {
            $page_url = 'pg/' . $pages;
            $rtmedia_media_pages .= "<span>...</span><a class='rtmedia-page-link' data-page-type='page' data-page='" . $pages . "' href='" . $page_url . "'>" . $pages . "</a>";
        }
        if ($paged < $pages && $showitems < $pages) {
            $page_url = 'pg/' . (rtmedia_page() + 1);
            $rtmedia_media_pages .= "<a class='rtmedia-page-link' data-page-type='next' href='" . $page_url . "'><i class='dashicons dashicons-arrow-right-alt2'></i></a>";
        }
        $rtmedia_media_pages .= "</div></div>\n";
    }
    return $rtmedia_media_pages;
}
 function json_output()
 {
     global $rtmedia_query;
     $media_array = array();
     if ($rtmedia_query->media) {
         foreach ($rtmedia_query->media as $key => $media) {
             $media_array[$key] = $media;
             $media_array[$key]->guid = rtmedia_image('rt_media_thumbnail', $media->id, false);
             $media_array[$key]->rt_permalink = get_rtmedia_permalink($media->id);
         }
     }
     $return_array['data'] = $media_array;
     $return_array['prev'] = rtmedia_page() - 1;
     $return_array['next'] = rtmedia_offset() + rtmedia_per_page_media() < rtmedia_count() ? rtmedia_page() + 1 : -1;
     echo json_encode($return_array);
     die;
 }