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

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

prevent bad display when page name contains double quotes

File size: 2.2 KB
Line 
1<?php 
2/*
3Plugin Name: Linked Pages
4Version: auto
5Description: Link Additional Pages to albums.
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13if (mobile_theme())
14{
15  return;
16}
17
18global $prefixeTable;
19
20// +-----------------------------------------------------------------------+
21// | Define plugin constants                                               |
22// +-----------------------------------------------------------------------+
23defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
24define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/');
25define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
26define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID);
27define('LINKEDPAGES_VERSION', 'auto');
28
29
30// init the plugin
31add_event_handler('init', 'linked_pages_init');
32
33
34/**
35 * plugin initialization
36 */
37function 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 = '
70UPDATE '. PLUGINS_TABLE .'
71SET version = "'. LINKEDPAGES_VERSION .'"
72WHERE 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?>
Note: See TracBrowser for help on using the repository browser.