[19561] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Instagram2Piwigo |
---|
| 4 | Version: auto |
---|
[24817] | 5 | Description: Import pictures from your instagram account |
---|
| 6 | Plugin URI: auto |
---|
[19561] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
[26199] | 11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[19561] | 12 | |
---|
| 13 | global $conf; |
---|
| 14 | |
---|
[26199] | 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); |
---|
[19561] | 18 | define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/'); |
---|
[26199] | 19 | define('INSTAG_VERSION', 'auto'); |
---|
[19561] | 20 | |
---|
| 21 | |
---|
[26199] | 22 | include_once(INSTAG_PATH . 'include/ws_functions.inc.php'); |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | add_event_handler('init', 'instagram_init'); |
---|
| 26 | add_event_handler('ws_add_methods', 'instagram_add_ws_method'); |
---|
| 27 | |
---|
[19561] | 28 | if (defined('IN_ADMIN')) |
---|
| 29 | { |
---|
| 30 | add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu'); |
---|
[26199] | 31 | |
---|
[24817] | 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); |
---|
[19561] | 34 | |
---|
| 35 | function instagram_admin_menu($menu) |
---|
| 36 | { |
---|
[26199] | 37 | $menu[] = array( |
---|
[19561] | 38 | 'NAME' => 'Instagram2Piwigo', |
---|
| 39 | 'URL' => INSTAG_ADMIN, |
---|
[26199] | 40 | ); |
---|
[19561] | 41 | return $menu; |
---|
| 42 | } |
---|
[24817] | 43 | |
---|
| 44 | function instagram_add_batch_manager_prefilters($prefilters) |
---|
| 45 | { |
---|
[26199] | 46 | $prefilters[] = array( |
---|
[24817] | 47 | 'ID' => 'instagram', |
---|
| 48 | 'NAME' => l10n('Imported from Instagram'), |
---|
[26199] | 49 | ); |
---|
[24817] | 50 | return $prefilters; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | function instagram_perform_batch_manager_prefilters($filter_sets, $prefilter) |
---|
| 54 | { |
---|
| 55 | if ($prefilter == 'instagram') |
---|
| 56 | { |
---|
| 57 | $query = ' |
---|
| 58 | SELECT id |
---|
| 59 | FROM '.IMAGES_TABLE.' |
---|
| 60 | WHERE file LIKE "instagram-%" |
---|
| 61 | ;'; |
---|
| 62 | $filter_sets[] = array_from_query($query, 'id'); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | return $filter_sets; |
---|
| 66 | } |
---|
[19561] | 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
[26199] | 70 | function instagram_init() |
---|
| 71 | { |
---|
| 72 | global $conf; |
---|
[19561] | 73 | |
---|
[26199] | 74 | include_once(INSTAG_PATH . 'maintain.inc.php'); |
---|
| 75 | $maintain = new instagram2piwigo_maintain(INSTAG_ID); |
---|
| 76 | $maintain->autoUpdate(INSTAG_VERSION, 'install'); |
---|
[19561] | 77 | |
---|
[26199] | 78 | $conf['Instagram2Piwigo'] = unserialize($conf['Instagram2Piwigo']); |
---|
| 79 | } |
---|