[30631] | 1 | <?php |
---|
[31361] | 2 | // +-----------------------------------------------------------------------+ |
---|
[32135] | 3 | // | Manage Properties Photos plugin for Piwigo by TEMMII | |
---|
[31361] | 4 | // +-----------------------------------------------------------------------+ |
---|
[32902] | 5 | // | Copyright(C) 2007-2023 ddtddt http://temmii.com/piwigo/ | |
---|
[31361] | 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 | // +-----------------------------------------------------------------------+ |
---|
[30631] | 21 | |
---|
[31360] | 22 | //add admin menu |
---|
[32391] | 23 | /* |
---|
[30631] | 24 | add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu'); |
---|
[31553] | 25 | function add_info_photo_admin_menu($menu){ |
---|
[32188] | 26 | if (is_webmaster()){ |
---|
[30702] | 27 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
[30631] | 28 | $menu[] = array( |
---|
[30702] | 29 | 'NAME' => l10n('Manage properties photos'), |
---|
| 30 | 'URL' => ADD_PROP_PHOTO_ADMIN, |
---|
[30631] | 31 | ); |
---|
[32188] | 32 | } |
---|
[30631] | 33 | return $menu; |
---|
| 34 | } |
---|
[32391] | 35 | */ |
---|
[30631] | 36 | add_event_handler('tabsheet_before_select', 'aip_tabsheet_before_select', |
---|
| 37 | EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
| 38 | |
---|
[31553] | 39 | function aip_tabsheet_before_select($sheets, $id){ |
---|
| 40 | global $template, $page; |
---|
| 41 | if ($id == 'photo'){ |
---|
[30631] | 42 | $sheets['iap'] = array( |
---|
[30702] | 43 | 'caption' => l10n('Properties additionals'), |
---|
| 44 | 'url' => ADD_PROP_PHOTO_ADMIN.'-iap&image_id='.$_GET['image_id'], |
---|
[30631] | 45 | ); |
---|
| 46 | } |
---|
| 47 | return $sheets; |
---|
| 48 | } |
---|
| 49 | |
---|
[31361] | 50 | //add manage by batch Manager |
---|
[31360] | 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 | |
---|
[31553] | 54 | function MPP_loc_end_element_set_global(){ |
---|
[32221] | 55 | global $template, $pwg_loaded_plugins; |
---|
[32135] | 56 | |
---|
| 57 | $template->assign(array( |
---|
| 58 | 'ADD_PROP_PHOTO_PATH'=> get_root_url() . ADD_PROP_PHOTO_PATH, |
---|
| 59 | )); |
---|
| 60 | |
---|
[31553] | 61 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE edit=1'; |
---|
| 62 | $test = pwg_query($q); |
---|
| 63 | $row = pwg_db_fetch_assoc($test); |
---|
[32180] | 64 | if (!empty($row)){ |
---|
[31553] | 65 | $propertieslist = array(); |
---|
| 66 | $propertieslist2 = tab_add_info_by_photo(); |
---|
[32221] | 67 | if (isset($pwg_loaded_plugins['ExtendedDescription'])){ |
---|
[31363] | 68 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
| 69 | $template->assign('useED',1); |
---|
[31553] | 70 | }else{ |
---|
[31363] | 71 | $template->assign('useED',0); |
---|
[31553] | 72 | } |
---|
[32162] | 73 | $template->assign('DATADATE', date('Y-m-d').' 10:05:05'); |
---|
[32135] | 74 | while ($info_select = pwg_db_fetch_assoc($propertieslist2)){ |
---|
| 75 | $items = array( |
---|
| 76 | 'IDINFOPHO' => $info_select['id_prop_pho'], |
---|
| 77 | 'AIPWORDING' => trigger_change('AP_render_content',$info_select['wording']), |
---|
| 78 | 'AIPTYP' => $info_select['Typ'], |
---|
| 79 | ); |
---|
| 80 | if($info_select['Typ']==4||$info_select['Typ']==5){ |
---|
| 81 | $items['AIPDATAPROP'] = json_encode(unserialize($info_select['dataprop'])); |
---|
[32902] | 82 | }else{ |
---|
| 83 | $items['AIPDATAPROP'] = ""; |
---|
[32162] | 84 | } |
---|
[32135] | 85 | if($info_select['wording']=="**delpho**"){ |
---|
| 86 | $items['AIPWORDING'] =l10n('Delete photo'); |
---|
| 87 | } |
---|
| 88 | $template->append('info_select', $items); |
---|
| 89 | } |
---|
| 90 | |
---|
[31553] | 91 | $template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl')); |
---|
| 92 | $template->assign('propertieslist', $propertieslist); |
---|
| 93 | $template->append('element_set_global_plugins_actions', array( |
---|
| 94 | 'ID' => 'MPP', |
---|
| 95 | 'NAME' => l10n('Change photos properties'), |
---|
| 96 | 'CONTENT' => $template->parse('MMPP', true) |
---|
| 97 | )); |
---|
[31360] | 98 | } |
---|
[31553] | 99 | } |
---|
[31360] | 100 | |
---|
[31553] | 101 | function MPP_element_set_global_action($action, $collection){ |
---|
| 102 | if ($action == 'MPP'){ |
---|
| 103 | global $page,$template,$prefixeTable; |
---|
| 104 | $id_prop_pho= $_POST['IDMPP']; |
---|
[32135] | 105 | $Typ=$_POST['invisibleTyp']; |
---|
| 106 | if($Typ==2){ |
---|
| 107 | $data= $_POST['datadate']; |
---|
| 108 | }else if($Typ==4){ |
---|
| 109 | $data= $_POST['dataselect']; |
---|
| 110 | }else if($Typ==5){ |
---|
| 111 | $data= $_POST['radioselect']; |
---|
| 112 | }else{ |
---|
| 113 | $data= $_POST['dataglob']; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | if($Typ==2){ |
---|
[31553] | 117 | if (!empty($_POST['check_MPP'])){ |
---|
| 118 | foreach ($collection as $image_id){ |
---|
[32135] | 119 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_datadate WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 120 | pwg_query($query); |
---|
| 121 | } |
---|
| 122 | }else{ |
---|
| 123 | foreach ($collection as $image_id){ |
---|
| 124 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATADATE_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 125 | $test = pwg_query($q); |
---|
| 126 | $row = pwg_db_fetch_assoc($test); |
---|
| 127 | if (!empty($row)) { |
---|
| 128 | if ($data != '') { |
---|
| 129 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_datadate SET datadate="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 130 | pwg_query($query); |
---|
| 131 | }else{ |
---|
| 132 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_datadate WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 133 | pwg_query($query); |
---|
| 134 | } |
---|
| 135 | }else if ($data != ''){ |
---|
| 136 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_datadate(id_img,id_prop_pho,datadate) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
| 137 | pwg_query($query); |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | } |
---|
| 141 | }else{ |
---|
| 142 | if (!empty($_POST['check_MPP'])){ |
---|
| 143 | foreach ($collection as $image_id){ |
---|
[31406] | 144 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 145 | pwg_query($query); |
---|
| 146 | } |
---|
[31553] | 147 | }else{ |
---|
| 148 | foreach ($collection as $image_id){ |
---|
[32135] | 149 | $q = 'SELECT id_img FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
[31360] | 150 | $test = pwg_query($q); |
---|
| 151 | $row = pwg_db_fetch_assoc($test); |
---|
[32135] | 152 | if (!empty($row)) { |
---|
[31553] | 153 | if ($data != '') { |
---|
| 154 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 155 | pwg_query($query); |
---|
| 156 | }else{ |
---|
| 157 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho; |
---|
| 158 | pwg_query($query); |
---|
| 159 | } |
---|
| 160 | }else if ($data != ''){ |
---|
[31360] | 161 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
| 162 | pwg_query($query); |
---|
| 163 | } |
---|
| 164 | } |
---|
| 165 | } |
---|
| 166 | } |
---|
[32135] | 167 | } |
---|
[31553] | 168 | } |
---|
[31360] | 169 | |
---|
[31553] | 170 | add_event_handler('loc_begin_admin_page', 'mpp_change_admin_show'); |
---|
| 171 | function mpp_change_admin_show(){ |
---|
| 172 | global $template; |
---|
| 173 | $template->set_prefilter('config', 'mpp_change_admin_show_prefilter'); |
---|
| 174 | } |
---|
| 175 | |
---|
[32650] | 176 | function mpp_change_admin_show_prefilter($content){ |
---|
[31553] | 177 | $search = '#(<fieldset id="pictureInfoConf">).*</fieldset>#ms'; |
---|
| 178 | return preg_replace($search, ' |
---|
| 179 | <fieldset id="pictureInfoConf"> |
---|
| 180 | <legend>{\'Photo Properties\'|@translate}</legend> |
---|
[31554] | 181 | <a href="'.ADD_PROP_PHOTO_ADMIN.'"><span class="icon-arrows-cw"></span>{\'Manage properties photos\'|@translate}</a> |
---|
[31553] | 182 | </fieldset> |
---|
| 183 | ', $content); |
---|
| 184 | } |
---|