1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Flickr2Piwigo |
---|
4 | Version: auto |
---|
5 | Description: Import pictures from your Flickr 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('FLICKR_ID', basename(dirname(__FILE__))); |
---|
16 | define('FLICKR_PATH', PHPWG_PLUGINS_PATH . FLICKR_ID . '/'); |
---|
17 | define('FLICKR_ADMIN', get_root_url() . 'admin.php?page=plugin-' . FLICKR_ID); |
---|
18 | define('FLICKR_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/'); |
---|
19 | define('FLICKR_VERSION', 'auto'); |
---|
20 | |
---|
21 | |
---|
22 | include_once(FLICKR_PATH . 'include/ws_functions.inc.php'); |
---|
23 | |
---|
24 | |
---|
25 | add_event_handler('init', 'flickr_init'); |
---|
26 | add_event_handler('ws_add_methods', 'flickr_add_ws_method'); |
---|
27 | |
---|
28 | if (defined('IN_ADMIN')) |
---|
29 | { |
---|
30 | add_event_handler('get_admin_plugin_menu_links', 'flickr_admin_menu'); |
---|
31 | |
---|
32 | add_event_handler('get_batch_manager_prefilters', 'flickr_add_batch_manager_prefilters'); |
---|
33 | add_event_handler('perform_batch_manager_prefilters', 'flickr_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
34 | |
---|
35 | function flickr_admin_menu($menu) |
---|
36 | { |
---|
37 | $menu[] = array( |
---|
38 | 'NAME' => 'Flickr2Piwigo', |
---|
39 | 'URL' => FLICKR_ADMIN, |
---|
40 | ); |
---|
41 | return $menu; |
---|
42 | } |
---|
43 | |
---|
44 | function flickr_add_batch_manager_prefilters($prefilters) |
---|
45 | { |
---|
46 | $prefilters[] = array( |
---|
47 | 'ID' => 'flickr', |
---|
48 | 'NAME' => l10n('Imported from Flickr'), |
---|
49 | ); |
---|
50 | return $prefilters; |
---|
51 | } |
---|
52 | |
---|
53 | function flickr_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
54 | { |
---|
55 | if ($prefilter == 'flickr') |
---|
56 | { |
---|
57 | $query = ' |
---|
58 | SELECT id |
---|
59 | FROM '.IMAGES_TABLE.' |
---|
60 | WHERE file LIKE "flickr-%" |
---|
61 | ;'; |
---|
62 | $filter_sets[] = array_from_query($query, 'id'); |
---|
63 | } |
---|
64 | |
---|
65 | return $filter_sets; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | function flickr_init() |
---|
71 | { |
---|
72 | global $conf; |
---|
73 | include_once(FLICKR_PATH . 'maintain.inc.php'); |
---|
74 | $maintain = new flickr2piwigo_maintain(FLICKR_ID); |
---|
75 | $maintain->autoUpdate(FLICKR_VERSION, 'install'); |
---|
76 | |
---|
77 | $conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']); |
---|
78 | } |
---|