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