forked from Piwigo/Piwigo-BatchDownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.inc.php
91 lines (72 loc) · 2.88 KB
/
main.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/*
Plugin Name: Batch Downloader
Version: auto
Description: Allows users to download pictures sets in ZIP. Compatible with User Collections.
Plugin URI: auto
Author: Mistic
Author URI: http://www.strangeplanet.fr
*/
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
if (basename(dirname(__FILE__)) != 'BatchDownloader')
{
add_event_handler('init', 'batch_download_error');
function batch_download_error()
{
global $page;
$page['errors'][] = 'Batch Downloader folder name is incorrect, uninstall the plugin and rename it to "BatchDownloader"';
}
return;
}
global $conf, $prefixeTable;
define('BATCH_DOWNLOAD_PATH', PHPWG_PLUGINS_PATH . 'BatchDownloader/');
define('BATCH_DOWNLOAD_TSETS', $prefixeTable . 'download_sets');
define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
define('IMAGE_SIZES_TABLE', $prefixeTable . 'image_sizes');
define('BATCH_DOWNLOAD_LOCAL', PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
define('BATCH_DOWNLOAD_ADMIN', get_root_url() . 'admin.php?page=plugin-BatchDownloader');
define('BATCH_DOWNLOAD_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/');
add_event_handler('init', 'batch_download_init');
if (defined('IN_ADMIN'))
{
add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
}
else
{
add_event_handler('init', 'batch_downloader_remove_image');
add_event_handler('loc_end_section_init', 'batch_download_section_init');
add_event_handler('loc_end_index', 'batch_download_page');
add_event_handler('loc_end_index', 'batch_download_clean');
add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
}
add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
add_event_handler('blockmanager_apply', 'batch_download_applymenu');
include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php');
include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php');
include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
/**
* update plugin & unserialize conf & load language
*/
function batch_download_init()
{
global $conf;
$conf['batch_download'] = safe_unserialize($conf['batch_download']);
$conf['batch_download']['file_pattern'] = isset($conf['batch_download_file_pattern']) ? $conf['batch_download_file_pattern'] : '%id%_%filename%_%dimensions%';
$conf['batch_download']['allowed_ext'] = $conf['picture_ext'];
if (!empty($conf['batch_download_additional_ext']))
{
$conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']);
}
load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
}
/**
* admin plugins menu
*/
function batch_download_admin_menu($menu)
{
$menu[] = array(
'NAME' => 'Batch Downloader',
'URL' => BATCH_DOWNLOAD_ADMIN,
);
return $menu;
}