source: trunk/admin/element_set_unit.php @ 1710

Last change on this file since 1710 was 1609, checked in by rvelices, 18 years ago

completely replaced get_thumbnail_src it get_thumbnail_url
or get_thumbnail_path

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
RevLine 
[763]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: 2006-11-15 04:25:12 +0000 (Wed, 15 Nov 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1609 $
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.
[1609]31 *
[763]32 */
[1609]33
[763]34if (!defined('PHPWG_ROOT_PATH'))
35{
36  die('Hacking attempt!');
37}
38
[1072]39include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
40
[763]41// +-----------------------------------------------------------------------+
[1072]42// | Check Access and exit when user status is not ok                      |
43// +-----------------------------------------------------------------------+
44check_status(ACCESS_ADMINISTRATOR);
45
46// +-----------------------------------------------------------------------+
[763]47// |                        unit mode form submission                      |
48// +-----------------------------------------------------------------------+
49
50if (isset($_POST['submit']))
51{
52  $collection = explode(',', $_POST['list']);
[1609]53
[763]54  $datas = array();
[1609]55
[763]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();
[836]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)
[763]72    {
73      if (!empty($_POST[$field.'-'.$row['id']]))
74      {
[836]75        $data{$field} = strip_tags($_POST[$field.'-'.$row['id']]);
[763]76      }
77    }
[1609]78
[836]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    }
[763]87
[836]88    if (isset($_POST['date_creation_action-'.$row['id']]))
[763]89    {
[836]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      }
[763]101    }
[836]102    else
[763]103    {
[836]104      $data{'date_creation'} = $row['date_creation'];
[763]105    }
[1609]106
[1119]107    array_push($datas, $data);
[763]108
[1119]109    // tags management
110    if (isset($_POST[ 'tags-'.$row['id'] ]))
[836]111    {
[1119]112      set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']);
[836]113    }
[763]114  }
[1609]115
[836]116  mass_updates(
117    IMAGES_TABLE,
118    array(
119      'primary' => array('id'),
[1119]120      'update' => array('name','author','comment','date_creation')
[836]121      ),
122    $datas
123    );
[1609]124
[836]125  array_push($page['infos'], l10n('Picture informations updated'));
[763]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(
[834]141    'CATEGORIES_NAV'=>$page['title'],
[764]142
[763]143    'L_SUBMIT'=>$lang['submit'],
[1609]144
[763]145    'U_ELEMENTS_PAGE'
146    =>$base_url.get_query_string_diff(array('display','start')),
[1609]147
[763]148    'U_GLOBAL_MODE'
[764]149    =>
150    $base_url
151    .get_query_string_diff(array('mode','display'))
152    .'&amp;mode=global',
[1609]153
[763]154    'F_ACTION'=>$base_url.get_query_string_diff(array()),
155    )
156  );
157
158// +-----------------------------------------------------------------------+
159// |                        global mode thumbnails                         |
160// +-----------------------------------------------------------------------+
161
[875]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}
[763]178
[764]179
[875]180
[764]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'],
[1084]187    $page['nb_images']
188    );
[764]189  $template->assign_vars(array('NAV_BAR' => $nav_bar));
190
[1119]191  // tags
192  $all_tags = get_all_tags();
[1609]193
[764]194  $element_ids = array();
195
196  $query = '
[1119]197SELECT id,path,tn_ext,name,date_creation,comment,author,file
[764]198  FROM '.IMAGES_TABLE.'
199  WHERE id IN ('.implode(',', $page['cat_elements_id']).')
[763]200  '.$conf['order_by'].'
201  LIMIT '.$page['start'].', '.$page['nb_images'].'
202;';
[764]203  $result = pwg_query($query);
[763]204
[1609]205  while ($row = mysql_fetch_assoc($result))
[763]206  {
[764]207    // echo '<pre>'; print_r($row); echo '</pre>';
208    array_push($element_ids, $row['id']);
[1119]209
[1609]210    $src = get_thumbnail_url($row);
211
[1119]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');
[1609]218
[764]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    }
[1314]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    }
[1609]244
[764]245    $template->assign_block_vars(
246      'element',
247      array(
[836]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'.
[1004]253            '&amp;image_id='.$row['id'],
[764]254        'ID' => $row['id'],
255        'FILENAME' => $row['path'],
256        'TN_SRC' => $src,
257        'NAME' => @$row['name'],
258        'AUTHOR' => @$row['author'],
[836]259        'DESCRIPTION' => @$row['comment'],
[764]260        'DATE_CREATION_YEAR' => $year,
[1609]261
[1314]262        'TAG_SELECTION' => $tag_selection,
[764]263        )
264      );
[1609]265
[764]266    get_day_list('element.date_creation_day', $day);
267    get_month_list('element.date_creation_month', $month);
[763]268  }
269
[764]270  $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids)));
[763]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.