-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.inc.php
106 lines (83 loc) · 3.32 KB
/
main.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*
Plugin Name: EasyRotate
Version: 0.8
Description: This plugin allows easy rotation of pictures from the picture page.
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=847
Author: ramack
Author URI: http://www.raphael-mack.de
Copyright (C) 2016,2017,2019 Raphael Mack
Copyright (C) 2019 Sam Wilson
Copyright (C) 2019 Thomas Ekstand
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
defined('PHPWG_ROOT_PATH') or die('Hacking attempt (main)!');
// +-----------------------------------------------------------------------+
// | Define plugin constants |
// +-----------------------------------------------------------------------+
global $prefixTable;
define('EASYROTATE_ID', basename(dirname(__FILE__)));
define('EASYROTATE_PATH' , PHPWG_PLUGINS_PATH . EASYROTATE_ID . '/');
define('EASYROTATE_ADMIN', get_root_url() . 'admin.php?page=plugin-' . EASYROTATE_ID);
define('EASYROTATE_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'EasyRotate/');
// +-----------------------------------------------------------------------+
// | Add event handlers |
// +-----------------------------------------------------------------------+
// init the plugin
add_event_handler('init', 'easyrotate_init');
/*
* this is the common way to define event functions: create a new function for each event you want to handle
*/
if (defined('IN_ADMIN'))
{
// file containing all admin handlers functions
$admin_file = EASYROTATE_PATH . 'include/admin_events.inc.php';
// admin plugins menu link
add_event_handler('get_admin_plugin_menu_links', 'easyrotate_admin_plugin_menu_links',
EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file);
}
else
{
// file containing all public handlers functions
$public_file = EASYROTATE_PATH . 'include/public_events.inc.php';
// add button on photos pages
add_event_handler('loc_end_picture', 'easyrotate_add_buttons',
EVENT_HANDLER_PRIORITY_NEUTRAL, $public_file);
// Retrieve the current user theme
$query = 'SELECT theme FROM ' . USER_INFOS_TABLE . ';';
$theme = strtolower(pwg_db_fetch_assoc(pwg_query($query))['theme']);
switch ($theme) {
case 'bootstrap_darkroom':
define('ROTATE_BOOTSTRAP', 1);
break;
case 'bootstrapdefault':
define('ROTATE_BOOTSTRAP', 1);
break;
default:
define('ROTATE_BOOTSTRAP', 0);
break;
}
}
/**
* plugin initialization
* - check for upgrades
* - unserialize configuration
* - load language
*/
function easyrotate_init()
{
global $conf;
// load plugin language file
load_language('plugin.lang', EASYROTATE_PATH);
// prepare plugin configuration
$conf['easyrotate'] = safe_unserialize($conf['easyrotate']);
}