Ignore:
Timestamp:
Jun 13, 2013, 2:01:34 PM (8 years ago)
Author:
mistic100
Message:

use serialized array for config + custom upgrade process

File:
1 edited

Legend:

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

    r21213 r23177  
    1212global $prefixeTable;
    1313
    14 define('B2F_DIR', basename(dirname(__FILE__)));
    15 define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_DIR . '/');
     14defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__)));
     15define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_ID . '/');
    1616define('B2F_TABLE', $prefixeTable . 'image_verso');
     17define('B2F_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . B2F_ID);
     18define('B2F_VERSION', 'auto');
    1719
    18 include_once(B2F_PATH . 'Back2Front.php');
     20include_once(B2F_PATH . 'include/Back2Front.php');
    1921
    20 add_event_handler('init', 'Back2Front_init');
     22add_event_handler('init', 'back2front_init');
    2123
    22 function Back2Front_init()
     24function back2front_init()
    2325{
     26  global $conf, $pwg_loaded_plugins;
     27 
     28  if (
     29    B2F_VERSION == 'auto' or
     30    $pwg_loaded_plugins[B2F_ID]['version'] == 'auto' or
     31    version_compare($pwg_loaded_plugins[B2F_ID]['version'], B2F_VERSION, '<')
     32  )
     33  {
     34    include_once(B2F_PATH . 'include/install.inc.php');
     35    back2front_install();
     36   
     37    if ( $pwg_loaded_plugins[B2F_ID]['version'] != 'auto' and B2F_VERSION != 'auto' )
     38    {
     39      $query = '
     40UPDATE '. PLUGINS_TABLE .'
     41SET version = "'. B2F_VERSION .'"
     42WHERE id = "'. B2F_ID .'"';
     43      pwg_query($query);
     44     
     45      $pwg_loaded_plugins[B2F_ID]['version'] = B2F_VERSION;
     46     
     47      if (defined('IN_ADMIN'))
     48      {
     49        $_SESSION['page_infos'][] = 'Back2Front updated to version '. B2F_VERSION;
     50      }
     51    }
     52  }
     53 
     54  $conf['back2front'] = unserialize($conf['back2front']);
    2455  load_language('plugin.lang', B2F_PATH);
    2556}
     
    2758if (script_basename() == 'picture')
    2859{
    29   add_event_handler('render_element_content', 'Back2Front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2);
     60  add_event_handler('render_element_content', 'back2front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2);
    3061}
    3162
    3263if (script_basename() == 'index')
    3364{
    34   add_event_handler('loc_end_index_thumbnails', 'Back2Front_thumbnails');
     65  add_event_handler('loc_end_index_thumbnails', 'back2front_thumbnails');
    3566}
    3667
    3768if (script_basename() == 'admin')
    3869{
    39   add_event_handler('loc_begin_admin_page', 'Back2Front_picture_modify');
     70  add_event_handler('loc_begin_admin_page', 'back2front_picture_modify');
    4071 
    41   add_event_handler('get_admin_plugin_menu_links', 'Back2Front_admin_menu');
    42   function Back2Front_admin_menu($menu)
     72  add_event_handler('get_admin_plugin_menu_links', 'back2front_admin_menu');
     73  function back2front_admin_menu($menu)
    4374  {
    4475    array_push($menu, array(
    4576      'NAME' => 'Back2Front',
    46       'URL' => get_root_url().'admin.php?page=plugin-' . B2F_DIR));
     77      'URL' => B2F_ADMIN,
     78    ));
    4779    return $menu;
    4880  }
Note: See TracChangeset for help on using the changeset viewer.