source: extensions/BatchDownloader/main.inc.php @ 23280

Last change on this file since 23280 was 23280, checked in by mistic100, 11 years ago

new advanced param $confbatch_download_additional_ext, default is $confpicture_ext

File size: 3.9 KB
Line 
1<?php 
2/*
3Plugin Name: Batch Downloader
4Version: auto
5Description: Allows users to download pictures sets in ZIP. Compatible with User Collections.
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11/*
12 * advanced config:
13 * $conf['batch_download_max_elements']   max value of the elements slider (default 1000)
14 * $conf['batch_download_max_size']       max value of the size slider (default 500)
15 * $conf['batch_download_force_pclzip']   if true, force the usage of PclZip instead of ZipArchive
16 * $conf['batch_download_direct']         if true, the download script will redirect to the zip instead of deliver it through PHP
17 * $conf['batch_download_additional_ext'] array containing downloadable filetypes (case sensitive), default is $conf['picture_ext']
18 */
19
20defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
21
22global $conf, $prefixeTable;
23
24defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
25define('BATCH_DOWNLOAD_PATH',    PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/');
26define('BATCH_DOWNLOAD_TSETS',   $prefixeTable . 'download_sets');
27define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
28define('BATCH_DOWNLOAD_LOCAL',   PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
29define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . BATCH_DOWNLOAD_ID);
30define('BATCH_DOWNLOAD_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/');
31define('BATCH_DOWNLOAD_VERSION', 'auto');
32
33
34add_event_handler('init', 'batch_download_init');
35
36if (defined('IN_ADMIN'))
37{
38  add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
39}
40else
41{
42  add_event_handler('loc_end_section_init', 'batch_download_section_init');
43  add_event_handler('loc_end_index', 'batch_download_page');
44
45  add_event_handler('loc_end_index', 'batch_download_clean');
46
47  add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
48
49  add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
50  add_event_handler('blockmanager_apply', 'batch_download_applymenu');
51}
52
53
54include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php');
55include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php');
56include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
57
58
59
60/**
61 * update plugin & unserialize conf & load language
62 */
63function batch_download_init()
64{
65  global $conf, $pwg_loaded_plugins;
66 
67  if (
68    BATCH_DOWNLOAD_VERSION == 'auto' or
69    $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] == 'auto' or
70    version_compare($pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'], BATCH_DOWNLOAD_VERSION, '<')
71  )
72  {
73    include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php');
74    batch_download_install();
75   
76    if ( $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] != 'auto' and BATCH_DOWNLOAD_VERSION != 'auto' )
77    {
78      $query = '
79UPDATE '. PLUGINS_TABLE .'
80SET version = "'. BATCH_DOWNLOAD_VERSION .'"
81WHERE id = "'. BATCH_DOWNLOAD_ID .'"';
82      pwg_query($query);
83     
84      $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] = BATCH_DOWNLOAD_VERSION;
85     
86      if (defined('IN_ADMIN'))
87      {
88        $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION;
89      }
90    }
91  }
92 
93  $conf['batch_download'] = unserialize($conf['batch_download']);
94  $conf['batch_download']['allowed_ext'] = $conf['picture_ext'];
95  if (!empty($conf['batch_download_additional_ext']))
96  {
97    $conf['batch_download']['allowed_ext'] = array_merge($conf['batch_download']['allowed_ext'], $conf['batch_download_additional_ext']);
98  }
99 
100  load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
101}
102
103/**
104 * admin plugins menu
105 */
106function batch_download_admin_menu($menu) 
107{
108  array_push($menu, array(
109    'NAME' => 'Batch Downloader',
110    'URL' => BATCH_DOWNLOAD_ADMIN,
111  ));
112  return $menu;
113}
114
115?>
Note: See TracBrowser for help on using the repository browser.