Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function query_args()
 {
     global $gmCore;
     $args['status'] = $gmCore->_get('status');
     $args['page'] = $gmCore->_get('pager', 1);
     $args['number'] = $gmCore->_get('per_page', $this->user_options["per_page_{$this->taxonomy}"]);
     $args['offset'] = ($args['page'] - 1) * $args['number'];
     $args['global'] = parent::filter_by_author($gmCore->_get('author'));
     $args['include'] = $gmCore->_get('include');
     $args['search'] = $gmCore->_get('s');
     $args['orderby'] = $gmCore->_get('orderby', $this->user_options["orderby_{$this->taxonomy}"]);
     $args['order'] = $gmCore->_get('order', $this->user_options["sortorder_{$this->taxonomy}"]);
     $args['hide_empty'] = $gmCore->_get('hide_empty');
     if ($args['search'] && '#' == substr($args['search'], 0, 1)) {
         $args['include'] = substr($args['search'], 1);
         $args['search'] = false;
     }
     if ('selected' == $gmCore->_req('filter') && !empty($this->selected_items)) {
         $args['include'] = $this->selected_items;
         $args['orderby'] = $gmCore->_get('orderby', 'include');
         $args['order'] = $gmCore->_get('order', 'ASC');
     }
     $query_args = apply_filters('gmedia_terms_query_args', $args);
     foreach ($query_args as $key => $val) {
         if (empty($val) && '0' !== $val && 0 !== $val) {
             unset($query_args[$key]);
         }
     }
     return $query_args;
 }
 /**
  * GmediaProcessor_Library constructor.
  */
 public function __construct()
 {
     parent::__construct();
     global $gmCore;
     $this->import = $gmCore->_get('import', false, true);
     $this->url = add_query_arg(array('import' => $this->import), $this->url);
 }
Ejemplo n.º 3
0
 /**
  * GmediaProcessor_Library constructor.
  */
 public function __construct()
 {
     parent::__construct();
     global $user_ID;
     self::$cookie_key = "gmedia_library:wpmedia";
     $this->selected_items = parent::selected_items(self::$cookie_key);
 }
Ejemplo n.º 4
0
 /**
  * @return array
  */
 public function query_args()
 {
     global $gmCore, $gmDB, $gmGallery;
     if ($this->edit_term) {
         $per_page = $this->user_options["per_page_{$this->taxonomy}_edit"];
         if ('album' === $this->taxterm) {
             $alb_meta = $gmDB->get_metadata('gmedia_term', $this->edit_term);
             $orderby = !empty($alb_meta['_orderby'][0]) ? $alb_meta['_orderby'][0] : $gmGallery->options['in_album_orderby'];
             $order = !empty($alb_meta['_order'][0]) ? $alb_meta['_order'][0] : $gmGallery->options['in_album_order'];
         } elseif ('category' === $this->taxterm) {
             $cat_meta = $gmDB->get_metadata('gmedia_term', $this->edit_term);
             $orderby = !empty($cat_meta['_orderby'][0]) ? $cat_meta['_orderby'][0] : $gmGallery->options['in_category_orderby'];
             $order = !empty($cat_meta['_order'][0]) ? $cat_meta['_order'][0] : $gmGallery->options['in_category_order'];
         } elseif ('tag' === $this->taxterm) {
             $orderby = $gmGallery->options['in_tag_orderby'];
             $order = $gmGallery->options['in_tag_order'];
         } else {
             $orderby = $this->user_options['orderby_gmedia'];
             $order = $this->user_options['sortorder_gmedia'];
         }
     } else {
         $per_page = $this->user_options["per_page_gmedia"];
         $orderby = $this->user_options['orderby_gmedia'];
         $order = $this->user_options['sortorder_gmedia'];
     }
     $args['mime_type'] = $gmCore->_get('mime_type');
     $args['status'] = $gmCore->_get('status');
     $args['page'] = $gmCore->_get('pager');
     $args['per_page'] = $gmCore->_get('per_page', $per_page);
     $args['author__in'] = parent::filter_by_author($gmCore->_get('author'));
     $args['alb'] = $gmCore->_get('alb');
     $args['album__in'] = $gmCore->_get('album__in');
     $args['album__not_in'] = $gmCore->_get('album__not_in');
     $args['tag_id'] = $gmCore->_get('tag_id');
     $args['tag__in'] = $gmCore->_get('tag__in');
     $args['tag__not_in'] = $gmCore->_get('tag__not_in');
     $args['cat'] = $gmCore->_get('cat');
     $args['category__in'] = $gmCore->_get('category__in');
     $args['category__not_in'] = $gmCore->_get('category__not_in');
     $args['category__and'] = $gmCore->_get('category__and');
     $args['gmedia__in'] = $gmCore->_get('gmedia__in');
     $args['s'] = $gmCore->_get('s');
     $args['orderby'] = $gmCore->_get('orderby', $orderby);
     $args['order'] = $gmCore->_get('order', $order);
     if ('duplicates' === $args['gmedia__in']) {
         $duplicates = $gmDB->get_duplicates();
         if (!empty($duplicates['duplicate_ids'])) {
             $args['gmedia__in'] = $duplicates['duplicate_ids'];
             $args['orderby'] = 'gmedia__in';
             setcookie(self::$cookie_key, implode('.', $duplicates['duplicate_select']));
             $_COOKIE[self::$cookie_key] = implode('.', $duplicates['duplicate_select']);
             $this->selected_items = $duplicates['duplicate_select'];
         } else {
             unset($args['gmedia__in']);
             $this->msg[] = __('No duplicates in Gmedia Library', 'grand-media');
         }
     }
     if ($args['s'] && '#' == substr($args['s'], 0, 1)) {
         $args['gmedia__in'] = substr($args['s'], 1);
         $args['s'] = false;
     }
     $show_stack = false;
     if ('show' == $gmCore->_req('stack') && !empty($this->stack_items)) {
         $args['gmedia__in'] = $this->stack_items;
         $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in');
         $args['order'] = $gmCore->_get('order', 'ASC');
         $show_stack = true;
     }
     if ('selected' == $gmCore->_req('filter') && !empty($this->selected_items)) {
         if ($show_stack) {
             $stack_items = wp_parse_id_list($this->stack_items);
             $selected_items = wp_parse_id_list($this->selected_items);
             $gmedia_in = array_intersect($stack_items, $selected_items);
             $args['gmedia__in'] = $gmedia_in;
         } else {
             $args['gmedia__in'] = $this->selected_items;
             $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in');
             $args['order'] = $gmCore->_get('order', 'ASC');
         }
     }
     $query_args = apply_filters('gmedia_library_query_args', $args);
     foreach ($query_args as $key => $val) {
         if (empty($val) && '0' !== $val && 0 !== $val) {
             unset($query_args[$key]);
         }
     }
     if (!empty($query_args['author__in']) && $gmCore->caps['gmedia_show_others_media']) {
         $authors_names = $query_args['author__in'];
         foreach ($authors_names as $i => $id) {
             if ((int) $id) {
                 $authors_names[$i] = get_the_author_meta('display_name', $id);
             }
         }
         $this->filters['filter_author'] = array('title' => __('Filter Author', 'grand-media'), 'filter' => $authors_names);
     }
     $gmDB->gmedias_album_stuff($query_args);
     if (!empty($query_args['album__in'])) {
         if (isset($query_args['within_album'])) {
             $filter_title = __('Exclude Album', 'grand-media');
             $albums_names = array();
             if (!empty($query_args['with_album__not_in'])) {
                 $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['with_album__not_in']));
             }
             array_push($albums_names, __('Hide items without album', 'grand-media'));
         } else {
             $filter_title = __('Filter Album', 'grand-media');
             $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__in']));
         }
         if (!empty($albums_names)) {
             $this->filters['filter_albums'] = array('title' => $filter_title, 'filter' => $albums_names);
         }
     }
     if (!empty($query_args['album__not_in'])) {
         if (isset($query_args['without_album'])) {
             $filter_title = __('Filter Album', 'grand-media');
             $albums_names = array();
             if (!empty($query_args['with_album__in'])) {
                 $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['with_album__in']));
             }
             array_push($albums_names, __('Show items without album', 'grand-media'));
         } else {
             $filter_title = __('Exclude Album', 'grand-media');
             $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__not_in']));
         }
         if (!empty($albums_names)) {
             $this->filters['exclude_albums'] = array('title' => $filter_title, 'filter' => $albums_names);
         }
     }
     $gmDB->gmedias_category_stuff($query_args);
     if (!empty($query_args['category__in'])) {
         if (isset($query_args['within_category'])) {
             $filter_title = __('Exclude Category', 'grand-media');
             $category_names = array();
             if (!empty($query_args['with_category__not_in'])) {
                 $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['with_category__not_in']));
             }
             $category_names = array_push($category_names, __('Hide items without categories', 'grand-media'));
         } else {
             $filter_title = __('Filter Category', 'grand-media');
             $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['category__in']));
         }
         if (!empty($category_names)) {
             $this->filters['filter_categories'] = array('title' => $filter_title, 'filter' => $category_names);
         }
     }
     if (!empty($query_args['category__not_in'])) {
         if (isset($query_args['without_category'])) {
             $filter_title = __('Filter Category', 'grand-media');
             $category_names = array();
             if (!empty($query_args['with_category__in'])) {
                 $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['with_category__in']));
             }
             $category_names = array_push($category_names, __('Show items without categories', 'grand-media'));
         } else {
             $filter_title = __('Exclude Category', 'grand-media');
             $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['category__not_in']));
         }
         if (!empty($category_names)) {
             $this->filters['exclude_categories'] = array('title' => $filter_title, 'filter' => $category_names);
         }
     }
     $gmDB->gmedias_tag_stuff($query_args);
     if (!empty($query_args['tag__in'])) {
         $tag_names = $gmDB->get_terms('gmedia_tag', array('fields' => 'names', 'include' => $query_args['tag__in']));
         if (!empty($tag_names)) {
             $this->filters['filter_tags'] = array('title' => __('Filter Tag', 'grand-media'), 'filter' => $tag_names);
         }
     }
     if (!empty($query_args['tag__not_in'])) {
         $tag_names = $gmDB->get_terms('gmedia_tag', array('fields' => 'names', 'include' => $query_args['tag__not_in']));
         if (!empty($tag_names)) {
             $this->filters['exclude_tags'] = array('title' => __('Exclude Tag', 'grand-media'), 'filter' => $tag_names);
         }
     }
     return $query_args;
 }
Ejemplo n.º 5
0
 /**
  * Autoloader
  */
 public static function autoload()
 {
     $path_ = GMEDIA_ABSPATH . 'admin/processor/class.processor.';
     $page = isset($_GET['page']) ? $_GET['page'] : '';
     switch ($page) {
         case 'GrandMedia':
             /** @var $gmProcessorLibrary */
             include_once $path_ . 'library.php';
             return $gmProcessorLibrary;
             break;
         case 'GrandMedia_AddMedia':
             /** @var $gmProcessorAddMedia */
             include_once $path_ . 'addmedia.php';
             return $gmProcessorAddMedia;
             break;
         case 'GrandMedia_Albums':
         case 'GrandMedia_Categories':
             /** @var $gmProcessorTerms */
             include_once $path_ . 'terms.php';
             /** @var $gmProcessorLibrary */
             include_once $path_ . 'library.php';
             return $gmProcessorTerms;
             break;
         case 'GrandMedia_Tags':
             /** @var $gmProcessorTerms */
             include_once $path_ . 'terms.php';
             return $gmProcessorTerms;
             break;
         case 'GrandMedia_Galleries':
             /** @var $gmProcessorGalleries */
             include_once $path_ . 'galleries.php';
             return $gmProcessorGalleries;
             break;
         case 'GrandMedia_Modules':
             /** @var $gmProcessorModules */
             include_once $path_ . 'modules.php';
             return $gmProcessorModules;
             break;
         case 'GrandMedia_Settings':
             /** @var $gmProcessorSettings */
             include_once $path_ . 'settings.php';
             return $gmProcessorSettings;
             break;
         case 'GrandMedia_WordpressLibrary':
             /** @var $gmProcessorWPMedia */
             include_once $path_ . 'wpmedia.php';
             return $gmProcessorWPMedia;
             break;
         default:
             if (self::$me == null) {
                 self::$me = new GmediaProcessor();
             }
             return self::$me;
             break;
     }
 }