source: extensions/skeleton/trunk/main.inc.php @ 28650

Last change on this file since 28650 was 28650, checked in by mistic100, 10 years ago

update for 2.7

File size: 5.0 KB
Line 
1<?php
2/*
3Plugin Name: skeleton
4Version: auto
5Description: This is not a plugin. It's a skeleton for future plugins.
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11/**
12 * This is the 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
17defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
18
19
20// +-----------------------------------------------------------------------+
21// | Define plugin constants                                               |
22// +-----------------------------------------------------------------------+
23global $prefixeTable;
24
25define('SKELETON_ID',      basename(dirname(__FILE__)));
26define('SKELETON_PATH' ,   PHPWG_PLUGINS_PATH . SKELETON_ID . '/');
27define('SKELETON_TABLE',   $prefixeTable . 'skeleton');
28define('SKELETON_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . SKELETON_ID);
29define('SKELETON_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'skeleton')) . '/');
30define('SKELETON_DIR',     PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'skeleton/');
31
32
33
34// +-----------------------------------------------------------------------+
35// | Add event handlers                                                    |
36// +-----------------------------------------------------------------------+
37// init the plugin
38add_event_handler('init', 'skeleton_init');
39
40/*
41 * this is the common way to define event functions: create a new function for each event you want to handle
42 */
43if (defined('IN_ADMIN'))
44{
45  // file containing all admin handlers functions
46  $admin_file = SKELETON_PATH . 'include/admin_events.inc.php';
47
48  // admin plugins menu link
49  add_event_handler('get_admin_plugin_menu_links', 'skeleton_admin_plugin_menu_links',
50    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
51
52  // new tab on photo page
53  add_event_handler('tabsheet_before_select', 'skeleton_tabsheet_before_select',
54    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
55
56  // new prefiler in Batch Manager
57  add_event_handler('get_batch_manager_prefilters', 'skeleton_add_batch_manager_prefilters',
58    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
59  add_event_handler('perform_batch_manager_prefilters', 'skeleton_perform_batch_manager_prefilters',
60    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
61
62  // new action in Batch Manager
63  add_event_handler('loc_end_element_set_global', 'skeleton_loc_end_element_set_global',
64    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
65  add_event_handler('element_set_global_action', 'skeleton_element_set_global_action',
66    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
67}
68else
69{
70  // file containing all public handlers functions
71  $public_file = SKELETON_PATH . 'include/public_events.inc.php';
72
73  // add a public section
74  add_event_handler('loc_end_section_init', 'skeleton_loc_end_section_init',
75    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
76  add_event_handler('loc_end_index', 'skeleton_loc_end_page',
77    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
78
79  // add button on album and photos pages
80  add_event_handler('loc_end_index', 'skeleton_add_button',
81    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
82  add_event_handler('loc_end_picture', 'skeleton_add_button',
83    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
84
85  // prefilter on photo page
86  add_event_handler('loc_end_picture', 'skeleton_loc_end_picture',
87    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
88}
89
90// file containing API function
91$ws_file = SKELETON_PATH . 'include/ws_functions.inc.php';
92
93// add API function
94add_event_handler('ws_add_methods', 'skeleton_ws_add_methods',
95    EVENT_HANDLER_PRIORITY_NEUTRAL, $ws_file);
96
97
98/*
99 * event functions can also be wrapped in a class
100 */
101
102// file containing the class for menu handlers functions
103$menu_file = SKELETON_PATH . 'include/menu_events.class.php';
104
105// add item to existing menu (EVENT_HANDLER_PRIORITY_NEUTRAL+10 is for compatibility with Advanced Menu Manager plugin)
106add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply1'),
107  EVENT_HANDLER_PRIORITY_NEUTRAL+10, $menu_file);
108
109// 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)
110add_event_handler('blockmanager_register_blocks', array('SkeletonMenu', 'blockmanager_register_blocks'),
111  EVENT_HANDLER_PRIORITY_NEUTRAL, $menu_file);
112add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply2'),
113  EVENT_HANDLER_PRIORITY_NEUTRAL, $menu_file);
114
115// NOTE: blockmanager_apply1() and blockmanager_apply2() can (must) be merged
116
117
118/**
119 * plugin initialization
120 *   - check for upgrades
121 *   - unserialize configuration
122 *   - load language
123 */
124function skeleton_init()
125{
126  global $conf;
127
128  // load plugin language file
129  load_language('plugin.lang', SKELETON_PATH);
130
131  // prepare plugin configuration
132  $conf['skeleton'] = safe_unserialize($conf['skeleton']);
133}
Note: See TracBrowser for help on using the repository browser.