[17475] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Google2Piwigo |
---|
| 4 | Version: auto |
---|
| 5 | Description: Import photos from your Google account (including Picasa Web Albums) |
---|
[24816] | 6 | Plugin URI: auto |
---|
[17475] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | global $conf; |
---|
| 14 | |
---|
[19830] | 15 | define('PICASA_WA_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
[17475] | 16 | define('PICASA_WA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); |
---|
[19830] | 17 | define('PICASA_WA_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'picasa_wa_cache/'); |
---|
[17475] | 18 | |
---|
[24816] | 19 | if (defined('IN_ADMIN')) |
---|
| 20 | { |
---|
| 21 | add_event_handler('get_admin_plugin_menu_links', 'picasa_wa_admin_menu'); |
---|
| 22 | add_event_handler('get_batch_manager_prefilters', 'picasa_wa_add_batch_manager_prefilters'); |
---|
| 23 | add_event_handler('perform_batch_manager_prefilters', 'picasa_wa_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 24 | add_event_handler('loc_begin_admin_page', 'picasa_wa_prefilter_from_url'); |
---|
[17475] | 25 | |
---|
[24816] | 26 | function picasa_wa_admin_menu($menu) |
---|
| 27 | { |
---|
| 28 | array_push($menu, array( |
---|
| 29 | 'NAME' => 'Google2Piwigo', |
---|
| 30 | 'URL' => PICASA_WA_ADMIN, |
---|
| 31 | )); |
---|
| 32 | return $menu; |
---|
| 33 | } |
---|
[17475] | 34 | |
---|
[24816] | 35 | function picasa_wa_add_batch_manager_prefilters($prefilters) |
---|
| 36 | { |
---|
| 37 | array_push($prefilters, array( |
---|
| 38 | 'ID' => 'picasa', |
---|
| 39 | 'NAME' => l10n('Imported from Google/Picasa'), |
---|
| 40 | )); |
---|
| 41 | return $prefilters; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | function picasa_wa_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
| 45 | { |
---|
| 46 | if ($prefilter == 'picasa') |
---|
| 47 | { |
---|
| 48 | $query = ' |
---|
| 49 | SELECT id |
---|
| 50 | FROM '.IMAGES_TABLE.' |
---|
| 51 | WHERE file LIKE "picasa-%" |
---|
| 52 | ;'; |
---|
| 53 | $filter_sets[] = array_from_query($query, 'id'); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | return $filter_sets; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | function picasa_wa_prefilter_from_url() |
---|
| 60 | { |
---|
| 61 | global $page; |
---|
| 62 | if ($page['page'] == 'batch_manager' && @$_GET['prefilter'] == 'picasa') |
---|
| 63 | { |
---|
| 64 | $_SESSION['bulk_manager_filter'] = array('prefilter' => 'picasa'); |
---|
| 65 | unset($_GET['prefilter']); |
---|
| 66 | } |
---|
| 67 | } |
---|
[17475] | 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | include_once(PICASA_WA_PATH . 'include/ws_functions.inc.php'); |
---|
| 72 | |
---|
| 73 | add_event_handler('ws_add_methods', 'picasa_wa_add_ws_method'); |
---|
| 74 | |
---|
| 75 | ?> |
---|