[17225] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: PBase2Piwigo |
---|
| 4 | Version: auto |
---|
[17314] | 5 | Description: Import photos from PBase |
---|
[24661] | 6 | Plugin URI: auto |
---|
[17225] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
[26201] | 11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[17225] | 12 | |
---|
| 13 | global $conf; |
---|
| 14 | |
---|
[26201] | 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); |
---|
[19832] | 18 | define('PBASE_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'pbase_cache/'); |
---|
[17225] | 19 | |
---|
[19832] | 20 | |
---|
[26201] | 21 | include_once(PBASE_PATH . 'include/ws_functions.inc.php'); |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | add_event_handler('ws_add_methods', 'pbase_add_ws_method'); |
---|
| 25 | |
---|
[17225] | 26 | if (defined('IN_ADMIN')) |
---|
| 27 | { |
---|
| 28 | add_event_handler('get_admin_plugin_menu_links', 'pbase_admin_menu'); |
---|
| 29 | |
---|
[26201] | 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 | |
---|
[17225] | 33 | function pbase_admin_menu($menu) |
---|
| 34 | { |
---|
[26201] | 35 | $menu[] = array( |
---|
[17225] | 36 | 'NAME' => 'PBase2Piwigo', |
---|
| 37 | 'URL' => PBASE_ADMIN, |
---|
[26201] | 38 | ); |
---|
[17225] | 39 | return $menu; |
---|
| 40 | } |
---|
| 41 | |
---|
[26201] | 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 | } |
---|
[19832] | 50 | |
---|
[26201] | 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 | } |
---|
[17225] | 62 | |
---|
[26201] | 63 | return $filter_sets; |
---|
| 64 | } |
---|
| 65 | } |
---|