[10819] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Back2Front |
---|
| 4 | Version: auto |
---|
| 5 | Description: Add a link on picture's page to show a alternative version of the pic (for postcards for example) |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=533 |
---|
| 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | global $prefixeTable; |
---|
| 13 | |
---|
[23177] | 14 | defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__))); |
---|
| 15 | define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_ID . '/'); |
---|
[10819] | 16 | define('B2F_TABLE', $prefixeTable . 'image_verso'); |
---|
[23177] | 17 | define('B2F_ADMIN', get_root_url() . 'admin.php?page=plugin-' . B2F_ID); |
---|
| 18 | define('B2F_VERSION', 'auto'); |
---|
[10819] | 19 | |
---|
[23177] | 20 | include_once(B2F_PATH . 'include/Back2Front.php'); |
---|
[10819] | 21 | |
---|
[23177] | 22 | add_event_handler('init', 'back2front_init'); |
---|
[21213] | 23 | |
---|
[23177] | 24 | function back2front_init() |
---|
[21213] | 25 | { |
---|
[23177] | 26 | global $conf, $pwg_loaded_plugins; |
---|
| 27 | |
---|
| 28 | if ( |
---|
| 29 | B2F_VERSION == 'auto' or |
---|
| 30 | $pwg_loaded_plugins[B2F_ID]['version'] == 'auto' or |
---|
| 31 | version_compare($pwg_loaded_plugins[B2F_ID]['version'], B2F_VERSION, '<') |
---|
| 32 | ) |
---|
| 33 | { |
---|
| 34 | include_once(B2F_PATH . 'include/install.inc.php'); |
---|
| 35 | back2front_install(); |
---|
| 36 | |
---|
| 37 | if ( $pwg_loaded_plugins[B2F_ID]['version'] != 'auto' and B2F_VERSION != 'auto' ) |
---|
| 38 | { |
---|
| 39 | $query = ' |
---|
| 40 | UPDATE '. PLUGINS_TABLE .' |
---|
| 41 | SET version = "'. B2F_VERSION .'" |
---|
| 42 | WHERE id = "'. B2F_ID .'"'; |
---|
| 43 | pwg_query($query); |
---|
| 44 | |
---|
| 45 | $pwg_loaded_plugins[B2F_ID]['version'] = B2F_VERSION; |
---|
| 46 | |
---|
| 47 | if (defined('IN_ADMIN')) |
---|
| 48 | { |
---|
| 49 | $_SESSION['page_infos'][] = 'Back2Front updated to version '. B2F_VERSION; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | $conf['back2front'] = unserialize($conf['back2front']); |
---|
[21213] | 55 | load_language('plugin.lang', B2F_PATH); |
---|
| 56 | } |
---|
| 57 | |
---|
[10852] | 58 | if (script_basename() == 'picture') |
---|
| 59 | { |
---|
[23177] | 60 | add_event_handler('render_element_content', 'back2front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2); |
---|
[10852] | 61 | } |
---|
[10819] | 62 | |
---|
[12361] | 63 | if (script_basename() == 'index') |
---|
| 64 | { |
---|
[23177] | 65 | add_event_handler('loc_end_index_thumbnails', 'back2front_thumbnails'); |
---|
[12361] | 66 | } |
---|
| 67 | |
---|
[10852] | 68 | if (script_basename() == 'admin') |
---|
| 69 | { |
---|
[23177] | 70 | add_event_handler('loc_begin_admin_page', 'back2front_picture_modify'); |
---|
[10852] | 71 | |
---|
[23177] | 72 | add_event_handler('get_admin_plugin_menu_links', 'back2front_admin_menu'); |
---|
| 73 | function back2front_admin_menu($menu) |
---|
[12361] | 74 | { |
---|
| 75 | array_push($menu, array( |
---|
| 76 | 'NAME' => 'Back2Front', |
---|
[23177] | 77 | 'URL' => B2F_ADMIN, |
---|
| 78 | )); |
---|
[12361] | 79 | return $menu; |
---|
| 80 | } |
---|
[10852] | 81 | } |
---|
| 82 | |
---|
[10821] | 83 | ?> |
---|