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