Changeset 633
- Timestamp:
- Dec 4, 2004, 6:42:07 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_modify.php
r632 r633 80 80 81 81 $template->assign_block_vars('confirmation' ,array()); 82 } 83 else if (isset($_POST['set_random_representant'])) 84 { 85 set_random_representant(array($_GET['cat_id'])); 82 86 } 83 87 … … 158 162 'L_NO'=>$lang['no'], 159 163 'L_SUBMIT'=>$lang['submit'], 164 'L_SET_RANDOM_REPRESENTANT'=>$lang['set_random_representant'], 160 165 161 166 'F_ACTION'=>add_session_id($form_action) 162 167 )); 163 168 169 if ($category['nb_images'] > 0) 170 { 171 $query = ' 172 SELECT tn_ext,path 173 FROM '.IMAGES_TABLE.' 174 WHERE id = '.$category['representative_picture_id'].' 175 ;'; 176 $row = mysql_fetch_array(pwg_query($query)); 177 $src = get_thumbnail_src($row['path'], @$row['tn_ext']); 178 $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; 179 $url.= '&image_id='.$category['representative_picture_id']; 180 $template->assign_block_vars('representant', 181 array('SRC' => $src, 182 'URL' => $url)); 183 } 184 164 185 if (!empty($category['dir'])) 165 186 { -
trunk/admin/include/functions.php
r632 r633 454 454 455 455 $query = ' 456 SELECT category_id, COUNT(image_id) AS count, max(date_available) AS date_last 456 SELECT category_id, 457 COUNT(image_id) AS nb_images, 458 MAX(date_available) AS date_last 457 459 FROM '.IMAGES_TABLE.' 458 460 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; … … 472 474 array_push($datas, array('id' => $row['category_id'], 473 475 'date_last' => $row['date_last'], 474 ' count' => $row['count']));476 'nb_images' => $row['nb_images'])); 475 477 } 476 478 $fields = array('primary' => array('id'), 477 'update' => array('date_last', ' count'));479 'update' => array('date_last', 'nb_images')); 478 480 mass_updates(CATEGORIES_TABLE, $fields, $datas); 479 481 … … 840 842 $query = 'SELECT VERSION() AS version;'; 841 843 $row = mysql_fetch_array(pwg_query($query)); 842 if ( version_compare($row['version'],'4.0.4') < 0)844 if (count($datas) < 10 or version_compare($row['version'],'4.0.4') < 0) 843 845 { 844 846 // MySQL is prior to version 4.0.4, multi table update feature is not 845 847 // available 846 echo 'MySQL is prior to version 4.0.4, multi table update feature is not available<br />';847 848 foreach ($datas as $data) 848 849 { … … 915 916 ;'; 916 917 pwg_query($query); 917 mass_inserts($tablename , $all_fields, $datas);918 mass_inserts($tablename.'_temporary', $all_fields, $datas); 918 919 // update of images table by joining with temporary table 919 920 $query = ' … … 1093 1094 } 1094 1095 } 1096 1097 /** 1098 * set a new random representant to the categories 1099 * 1100 * @param array categories 1101 */ 1102 function set_random_representant($categories) 1103 { 1104 $datas = array(); 1105 foreach ($categories as $category_id) 1106 { 1107 $query = ' 1108 SELECT image_id 1109 FROM '.IMAGE_CATEGORY_TABLE.' 1110 WHERE category_id = '.$category_id.' 1111 ORDER BY RAND() 1112 LIMIT 0,1 1113 ;'; 1114 list($representative) = mysql_fetch_array(pwg_query($query)); 1115 $data = array('id' => $category_id, 1116 'representative_picture_id' => $representative); 1117 array_push($datas, $data); 1118 } 1119 1120 $fields = array('primary' => array('id'), 1121 'update' => array('representative_picture_id')); 1122 mass_updates(CATEGORIES_TABLE, $fields, $datas); 1123 } 1095 1124 ?> -
trunk/admin/update.php
r625 r633 516 516 pwg_query($query); 517 517 518 // set a new representative element for this category 519 $query = ' 520 SELECT image_id 521 FROM '.IMAGE_CATEGORY_TABLE.' 522 WHERE category_id = '.$category_id.' 523 ORDER BY RAND() 524 LIMIT 0,1 525 ;'; 526 list($representative) = mysql_fetch_array(pwg_query($query)); 527 $query = ' 528 UPDATE '.CATEGORIES_TABLE.' 529 SET representative_picture_id = '.$representative.' 530 WHERE id = '.$category_id.' 531 ;'; 532 pwg_query($query); 518 set_random_representant(array($category_id)); 533 519 } 534 520 return $output; -
trunk/language/en_UK.iso-8859-1/admin.lang.php
r632 r633 345 345 $lang['cat_list_virtual_category_added'] = 'virtual category added'; 346 346 $lang['cat_list_virtual_category_deleted'] = 'virtual category deleted'; 347 $lang['set_random_representant'] = 'set new random representant'; 347 348 ?> -
trunk/template/default/admin/cat_modify.tpl
r632 r633 6 6 <form action="{F_ACTION}" method="POST"> 7 7 <table style="width:100%;"> 8 <!-- BEGIN representant --> 9 <tr> 10 <td style="width:50%;" align="center"> 11 <a href="{representant.URL}"><img src="{representant.SRC}" alt="" class="miniature" /></a> 12 </td> 13 <td class="row1"><input type="submit" name="set_random_representant" value="{L_SET_RANDOM_REPRESENTANT}" class="bouton" /></td> 14 </tr> 15 <!-- END representant --> 8 16 <!-- BEGIN server --> 9 17 <tr>
Note: See TracChangeset
for help on using the changeset viewer.