Changeset 133
- Timestamp:
- Sep 19, 2003, 11:40:52 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r68 r133 292 292 293 293 // update_category updates calculated informations about a category : 294 // date_last and nb_images 294 // date_last and nb_images. It also verifies that the representative picture 295 // is really linked to the category. 295 296 function update_category( $id = 'all' ) 296 297 { … … 334 335 $query.= ';'; 335 336 mysql_query( $query ); 337 // updating the representative_picture_id : if the representative 338 // picture of the category is not any more linked to the category, we 339 // have to set representative_picture_id to NULL 340 $query = 'SELECT representative_picture_id'; 341 $query.= ' FROM '.PREFIX_TABLE.'categories'; 342 $query.= ' WHERE id = '.$id; 343 $row = mysql_fetch_array( mysql_query( $query ) ); 344 // if the category has no representative picture (ie 345 // representative_picture_id == NULL) we don't update anything 346 if ( $row['representative_picture_id'] != '' ) 347 { 348 $query = 'SELECT image_id'; 349 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 350 $query.= ' WHERE category_id = '.$id; 351 $query.= ' AND image_id = '.$row['representative_picture_id']; 352 $query.= ';'; 353 $result = mysql_query( $query ); 354 if ( mysql_num_rows( $result ) == 0 ) 355 { 356 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 357 $query.= ' SET representative_picture_id = NULL'; 358 $query.= ' WHERE id = '.$id; 359 $query.= ';'; 360 mysql_query( $query ); 361 } 362 } 336 363 } 337 364 } -
trunk/admin/picture_modify.php
r61 r133 74 74 $query.= ';'; 75 75 mysql_query( $query ); 76 // make the picture representative of a category ? 77 $query = 'SELECT DISTINCT(category_id) as category_id'; 78 $query.= ',representative_picture_id'; 79 $query.= ' FROM '.PREFIX_TABLE.'image_category AS ic'; 80 $query.= ', '.PREFIX_TABLE.'categories AS c'; 81 $query.= ' WHERE c.id = ic.category_id'; 82 $query.= ' AND image_id = '.$_GET['image_id']; 83 $query.= ';'; 84 $result = mysql_query( $query ); 85 while ( $row = mysql_fetch_array( $result ) ) 86 { 87 // if the user ask the picture to be the representative picture of its 88 // category, the category is updated in the database (without wondering 89 // if this picture was already the representative one) 90 if ( $_POST['representative-'.$row['category_id']] == 1 ) 91 { 92 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 93 $query.= ' SET representative_picture_id = '.$_GET['image_id']; 94 $query.= ' WHERE id = '.$row['category_id']; 95 $query.= ';'; 96 mysql_query( $query ); 97 } 98 // if the user ask this picture to be not any more the representative, 99 // we have to set the representative_picture_id of this category to NULL 100 else if ( $row['representative_picture_id'] == $_GET['image_id'] ) 101 { 102 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 103 $query.= ' SET representative_picture_id = NULL'; 104 $query.= ' WHERE id = '.$row['category_id']; 105 $query.= ';'; 106 mysql_query( $query ); 107 } 108 } 76 109 // associate with a new category ? 77 110 if ( $_POST['associate'] != '-1' ) … … 112 145 'author','creation_date','keywords','comment', 'upload_name', 113 146 'dissociate','categories','infoimage_associate', 114 'cat_image_info' );147 'cat_image_info','category_representative' ); 115 148 templatize_array( $tpl, 'lang', $sub ); 116 149 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); … … 206 239 $vtp->setVar( $sub, 'linked_category.invisible', $invisible_string ); 207 240 } 241 $vtp->setVar( $sub, 'linked_category.id', $row['storage_category_id'] ); 242 if ( $result['representative_picture_id'] == $_GET['image_id'] ) 243 { 244 $vtp->setVar( $sub, 'linked_category.representative_checked', 245 ' checked="checked"' ); 246 } 208 247 $vtp->closeSession( $sub, 'linked_category' ); 209 248 // retrieving all the linked categories 210 249 $query = 'SELECT DISTINCT(category_id) as category_id,status,visible'; 250 $query.= ',representative_picture_id'; 211 251 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 212 252 $query.= ','.PREFIX_TABLE.'categories'; … … 219 259 { 220 260 $vtp->addSession( $sub, 'linked_category' ); 261 $vtp->setVar( $sub, 'linked_category.id', $row['category_id'] ); 221 262 222 263 $vtp->addSession( $sub, 'checkbox' ); … … 250 291 } 251 292 293 if ( $row['representative_picture_id'] == $_GET['image_id'] ) 294 { 295 $vtp->setVar( $sub, 'linked_category.representative_checked', 296 ' checked="checked"' ); 297 } 298 252 299 $vtp->closeSession( $sub, 'linked_category' ); 253 300 } -
trunk/include/functions_category.inc.php
r83 r133 289 289 290 290 $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir'; 291 $query.= ',date_last,uploadable,status,visible ';291 $query.= ',date_last,uploadable,status,visible,representative_picture_id'; 292 292 $query.= ' FROM '.PREFIX_TABLE.'categories AS a'; 293 293 $query.= ', '.PREFIX_TABLE.'sites AS b'; … … 304 304 $cat['status'] = $row['status']; 305 305 $cat['visible'] = get_boolean( $row['visible'] ); 306 $cat['representative_picture_id'] = $row['representative_picture_id']; 306 307 307 308 $cat['name'] = array(); -
trunk/language/francais.php
r128 r133 34 34 $lang['default'] = 'défaut'; 35 35 $lang['comments'] = 'commentaires'; 36 $lang['category_representative'] = 'représentant'; 36 37 // end version 1.3 37 38 -
trunk/template/default/admin/picture_modify.vtp
r74 r133 66 66 <!--VTP_linked_category--> 67 67 <tr> 68 <td><!--VTP_checkbox--><input type="checkbox" name="dissociate-{#id}" value="1" /><!--/VTP_checkbox--><a href="{#url}">{#name}</a> [ <a href="{#infos_images_link}">{#cat_image_info}</a> ] {#private} {#invisible} 68 <td><!--VTP_checkbox--><input type="checkbox" name="dissociate-{#id}" value="1" /><!--/VTP_checkbox--><a href="{#url}">{#name}</a> [ <a href="{#infos_images_link}">{#cat_image_info}</a> ] {#private} {#invisible} [ <input type="checkbox" name="representative-{#id}" value="1"{#representative_checked} /> {#category_representative} ] 69 69 </tr> 70 70 <!--/VTP_linked_category-->
Note: See TracChangeset
for help on using the changeset viewer.