[17882] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Linked Pages |
---|
| 4 | Version: auto |
---|
| 5 | Description: Link Additional Pages to albums. |
---|
[23218] | 6 | Plugin URI: auto |
---|
[17882] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
[22866] | 13 | if (mobile_theme()) |
---|
| 14 | { |
---|
| 15 | return; |
---|
| 16 | } |
---|
| 17 | |
---|
[17882] | 18 | global $prefixeTable; |
---|
| 19 | |
---|
| 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | // | Define plugin constants | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[17925] | 23 | defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__))); |
---|
| 24 | define('LINKEDPAGES_PATH' , PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/'); |
---|
[17882] | 25 | define('LINKEDPAGES_TABLE', $prefixeTable . 'linked_pages'); |
---|
[17925] | 26 | define('LINKEDPAGES_ADMIN', get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID); |
---|
[21326] | 27 | define('LINKEDPAGES_VERSION', 'auto'); |
---|
[17882] | 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 | |
---|
[17888] | 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 | |
---|
[17882] | 58 | if ( |
---|
[21326] | 59 | LINKEDPAGES_VERSION == 'auto' or |
---|
[17925] | 60 | $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or |
---|
| 61 | version_compare($pwg_loaded_plugins[LINKEDPAGES_ID]['version'], LINKEDPAGES_VERSION, '<') |
---|
[17882] | 62 | ) |
---|
| 63 | { |
---|
| 64 | include_once(LINKEDPAGES_PATH . 'include/install.inc.php'); |
---|
| 65 | linked_pages_install(); |
---|
| 66 | |
---|
[21326] | 67 | if ( $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] != 'auto' and LINKEDPAGES_VERSION != 'auto') |
---|
[17882] | 68 | { |
---|
| 69 | $query = ' |
---|
| 70 | UPDATE '. PLUGINS_TABLE .' |
---|
| 71 | SET version = "'. LINKEDPAGES_VERSION .'" |
---|
[17925] | 72 | WHERE id = "'. LINKEDPAGES_ID .'"'; |
---|
[17882] | 73 | pwg_query($query); |
---|
| 74 | |
---|
[17925] | 75 | $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] = LINKEDPAGES_VERSION; |
---|
[17882] | 76 | |
---|
| 77 | if (defined('IN_ADMIN')) |
---|
| 78 | { |
---|
[17925] | 79 | $_SESSION['page_infos'][] = 'Linked Pages updated to version '. LINKEDPAGES_VERSION; |
---|
[17882] | 80 | } |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | ?> |
---|