1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: PBase2Piwigo |
---|
4 | Version: auto |
---|
5 | Description: Import photos from PBase |
---|
6 | Plugin URI: auto |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $conf; |
---|
14 | |
---|
15 | define('PBASE_ID', basename(dirname(__FILE__))); |
---|
16 | define('PBASE_PATH', PHPWG_PLUGINS_PATH . PBASE_ID . '/'); |
---|
17 | define('PBASE_ADMIN', get_root_url() . 'admin.php?page=plugin-' . PBASE_ID); |
---|
18 | define('PBASE_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'pbase_cache/'); |
---|
19 | |
---|
20 | |
---|
21 | include_once(PBASE_PATH . 'include/ws_functions.inc.php'); |
---|
22 | |
---|
23 | |
---|
24 | add_event_handler('ws_add_methods', 'pbase_add_ws_method'); |
---|
25 | |
---|
26 | if (defined('IN_ADMIN')) |
---|
27 | { |
---|
28 | add_event_handler('get_admin_plugin_menu_links', 'pbase_admin_menu'); |
---|
29 | |
---|
30 | add_event_handler('get_batch_manager_prefilters', 'pbase_add_batch_manager_prefilters'); |
---|
31 | add_event_handler('perform_batch_manager_prefilters', 'pbase_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
32 | |
---|
33 | function pbase_admin_menu($menu) |
---|
34 | { |
---|
35 | $menu[] = array( |
---|
36 | 'NAME' => 'PBase2Piwigo', |
---|
37 | 'URL' => PBASE_ADMIN, |
---|
38 | ); |
---|
39 | return $menu; |
---|
40 | } |
---|
41 | |
---|
42 | function pbase_add_batch_manager_prefilters($prefilters) |
---|
43 | { |
---|
44 | $prefilters[] = array( |
---|
45 | 'ID' => 'pbase', |
---|
46 | 'NAME' => l10n('Imported from PBase'), |
---|
47 | ); |
---|
48 | return $prefilters; |
---|
49 | } |
---|
50 | |
---|
51 | function pbase_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
52 | { |
---|
53 | if ($prefilter == 'pbase') |
---|
54 | { |
---|
55 | $query = ' |
---|
56 | SELECT id |
---|
57 | FROM '.IMAGES_TABLE.' |
---|
58 | WHERE file LIKE "pbase-%" |
---|
59 | ;'; |
---|
60 | $filter_sets[] = array_from_query($query, 'id'); |
---|
61 | } |
---|
62 | |
---|
63 | return $filter_sets; |
---|
64 | } |
---|
65 | } |
---|