Template to display rtMedia Gallery. A stand alone template that renders the gallery/uploader on the page.
저자: saurabh
function rtmedia_load_template()
{
    do_action("rtmedia_before_template_load");
    include RTMediaTemplate::locate_template();
    do_action("rtmedia_after_template_load");
}
예제 #2
0
 /**
  * Hook into the template_include filter to load custom template files
  *
  * @param string $template Template file path of the default template
  * @return string File path of the template file to be loaded
  */
 function template_include($template)
 {
     // if it is not our route, return the default template early
     if (!$this->is_template()) {
         return $template;
     }
     // otherwise, apply a filter to the template,
     // pass the template  and slug to the function hooking here
     // so it can load a custom template
     $template_load = new RTMediaTemplate();
     global $new_rt_template;
     $new_rt_template = $template_load->set_template($template);
     $new_rt_template = apply_filters("rtmedia_" . $this->slug . "_include", $new_rt_template);
     global $rt_ajax_request;
     $rt_ajax_request = false;
     // check if it is an ajax request
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $rt_ajax_request = true;
     }
     if ($rt_ajax_request) {
         return $new_rt_template;
     }
     if (function_exists('bp_set_theme_compat_active')) {
         bp_set_theme_compat_active(apply_filters('rtmedia_main_template_set_theme_compat', true));
     }
     add_filter('the_content', array(&$this, 'rt_replace_the_content'));
     $this->rt_theme_compat_reset_post();
     return apply_filters('rtmedia_main_template_include', $template, $new_rt_template);
 }
예제 #3
0
 /**
  * Scan the rtmedia template files.
  *
  * @access public
  *
  * @param  string $template_path
  *
  * @return array  $result
  */
 public function rtmedia_scan_template_files($template_path)
 {
     $files = scandir($template_path);
     $result = array();
     if ($files) {
         foreach ($files as $key => $value) {
             if (!in_array($value, array('.', '..'))) {
                 if (is_dir($template_path . DIRECTORY_SEPARATOR . $value)) {
                     $sub_files = $this->rtmedia_scan_template_files($template_path . DIRECTORY_SEPARATOR . $value);
                     foreach ($sub_files as $sub_file) {
                         $result[] = str_replace(ABSPATH . 'wp-content/', '', RTMediaTemplate::locate_template(substr($sub_file, 0, sizeof($sub_file) - 5)));
                     }
                 } else {
                     if ('main.php' != $value) {
                         $result[] = $value;
                     }
                 }
             }
         }
     }
     return $result;
 }
 /**
  * Render a shortcode according to the attributes passed with it
  *
  * @param boolean $attr
  */
 static function render($attr)
 {
     if (self::display_allowed()) {
         self::$add_script = true;
         ob_start();
         $authorized_member = true;
         //by default, viewer is authorized
         if (!isset($attr) || empty($attr)) {
             $attr = true;
         }
         $attr = array('name' => 'gallery', 'attr' => $attr);
         global $post;
         if (isset($attr) && isset($attr["attr"])) {
             if (!is_array($attr["attr"])) {
                 $attr["attr"] = array();
             }
             if (!isset($attr["attr"]["context_id"]) && isset($attr["attr"]["context"]) && $attr["attr"]["context"] == 'profile') {
                 $attr["attr"]["context_id"] = get_current_user_id();
             } elseif (!isset($attr["attr"]["context_id"]) && isset($post->ID)) {
                 $attr["attr"]["context_id"] = $post->ID;
             }
             //check if context is group, then the gallery should only be visible to users according to the group privacy
             if (isset($attr['attr']['context']) && $attr['attr']['context'] == 'group') {
                 if (function_exists('groups_get_group')) {
                     //if buddypress group is enabled
                     $group = groups_get_group(array('group_id' => $attr["attr"]["context_id"]));
                     if (isset($group->status) && $group->status != 'public') {
                         if (is_user_logged_in()) {
                             $is_member = groups_is_user_member(get_current_user_id(), $attr["attr"]["context_id"]);
                             if (!$is_member) {
                                 $authorized_member = false;
                                 //if user doesnot have access to the specified group
                             }
                         } else {
                             $authorized_member = false;
                             //if user is  groupnot logged in and visits group media gallery
                         }
                     }
                 }
             }
             if (!isset($attr["attr"]["context"]) && isset($post->post_type)) {
                 $attr["attr"]["context"] = $post->post_type;
             }
         }
         if ($authorized_member) {
             // if current user has access to view the gallery (when context is 'group')
             global $rtmedia_query;
             if (!$rtmedia_query) {
                 $rtmedia_query = new RTMediaQuery($attr["attr"]);
             }
             $rtmedia_query->is_gallery_shortcode = true;
             // to check if gallery shortcode is executed to display the gallery.
             $template = new RTMediaTemplate();
             $gallery_template = false;
             if (isset($attr["attr"]["global"]) && $attr["attr"]["global"] == true) {
                 add_filter('rtmedia-model-where-query', array('RTMediaGalleryShortcode', 'rtmedia_query_where_filter'), 10, 3);
             }
             $template->set_template($gallery_template, $attr);
             if (isset($attr["attr"]["global"]) && $attr["attr"]["global"] == true) {
                 remove_filter('rtmedia-model-where-query', array('RTMediaGalleryShortcode', 'rtmedia_query_where_filter'), 10, 3);
             }
         } else {
             //if user cannot view the media gallery (when context is 'group'), show message
             echo __('You do not have sufficient privileges to view this gallery', 'rtmedia');
             return false;
         }
         return ob_get_clean();
     }
 }
예제 #5
0
                        ?>

											<?php 
                        do_action('rtmedia_sub_nav');
                        ?>

										</ul>
									</div><!-- .item-list-tabs -->
									<?php 
                    }
                }
            }
        }
    }
}
include RTMediaTemplate::locate_template($template);
if (!$ajax) {
    if ($template_type == 'buddypress' && (bp_displayed_user_id() || bp_is_group())) {
        if (bp_is_group()) {
            do_action('bp_after_group_media');
            do_action('bp_after_group_body');
        }
        if (bp_displayed_user_id()) {
            do_action('bp_after_member_media');
            do_action('bp_after_member_body');
        }
        ?>



예제 #6
0
 function rtmedia_scan_template_files($template_path)
 {
     $files = scandir($template_path);
     $result = array();
     if ($files) {
         foreach ($files as $key => $value) {
             if (!in_array($value, array(".", ".."))) {
                 if (is_dir($template_path . DIRECTORY_SEPARATOR . $value)) {
                     $sub_files = $this->rtmedia_scan_template_files($template_path . DIRECTORY_SEPARATOR . $value);
                     foreach ($sub_files as $sub_file) {
                         $result[] = str_replace(ABSPATH . "wp-content/", "", RTMediaTemplate::locate_template(substr($sub_file, 0, sizeof($sub_file) - 5)));
                         //$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
                     }
                 } else {
                     if ($value != "main.php") {
                         $result[] = $value;
                     }
                 }
             }
         }
     }
     return $result;
 }