Ignore:
Timestamp:
Nov 7, 2012, 10:05:44 PM (11 years ago)
Author:
mistic100
Message:

small code cleaning, use mkgetdir(), add missing language string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/main.inc.php

    r18291 r18973  
    1313global $conf, $prefixeTable;
    1414
    15 define('BATCH_DOWNLOAD_PATH',    PHPWG_PLUGINS_PATH . 'BatchDownloader/');
     15defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
     16define('BATCH_DOWNLOAD_PATH',    PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/');
    1617define('BATCH_DOWNLOAD_TSETS',   $prefixeTable . 'download_sets');
    1718define('BATCH_DOWNLOAD_TIMAGES', $prefixeTable . 'download_sets_images');
    1819define('BATCH_DOWNLOAD_LOCAL',   PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
    19 define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-BatchDownloader');
     20define('BATCH_DOWNLOAD_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . BATCH_DOWNLOAD_ID);
    2021define('BATCH_DOWNLOAD_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'download')) . '/');
    2122define('BATCH_DOWNLOAD_VERSION', 'auto');
     
    2425add_event_handler('init', 'batch_download_init');
    2526
    26 add_event_handler('loc_end_section_init', 'batch_download_section_init');
    27 add_event_handler('loc_end_index', 'batch_download_page');
     27if (defined('IN_ADMIN'))
     28{
     29  add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
     30}
     31else
     32{
     33  add_event_handler('loc_end_section_init', 'batch_download_section_init');
     34  add_event_handler('loc_end_index', 'batch_download_page');
    2835
    29 add_event_handler('loc_end_index', 'batch_download_clean');
     36  add_event_handler('loc_end_index', 'batch_download_clean');
    3037
    31 add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
     38  add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
    3239
    33 add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
    34 add_event_handler('blockmanager_apply', 'batch_download_applymenu');
     40  add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
     41  add_event_handler('blockmanager_apply', 'batch_download_applymenu');
     42}
     43
    3544
    3645include_once(BATCH_DOWNLOAD_PATH . 'include/BatchDownloader.class.php');
    3746include_once(BATCH_DOWNLOAD_PATH . 'include/functions.inc.php');
    3847include_once(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
    39 
    40 if (defined('IN_ADMIN'))
    41 {
    42   add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
    43 }
    4448
    4549
     
    5357 
    5458  if (
    55     $pwg_loaded_plugins['BatchDownloader']['version'] == 'auto' or
    56     version_compare($pwg_loaded_plugins['BatchDownloader']['version'], BATCH_DOWNLOAD_VERSION, '<')
     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, '<')
    5762  )
    5863  {
     
    6065    batch_download_install();
    6166   
    62     if ($pwg_loaded_plugins['BatchDownloader']['version'] != 'auto')
     67    if ( $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] != 'auto' and BATCH_DOWNLOAD_VERSION != 'auto' )
    6368    {
    6469      $query = '
    6570UPDATE '. PLUGINS_TABLE .'
    6671SET version = "'. BATCH_DOWNLOAD_VERSION .'"
    67 WHERE id = "BatchDownloader"';
     72WHERE id = "'. BATCH_DOWNLOAD_ID .'"';
    6873      pwg_query($query);
    6974     
    70       $pwg_loaded_plugins['BatchDownloader']['version'] = BATCH_DOWNLOAD_VERSION;
     75      $pwg_loaded_plugins[BATCH_DOWNLOAD_ID]['version'] = BATCH_DOWNLOAD_VERSION;
    7176     
    7277      if (defined('IN_ADMIN'))
Note: See TracChangeset for help on using the changeset viewer.