[17882] | 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 | global $prefixeTable; |
---|
| 14 | |
---|
| 15 | // +-----------------------------------------------------------------------+ |
---|
| 16 | // | Define plugin constants | |
---|
| 17 | // +-----------------------------------------------------------------------+ |
---|
[17925] | 18 | defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__))); |
---|
| 19 | define('LINKEDPAGES_PATH' , PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/'); |
---|
[17882] | 20 | define('LINKEDPAGES_TABLE', $prefixeTable . 'linked_pages'); |
---|
[17925] | 21 | define('LINKEDPAGES_ADMIN', get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID); |
---|
[17882] | 22 | define('LINKEDPAGES_VERSION', '1.0.0'); |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | // init the plugin |
---|
| 26 | add_event_handler('init', 'linked_pages_init'); |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * plugin initialization |
---|
| 31 | */ |
---|
| 32 | function 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 = ' |
---|
| 64 | UPDATE '. PLUGINS_TABLE .' |
---|
| 65 | SET version = "'. LINKEDPAGES_VERSION .'" |
---|
[17925] | 66 | WHERE 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 | ?> |
---|