source: extensions/manage_properties_photos/initadmin.php @ 31363

Last change on this file since 31363 was 31363, checked in by ddtddt, 8 years ago

[extensions] - manage_properties_photos - add manage by batch Manager language

File size: 4.8 KB
Line 
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
23add_event_handler('get_admin_plugin_menu_links', 'add_info_photo_admin_menu');
24
25function 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
34add_event_handler('tabsheet_before_select', 'aip_tabsheet_before_select',
35    EVENT_HANDLER_PRIORITY_NEUTRAL);
36
37function 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&amp;image_id='.$_GET['image_id'],
45      );
46  }
47  return $sheets;
48}
49
50//add manage by batch Manager
51add_event_handler('loc_end_element_set_global', 'MPP_loc_end_element_set_global');
52add_event_handler('element_set_global_action', 'MPP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
53 
54function 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                $template->assign('useED',1);
65    }else{
66        $template->assign('useED',0);
67    }
68
69  while ($row = pwg_db_fetch_assoc($propertieslist2))
70  {
71    $propertieslist[$row['id_prop_pho']] = trigger_change('AP_render_content', $row['wording']);
72  }
73$template->set_filename('MMPP', realpath(ADD_PROP_PHOTO_PATH.'mmp.tpl'));
74$template->assign('propertieslist', $propertieslist);
75$template->append('element_set_global_plugins_actions', array(
76    'ID' => 'MPP', 
77    'NAME' => l10n('Change photos properties'), 
78    'CONTENT' => $template->parse('MMPP', true)
79        ));
80 }
81 
82 function MPP_element_set_global_action($action, $collection)
83 {
84  load_language('plugin.lang', ADD_PROP_PHOTO_PATH);
85        if ($action == 'MPP')
86  {
87    global $page,$template,$prefixeTable;
88   
89    if (empty($_POST['check_MPP']))
90    {
91
92          $template->assign('PLUG_MPP', $_POST['dataglob']);
93          $template->assign('SELECTEDMPP', $_POST['IDMPP']);
94      array_push($page['warnings'], l10n('You need to confirm'));
95    }
96    else
97    {
98$id_prop_pho= $_POST['IDMPP'];
99$data= $_POST['dataglob'];             
100         
101    foreach ($collection as $image_id)
102      {
103            $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
104        $test = pwg_query($q);
105        $row = pwg_db_fetch_assoc($test);
106        if (count($row) > 0) {
107            if ($data != '') {
108                $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
109                pwg_query($query);
110            } else {
111                $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $image_id . ' AND id_prop_pho=' . $id_prop_pho;
112                pwg_query($query);
113            }
114        } else if ($data != '') {
115            $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $image_id . ',' . $id_prop_pho . ',"' . $data . '");';
116            pwg_query($query);
117        }
118      }
119    }
120  }
121 }
122 
123 
Note: See TracBrowser for help on using the repository browser.