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-04-16 07:49:55 +0000 (Sat, 16 Apr 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 763 $ |
---|
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 | |
---|
34 | if (!defined('PHPWG_ROOT_PATH')) |
---|
35 | { |
---|
36 | die('Hacking attempt!'); |
---|
37 | } |
---|
38 | include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
---|
39 | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | // | unit mode form submission | |
---|
42 | // +-----------------------------------------------------------------------+ |
---|
43 | $errors = array(); |
---|
44 | |
---|
45 | if (isset($_POST['submit'])) |
---|
46 | { |
---|
47 | $collection = explode(',', $_POST['list']); |
---|
48 | |
---|
49 | // echo '<pre>'; |
---|
50 | // print_r($_POST); |
---|
51 | // echo '</pre>'; |
---|
52 | // exit(); |
---|
53 | |
---|
54 | $datas = array(); |
---|
55 | $dbfields = |
---|
56 | array( |
---|
57 | 'primary' => array('id'), |
---|
58 | 'update' => array('name','author','comment','date_creation','keywords') |
---|
59 | ); |
---|
60 | |
---|
61 | $query = ' |
---|
62 | SELECT id, date_creation |
---|
63 | FROM '.IMAGES_TABLE.' |
---|
64 | WHERE id IN ('.implode(',', $collection).') |
---|
65 | ;'; |
---|
66 | $result = pwg_query($query); |
---|
67 | |
---|
68 | while ($row = mysql_fetch_array($result)) |
---|
69 | { |
---|
70 | $data = array(); |
---|
71 | $data['id'] = $row['id']; |
---|
72 | |
---|
73 | foreach (array_diff($dbfields['update'], array('date_creation')) as $field) |
---|
74 | { |
---|
75 | if (!empty($_POST[$field.'-'.$row['id']])) |
---|
76 | { |
---|
77 | $data[$field] = $_POST[$field.'-'.$row['id']]; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | if ('set' == $_POST['date_creation_action-'.$row['id']]) |
---|
82 | { |
---|
83 | $data['date_creation'] = |
---|
84 | $_POST['date_creation_year-'.$row['id']] |
---|
85 | .'-'.$_POST['date_creation_month-'.$row['id']] |
---|
86 | .'-'.$_POST['date_creation_day-'.$row['id']] |
---|
87 | ; |
---|
88 | } |
---|
89 | else if ('leave' == $_POST['date_creation_action-'.$row['id']] |
---|
90 | and !empty($row['date_creation'])) |
---|
91 | { |
---|
92 | $data['date_creation'] = $row['date_creation']; |
---|
93 | } |
---|
94 | |
---|
95 | array_push($datas, $data); |
---|
96 | } |
---|
97 | // echo '<pre>'; print_r($datas); echo '</pre>'; |
---|
98 | mass_updates(IMAGES_TABLE, $dbfields, $datas); |
---|
99 | } |
---|
100 | |
---|
101 | // +-----------------------------------------------------------------------+ |
---|
102 | // | page information init | |
---|
103 | // +-----------------------------------------------------------------------+ |
---|
104 | |
---|
105 | // $page['start'] contains the number of the first element in its |
---|
106 | // category. For exampe, $page['start'] = 12 means we must show elements #12 |
---|
107 | // and $page['nb_images'] next elements |
---|
108 | if (!isset($_GET['start']) |
---|
109 | or !is_numeric($_GET['start']) |
---|
110 | or $_GET['start'] < 0) |
---|
111 | { |
---|
112 | $page['start'] = 0; |
---|
113 | } |
---|
114 | else |
---|
115 | { |
---|
116 | $page['start'] = $_GET['start']; |
---|
117 | } |
---|
118 | |
---|
119 | // $page['nb_images'] is the number of elements to show in the page |
---|
120 | $page['nb_images'] = !empty($_GET['display']) ? $_GET['display'] : 5; |
---|
121 | |
---|
122 | // $page['cat_nb_images'] is the total number of elements to show in the |
---|
123 | // category |
---|
124 | $query = ' |
---|
125 | SELECT COUNT(*) |
---|
126 | FROM '.CADDIE_TABLE.' |
---|
127 | WHERE user_id = '.$user['id'].' |
---|
128 | ;'; |
---|
129 | list($page['cat_nb_images']) = mysql_fetch_row(pwg_query($query)); |
---|
130 | |
---|
131 | // +-----------------------------------------------------------------------+ |
---|
132 | // | template init | |
---|
133 | // +-----------------------------------------------------------------------+ |
---|
134 | |
---|
135 | $template->set_filenames( |
---|
136 | array('element_set_unit' => 'admin/element_set_unit.tpl')); |
---|
137 | |
---|
138 | $base_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
139 | |
---|
140 | // $form_action = $base_url.'?page=element_set_global'; |
---|
141 | |
---|
142 | $template->assign_vars( |
---|
143 | array( |
---|
144 | 'L_SUBMIT'=>$lang['submit'], |
---|
145 | |
---|
146 | 'U_ELEMENTS_PAGE' |
---|
147 | =>$base_url.get_query_string_diff(array('display','start')), |
---|
148 | |
---|
149 | 'U_GLOBAL_MODE' |
---|
150 | // =>$base_url.get_query_string_diff(array('mode','display','start')), |
---|
151 | =>add_session_id($base_url.'?page=element_set_global'), |
---|
152 | |
---|
153 | 'F_ACTION'=>$base_url.get_query_string_diff(array()), |
---|
154 | ) |
---|
155 | ); |
---|
156 | |
---|
157 | // +-----------------------------------------------------------------------+ |
---|
158 | // | global mode thumbnails | |
---|
159 | // +-----------------------------------------------------------------------+ |
---|
160 | |
---|
161 | $element_ids = array(); |
---|
162 | |
---|
163 | $query = ' |
---|
164 | SELECT element_id,path,tn_ext,name,date_creation,comment,keywords,author |
---|
165 | FROM '.IMAGES_TABLE.' INNER JOIN '.CADDIE_TABLE.' ON id=element_id |
---|
166 | WHERE user_id = '.$user['id'].' |
---|
167 | '.$conf['order_by'].' |
---|
168 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
169 | ;'; |
---|
170 | $result = pwg_query($query); |
---|
171 | |
---|
172 | while ($row = mysql_fetch_array($result)) |
---|
173 | { |
---|
174 | // echo '<pre>'; print_r($row); echo '</pre>'; |
---|
175 | array_push($element_ids, $row['element_id']); |
---|
176 | |
---|
177 | $src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
178 | |
---|
179 | // creation date |
---|
180 | if (!empty($row['date_creation'])) |
---|
181 | { |
---|
182 | list($year,$month,$day) = explode('-', $row['date_creation']); |
---|
183 | } |
---|
184 | else |
---|
185 | { |
---|
186 | list($year,$month,$day) = array('','',''); |
---|
187 | } |
---|
188 | |
---|
189 | $template->assign_block_vars( |
---|
190 | 'element', |
---|
191 | array( |
---|
192 | 'ID' => $row['element_id'], |
---|
193 | 'FILENAME' => $row['path'], |
---|
194 | 'TN_SRC' => $src, |
---|
195 | 'NAME' => @$row['name'], |
---|
196 | 'AUTHOR' => @$row['author'], |
---|
197 | 'COMMENT' => @$row['comment'], |
---|
198 | 'DATE_CREATION_YEAR' => $year, |
---|
199 | 'KEYWORDS' => @$row['keywords'] |
---|
200 | ) |
---|
201 | ); |
---|
202 | |
---|
203 | get_day_list('element.date_creation_day', $day); |
---|
204 | get_month_list('element.date_creation_month', $month); |
---|
205 | } |
---|
206 | |
---|
207 | $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids))); |
---|
208 | |
---|
209 | $nav_bar = create_navigation_bar( |
---|
210 | $base_url.get_query_string_diff(array('start')), |
---|
211 | $page['cat_nb_images'], |
---|
212 | $page['start'], |
---|
213 | $page['nb_images'], |
---|
214 | ''); |
---|
215 | $template->assign_vars(array('NAV_BAR' => $nav_bar)); |
---|
216 | |
---|
217 | // +-----------------------------------------------------------------------+ |
---|
218 | // | sending html code | |
---|
219 | // +-----------------------------------------------------------------------+ |
---|
220 | |
---|
221 | $template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit'); |
---|
222 | ?> |
---|