1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Instagram2Piwigo |
---|
4 | Version: auto |
---|
5 | Description: Import pictures from your instagram account |
---|
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('INSTAG_ID', basename(dirname(__FILE__))); |
---|
16 | define('INSTAG_PATH', PHPWG_PLUGINS_PATH . INSTAG_ID . '/'); |
---|
17 | define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . INSTAG_ID); |
---|
18 | define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/'); |
---|
19 | |
---|
20 | include_once(INSTAG_PATH . 'include/ws_functions.inc.php'); |
---|
21 | |
---|
22 | |
---|
23 | $conf['Instagram2Piwigo'] = safe_unserialize($conf['Instagram2Piwigo']); |
---|
24 | |
---|
25 | |
---|
26 | add_event_handler('ws_add_methods', 'instagram_add_ws_method'); |
---|
27 | |
---|
28 | if (defined('IN_ADMIN')) |
---|
29 | { |
---|
30 | add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu'); |
---|
31 | |
---|
32 | add_event_handler('get_batch_manager_prefilters', 'instagram_add_batch_manager_prefilters'); |
---|
33 | add_event_handler('perform_batch_manager_prefilters', 'instagram_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | function instagram_admin_menu($menu) |
---|
38 | { |
---|
39 | $menu[] = array( |
---|
40 | 'NAME' => 'Instagram2Piwigo', |
---|
41 | 'URL' => INSTAG_ADMIN, |
---|
42 | ); |
---|
43 | return $menu; |
---|
44 | } |
---|
45 | |
---|
46 | function instagram_add_batch_manager_prefilters($prefilters) |
---|
47 | { |
---|
48 | $prefilters[] = array( |
---|
49 | 'ID' => 'instagram', |
---|
50 | 'NAME' => l10n('Imported from Instagram'), |
---|
51 | ); |
---|
52 | return $prefilters; |
---|
53 | } |
---|
54 | |
---|
55 | function instagram_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
56 | { |
---|
57 | if ($prefilter == 'instagram') |
---|
58 | { |
---|
59 | $query = ' |
---|
60 | SELECT id |
---|
61 | FROM '.IMAGES_TABLE.' |
---|
62 | WHERE file LIKE "instagram-%" |
---|
63 | ;'; |
---|
64 | $filter_sets[] = array_from_query($query, 'id'); |
---|
65 | } |
---|
66 | |
---|
67 | return $filter_sets; |
---|
68 | } |
---|