source: trunk/admin/picture_modify.php @ 817

Last change on this file since 817 was 817, checked in by plg, 19 years ago
  • modification : major simplification of admin.php. Titles are managed by included page, localized items are managed directly in the template.
  • new : sub template admin/double_select is included in templates admin/cat_options, admin/user_perm and admin/group_perm. I haven't been able to use it in admin/picture_modify because it seems impossible to have two instance of the same sub-template without interfering.
  • modification : bug 99, in profile manager, no auto submit when changing language (useless and generate accessibility problem).
  • improvement : HTML semantically correct for administration menu, simpler syntax, less tags, correct tags (dl/dt/dd instead of div/div).
  • modification : number of waiting elements and unvalidated comments are displayed in admin/intro instead of administration menu (with a link to the dedicated pages).
  • deletion : no link to profile from admin/user_list anymore (no need).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-08-17 14:25:38 +0000 (Wed, 17 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 817 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28if(!defined("PHPWG_ROOT_PATH"))
29{
30  die ("Hacking attempt!");
31}
32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33//--------------------------------------------------------- update informations
34// first, we verify whether there is a mistake on the given creation date
35if (isset($_POST['date_creation']) and !empty($_POST['date_creation']))
36{
37  if (!check_date_format($_POST['date_creation']))
38  {
39    array_push($page['errors'], $lang['err_date']);
40  }
41}
42if (isset($_POST['submit']) and count($page['errors']) == 0)
43{
44  $query = 'UPDATE '.IMAGES_TABLE.' SET name = ';
45  if ($_POST['name'] == '')
46    $query.= 'NULL';
47  else
48    $query.= "'".htmlentities($_POST['name'], ENT_QUOTES)."'";
49 
50  $query.= ', author = ';
51  if ($_POST['author'] == '')
52    $query.= 'NULL';
53  else
54    $query.= "'".htmlentities($_POST['author'],ENT_QUOTES)."'";
55
56  $query.= ', comment = ';
57  if ($_POST['comment'] == '')
58    $query.= 'NULL';
59  else
60    $query.= "'".htmlentities($_POST['comment'],ENT_QUOTES)."'";
61
62  $query.= ', date_creation = ';
63  if (!empty($_POST['date_creation']))
64    $query.= "'".date_convert($_POST['date_creation'])."'";
65  else if ($_POST['date_creation'] == '')
66    $query.= 'NULL';
67
68  $query.= ', keywords = ';
69  $keywords_array = get_keywords($_POST['keywords']);
70  if (count($keywords_array) == 0)
71    $query.= 'NULL';
72  else
73  {
74    $query.= "'";
75    foreach ($keywords_array as $i => $keyword) {
76      if ($i > 0) $query.= ',';
77      $query.= $keyword;
78    }
79    $query.= "'";
80  }
81
82  $query.= ' WHERE id = '.$_GET['image_id'];
83  $query.= ';';
84  pwg_query($query);
85}
86// associate the element to other categories than its storage category
87if (isset($_POST['associate'])
88    and isset($_POST['cat_dissociated'])
89    and count($_POST['cat_dissociated']) > 0)
90{
91  $datas = array();
92  foreach ($_POST['cat_dissociated'] as $category_id)
93  {
94    array_push($datas, array('image_id' => $_GET['image_id'],
95                             'category_id' => $category_id));
96  }
97  mass_inserts(IMAGE_CATEGORY_TABLE, array('image_id', 'category_id'), $datas);
98
99  update_category($_POST['cat_dissociated']);
100}
101// dissociate the element from categories (but not from its storage category)
102if (isset($_POST['dissociate'])
103    and isset($_POST['cat_associated'])
104    and count($_POST['cat_associated']) > 0)
105{
106  $query = '
107DELETE FROM '.IMAGE_CATEGORY_TABLE.'
108  WHERE image_id = '.$_GET['image_id'].'
109    AND category_id IN ('.implode(',',$_POST['cat_associated'] ).')
110';
111  pwg_query($query);
112  update_category($_POST['cat_associated']);
113}
114// elect the element to represent the given categories
115if (isset($_POST['elect'])
116    and isset($_POST['cat_dismissed'])
117    and count($_POST['cat_dismissed']) > 0)
118{
119  $datas = array();
120  foreach ($_POST['cat_dismissed'] as $category_id)
121  {
122    array_push($datas,
123               array('id' => $category_id,
124                     'representative_picture_id' => $_GET['image_id']));
125  }
126  $fields = array('primary' => array('id'),
127                  'update' => array('representative_picture_id'));
128  mass_updates(CATEGORIES_TABLE, $fields, $datas);
129}
130// dismiss the element as representant of the given categories
131if (isset($_POST['dismiss'])
132    and isset($_POST['cat_elected'])
133    and count($_POST['cat_elected']) > 0)
134{
135  set_random_representant($_POST['cat_elected']);
136}
137
138// retrieving direct information about picture
139$query = '
140SELECT i.*, c.uppercats
141  FROM '.IMAGES_TABLE.' AS i
142   INNER JOIN '.CATEGORIES_TABLE.' AS c ON i.storage_category_id = c.id
143  WHERE i.id = '.$_GET['image_id'].'
144;';
145$row = mysql_fetch_array(pwg_query($query));
146
147$storage_category_id = $row['storage_category_id'];
148
149if (empty($row['name']))
150{
151  $title = str_replace('_', ' ',get_filename_wo_extension($row['file']));
152}
153else
154{
155  $title = $row['name'];
156}
157// Navigation path
158$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
159
160$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id'];
161$url_img .= '&amp;cat='.$row['storage_category_id'];
162$date = isset($_POST['date_creation']) && empty($page['errors'])
163?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
164
165$url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id=';
166$storage_category = get_cat_display_name_cache($row['uppercats'],
167                                               $url,
168                                               false);
169//----------------------------------------------------- template initialization
170$template->set_filenames(
171  array(
172    'picture_modify' => 'admin/picture_modify.tpl'
173    )
174  );
175
176$template->assign_vars(array(
177  'TITLE_IMG'=>$title,
178  'STORAGE_CATEGORY_IMG'=>$storage_category,
179  'PATH_IMG'=>$row['path'],
180  'FILE_IMG'=>$row['file'],
181  'TN_URL_IMG'=>$thumbnail_url,
182  'URL_IMG'=>add_session_id($url_img),
183  'DEFAULT_NAME_IMG'=>str_replace('_',' ',get_filename_wo_extension($row['file'])),
184  'FILE_IMG'=>$row['file'],
185  'NAME_IMG'=>isset($_POST['name'])?$_POST['name']:@$row['name'],
186  'SIZE_IMG'=>@$row['width'].' * '.@$row['height'],
187  'FILESIZE_IMG'=>@$row['filesize'].' KB',
188  'REGISTRATION_DATE_IMG'
189  => format_date($row['date_available'], 'mysql_datetime', true),
190  'AUTHOR_IMG'=>isset($_POST['author'])?$_POST['author']:@$row['author'],
191  'CREATION_DATE_IMG'=>$date,
192  'KEYWORDS_IMG'=>isset($_POST['keywords'])?$_POST['keywords']:@$row['keywords'],
193  'COMMENT_IMG'=>isset($_POST['comment'])?$_POST['comment']:@$row['comment'],
194 
195  'L_UPLOAD_NAME'=>$lang['upload_name'],
196  'L_DEFAULT'=>$lang['default'],
197  'L_FILE'=>$lang['file'],
198  'L_SIZE'=>$lang['size'],
199  'L_FILESIZE'=>$lang['filesize'],
200  'L_REGISTRATION_DATE'=>$lang['registration_date'],
201  'L_AUTHOR'=>$lang['author'],
202  'L_CREATION_DATE'=>$lang['creation_date'],
203  'L_KEYWORDS'=>$lang['keywords'],
204  'L_COMMENT'=>$lang['description'],
205  'L_CATEGORIES'=>$lang['categories'],
206  'L_DISSOCIATE'=>$lang['dissociate'],
207  'L_INFOIMAGE_ASSOCIATE'=>$lang['infoimage_associate'],
208  'L_SUBMIT'=>$lang['submit'],
209  'L_RESET'=>$lang['reset'],
210  'L_CAT_ASSOCIATED'=>$lang['infoimage_associated'],
211  'L_CAT_DISSOCIATED'=>$lang['infoimage_dissociated'],
212  'L_PATH'=>$lang['path'],
213  'L_STORAGE_CATEGORY'=>$lang['storage_category'],
214  'L_REPRESENTS'=>$lang['represents'],
215  'L_DOESNT_REPRESENT'=>$lang['doesnt_represent'],
216 
217  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?'.$_SERVER['QUERY_STRING'])
218 ));
219 
220// associate to another category ?
221$query = '
222SELECT id,name,uppercats,global_rank
223  FROM '.CATEGORIES_TABLE.'
224    INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id
225  WHERE image_id = '.$_GET['image_id'].'
226    AND id != '.$storage_category_id.'
227;';
228display_select_cat_wrapper($query, array(), 'associated_option');
229
230$result = pwg_query($query);
231$associateds = array($storage_category_id);
232while ($row = mysql_fetch_array($result))
233{
234  array_push($associateds, $row['id']);
235}
236$query = '
237SELECT id,name,uppercats,global_rank
238  FROM '.CATEGORIES_TABLE.'
239  WHERE id NOT IN ('.implode(',', $associateds).')
240;';
241display_select_cat_wrapper($query, array(), 'dissociated_option');
242
243// representing
244$query = '
245SELECT id,name,uppercats,global_rank
246  FROM '.CATEGORIES_TABLE.'
247  WHERE representative_picture_id = '.$_GET['image_id'].'
248;';
249display_select_cat_wrapper($query, array(), 'elected_option');
250
251$query = '
252SELECT id,name,uppercats,global_rank
253  FROM '.CATEGORIES_TABLE.'
254  WHERE representative_picture_id != '.$_GET['image_id'].'
255    OR representative_picture_id IS NULL
256;';
257display_select_cat_wrapper($query, array(), 'dismissed_option');
258
259//----------------------------------------------------------- sending html code
260
261
262$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_modify');
263?>
Note: See TracBrowser for help on using the repository browser.