source: extensions/linked_pages/main.inc.php @ 21326

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

remove hard-coded version

File size: 2.3 KB
Line 
1<?php 
2/*
3Plugin Name: Linked Pages
4Version: auto
5Description: Link Additional Pages to albums.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=635
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15// +-----------------------------------------------------------------------+
16// | Define plugin constants                                               |
17// +-----------------------------------------------------------------------+
18defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
19define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/');
20define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
21define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID);
22define('LINKEDPAGES_VERSION', 'auto');
23
24
25// init the plugin
26add_event_handler('init', 'linked_pages_init');
27
28
29/**
30 * plugin initialization
31 */
32function linked_pages_init()
33{
34  global $conf, $pwg_loaded_plugins;
35 
36  if (!isset($pwg_loaded_plugins['AdditionalPages']))
37  {
38    return;
39  }
40 
41  // add event handlers
42  if (defined('IN_ADMIN'))
43  {
44    add_event_handler('tabsheet_before_select', 'linked_pages_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
45  }
46  else
47  {
48    add_event_handler('loc_end_index', 'linked_pages_loc_end_index', EVENT_HANDLER_PRIORITY_NEUTRAL+20);
49  }
50
51  include_once(LINKEDPAGES_PATH . 'include/functions.inc.php');
52 
53  if (
54    LINKEDPAGES_VERSION == 'auto' or
55    $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or
56    version_compare($pwg_loaded_plugins[LINKEDPAGES_ID]['version'], LINKEDPAGES_VERSION, '<')
57  )
58  {
59    include_once(LINKEDPAGES_PATH . 'include/install.inc.php');
60    linked_pages_install();
61   
62    if ( $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] != 'auto' and LINKEDPAGES_VERSION != 'auto')
63    {
64      $query = '
65UPDATE '. PLUGINS_TABLE .'
66SET version = "'. LINKEDPAGES_VERSION .'"
67WHERE id = "'. LINKEDPAGES_ID .'"';
68      pwg_query($query);
69     
70      $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] = LINKEDPAGES_VERSION;
71     
72      if (defined('IN_ADMIN'))
73      {
74        $_SESSION['page_infos'][] = 'Linked Pages updated to version '. LINKEDPAGES_VERSION;
75      }
76    }
77  }
78}
79
80?>
Note: See TracBrowser for help on using the repository browser.