1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Add Index - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2019-2011 Piwigo team | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | This program is free software; you can redistribute it and/or modify | |
---|
7 | // | it under the terms of the GNU General Public License as published by | |
---|
8 | // | the Free Software Foundation | |
---|
9 | // | | |
---|
10 | // | This program is distributed in the hope that it will be useful, but | |
---|
11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | // | General Public License for more details. | |
---|
14 | // | | |
---|
15 | // | You should have received a copy of the GNU General Public License | |
---|
16 | // | along with this program; if not, write to the Free Software | |
---|
17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | // | USA. | |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | |
---|
21 | if ((!defined('PHPWG_ROOT_PATH')) or (!(defined('IN_ADMIN') and IN_ADMIN))) |
---|
22 | { |
---|
23 | die('Hacking attempt!'); |
---|
24 | } |
---|
25 | |
---|
26 | add_event_handler('loc_begin_admin', 'plugAIPf'); |
---|
27 | function plugAIPf(){ |
---|
28 | global $template; |
---|
29 | $admin_base_url = $_SERVER['REQUEST_URI']; |
---|
30 | $template->set_prefilter('maintenance', 'plugAIPT'); |
---|
31 | $template->assign( |
---|
32 | array( |
---|
33 | 'U_ADDINDEX' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/main_page.php').'&overwrite&pwg_token='.get_pwg_token(), |
---|
34 | 'U_AIreturnmaintenance' => get_root_url().'admin.php?page=maintenance', |
---|
35 | |
---|
36 | )); |
---|
37 | } |
---|
38 | |
---|
39 | function plugAIPT($content){ |
---|
40 | // add js link |
---|
41 | $search = '{/footer_script}'; |
---|
42 | $replace = ' |
---|
43 | $(".addindex-level-button").each(function() { |
---|
44 | const title = \'{"Advanced_Add_Index"|@translate|@escape:\'javascript\'}\'; |
---|
45 | $(this).pwg_jconfirm_follow_href({ |
---|
46 | alert_title: title, |
---|
47 | alert_confirm: confirm_msg, |
---|
48 | alert_cancel: cancel_msg |
---|
49 | }); |
---|
50 | }); |
---|
51 | '; |
---|
52 | $content = str_replace($search, $replace.$search, $content); |
---|
53 | |
---|
54 | //add action |
---|
55 | $search = '<a href="{$U_MAINT_C13Y}" class="icon-ok maintenance-action">{\'Reinitialize check integrity\'|@translate}</a>'; |
---|
56 | $replacement = '<a href="{$U_ADDINDEX}" class="icon-plus maintenance-action addindex-level-button" >{\'Advanced_Add_Index\'|@translate}</a>'; |
---|
57 | return str_replace($search, $search.$replacement, $content); |
---|
58 | } |
---|
59 | |
---|
60 | class AdminAddIndex extends AddIndex |
---|
61 | { |
---|
62 | function load_params() |
---|
63 | { |
---|
64 | global $conf; |
---|
65 | |
---|
66 | // Name of index file (index.php or index.htm or index.html) |
---|
67 | if (!isset($conf['add_index_filename'])) |
---|
68 | { |
---|
69 | $conf['add_index_filename'] = 'index.php'; |
---|
70 | } |
---|
71 | // Name of index file (index.php or index.htm or index.html) |
---|
72 | if (!isset($conf['add_index_source_directory_path'])) |
---|
73 | { |
---|
74 | // Name of the directoty use in order to copy index file |
---|
75 | $conf['add_index_source_directory_path'] = PHPWG_ROOT_PATH.'include/'; |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | function loading_lang() |
---|
80 | { |
---|
81 | load_language('plugin.lang', $this->path); |
---|
82 | } |
---|
83 | |
---|
84 | function get_admin_advanced_features_links($advanced_features) |
---|
85 | { |
---|
86 | array_push($advanced_features, |
---|
87 | array |
---|
88 | ( |
---|
89 | 'CAPTION' => l10n('Advanced_Add_Index'), |
---|
90 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/main_page.php').'&overwrite' |
---|
91 | )); |
---|
92 | |
---|
93 | return $advanced_features; |
---|
94 | } |
---|
95 | |
---|
96 | function get_admins_site_links($site_manager_plugin_links, $site_id, $is_remote) |
---|
97 | { |
---|
98 | if (!$is_remote) |
---|
99 | { |
---|
100 | array_push($site_manager_plugin_links, |
---|
101 | array |
---|
102 | ( |
---|
103 | 'U_HREF' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/main_page.php').'&site_id='.$site_id, |
---|
104 | 'U_CAPTION' => l10n('Manager_Add_Index'), |
---|
105 | 'U_HINT' => l10n('Add_Index') |
---|
106 | )); |
---|
107 | } |
---|
108 | |
---|
109 | return $site_manager_plugin_links; |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | // Create object |
---|
114 | $add_index = new AdminAddIndex(); |
---|
115 | |
---|
116 | // Load Add Index parameters |
---|
117 | $add_index->load_params(); |
---|
118 | |
---|
119 | // Add events |
---|
120 | add_event_handler('loading_lang', array(&$add_index, 'loading_lang')); |
---|
121 | add_event_handler('get_admin_advanced_features_links', array(&$add_index, 'get_admin_advanced_features_links')); |
---|
122 | add_event_handler('get_admins_site_links', array(&$add_index, 'get_admins_site_links'), EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
123 | |
---|
124 | ?> |
---|