source: trunk/admin/element_set_unit.php @ 2249

Last change on this file since 2249 was 2249, checked in by rvelices, 16 years ago
  • admin comments, configuration, element_set_global, element_set_unit, thumbnail and double_select migration to smarty
  • fix in redirect.tpl
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 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-2008 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: element_set_unit.php 2249 2008-03-05 01:50:08Z rvelices $
8// | last update   : $Date: 2008-03-05 01:50:08 +0000 (Wed, 05 Mar 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2249 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27/**
28 * Management of elements set. Elements can belong to a category or to the
29 * user caddie.
30 *
31 */
32
33if (!defined('PHPWG_ROOT_PATH'))
34{
35  die('Hacking attempt!');
36}
37
38include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
39
40// +-----------------------------------------------------------------------+
41// | Check Access and exit when user status is not ok                      |
42// +-----------------------------------------------------------------------+
43check_status(ACCESS_ADMINISTRATOR);
44
45// +-----------------------------------------------------------------------+
46// |                        unit mode form submission                      |
47// +-----------------------------------------------------------------------+
48
49if (isset($_POST['submit']))
50{
51  $collection = explode(',', $_POST['element_ids']);
52
53  $datas = array();
54
55  $query = '
56SELECT id, date_creation
57  FROM '.IMAGES_TABLE.'
58  WHERE id IN ('.implode(',', $collection).')
59;';
60  $result = pwg_query($query);
61
62  while ($row = mysql_fetch_array($result))
63  {
64    $data = array();
65
66    $data{'id'} = $row['id'];
67    $data{'name'} = $_POST['name-'.$row['id']];
68    $data{'author'} = $_POST['author-'.$row['id']];
69
70    foreach (array('name', 'author') as $field)
71    {
72      if (!empty($_POST[$field.'-'.$row['id']]))
73      {
74        $data{$field} = strip_tags($_POST[$field.'-'.$row['id']]);
75      }
76    }
77
78    if ($conf['allow_html_descriptions'])
79    {
80      $data{'comment'} = @$_POST['description-'.$row['id']];
81    }
82    else
83    {
84      $data{'comment'} = strip_tags(@$_POST['description-'.$row['id']]);
85    }
86
87    if (isset($_POST['date_creation_action-'.$row['id']]))
88    {
89      if ('set' == $_POST['date_creation_action-'.$row['id']])
90      {
91        $data{'date_creation'} =
92          $_POST['date_creation_year-'.$row['id']]
93            .'-'.$_POST['date_creation_month-'.$row['id']]
94            .'-'.$_POST['date_creation_day-'.$row['id']];
95      }
96      else if ('unset' == $_POST['date_creation_action-'.$row['id']])
97      {
98        $data{'date_creation'} = '';
99      }
100    }
101    else
102    {
103      $data{'date_creation'} = $row['date_creation'];
104    }
105
106    array_push($datas, $data);
107
108    // tags management
109    if (isset($_POST[ 'tags-'.$row['id'] ]))
110    {
111      set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']);
112    }
113  }
114
115  mass_updates(
116    IMAGES_TABLE,
117    array(
118      'primary' => array('id'),
119      'update' => array('name','author','comment','date_creation')
120      ),
121    $datas
122    );
123
124  array_push($page['infos'], l10n('Picture informations updated'));
125}
126
127// +-----------------------------------------------------------------------+
128// |                             template init                             |
129// +-----------------------------------------------------------------------+
130
131$template->set_filenames(
132  array('element_set_unit' => 'admin/element_set_unit.tpl'));
133
134$base_url = PHPWG_ROOT_PATH.'admin.php';
135
136$month_list = $lang['month'];
137$month_list[0]='------------';
138ksort($month_list);
139
140$template->assign(
141  array(
142    'CATEGORIES_NAV'=>$page['title'],
143
144    'U_ELEMENTS_PAGE'
145    =>$base_url.get_query_string_diff(array('display','start')),
146
147    'U_GLOBAL_MODE'
148    =>
149    $base_url
150    .get_query_string_diff(array('mode','display'))
151    .'&amp;mode=global',
152
153    'F_ACTION'=>$base_url.get_query_string_diff(array()),
154   
155    'month_list' => $month_list
156    )
157  );
158
159// +-----------------------------------------------------------------------+
160// |                        global mode thumbnails                         |
161// +-----------------------------------------------------------------------+
162
163// how many items to display on this page
164if (!empty($_GET['display']))
165{
166  if ('all' == $_GET['display'])
167  {
168    $page['nb_images'] = count($page['cat_elements_id']);
169  }
170  else
171  {
172    $page['nb_images'] = intval($_GET['display']);
173  }
174}
175else
176{
177  $page['nb_images'] = 5;
178}
179
180
181
182if (count($page['cat_elements_id']) > 0)
183{
184  $nav_bar = create_navigation_bar(
185    $base_url.get_query_string_diff(array('start')),
186    count($page['cat_elements_id']),
187    $page['start'],
188    $page['nb_images']
189    );
190  $template->assign(array('NAV_BAR' => $nav_bar));
191
192  // tags
193  $all_tags = get_all_tags();
194
195  $element_ids = array();
196
197  $query = '
198SELECT id,path,tn_ext,name,date_creation,comment,author,file
199  FROM '.IMAGES_TABLE.'
200  WHERE id IN ('.implode(',', $page['cat_elements_id']).')
201  '.$conf['order_by'].'
202  LIMIT '.$page['start'].', '.$page['nb_images'].'
203;';
204  $result = pwg_query($query);
205
206  while ($row = mysql_fetch_assoc($result))
207  {
208    // echo '<pre>'; print_r($row); echo '</pre>';
209    array_push($element_ids, $row['id']);
210
211    $src = get_thumbnail_url($row);
212
213    $query = '
214SELECT tag_id
215  FROM '.IMAGE_TAG_TABLE.'
216  WHERE image_id = '.$row['id'].'
217;';
218    $selected_tags = array_from_query($query, 'tag_id');
219
220    // creation date
221    if (!empty($row['date_creation']))
222    {
223      list($year,$month,$day) = explode('-', $row['date_creation']);
224    }
225    else
226    {
227      list($year,$month,$day) = array('',0,0);
228    }
229
230    if (count($all_tags) > 0)
231    {
232      $tag_selection = get_html_tag_selection(
233        $all_tags,
234        'tags-'.$row['id'],
235        $selected_tags
236        );
237    }
238    else
239    {
240      $tag_selection =
241        '<p>'.
242        l10n('No tag defined. Use Administration>Pictures>Tags').
243        '</p>';
244    }
245
246    $template->append(
247      'elements',
248      array(
249        'ID' => $row['id'],
250        'TN_SRC' => $src,
251        'LEGEND' =>
252          !empty($row['name']) ?
253            $row['name'] : get_name_from_file($row['file']),
254        'U_EDIT' =>
255            PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
256            '&amp;image_id='.$row['id'],
257        'NAME' => @$row['name'],
258        'AUTHOR' => @$row['author'],
259        'DESCRIPTION' => @$row['comment'],
260        'DATE_CREATION_YEAR' => $year,
261        'DATE_CREATION_MONTH' => (int)$month,
262        'DATE_CREATION_DAY' => (int)$day,
263
264        'TAG_SELECTION' => $tag_selection,
265        )
266      );
267  }
268
269  $template->assign('ELEMENT_IDS', implode(',', $element_ids));
270}
271
272// +-----------------------------------------------------------------------+
273// |                           sending html code                           |
274// +-----------------------------------------------------------------------+
275
276$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit');
277?>
Note: See TracBrowser for help on using the repository browser.