1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: skeleton |
---|
4 | Version: auto |
---|
5 | Description: This is not a plugin. It's a skeleton for future plugins. |
---|
6 | Plugin URI: auto |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | /** |
---|
12 | * This is te main file of the plugin, called by Piwigo in "include/common.inc.php" line 137. |
---|
13 | * At this point of the code, Piwigo is not completely initialized, so nothing should be done directly |
---|
14 | * except define constants and event handlers (see http://piwigo.org/doc/doku.php?id=dev:plugins) |
---|
15 | */ |
---|
16 | |
---|
17 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
18 | |
---|
19 | global $prefixeTable; |
---|
20 | |
---|
21 | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | // | Define plugin constants | |
---|
24 | // +-----------------------------------------------------------------------+ |
---|
25 | defined('SKELETON_ID') or define('SKELETON_ID', basename(dirname(__FILE__))); |
---|
26 | define('SKELETON_PATH' , PHPWG_PLUGINS_PATH . SKELETON_ID . '/'); |
---|
27 | define('SKELETON_TABLE', $prefixeTable . 'skeleton'); |
---|
28 | define('SKELETON_ADMIN', get_root_url() . 'admin.php?page=plugin-' . SKELETON_ID); |
---|
29 | define('SKELETON_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'skeleton')) . '/'); |
---|
30 | define('SKELETON_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'skeleton/'); |
---|
31 | define('SKELETON_VERSION', 'auto'); |
---|
32 | // this is automatically updated by PEM if you publish your plugin with SVN, otherwise you musn't forget to change it, as well as "Version" in the plugin header |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | // | Add event handlers | |
---|
38 | // +-----------------------------------------------------------------------+ |
---|
39 | // init the plugin |
---|
40 | add_event_handler('init', 'skeleton_init'); |
---|
41 | |
---|
42 | /* |
---|
43 | * this is the common way to define event functions: create a new function for each event you want to handle |
---|
44 | */ |
---|
45 | if (defined('IN_ADMIN')) |
---|
46 | { |
---|
47 | // file containing all admin handlers functions |
---|
48 | include_once(SKELETON_PATH . 'include/admin_events.inc.php'); |
---|
49 | |
---|
50 | // admin plugins menu link |
---|
51 | add_event_handler('get_admin_plugin_menu_links', 'skeleton_admin_plugin_menu_links'); |
---|
52 | |
---|
53 | // new tab on photo page |
---|
54 | add_event_handler('tabsheet_before_select', 'skeleton_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
55 | |
---|
56 | // new prefiler in Batch Manager |
---|
57 | add_event_handler('get_batch_manager_prefilters', 'skeleton_add_batch_manager_prefilters'); |
---|
58 | add_event_handler('perform_batch_manager_prefilters', 'skeleton_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
59 | |
---|
60 | // new action in Batch Manager |
---|
61 | add_event_handler('loc_end_element_set_global', 'skeleton_loc_end_element_set_global'); |
---|
62 | add_event_handler('element_set_global_action', 'skeleton_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
63 | } |
---|
64 | else |
---|
65 | { |
---|
66 | // file containing all public handlers functions |
---|
67 | include_once(SKELETON_PATH . 'include/public_events.inc.php'); |
---|
68 | |
---|
69 | // add a public section |
---|
70 | add_event_handler('loc_end_section_init', 'skeleton_loc_end_section_init'); |
---|
71 | add_event_handler('loc_end_index', 'skeleton_loc_end_page'); |
---|
72 | |
---|
73 | // add button on album and photos pages |
---|
74 | add_event_handler('loc_end_index', 'skeleton_add_button'); |
---|
75 | add_event_handler('loc_end_picture', 'skeleton_add_button'); |
---|
76 | |
---|
77 | // prefilter on photo page |
---|
78 | add_event_handler('loc_end_picture', 'skeleton_loc_end_picture'); |
---|
79 | } |
---|
80 | |
---|
81 | // add API function |
---|
82 | add_event_handler('ws_add_methods', 'skeleton_ws_add_methods'); |
---|
83 | |
---|
84 | |
---|
85 | /* |
---|
86 | * event functions can also be wrapped in a class |
---|
87 | */ |
---|
88 | |
---|
89 | // file containing the class for menu handlers functions |
---|
90 | include_once(SKELETON_PATH . 'include/menu_events.class.php'); |
---|
91 | |
---|
92 | // add item to existing menu (EVENT_HANDLER_PRIORITY_NEUTRAL+10 is for compatibility with Advanced Menu Manager plugin) |
---|
93 | add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply1'), EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
94 | |
---|
95 | // add a new menu block (the declaration must be done every time, in order to be able to manage the menu block in "Menus" screen and Advanced Menu Manager) |
---|
96 | add_event_handler('blockmanager_register_blocks', array('SkeletonMenu', 'blockmanager_register_blocks')); |
---|
97 | add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply2')); |
---|
98 | // NOTE: blockmanager_apply1() and blockmanager_apply2() can (must) be merged |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | // files containing specific plugin functions |
---|
103 | include_once(SKELETON_PATH . 'include/functions.inc.php'); |
---|
104 | include_once(SKELETON_PATH . 'include/ws_functions.inc.php'); |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | /** |
---|
110 | * plugin initialization |
---|
111 | * - check for upgrades |
---|
112 | * - unserialize configuration |
---|
113 | * - load language |
---|
114 | */ |
---|
115 | function skeleton_init() |
---|
116 | { |
---|
117 | global $conf, $pwg_loaded_plugins; |
---|
118 | |
---|
119 | // apply upgrade if needed |
---|
120 | include_once(SKELETON_PATH . 'include/install.inc.php'); |
---|
121 | request_plugin_update(SKELETON_ID, SKELETON_VERSION, 'skeleton_install'); |
---|
122 | |
---|
123 | // load plugin language file |
---|
124 | load_language('plugin.lang', SKELETON_PATH); |
---|
125 | |
---|
126 | // prepare plugin configuration |
---|
127 | $conf['skeleton'] = unserialize($conf['skeleton']); |
---|
128 | } |
---|