source: trunk/admin/element_set_unit.php @ 1084

Last change on this file since 1084 was 1084, checked in by plg, 18 years ago

bug fixed: create_navigation_bar take into account clean URL if requested.

deletion: argument link_class (HTML class of links) in function
create_navigation_bar was removed, useless since branch 1.5.

bug fixed: rate_items are now a configuration parameter (set in config file)

modification: new functions library functions_rate.inc.php to reduce
picture.php length.

bug fixed: categories were never expanded in the menu since clean URLs.

bug fixed: changing pictures sorting order in main page was always
rederecting to root category.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 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: 2006-03-16 22:34:45 +0000 (Thu, 16 Mar 2006) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 1084 $
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    $keywords = get_keywords($_POST['keywords-'.$row['id']]);
108    if (count($keywords) > 0)
109    {
110      $data{'keywords'} = implode(',', $keywords);
111    }
112    else
113    {
114      $data{'keywords'} = '';
115    }
116
117    array_push($datas, $data);
118  }
119 
120  mass_updates(
121    IMAGES_TABLE,
122    array(
123      'primary' => array('id'),
124      'update' => array('name','author','comment','date_creation','keywords')
125      ),
126    $datas
127    );
128 
129  array_push($page['infos'], l10n('Picture informations updated'));
130}
131
132// +-----------------------------------------------------------------------+
133// |                             template init                             |
134// +-----------------------------------------------------------------------+
135
136$template->set_filenames(
137  array('element_set_unit' => 'admin/element_set_unit.tpl'));
138
139$base_url = PHPWG_ROOT_PATH.'admin.php';
140
141// $form_action = $base_url.'?page=element_set_global';
142
143$template->assign_vars(
144  array(
145    'CATEGORIES_NAV'=>$page['title'],
146
147    'L_SUBMIT'=>$lang['submit'],
148   
149    'U_ELEMENTS_PAGE'
150    =>$base_url.get_query_string_diff(array('display','start')),
151   
152    'U_GLOBAL_MODE'
153    =>
154    $base_url
155    .get_query_string_diff(array('mode','display'))
156    .'&amp;mode=global',
157   
158    'F_ACTION'=>$base_url.get_query_string_diff(array()),
159    )
160  );
161
162// +-----------------------------------------------------------------------+
163// |                        global mode thumbnails                         |
164// +-----------------------------------------------------------------------+
165
166// how many items to display on this page
167if (!empty($_GET['display']))
168{
169  if ('all' == $_GET['display'])
170  {
171    $page['nb_images'] = count($page['cat_elements_id']);
172  }
173  else
174  {
175    $page['nb_images'] = intval($_GET['display']);
176  }
177}
178else
179{
180  $page['nb_images'] = 5;
181}
182
183
184
185if (count($page['cat_elements_id']) > 0)
186{
187  $nav_bar = create_navigation_bar(
188    $base_url.get_query_string_diff(array('start')),
189    count($page['cat_elements_id']),
190    $page['start'],
191    $page['nb_images']
192    );
193  $template->assign_vars(array('NAV_BAR' => $nav_bar));
194
195 
196  $element_ids = array();
197
198  $query = '
199SELECT id,path,tn_ext,name,date_creation,comment,keywords,author,file
200  FROM '.IMAGES_TABLE.'
201  WHERE id IN ('.implode(',', $page['cat_elements_id']).')
202  '.$conf['order_by'].'
203  LIMIT '.$page['start'].', '.$page['nb_images'].'
204;';
205  $result = pwg_query($query);
206
207  while ($row = mysql_fetch_array($result))
208  {
209    // echo '<pre>'; print_r($row); echo '</pre>';
210    array_push($element_ids, $row['id']);
211   
212    $src = get_thumbnail_src($row['path'], @$row['tn_ext']);
213   
214    // creation date
215    if (!empty($row['date_creation']))
216    {
217      list($year,$month,$day) = explode('-', $row['date_creation']);
218    }
219    else
220    {
221      list($year,$month,$day) = array('','','');
222    }
223   
224    $template->assign_block_vars(
225      'element',
226      array(
227        'LEGEND' =>
228          !empty($row['name']) ?
229            $row['name'] : get_name_from_file($row['file']),
230        'U_EDIT' =>
231            PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
232            '&amp;image_id='.$row['id'],
233        'ID' => $row['id'],
234        'FILENAME' => $row['path'],
235        'TN_SRC' => $src,
236        'NAME' => @$row['name'],
237        'AUTHOR' => @$row['author'],
238        'DESCRIPTION' => @$row['comment'],
239        'DATE_CREATION_YEAR' => $year,
240        'KEYWORDS' => @$row['keywords']
241        )
242      );
243   
244    get_day_list('element.date_creation_day', $day);
245    get_month_list('element.date_creation_month', $month);
246  }
247
248  $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids)));
249}
250
251// +-----------------------------------------------------------------------+
252// |                           sending html code                           |
253// +-----------------------------------------------------------------------+
254
255$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit');
256?>
Note: See TracBrowser for help on using the repository browser.