source: extensions/instagram2piwigo/main.inc.php @ 24817

Last change on this file since 24817 was 24817, checked in by mistic100, 11 years ago

add batch manager prefilter

File size: 2.0 KB
Line 
1<?php 
2/*
3Plugin Name: Instagram2Piwigo
4Version: auto
5Description: Import pictures from your instagram account
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $conf;
14
15define('INSTAG_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
16define('INSTAG_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
17define('INSTAG_FS_CACHE', $conf['data_location'].'instagram_cache/');
18
19
20if (defined('IN_ADMIN'))
21{
22  add_event_handler('get_admin_plugin_menu_links', 'instagram_admin_menu');
23  add_event_handler('get_batch_manager_prefilters', 'instagram_add_batch_manager_prefilters');
24  add_event_handler('perform_batch_manager_prefilters', 'instagram_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
25  add_event_handler('loc_begin_admin_page', 'instagram_prefilter_from_url');
26
27  function instagram_admin_menu($menu) 
28  {
29    array_push($menu, array(
30      'NAME' => 'Instagram2Piwigo',
31      'URL' => INSTAG_ADMIN,
32    ));
33    return $menu;
34  }
35 
36  function instagram_add_batch_manager_prefilters($prefilters)
37  {
38    array_push($prefilters, array(
39      'ID' => 'instagram',
40      'NAME' => l10n('Imported from Instagram'),
41    ));
42    return $prefilters;
43  }
44
45  function instagram_perform_batch_manager_prefilters($filter_sets, $prefilter)
46  {
47    if ($prefilter == 'instagram')
48    {
49      $query = '
50  SELECT id
51    FROM '.IMAGES_TABLE.'
52    WHERE file LIKE "instagram-%"
53  ;';
54      $filter_sets[] = array_from_query($query, 'id');
55    }
56   
57    return $filter_sets;
58  }
59 
60  function instagram_prefilter_from_url()
61  {
62    global $page;
63    if ($page['page'] == 'batch_manager' && @$_GET['prefilter'] == 'instagram')
64    {
65      $_SESSION['bulk_manager_filter'] = array('prefilter' => 'instagram');
66      unset($_GET['prefilter']);
67    }
68  }
69}
70
71
72include_once(INSTAG_PATH . 'include/ws_functions.inc.php');
73
74add_event_handler('ws_add_methods', 'instagram_add_ws_method');
75
76?>
Note: See TracBrowser for help on using the repository browser.