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

Last change on this file since 18379 was 18291, checked in by mistic100, 12 years ago

load pclzip from Piwigo/admin/include

File size: 2.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: http://piwigo.org/ext/extension_view.php?eid=616
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
12
13global $conf, $prefixeTable;
14
15define('BATCH_DOWNLOAD_PATH',    PHPWG_PLUGINS_PATH . 'BatchDownloader/');
16define('BATCH_DOWNLOAD_TSETS',   $prefixeTable . 'download_sets');
17define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
18define('BATCH_DOWNLOAD_LOCAL',   PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
19define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-BatchDownloader');
20define('BATCH_DOWNLOAD_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/');
21define('BATCH_DOWNLOAD_VERSION', 'auto');
22
23
24add_event_handler('init', 'batch_download_init');
25
26add_event_handler('loc_end_section_init', 'batch_download_section_init');
27add_event_handler('loc_end_index', 'batch_download_page');
28
29add_event_handler('loc_end_index', 'batch_download_clean');
30
31add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
32
33add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
34add_event_handler('blockmanager_apply', 'batch_download_applymenu');
35
36include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php');
37include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php');
38include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
39
40if (defined('IN_ADMIN'))
41{
42  add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
43}
44
45
46
47/**
48 * update plugin & unserialize conf & load language
49 */
50function batch_download_init()
51{
52  global $conf, $pwg_loaded_plugins;
53 
54  if (
55    $pwg_loaded_plugins['BatchDownloader']['version'] == 'auto' or
56    version_compare($pwg_loaded_plugins['BatchDownloader']['version'], BATCH_DOWNLOAD_VERSION, '<')
57  )
58  {
59    include_once(BATCH_DOWNLOAD_PATH . 'include/install.inc.php');
60    batch_download_install();
61   
62    if ($pwg_loaded_plugins['BatchDownloader']['version'] != 'auto')
63    {
64      $query = '
65UPDATE '. PLUGINS_TABLE .'
66SET version = "'. BATCH_DOWNLOAD_VERSION .'"
67WHERE id = "BatchDownloader"';
68      pwg_query($query);
69     
70      $pwg_loaded_plugins['BatchDownloader']['version'] = BATCH_DOWNLOAD_VERSION;
71     
72      if (defined('IN_ADMIN'))
73      {
74        $_SESSION['page_infos'][] = 'BatchDownloader updated to version '. BATCH_DOWNLOAD_VERSION;
75      }
76    }
77  }
78 
79  $conf['batch_download'] = unserialize($conf['batch_download']);
80  load_language('plugin.lang', BATCH_DOWNLOAD_PATH);
81}
82
83/**
84 * admin plugins menu
85 */
86function batch_download_admin_menu($menu) 
87{
88  array_push($menu, array(
89    'NAME' => 'Batch Downloader',
90    'URL' => BATCH_DOWNLOAD_ADMIN,
91  ));
92  return $menu;
93}
94
95?>
Note: See TracBrowser for help on using the repository browser.