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