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 16:56:32 +0000 (Sat, 16 Apr 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 764 $ |
---|
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 | // | template init | |
---|
103 | // +-----------------------------------------------------------------------+ |
---|
104 | |
---|
105 | $template->set_filenames( |
---|
106 | array('element_set_unit' => 'admin/element_set_unit.tpl')); |
---|
107 | |
---|
108 | $base_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
109 | |
---|
110 | // $form_action = $base_url.'?page=element_set_global'; |
---|
111 | |
---|
112 | $template->assign_vars( |
---|
113 | array( |
---|
114 | 'CATEGORY_TITLE'=>$page['title'], |
---|
115 | |
---|
116 | 'L_SUBMIT'=>$lang['submit'], |
---|
117 | |
---|
118 | 'U_ELEMENTS_PAGE' |
---|
119 | =>$base_url.get_query_string_diff(array('display','start')), |
---|
120 | |
---|
121 | 'U_GLOBAL_MODE' |
---|
122 | => |
---|
123 | $base_url |
---|
124 | .get_query_string_diff(array('mode','display')) |
---|
125 | .'&mode=global', |
---|
126 | |
---|
127 | 'F_ACTION'=>$base_url.get_query_string_diff(array()), |
---|
128 | ) |
---|
129 | ); |
---|
130 | |
---|
131 | // +-----------------------------------------------------------------------+ |
---|
132 | // | global mode thumbnails | |
---|
133 | // +-----------------------------------------------------------------------+ |
---|
134 | |
---|
135 | $page['nb_images'] = !empty($_GET['display']) ? intval($_GET['display']) : 5; |
---|
136 | |
---|
137 | |
---|
138 | if (count($page['cat_elements_id']) > 0) |
---|
139 | { |
---|
140 | $nav_bar = create_navigation_bar( |
---|
141 | $base_url.get_query_string_diff(array('start')), |
---|
142 | count($page['cat_elements_id']), |
---|
143 | $page['start'], |
---|
144 | $page['nb_images'], |
---|
145 | ''); |
---|
146 | $template->assign_vars(array('NAV_BAR' => $nav_bar)); |
---|
147 | |
---|
148 | |
---|
149 | $element_ids = array(); |
---|
150 | |
---|
151 | $query = ' |
---|
152 | SELECT id,path,tn_ext,name,date_creation,comment,keywords,author |
---|
153 | FROM '.IMAGES_TABLE.' |
---|
154 | WHERE id IN ('.implode(',', $page['cat_elements_id']).') |
---|
155 | '.$conf['order_by'].' |
---|
156 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
157 | ;'; |
---|
158 | $result = pwg_query($query); |
---|
159 | |
---|
160 | while ($row = mysql_fetch_array($result)) |
---|
161 | { |
---|
162 | // echo '<pre>'; print_r($row); echo '</pre>'; |
---|
163 | array_push($element_ids, $row['id']); |
---|
164 | |
---|
165 | $src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
166 | |
---|
167 | // creation date |
---|
168 | if (!empty($row['date_creation'])) |
---|
169 | { |
---|
170 | list($year,$month,$day) = explode('-', $row['date_creation']); |
---|
171 | } |
---|
172 | else |
---|
173 | { |
---|
174 | list($year,$month,$day) = array('','',''); |
---|
175 | } |
---|
176 | |
---|
177 | $template->assign_block_vars( |
---|
178 | 'element', |
---|
179 | array( |
---|
180 | 'ID' => $row['id'], |
---|
181 | 'FILENAME' => $row['path'], |
---|
182 | 'TN_SRC' => $src, |
---|
183 | 'NAME' => @$row['name'], |
---|
184 | 'AUTHOR' => @$row['author'], |
---|
185 | 'COMMENT' => @$row['comment'], |
---|
186 | 'DATE_CREATION_YEAR' => $year, |
---|
187 | 'KEYWORDS' => @$row['keywords'] |
---|
188 | ) |
---|
189 | ); |
---|
190 | |
---|
191 | get_day_list('element.date_creation_day', $day); |
---|
192 | get_month_list('element.date_creation_month', $month); |
---|
193 | } |
---|
194 | |
---|
195 | $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids))); |
---|
196 | } |
---|
197 | |
---|
198 | // +-----------------------------------------------------------------------+ |
---|
199 | // | sending html code | |
---|
200 | // +-----------------------------------------------------------------------+ |
---|
201 | |
---|
202 | $template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit'); |
---|
203 | ?> |
---|