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

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

first 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// +-----------------------------------------------------------------------+
18define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . 'linked_pages/');
19define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
20define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-linked_pages');
21define('LINKEDPAGES_VERSION', '1.0.0');
22
23
24// +-----------------------------------------------------------------------+
25// | Add event handlers                                                    |
26// +-----------------------------------------------------------------------+
27// init the plugin
28add_event_handler('init', 'linked_pages_init');
29
30if (defined('IN_ADMIN'))
31{
32  add_event_handler('tabsheet_before_select', 'linked_pages_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
33}
34else
35{
36  add_event_handler('loc_end_index', 'linked_pages_loc_end_index', EVENT_HANDLER_PRIORITY_NEUTRAL+20);
37}
38
39include_once(LINKEDPAGES_PATH . 'include/functions.inc.php');
40
41
42
43/**
44 * plugin initialization
45 */
46function linked_pages_init()
47{
48  global $conf, $pwg_loaded_plugins;
49 
50  if (!isset($pwg_loaded_plugins['AdditionalPages']))
51  {
52    return;
53  }
54 
55  if (
56    $pwg_loaded_plugins['linked_pages']['version'] == 'auto' or
57    version_compare($pwg_loaded_plugins['linked_pages']['version'], LINKEDPAGES_VERSION, '<')
58  )
59  {
60    include_once(LINKEDPAGES_PATH . 'include/install.inc.php');
61    linked_pages_install();
62   
63    if ($pwg_loaded_plugins['linked_pages']['version'] != 'auto')
64    {
65      $query = '
66UPDATE '. PLUGINS_TABLE .'
67SET version = "'. LINKEDPAGES_VERSION .'"
68WHERE id = "linked_pages"';
69      pwg_query($query);
70     
71      $pwg_loaded_plugins['linked_pages']['version'] = LINKEDPAGES_VERSION;
72     
73      if (defined('IN_ADMIN'))
74      {
75        $_SESSION['page_infos'][] = 'Skeleton updated to version '. LINKEDPAGES_VERSION;
76      }
77    }
78  }
79}
80
81?>
Note: See TracBrowser for help on using the repository browser.