source: extensions/batch_manager_prefilters/main.inc.php @ 10379

Revision 10379, 1.3 KB checked in by patdenice, 9 years ago (diff)

Add Batch Manager Prefilters plugin.

Line 
1<?php
2/*
3Plugin Name: Batch Manager Prefilters
4Version: auto
5Description: Add some prefilters in Batch Manager.
6Plugin URI: auto
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13add_event_handler('get_batch_manager_prefilters', 'add_bmp');
14add_event_handler('perform_batch_manager_prefilters', 'perform_bmp', 50, 2);
15
16function add_bmp($prefilters)
17{
18  load_language('plugin.lang', dirname(__FILE__).'/');
19
20  array_push($prefilters,
21    array('ID' => 'with tags', 'NAME' => l10n('with tags')),
22    array('ID' => 'with HD', 'NAME' => l10n('with HD')),
23    array('ID' => 'without HD', 'NAME' => l10n('without HD'))
24  );
25
26  return $prefilters;
27}
28
29function perform_bmp($filter_sets, $prefilter)
30{
31  if ('with tags' == $prefilter)
32  {
33    $query = 'SELECT DISTINCT image_id FROM '.IMAGE_TAG_TABLE.';';
34    array_push($filter_sets, array_from_query($query, 'image_id'));
35  }
36
37  if ('with HD' == $prefilter)
38  {
39    $query = 'SELECT id FROM '.IMAGES_TABLE.' WHERE has_high IS NOT NULL;';
40    array_push($filter_sets, array_from_query($query, 'id'));
41  }
42
43  if ('without HD' == $prefilter)
44  {
45    $query = 'SELECT id FROM '.IMAGES_TABLE.' WHERE has_high IS NULL;';
46    array_push($filter_sets, array_from_query($query, 'id'));
47  }
48
49  return $filter_sets;
50}
51
52?>
Note: See TracBrowser for help on using the repository browser.