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

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

next release is 1.0.1

File size: 2.2 KB
RevLine 
[17882]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// +-----------------------------------------------------------------------+
[17925]18defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
19define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/');
[17882]20define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
[17925]21define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID);
[17926]22define('LINKEDPAGES_VERSION', '1.0.1');
[17882]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 
[17888]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 
[17882]53  if (
[17925]54    $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or
55    version_compare($pwg_loaded_plugins[LINKEDPAGES_ID]['version'], LINKEDPAGES_VERSION, '<')
[17882]56  )
57  {
58    include_once(LINKEDPAGES_PATH . 'include/install.inc.php');
59    linked_pages_install();
60   
[17925]61    if ($pwg_loaded_plugins[LINKEDPAGES_ID]['version'] != 'auto')
[17882]62    {
63      $query = '
64UPDATE '. PLUGINS_TABLE .'
65SET version = "'. LINKEDPAGES_VERSION .'"
[17925]66WHERE id = "'. LINKEDPAGES_ID .'"';
[17882]67      pwg_query($query);
68     
[17925]69      $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] = LINKEDPAGES_VERSION;
[17882]70     
71      if (defined('IN_ADMIN'))
72      {
[17925]73        $_SESSION['page_infos'][] = 'Linked Pages updated to version '. LINKEDPAGES_VERSION;
[17882]74      }
75    }
76  }
77}
78
79?>
Note: See TracBrowser for help on using the repository browser.