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: 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, $prefixeTable; |
---|
14 | |
---|
15 | defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__))); |
---|
16 | define('BATCH_DOWNLOAD_PATH', PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/'); |
---|
17 | define('BATCH_DOWNLOAD_TSETS', $prefixeTable . 'download_sets'); |
---|
18 | define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images'); |
---|
19 | define('IMAGE_SIZES_TABLE', $prefixeTable . 'image_sizes'); |
---|
20 | define('BATCH_DOWNLOAD_LOCAL', PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'); |
---|
21 | define('BATCH_DOWNLOAD_ADMIN', get_root_url() . 'admin.php?page=plugin-' . BATCH_DOWNLOAD_ID); |
---|
22 | define('BATCH_DOWNLOAD_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/'); |
---|
23 | define('BATCH_DOWNLOAD_VERSION', 'auto'); |
---|
24 | |
---|
25 | |
---|
26 | add_event_handler('init', 'batch_download_init'); |
---|
27 | |
---|
28 | if (defined('IN_ADMIN')) |
---|
29 | { |
---|
30 | add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu'); |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | add_event_handler('init', 'batch_downloader_remove_image'); |
---|
35 | |
---|
36 | add_event_handler('loc_end_section_init', 'batch_download_section_init'); |
---|
37 | add_event_handler('loc_end_index', 'batch_download_page'); |
---|
38 | |
---|
39 | add_event_handler('loc_end_index', 'batch_download_clean'); |
---|
40 | |
---|
41 | add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
42 | } |
---|
43 | |
---|
44 | add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock'); |
---|
45 | add_event_handler('blockmanager_apply', 'batch_download_applymenu'); |
---|
46 | |
---|
47 | |
---|
48 | include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php'); |
---|
49 | include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php'); |
---|
50 | include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php'); |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | /** |
---|
55 | * update plugin & unserialize conf & load language |
---|
56 | */ |
---|
57 | function batch_download_init() |
---|
58 | { |
---|
59 | global $conf; |
---|
60 | |
---|
61 | include_once(BATCH_DOWNLOAD_PATH . 'maintain.inc.php'); |
---|
62 | $maintain = new BatchDownloader_maintain(BATCH_DOWNLOAD_ID); |
---|
63 | $maintain->autoUpdate(BATCH_DOWNLOAD_VERSION, 'install'); |
---|
64 | |
---|
65 | $conf['batch_download'] = unserialize($conf['batch_download']); |
---|
66 | $conf['batch_download']['file_pattern'] = isset($conf['batch_download_file_pattern']) ? $conf['batch_download_file_pattern'] : '%id%_%filename%_%dimensions%'; |
---|
67 | $conf['batch_download']['allowed_ext'] = $conf['picture_ext']; |
---|
68 | if (!empty($conf['batch_download_additional_ext'])) |
---|
69 | { |
---|
70 | $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']); |
---|
71 | } |
---|
72 | |
---|
73 | load_language('plugin.lang', BATCH_DOWNLOAD_PATH); |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * admin plugins menu |
---|
78 | */ |
---|
79 | function batch_download_admin_menu($menu) |
---|
80 | { |
---|
81 | $menu[] = array( |
---|
82 | 'NAME' => 'Batch Downloader', |
---|
83 | 'URL' => BATCH_DOWNLOAD_ADMIN, |
---|
84 | ); |
---|
85 | return $menu; |
---|
86 | } |
---|