source: trunk/admin/element_set_unit.php @ 1900

Last change on this file since 1900 was 1900, checked in by rub, 17 years ago

Apply property svn:eol-style Value: LF

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 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: 2007-03-12 22:33:53 +0000 (Mon, 12 Mar 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1900 $
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
28/**
29 * Management of elements set. Elements can belong to a category or to the
30 * user caddie.
31 *
32 */
33
34if (!defined('PHPWG_ROOT_PATH'))
35{
36  die('Hacking attempt!');
37}
38
39include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
40
41// +-----------------------------------------------------------------------+
42// | Check Access and exit when user status is not ok                      |
43// +-----------------------------------------------------------------------+
44check_status(ACCESS_ADMINISTRATOR);
45
46// +-----------------------------------------------------------------------+
47// |                        unit mode form submission                      |
48// +-----------------------------------------------------------------------+
49
50if (isset($_POST['submit']))
51{
52  $collection = explode(',', $_POST['list']);
53
54  $datas = array();
55
56  $query = '
57SELECT id, date_creation
58  FROM '.IMAGES_TABLE.'
59  WHERE id IN ('.implode(',', $collection).')
60;';
61  $result = pwg_query($query);
62
63  while ($row = mysql_fetch_array($result))
64  {
65    $data = array();
66
67    $data{'id'} = $row['id'];
68    $data{'name'} = $_POST['name-'.$row['id']];
69    $data{'author'} = $_POST['author-'.$row['id']];
70
71    foreach (array('name', 'author') as $field)
72    {
73      if (!empty($_POST[$field.'-'.$row['id']]))
74      {
75        $data{$field} = strip_tags($_POST[$field.'-'.$row['id']]);
76      }
77    }
78
79    if ($conf['allow_html_descriptions'])
80    {
81      $data{'comment'} = @$_POST['description-'.$row['id']];
82    }
83    else
84    {
85      $data{'comment'} = strip_tags(@$_POST['description-'.$row['id']]);
86    }
87
88    if (isset($_POST['date_creation_action-'.$row['id']]))
89    {
90      if ('set' == $_POST['date_creation_action-'.$row['id']])
91      {
92        $data{'date_creation'} =
93          $_POST['date_creation_year-'.$row['id']]
94            .'-'.$_POST['date_creation_month-'.$row['id']]
95            .'-'.$_POST['date_creation_day-'.$row['id']];
96      }
97      else if ('unset' == $_POST['date_creation_action-'.$row['id']])
98      {
99        $data{'date_creation'} = '';
100      }
101    }
102    else
103    {
104      $data{'date_creation'} = $row['date_creation'];
105    }
106
107    array_push($datas, $data);
108
109    // tags management
110    if (isset($_POST[ 'tags-'.$row['id'] ]))
111    {
112      set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']);
113    }
114  }
115
116  mass_updates(
117    IMAGES_TABLE,
118    array(
119      'primary' => array('id'),
120      'update' => array('name','author','comment','date_creation')
121      ),
122    $datas
123    );
124
125  array_push($page['infos'], l10n('Picture informations updated'));
126}
127
128// +-----------------------------------------------------------------------+
129// |                             template init                             |
130// +-----------------------------------------------------------------------+
131
132$template->set_filenames(
133  array('element_set_unit' => 'admin/element_set_unit.tpl'));
134
135$base_url = PHPWG_ROOT_PATH.'admin.php';
136
137// $form_action = $base_url.'?page=element_set_global';
138
139$template->assign_vars(
140  array(
141    'CATEGORIES_NAV'=>$page['title'],
142
143    'L_SUBMIT'=>$lang['submit'],
144
145    'U_ELEMENTS_PAGE'
146    =>$base_url.get_query_string_diff(array('display','start')),
147
148    'U_GLOBAL_MODE'
149    =>
150    $base_url
151    .get_query_string_diff(array('mode','display'))
152    .'&amp;mode=global',
153
154    'F_ACTION'=>$base_url.get_query_string_diff(array()),
155    )
156  );
157
158// +-----------------------------------------------------------------------+
159// |                        global mode thumbnails                         |
160// +-----------------------------------------------------------------------+
161
162// how many items to display on this page
163if (!empty($_GET['display']))
164{
165  if ('all' == $_GET['display'])
166  {
167    $page['nb_images'] = count($page['cat_elements_id']);
168  }
169  else
170  {
171    $page['nb_images'] = intval($_GET['display']);
172  }
173}
174else
175{
176  $page['nb_images'] = 5;
177}
178
179
180
181if (count($page['cat_elements_id']) > 0)
182{
183  $nav_bar = create_navigation_bar(
184    $base_url.get_query_string_diff(array('start')),
185    count($page['cat_elements_id']),
186    $page['start'],
187    $page['nb_images']
188    );
189  $template->assign_vars(array('NAV_BAR' => $nav_bar));
190
191  // tags
192  $all_tags = get_all_tags();
193
194  $element_ids = array();
195
196  $query = '
197SELECT id,path,tn_ext,name,date_creation,comment,author,file
198  FROM '.IMAGES_TABLE.'
199  WHERE id IN ('.implode(',', $page['cat_elements_id']).')
200  '.$conf['order_by'].'
201  LIMIT '.$page['start'].', '.$page['nb_images'].'
202;';
203  $result = pwg_query($query);
204
205  while ($row = mysql_fetch_assoc($result))
206  {
207    // echo '<pre>'; print_r($row); echo '</pre>';
208    array_push($element_ids, $row['id']);
209
210    $src = get_thumbnail_url($row);
211
212    $query = '
213SELECT tag_id
214  FROM '.IMAGE_TAG_TABLE.'
215  WHERE image_id = '.$row['id'].'
216;';
217    $selected_tags = array_from_query($query, 'tag_id');
218
219    // creation date
220    if (!empty($row['date_creation']))
221    {
222      list($year,$month,$day) = explode('-', $row['date_creation']);
223    }
224    else
225    {
226      list($year,$month,$day) = array('','','');
227    }
228
229    if (count($all_tags) > 0)
230    {
231      $tag_selection = get_html_tag_selection(
232        $all_tags,
233        'tags-'.$row['id'],
234        $selected_tags
235        );
236    }
237    else
238    {
239      $tag_selection =
240        '<p>'.
241        l10n('No tag defined. Use Administration>Pictures>Tags').
242        '</p>';
243    }
244
245    $template->assign_block_vars(
246      'element',
247      array(
248        'LEGEND' =>
249          !empty($row['name']) ?
250            $row['name'] : get_name_from_file($row['file']),
251        'U_EDIT' =>
252            PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
253            '&amp;image_id='.$row['id'],
254        'ID' => $row['id'],
255        'FILENAME' => $row['path'],
256        'TN_SRC' => $src,
257        'NAME' => @$row['name'],
258        'AUTHOR' => @$row['author'],
259        'DESCRIPTION' => @$row['comment'],
260        'DATE_CREATION_YEAR' => $year,
261
262        'TAG_SELECTION' => $tag_selection,
263        )
264      );
265
266    get_day_list('element.date_creation_day', $day);
267    get_month_list('element.date_creation_month', $month);
268  }
269
270  $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids)));
271}
272
273// +-----------------------------------------------------------------------+
274// |                           sending html code                           |
275// +-----------------------------------------------------------------------+
276
277$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit');
278?>
Note: See TracBrowser for help on using the repository browser.