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

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

update for 2.7

File size: 5.0 KB
RevLine 
[28650]1<?php
[17899]2/*
3Plugin Name: skeleton
4Version: auto
5Description: This is not a plugin. It's a skeleton for future plugins.
[18408]6Plugin URI: auto
[17899]7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11/**
[28650]12 * This is the main file of the plugin, called by Piwigo in "include/common.inc.php" line 137.
[17899]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// +-----------------------------------------------------------------------+
[28650]23global $prefixeTable;
24
[25407]25define('SKELETON_ID',      basename(dirname(__FILE__)));
[17924]26define('SKELETON_PATH' ,   PHPWG_PLUGINS_PATH . SKELETON_ID . '/');
[17899]27define('SKELETON_TABLE',   $prefixeTable . 'skeleton');
[17924]28define('SKELETON_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . SKELETON_ID);
[17899]29define('SKELETON_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'skeleton')) . '/');
[19842]30define('SKELETON_DIR',     PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'skeleton/');
[17899]31
32
[24182]33
[17899]34// +-----------------------------------------------------------------------+
35// | Add event handlers                                                    |
36// +-----------------------------------------------------------------------+
37// init the plugin
38add_event_handler('init', 'skeleton_init');
39
[24182]40/*
41 * this is the common way to define event functions: create a new function for each event you want to handle
42 */
[17899]43if (defined('IN_ADMIN'))
44{
[24182]45  // file containing all admin handlers functions
[28650]46  $admin_file = SKELETON_PATH . 'include/admin_events.inc.php';
47
[17899]48  // admin plugins menu link
[28650]49  add_event_handler('get_admin_plugin_menu_links', 'skeleton_admin_plugin_menu_links',
50    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
51
[17899]52  // new tab on photo page
[28650]53  add_event_handler('tabsheet_before_select', 'skeleton_tabsheet_before_select',
54    EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
55
[17899]56  // new prefiler in Batch Manager
[28650]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
[17899]62  // new action in Batch Manager
[28650]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);
[17899]67}
68else
69{
[24182]70  // file containing all public handlers functions
[28650]71  $public_file = SKELETON_PATH . 'include/public_events.inc.php';
72
[17899]73  // add a public section
[28650]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
[21307]79  // add button on album and photos pages
[28650]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
[17924]85  // prefilter on photo page
[28650]86  add_event_handler('loc_end_picture', 'skeleton_loc_end_picture',
87    EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
[17899]88}
89
[28650]90// file containing API function
91$ws_file = SKELETON_PATH . 'include/ws_functions.inc.php';
92
[17933]93// add API function
[28650]94add_event_handler('ws_add_methods', 'skeleton_ws_add_methods',
95    EVENT_HANDLER_PRIORITY_NEUTRAL, $ws_file);
[17899]96
[17933]97
[24182]98/*
99 * event functions can also be wrapped in a class
100 */
101
102// file containing the class for menu handlers functions
[28650]103$menu_file = SKELETON_PATH . 'include/menu_events.class.php';
[24182]104
105// add item to existing menu (EVENT_HANDLER_PRIORITY_NEUTRAL+10 is for compatibility with Advanced Menu Manager plugin)
[28650]106add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply1'),
107  EVENT_HANDLER_PRIORITY_NEUTRAL+10, $menu_file);
[24182]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)
[28650]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
[24182]115// NOTE: blockmanager_apply1() and blockmanager_apply2() can (must) be merged
116
117
[17899]118/**
119 * plugin initialization
120 *   - check for upgrades
121 *   - unserialize configuration
122 *   - load language
123 */
124function skeleton_init()
125{
[25407]126  global $conf;
[28650]127
[17899]128  // load plugin language file
129  load_language('plugin.lang', SKELETON_PATH);
[28650]130
[17899]131  // prepare plugin configuration
[28650]132  $conf['skeleton'] = safe_unserialize($conf['skeleton']);
[17899]133}
Note: See TracBrowser for help on using the repository browser.