1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Batch Downloader |
---|
4 | Version: auto |
---|
5 | Description: Allows users to download pictures sets in ZIP. Compatible with User Collections. |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=616 |
---|
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, $prefixeTable; |
---|
14 | |
---|
15 | define('BATCH_DOWNLOAD_PATH', PHPWG_PLUGINS_PATH . 'BatchDownloader/'); |
---|
16 | define('BATCH_DOWNLOAD_TSETS', $prefixeTable . 'download_sets'); |
---|
17 | define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images'); |
---|
18 | define('BATCH_DOWNLOAD_LOCAL', PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'); |
---|
19 | define('BATCH_DOWNLOAD_ADMIN', get_root_url() . 'admin.php?page=plugin-BatchDownloader'); |
---|
20 | define('BATCH_DOWNLOAD_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/'); |
---|
21 | define('BATCH_DOWNLOAD_VERSION', '1.0.3'); |
---|
22 | |
---|
23 | |
---|
24 | add_event_handler('init', 'batch_download_init'); |
---|
25 | |
---|
26 | if (class_exists('ZipArchive')) |
---|
27 | { |
---|
28 | add_event_handler('loc_end_section_init', 'batch_download_section_init'); |
---|
29 | add_event_handler('loc_end_index', 'batch_download_page'); |
---|
30 | |
---|
31 | add_event_handler('loc_end_index', 'batch_download_clean'); |
---|
32 | |
---|
33 | add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
34 | |
---|
35 | add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); |
---|
36 | add_event_handler('blockmanager_apply', 'batch_download_applymenu'); |
---|
37 | |
---|
38 | include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php'); |
---|
39 | include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php'); |
---|
40 | include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php'); |
---|
41 | } |
---|
42 | |
---|
43 | if (defined('IN_ADMIN')) |
---|
44 | { |
---|
45 | add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu'); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | /** |
---|
51 | * unserialize conf and load language |
---|
52 | */ |
---|
53 | function batch_download_init() |
---|
54 | { |
---|
55 | global $conf, $pwg_loaded_plugins; |
---|
56 | |
---|
57 | if ( |
---|
58 | $pwg_loaded_plugins['BatchDownloader']['version'] == 'auto' or |
---|
59 | version_compare($pwg_loaded_plugins['BatchDownloader']['version'], BATCH_DOWNLOAD_VERSION, '<') |
---|
60 | ) |
---|
61 | { |
---|
62 | include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php'); |
---|
63 | batch_download_install(); |
---|
64 | |
---|
65 | if ($pwg_loaded_plugins['BatchDownloader']['version'] != 'auto') |
---|
66 | { |
---|
67 | $query = ' |
---|
68 | UPDATE '. PLUGINS_TABLE .' |
---|
69 | SET version = "'. BATCH_DOWNLOAD_VERSION .'" |
---|
70 | WHERE id = "BatchDownloader"'; |
---|
71 | pwg_query($query); |
---|
72 | |
---|
73 | $pwg_loaded_plugins['BatchDownloader']['version'] = BATCH_DOWNLOAD_VERSION; |
---|
74 | |
---|
75 | if (defined('IN_ADMIN')) |
---|
76 | { |
---|
77 | $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION; |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | $conf['batch_download'] = unserialize($conf['batch_download']); |
---|
83 | load_language('plugin.lang', BATCH_DOWNLOAD_PATH); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * admin plugins menu |
---|
88 | */ |
---|
89 | function batch_download_admin_menu($menu) |
---|
90 | { |
---|
91 | array_push($menu, array( |
---|
92 | 'NAME' => 'Batch Downloader', |
---|
93 | 'URL' => BATCH_DOWNLOAD_ADMIN, |
---|
94 | )); |
---|
95 | return $menu; |
---|
96 | } |
---|
97 | |
---|
98 | ?> |
---|