1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Manage Properties Photos plugin for Piwigo | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2014-2016 ddtddt http://temmii.com | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | This program is free software; you can redistribute it and/or modify | |
---|
8 | // | it under the terms of the GNU General Public License as published by | |
---|
9 | // | the Free Software Foundation | |
---|
10 | // | | |
---|
11 | // | This program is distributed in the hope that it will be useful, but | |
---|
12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
14 | // | General Public License for more details. | |
---|
15 | // | | |
---|
16 | // | You should have received a copy of the GNU General Public License | |
---|
17 | // | along with this program; if not, write to the Free Software | |
---|
18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
19 | // | USA. | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | //add admin menu |
---|
23 | add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu'); |
---|
24 | |
---|
25 | function add_info_photo_admin_menu($menu) { |
---|
26 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
27 | $menu[] = array( |
---|
28 | 'NAME' => l10n('Manage properties photos'), |
---|
29 | 'URL' => ADD_PROP_PHOTO_ADMIN, |
---|
30 | ); |
---|
31 | return $menu; |
---|
32 | } |
---|
33 | |
---|
34 | add_event_handler('tabsheet_before_select', 'aip_tabsheet_before_select', |
---|
35 | EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
36 | |
---|
37 | function aip_tabsheet_before_select($sheets, $id) |
---|
38 | { |
---|
39 | global $template, $page; |
---|
40 | if ($id == 'photo') |
---|
41 | { |
---|
42 | $sheets['iap'] = array( |
---|
43 | 'caption' => l10n('Properties additionals'), |
---|
44 | 'url' => ADD_PROP_PHOTO_ADMIN.'-iap&image_id='.$_GET['image_id'], |
---|
45 | ); |
---|
46 | } |
---|
47 | return $sheets; |
---|
48 | } |
---|
49 | |
---|
50 | //add manage by batch Manager |
---|
51 | add_event_handler('loc_end_element_set_global', 'MPP_loc_end_element_set_global'); |
---|
52 | add_event_handler('element_set_global_action', 'MPP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
53 | |
---|
54 | function MPP_loc_end_element_set_global() |
---|
55 | { |
---|
56 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
57 | global $template; |
---|
58 | $propertieslist = array(); |
---|
59 | $propertieslist2 = tab_add_info_by_photo(); |
---|
60 | |
---|
61 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
62 | if ($PAED['state'] == 'active') |
---|
63 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
64 | |
---|
65 | while ($row = pwg_db_fetch_assoc($propertieslist2)) |
---|
66 | { |
---|
67 | $propertieslist[$row['id_prop_pho']] = trigger_change('AP_render_content', $row['wording']); |
---|
68 | } |
---|
69 | $template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl')); |
---|
70 | $template->assign('propertieslist', $propertieslist); |
---|
71 | $template->append('element_set_global_plugins_actions', array( |
---|
72 | 'ID' => 'MPP', |
---|
73 | 'NAME' => l10n('Change properties'), |
---|
74 | 'CONTENT' => $template->parse('MMPP', true) |
---|
75 | )); |
---|
76 | } |
---|
77 | |
---|
78 | function MPP_element_set_global_action($action, $collection) |
---|
79 | { |
---|
80 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
81 | if ($action == 'MPP') |
---|
82 | { |
---|
83 | global $page,$template,$prefixeTable; |
---|
84 | |
---|
85 | if (empty($_POST['check_MPP'])) |
---|
86 | { |
---|
87 | |
---|
88 | $template->assign('PLUG_MPP', $_POST['dataglob']); |
---|
89 | $template->assign('SELECTEDMPP', $_POST['IDMPP']); |
---|
90 | array_push($page['warnings'], l10n('You need to confirm')); |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | $id_prop_pho= $_POST['IDMPP']; |
---|
95 | $data= $_POST['dataglob']; |
---|
96 | |
---|
97 | foreach ($collection as $image_id) |
---|
98 | { |
---|
99 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
100 | $test = pwg_query($q); |
---|
101 | $row = pwg_db_fetch_assoc($test); |
---|
102 | if (count($row) > 0) { |
---|
103 | if ($data != '') { |
---|
104 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
105 | pwg_query($query); |
---|
106 | } else { |
---|
107 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
108 | pwg_query($query); |
---|
109 | } |
---|
110 | } else if ($data != '') { |
---|
111 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
112 | pwg_query($query); |
---|
113 | } |
---|
114 | } |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | |
---|