| [ PHPXref.com ] | [ Generated: Sun Jul 20 21:17:54 2008 ] | [ Zoph 0.5.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /* This file is part of Zoph. 3 * 4 * Zoph is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * Zoph is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with Zoph; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 */ 17 require_once ("include.inc.php"); 18 19 $_cols = getvar("_cols"); 20 $_rows = getvar("_rows"); 21 $_off = getvar("_off"); 22 $_order = getvar("_order"); 23 $_dir = getvar("_dir"); 24 25 if (!$_cols) { $_cols = $DEFAULT_COLS; } 26 if (!$_rows) { $_rows = $DEFAULT_ROWS; } 27 if (!$_off) { $_off = 0; } 28 29 if (!$_order) { $_order = $DEFAULT_ORDER; } 30 if (!$_dir) { $_dir = $DEFAULT_DIRECTION; } 31 32 $cells = $_cols * $_rows; 33 $offset = $_off; 34 35 $thumbnails; 36 $clean_vars = clean_request_vars($request_vars); 37 $num_photos = 38 get_photos($clean_vars, $offset, $cells, $thumbnails, $user); 39 40 $num_thumbnails = sizeof($thumbnails); 41 42 if ($num_thumbnails) { 43 $num_pages = ceil($num_photos / $cells); 44 $page_num = floor($offset / $cells) + 1; 45 46 $num = min($cells, $num_thumbnails); 47 48 $title = sprintf(translate("Edit Photos (Page %s/%s)", 0), $page_num, $num_pages); 49 $title_bar = sprintf(translate("edit photos %s to %s of %s"), ($offset + 1), ($offset + $num), $num_photos); 50 } 51 else { 52 $title = translate("No Photos Found"); 53 $title_bar = translate("edit photos"); 54 } 55 56 require_once ("header.inc.php"); 57 ?> 58 <h1><?php echo $title_bar ?></h1> 59 <div class="main"> 60 <form action="edit_photos.php" method="POST"> 61 <?php 62 if ($num_thumbnails <= 0) { 63 ?> 64 <div class="error"> 65 <?php echo translate("No photos were found matching your search criteria.") ?> 66 </div> 67 <?php 68 } 69 else { 70 // create once 71 $category_pulldown = create_pulldown("_category", "", get_categories_select_array($user)); 72 $album_pulldown = create_pulldown("_album", "", get_albums_select_array($user)); 73 $place_pulldown = get_places_select_array(); 74 75 // used to create hidden fields for recreating the results query 76 $queryIgnoreArray[] = '_action'; 77 $queryIgnoreArray[] = '_overwrite'; 78 $queryIgnoreArray[] = '__location_id__all'; 79 $queryIgnoreArray[] = '__photographer_id__all'; 80 $queryIgnoreArray[] = '_rating__all'; 81 $queryIgnoreArray[] = '_album__all'; 82 $queryIgnoreArray[] = '_category__all'; 83 ?> 84 <input type="submit" value="<? echo translate("update", 0) ?>"> 85 <fieldset class="editphotos"> 86 <legend><?php echo translate("All photos")?></legend> 87 <input type="hidden" name="_action" value="update"> 88 <label for="overwrite"><?php echo translate("overwrite values below", 0) ?></label> 89 <?php echo create_pulldown("_overwrite", "0", array("0" => translate("No"), "1" => translate("Yes"))) ?><br> 90 <label for="location_id__all"><?php echo translate("location") ?></label> 91 <?php echo create_smart_pulldown("__location_id__all", null, $place_pulldown) ?><br> 92 <label for="photographer_id__all"><?php echo translate("photographer") ?></label> 93 <?php echo create_smart_pulldown("__photographer_id__all", null, get_people_select_array()) ?><br> 94 <label for="rating__all"><?php echo translate("rating") ?></label> 95 <?php echo create_rating_pulldown(null, "_rating__all") ?><br> 96 <label for="album"><?php echo translate("albums") ?></label> 97 <?php echo str_replace("_album", "_album__all", $album_pulldown) ?><br> 98 <label for="category"><?php echo translate("categories") ?></label> 99 <?php echo str_replace("_category", "_category__all", $category_pulldown) ?><br> 100 </fieldset> 101 <?php 102 for ($i = 0; $i < $num_thumbnails; $i++) { 103 $photo_id = $thumbnails[$i]->get('photo_id'); 104 105 $permissions = $user->get_permissions_for_photo($photo_id); 106 if (!$user->is_admin() && !$permissions) { 107 continue; 108 } 109 110 $can_edit = false; 111 $can_edit = $user->is_admin() || $permissions->get("writable"); 112 113 $photo = new photo($photo_id); 114 115 $action = $request_vars["_action__$photo_id"]; 116 if ($can_edit && $action == 'update') { 117 118 $rating = null; 119 if ($request_vars['_overwrite']) { 120 // set any specific fields 121 $photo->set_fields($request_vars, '__', "__$photo_id"); 122 // set "apply to all" fields 123 $photo->set_fields($request_vars, '__', '__all'); 124 125 $rating = $request_vars["_rating__$photo_id"]; 126 if ($request_vars["_rating__all"]) { 127 $rating = $request_vars["_rating__all"]; 128 } 129 } 130 else { // reverse order 131 $photo->set_fields($request_vars, '__', '__all'); 132 $photo->set_fields($request_vars, '__', "__$photo_id"); 133 134 $rating = $request_vars["_rating__all"]; 135 if ($request_vars["_rating__$photo_id"]) { 136 $rating = $request_vars["_rating__$photo_id"]; 137 } 138 } 139 140 if ($rating != null) { 141 if (ALLOW_RATINGS) { // multiple ratings 142 $photo->rate($user->get('user_id'), $rating); 143 } 144 else { // single rating 145 $photo->set('rating', $rating); 146 } 147 } 148 149 // this will update any specific albums, cats & people 150 $photo->update($request_vars, "__$photo_id"); 151 152 // update "apply to all" albums, cats & people 153 154 $photo->update_relations($request_vars, '__all'); 155 156 $deg = $request_vars["_deg__$photo_id"]; 157 if ($deg && $deg != 0) { 158 $photo->lookup($user); 159 $photo->rotate($deg); 160 } 161 } 162 else if ($can_edit && $action == 'delete') { 163 $photo->delete(); 164 continue; 165 } 166 167 if ($action == "update") { 168 $request_vars["_action"]="display"; 169 } 170 171 $photo->lookup($user); 172 173 $queryIgnoreArray[] = "__photo_id__$photo_id"; 174 $queryIgnoreArray[] = "__location_id__$photo_id"; 175 $queryIgnoreArray[] = "__photographer_id__$photo_id"; 176 $queryIgnoreArray[] = "__title__$photo_id"; 177 $queryIgnoreArray[] = "__description__$photo_id"; 178 $queryIgnoreArray[] = "_rating__$photo_id"; 179 $queryIgnoreArray[] = "_album__$photo_id"; 180 $queryIgnoreArray[] = "_remove_album__$photo_id"; 181 $queryIgnoreArray[] = "_category__$photo_id"; 182 $queryIgnoreArray[] = "_remove_category__$photo_id"; 183 $queryIgnoreArray[] = "_remove_person__$photo_id"; 184 for ($p = 0; $p < $user->prefs->get("people_slots"); $p++ ) { 185 $queryIgnoreArray[] = "_position_" . $p . "__" . $photo_id; 186 $queryIgnoreArray[] = "_person_" . $p . "__" . $photo_id; 187 } 188 $queryIgnoreArray[] = "_deg__$photo_id"; 189 $queryIgnoreArray[] = "_action__$photo_id"; 190 ?> 191 <fieldset class="editphotos"> 192 <legend><?php echo $photo->get('name')?></legend> 193 <div class="editchoice"> 194 <?php 195 if ($can_edit) { 196 ?> 197 <input type="hidden" name="__photo_id__<?php echo $photo_id ?>" value="<?php echo $photo_id ?>"> 198 <input type="radio" name="_action__<?php echo $photo_id ?>" value="update" checked><?php echo translate("edit", 0) ?><br> 199 <input type="radio" name="_action__<?php echo $photo_id ?>" value=""><?php echo translate("skip", 0) ?><br> 200 <input type="radio" name="_action__<?php echo $photo_id ?>" value="delete"><?php echo translate("delete", 0) ?> 201 <?php 202 } 203 else { 204 echo " "; 205 } 206 ?> 207 </div> 208 <div class="thumbnail"> 209 <?php echo $photo->get_thumbnail_link("photo.php?photo_id=$photo_id") . "\n" ?><br> 210 <?php 211 if ($can_edit && ALLOW_ROTATIONS && 212 ($user->is_admin() || $permissions->get("writable"))) { 213 ?> 214 <?php echo translate("rotate", 0) ?> 215 <select name="_deg__<?php echo $photo_id ?>"> 216 <option> </option> 217 <option>90</option> 218 <option>180</option> 219 <option>270</option> 220 </select> 221 <?php 222 } 223 ?> 224 </div> 225 <?php 226 if (!$can_edit) { 227 ?> 228 <?php echo $photo->get('name') ?>:<br> 229 <?php echo translate("Insufficient permissions to edit photo", 0)?>. 230 <?php 231 } 232 else { 233 ?> 234 <fieldset class="editphotos-fields"> 235 <label for="location_id__<?php echo $photo_id ?>"><?php echo translate("location") ?></label> 236 <?php echo create_smart_pulldown("__location_id__$photo_id", $photo->get("location_id"), $place_pulldown) ?><br> 237 <label for="photographer_id__<?php echo $photo_id?>"><?php echo translate("photographer") ?></label> 238 <?php echo create_smart_pulldown("__photographer_id__$photo_id", $photo->get("photographer_id"), get_people_select_array()) ?><br> 239 <label for="rating__<?php echo $photo_id?>"><?php echo translate("rating") ?></label> 240 <?php 241 $rating = $photo->get('rating'); 242 if (ALLOW_RATINGS) { 243 $rating = $photo->get_rating($user->get('user_id')); 244 } 245 ?> 246 <?php echo create_rating_pulldown($rating, "_rating__$photo_id") ?> 247 <br> 248 <label for="album__<?php echo $photo_id?>"><?php echo translate("albums") ?></label> 249 <fieldset class="checkboxlist"> 250 <?php 251 $albums = $photo->lookup_albums($user); 252 if ($albums) { 253 $append = ""; 254 foreach ($albums as $album) { 255 ?> 256 <?php echo $append ?> 257 <input type="checkbox" name="_remove_album__<?php echo $photo_id ?>[]" value="<?php echo $album->get("album_id") ?>"> 258 <?php echo $album->get_link() ?> 259 <?php 260 $append = "<br>"; 261 } 262 echo "<br>\n"; 263 } 264 ?> 265 <?php echo str_replace("album", "album__$photo_id", $album_pulldown) ?> 266 </fieldset> 267 <label for="category__<?php echo $photo_id?>"><?php echo translate("categories") ?></label> 268 <fieldset class="checkboxlist"> 269 <?php 270 $categories = $photo->lookup_categories($user); 271 if ($categories) { 272 $append = ""; 273 foreach ($categories as $category) { 274 ?> 275 <?php echo $append ?> 276 <input type="checkbox" name="_remove_category__<?php echo $photo_id ?>[]" value="<?php echo $category->get("category_id") ?>"> 277 <?php echo $category->get_link() ?> 278 <?php 279 $append = "<br>\n"; 280 } 281 echo "<br>\n"; 282 } 283 ?> 284 <?php echo str_replace("category", "category__$photo_id", $category_pulldown) ?> 285 </fieldset> 286 <label for="person_0__<?php echo $photo_id ?>"><?php echo translate("people") ?></label> 287 <fieldset class="checkboxlist"> 288 <?php 289 $people = $photo->lookup_people(); 290 $next_pos = 1; 291 if ($people) { 292 $append = ""; 293 foreach ($people as $person) { 294 $next_pos++; 295 ?> 296 <?php echo $append ?> 297 <input type="checkbox" name="_remove_person__<?php echo $photo_id ?>[]" value="<?php echo $person->get("person_id") ?>"> 298 <?php echo $person->get_link() ?> 299 <?php 300 $append = "<br>\n"; 301 } 302 echo "<br>\n"; 303 } 304 for ($p = 0; $p < $user->prefs->get("people_slots"); $p++ ) { 305 ?> 306 <?php echo create_smart_pulldown("_person_" . $p . "__" . $photo_id, "", get_people_select_array()) ?> 307 <?php echo translate("position") ?>: 308 <?php echo create_text_input("_position_" . $p ."__" . $photo_id, $next_pos + $p, 2, 2) ?><br> 309 <?php 310 } 311 ?> 312 </fieldset> 313 <label for="title__<?php echo $photo_id?>"><?php echo translate("title") ?></label> 314 <?php echo create_text_input("__title__$photo_id", $photo->get("title"), 40, 64) ?> 315 <br> 316 <label for="description__<?php echo $photo_id?>"><?php echo translate("description") ?></label> 317 <textarea name="__description__<?php echo $photo_id ?>" id="description__<?php echo $photo_id?>" class="desc" cols="50" rows="3"><?php echo $photo->get("description") ?></textarea> 318 <br> 319 </fieldset> 320 </fieldset> 321 <?php 322 } 323 } 324 ?> 325 <?php echo create_form($clean_vars, $queryIgnoreArray) ?> 326 <input type="submit" value="<? echo translate("update", 0) ?>"> 327 </form> 328 329 <?php 330 // Here we clean out $request_vars, so the pager links will not contain 331 // all the edits made on this page. 332 while (list($key, $val) = each($clean_vars)) { 333 if (in_array($key, $queryIgnoreArray)) { continue; } 334 $pager_vars[$key] = $val; 335 } 336 $request_vars = $pager_vars; 337 include "pager.inc.php"; 338 } // if photos 339 ?> 340 <br> 341 </div> 342 343 <?php require_once ("footer.inc.php"); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |