Changeset 809
- Timestamp:
- Aug 14, 2005, 1:09:54 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r808 r809 166 166 { 167 167 $title = 'batch management'; 168 $page_valide = true; 169 break; 170 } 171 case 'maintenance' : 172 { 173 $title = l10n('Maintenance'); 174 $page_valide = true; 175 break; 176 } 177 case 'representative' : 178 { 179 $title = l10n('Representative'); 168 180 $page_valide = true; 169 181 break; … … 245 257 'U_SITES'=>add_session_id($link_start.'remote_site'), 246 258 'U_PHPINFO'=>add_session_id($link_start.'admin_phpinfo' ), 259 'U_MAINTENANCE'=>add_session_id($link_start.'maintenance'), 247 260 'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ), 248 261 'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ), … … 270 283 )); 271 284 285 if ($conf['allow_random_representative']) 286 { 287 $template->assign_block_vars( 288 'representative', 289 array( 290 'URL' => add_session_id($opt_link.'representative') 291 ) 292 ); 293 } 294 272 295 //--------------------------------------------------------------------- summary 273 296 $link_start = PHPWG_ROOT_PATH.'admin.php?page='; -
trunk/admin/cat_modify.php
r792 r809 42 42 if ( isset( $_POST['submit'] ) ) 43 43 { 44 $query = 'SELECT status';45 $query.= ' FROM '.CATEGORIES_TABLE;46 $query.= ' WHERE id = '.$_GET['cat_id'];47 $query.= ';';48 $row = mysql_fetch_array( pwg_query( $query ) );49 50 44 $query = 'UPDATE '.CATEGORIES_TABLE; 51 45 $query.= ' SET name = '; … … 82 76 set_cat_status(array($_GET['cat_id']), $_POST['status']); 83 77 84 array_push($infos, $lang['editcat_confirm']); 78 if (isset($_POST['parent'])) 79 { 80 move_category($_GET['cat_id'], $_POST['parent']); 81 } 82 83 array_push($page['infos'], $lang['editcat_confirm']); 85 84 } 86 85 else if (isset($_POST['set_random_representant'])) 87 86 { 88 87 set_random_representant(array($_GET['cat_id'])); 88 } 89 else if (isset($_POST['delete_representant'])) 90 { 91 $query = ' 92 UPDATE '.CATEGORIES_TABLE.' 93 SET representative_picture_id = NULL 94 WHERE id = '.$_GET['cat_id'].' 95 ;'; 96 pwg_query($query); 89 97 } 90 98 … … 96 104 $category = mysql_fetch_array( pwg_query( $query ) ); 97 105 // nullable fields 98 foreach (array('comment','dir','site_id' ) as $nullable)106 foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable) 99 107 { 100 108 if (!isset($category[$nullable])) … … 103 111 } 104 112 } 113 114 $category['is_virtual'] = empty($category['dir']) ? true : false; 105 115 106 116 // Navigation path … … 135 145 136 146 //----------------------------------------------------- template initialization 147 148 $base_url = PHPWG_ROOT_PATH.'admin.php?page='; 149 $cat_list_url = $base_url.'cat_list'; 150 151 $self_url = $cat_list_url; 152 if (!empty($category['id_uppercat'])) 153 { 154 $self_url.= '&parent_id='.$category['id_uppercat']; 155 } 156 137 157 $template->assign_vars(array( 138 158 'CATEGORIES_NAV'=>$navigation, … … 164 184 'L_SUBMIT'=>$lang['submit'], 165 185 'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'], 186 187 'U_JUMPTO'=> 188 add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']), 189 'U_CHILDREN'=> 190 add_session_id($cat_list_url.'&parent_id='.$category['id']), 166 191 167 192 'F_ACTION'=>add_session_id($form_action) 168 193 )); 169 194 195 196 if ('private' == $category['status']) 197 { 198 $template->assign_block_vars( 199 'permissions', 200 array( 201 'URL'=>add_session_id($base_url.'cat_perm&cat='.$category['id']) 202 ) 203 ); 204 } 205 206 // manage category elements link 170 207 if ($category['nb_images'] > 0) 171 208 { 172 $query = ' 209 $template->assign_block_vars( 210 'elements', 211 array( 212 'URL'=>add_session_id($base_url.'element_set&cat='.$category['id']) 213 ) 214 ); 215 } 216 217 // representant management 218 if ($category['nb_images'] > 0 219 or !empty($category['representative_picture_id'])) 220 { 221 $template->assign_block_vars('representant', array()); 222 223 // picture to display : the identified representant or the generic random 224 // representant ? 225 if (!empty($category['representative_picture_id'])) 226 { 227 $query = ' 173 228 SELECT tn_ext,path 174 229 FROM '.IMAGES_TABLE.' 175 230 WHERE id = '.$category['representative_picture_id'].' 176 231 ;'; 177 $row = mysql_fetch_array(pwg_query($query)); 178 $src = get_thumbnail_src($row['path'], @$row['tn_ext']); 179 $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; 180 $url.= '&image_id='.$category['representative_picture_id']; 181 $template->assign_block_vars('representant', 182 array('SRC' => $src, 183 'URL' => $url)); 184 } 185 186 if (!empty($category['dir'])) 232 $row = mysql_fetch_array(pwg_query($query)); 233 $src = get_thumbnail_src($row['path'], @$row['tn_ext']); 234 $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; 235 $url.= '&image_id='.$category['representative_picture_id']; 236 237 $template->assign_block_vars( 238 'representant.picture', 239 array( 240 'SRC' => $src, 241 'URL' => $url 242 ) 243 ); 244 } 245 else // $category['nb_images'] > 0 246 { 247 $template->assign_block_vars('representant.random', array()); 248 } 249 250 // can the admin choose to set a new random representant ? 251 if ($category['nb_images'] > 0) 252 { 253 $template->assign_block_vars('representant.set_random', array()); 254 } 255 256 // can the admin delete the current representant ? 257 if ( 258 ($category['nb_images'] > 0 259 and $conf['allow_random_representative']) 260 or 261 ($category['nb_images'] == 0 262 and !empty($category['representative_picture_id']))) 263 { 264 $template->assign_block_vars('representant.delete_representant', array()); 265 } 266 } 267 268 if (!$category['is_virtual']) //!empty($category['dir'])) 187 269 { 188 270 $template->assign_block_vars( … … 193 275 $template->assign_block_vars('upload' ,array()); 194 276 } 277 else 278 { 279 $template->assign_block_vars( 280 'delete', 281 array( 282 'URL'=>add_session_id($self_url.'&delete='.$category['id']) 283 ) 284 ); 285 286 $template->assign_block_vars('move', array()); 287 288 // the category can be moved in any category but in itself, in any 289 // sub-category 290 $unmovables = get_subcat_ids(array($category['id'])); 291 292 $blockname = 'move.parent_option'; 293 294 $template->assign_block_vars( 295 $blockname, 296 array( 297 'SELECTED' 298 => empty($category['id_uppercat']) ? 'selected="selected"' : '', 299 'VALUE'=> 0, 300 'OPTION' => '------------' 301 ) 302 ); 303 304 $query = ' 305 SELECT id,name,uppercats,global_rank 306 FROM '.CATEGORIES_TABLE.' 307 WHERE id NOT IN ('.implode(',', $unmovables).') 308 ;'; 309 310 display_select_cat_wrapper( 311 $query, 312 empty($category['id_uppercat']) ? array() : array($category['id_uppercat']), 313 $blockname 314 ); 315 } 195 316 196 317 if (is_numeric($category['site_id']) and $category['site_id'] != 1) -
trunk/admin/cat_options.php
r675 r809 73 73 break; 74 74 } 75 case 'representative' : 76 { 77 $query = ' 78 UPDATE '.CATEGORIES_TABLE.' 79 SET representative_picture_id = NULL 80 WHERE id IN ('.implode(',', $_POST['cat_true']).') 81 ;'; 82 pwg_query($query); 83 break; 84 } 75 85 } 76 86 } … … 109 119 { 110 120 set_cat_status($_POST['cat_false'], 'public'); 121 break; 122 } 123 case 'representative' : 124 { 125 // theoretically, all categories in $_POST['cat_false'] contain at 126 // least one element, so PhpWebGallery can find a representant. 127 set_random_representant($_POST['cat_false']); 111 128 break; 112 129 } … … 179 196 ) 180 197 ); 181 $template->assign_block_vars('upload', array());182 198 break; 183 199 } … … 202 218 ) 203 219 ); 204 $template->assign_block_vars('comments', array());205 220 break; 206 221 } … … 225 240 ) 226 241 ); 227 $template->assign_block_vars('visible', array());228 242 break; 229 243 } … … 248 262 ) 249 263 ); 250 $template->assign_block_vars('status', array()); 264 break; 265 } 266 case 'representative' : 267 { 268 $query_true = ' 269 SELECT id,name,uppercats,global_rank 270 FROM '.CATEGORIES_TABLE.' 271 WHERE representative_picture_id IS NOT NULL 272 ;'; 273 $query_false = ' 274 SELECT id,name,uppercats,global_rank 275 FROM '.CATEGORIES_TABLE.' 276 WHERE nb_images != 0 277 AND representative_picture_id IS NULL 278 ;'; 279 $template->assign_vars( 280 array( 281 'L_CAT_TITLE' => l10n('Representative'), 282 'L_CAT_OPTIONS_TRUE' => l10n('singly represented'), 283 'L_CAT_OPTIONS_FALSE' => l10n('randomly represented'), 284 'L_CAT_OPTIONS_INFO' => l10n('') 285 ) 286 ); 251 287 break; 252 288 } -
trunk/admin/include/functions.php
r808 r809 396 396 function update_category($ids = 'all', $recursive = false) 397 397 { 398 global $conf; 399 398 400 // retrieving all categories to update 399 401 $cat_ids = array(); … … 429 431 $query.= ' 430 432 ;'; 431 $result = pwg_query( $query ); 432 while ( $row = mysql_fetch_array( $result ) ) 433 { 434 array_push($cat_ids, $row['id']); 435 } 436 $cat_ids = array_unique($cat_ids); 433 $cat_ids = array_unique(array_from_query($query, 'id')); 437 434 438 435 if (count($cat_ids) == 0) … … 471 468 mass_updates(CATEGORIES_TABLE, $fields, $datas); 472 469 473 $query = ' 470 // representative pictures 471 if (count($cat_ids) > 0) 472 { 473 // find all categories where the setted representative is not possible : 474 // the picture does not exist 475 $query = ' 476 SELECT c.id 477 FROM '.CATEGORIES_TABLE.' AS c LEFT JOIN '.IMAGES_TABLE.' AS i 478 ON c.representative_picture_id = i.id 479 WHERE representative_picture_id IS NOT NULL 480 AND c.id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') 481 AND i.id IS NULL 482 ;'; 483 $wrong_representant = array_from_query($query, 'id'); 484 485 if ($conf['allow_random_representative']) 486 { 487 if (count($wrong_representant) > 0) 488 { 489 $query = ' 474 490 UPDATE '.CATEGORIES_TABLE.' 475 491 SET representative_picture_id = NULL 476 WHERE nb_images = 0 477 ;'; 478 pwg_query($query); 479 480 if (count($cat_ids) > 0) 481 { 482 $categories = array(); 483 // find all categories where the setted representative is not possible 484 $query = ' 492 WHERE id IN ('.wordwrap(implode(', ', $wrong_representant), 80, "\n").') 493 ;'; 494 pwg_query($query); 495 } 496 } 497 else 498 { 499 $to_null = array(); 500 $to_rand = array(); 501 502 if (count($wrong_representant) > 0) 503 { 504 // among the categories with an unknown representant, we dissociate 505 // categories containing pictures and categories containing no 506 // pictures. Indeed, the representant must set to NULL if no picture 507 // in the category and set to a random picture otherwise. 508 $query = ' 485 509 SELECT id 486 FROM '.CATEGORIES_TABLE.' LEFT JOIN '.IMAGE_CATEGORY_TABLE.' 487 ON id = category_id AND representative_picture_id = image_id 488 WHERE representative_picture_id IS NOT NULL 489 AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') 490 AND category_id IS NULL 491 ;'; 492 $result = pwg_query($query); 493 while ($row = mysql_fetch_array($result)) 494 { 495 array_push($categories, $row['id']); 496 } 497 // find categories with elements and with no representant 498 $query = ' 510 FROM '.CATEGORIES_TABLE.' 511 WHERE id IN ('.wordwrap(implode(', ', $wrong_representant), 80, "\n").') 512 AND nb_images = 0 513 ;'; 514 $to_null = array_from_query($query, 'id'); 515 $to_rand = array_diff($wrong_representant, $to_null); 516 } 517 518 if (count($to_null) > 0) 519 { 520 $query = ' 521 UPDATE '.CATEGORIES_TABLE.' 522 SET representative_picture_id = NULL 523 WHERE id IN ('.wordwrap(implode(', ', $to_null), 80, "\n").') 524 ;'; 525 pwg_query($query); 526 } 527 528 // If the random representant is not allowed, we need to find 529 // categories with elements and with no representant. Those categories 530 // must be added to the list of categories to set to a random 531 // representant. 532 $query = ' 499 533 SELECT id 500 534 FROM '.CATEGORIES_TABLE.' 501 535 WHERE representative_picture_id IS NULL 502 536 AND nb_images != 0 503 ;'; 504 $result = pwg_query($query); 505 while ($row = mysql_fetch_array($result)) 506 { 507 array_push($categories, $row['id']); 508 } 509 510 $categories = array_unique($categories); 511 set_random_representant($categories); 537 AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') 538 ;'; 539 $to_rand = 540 array_unique( 541 array_merge( 542 $to_rand, 543 array_from_query($query, 'id') 544 ) 545 ); 546 547 if (count($to_rand) > 0) 548 { 549 set_random_representant($to_rand); 550 } 551 } 512 552 } 513 553 } … … 1187 1227 1188 1228 /** 1189 * compares and synchronizes USERS_TABLE and USER_INFOS_TABLE : each user in 1190 * USERS_TABLE must be present in USER_INFOS_TABLE. 1229 * synchronize base users list and related users list 1230 * 1231 * compares and synchronizes base users table (USERS_TABLE) with its child 1232 * tables (USER_INFOS_TABLE, USER_ACCESS, USER_CACHE, USER_GROUP) : each 1233 * base user must be present in child tables, users in child tables not 1234 * present in base table must be deleted. 1235 * 1236 * @return void 1191 1237 */ 1192 1238 function sync_users() … … 1241 1287 } 1242 1288 1243 // users present in $infos_users and not in $base_users must be deleted 1244 $to_delete = array_diff($infos_users, $base_users); 1245 1246 if (count($to_delete) > 0) 1289 // users present in user related tables must be present in the base user 1290 // table 1291 $tables = 1292 array( 1293 USER_INFOS_TABLE, 1294 USER_ACCESS_TABLE, 1295 USER_CACHE_TABLE, 1296 USER_GROUP_TABLE 1297 ); 1298 foreach ($tables as $table) 1247 1299 { 1248 1300 $query = ' 1301 SELECT user_id 1302 FROM '.$table.' 1303 ;'; 1304 $to_delete = 1305 array_diff( 1306 array_from_query($query, 'user_id'), 1307 $base_users 1308 ); 1309 1310 if (count($to_delete) > 0) 1311 { 1312 $query = ' 1249 1313 DELETE 1250 FROM '. USER_INFOS_TABLE.'1314 FROM '.$table.' 1251 1315 WHERE user_id in ('.implode(',', $to_delete).') 1252 1316 ;'; 1317 pwg_query($query); 1318 } 1319 } 1320 } 1321 1322 /** 1323 * updates categories.uppercats field based on categories.id + 1324 * categories.id_uppercat 1325 * 1326 * @return void 1327 */ 1328 function update_uppercats() 1329 { 1330 $uppercat_ids = array(); 1331 1332 $query = ' 1333 SELECT id, id_uppercat 1334 FROM '.CATEGORIES_TABLE.' 1335 ;'; 1336 $result = pwg_query($query); 1337 while ($row = mysql_fetch_array($result)) 1338 { 1339 $uppercat_ids[$row['id']] = 1340 !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL'; 1341 } 1342 1343 // uppercats array associates a category id to the list of uppercats id. 1344 $uppercats = array(); 1345 1346 foreach (array_keys($uppercat_ids) as $id) 1347 { 1348 $uppercats[$id] = array(); 1349 1350 $uppercat = $id; 1351 1352 while ($uppercat != 'NULL') 1353 { 1354 array_push($uppercats[$id], $uppercat); 1355 $uppercat = $uppercat_ids[$uppercat]; 1356 } 1357 } 1358 1359 $datas = array(); 1360 1361 foreach ($uppercats as $id => $list) 1362 { 1363 array_push( 1364 $datas, 1365 array( 1366 'id' => $id, 1367 'uppercats' => implode(',', array_reverse($list)) 1368 ) 1369 ); 1370 } 1371 1372 $fields = array('primary' => array('id'), 'update' => array('uppercats')); 1373 mass_updates(CATEGORIES_TABLE, $fields, $datas); 1374 } 1375 1376 /** 1377 * update images.path field 1378 * 1379 * @return void 1380 */ 1381 function update_path() 1382 { 1383 $query = ' 1384 SELECT DISTINCT(storage_category_id) 1385 FROM '.IMAGES_TABLE.' 1386 ;'; 1387 $cat_ids = array_from_query($query, 'storage_category_id'); 1388 $fulldirs = get_fulldirs($cat_ids); 1389 1390 foreach ($cat_ids as $cat_id) 1391 { 1392 $query = ' 1393 UPDATE '.IMAGES_TABLE.' 1394 SET path = CONCAT(\''.$fulldirs[$cat_id].'\',\'/\',file) 1395 WHERE storage_category_id = '.$cat_id.' 1396 ;'; 1253 1397 pwg_query($query); 1254 } 1398 } 1399 } 1400 1401 /** 1402 * update images.average_rate field 1403 * 1404 * @return void 1405 */ 1406 function update_average_rate() 1407 { 1408 $average_rates = array(); 1409 1410 $query = ' 1411 SELECT element_id, 1412 ROUND(AVG(rate),2) AS average_rate 1413 FROM '.RATE_TABLE.' 1414 GROUP BY element_id 1415 ;'; 1416 $result = pwg_query($query); 1417 while ($row = mysql_fetch_array($result)) 1418 { 1419 array_push($average_rates, $row); 1420 } 1421 1422 $datas = array(); 1423 foreach ($average_rates as $item) 1424 { 1425 array_push( 1426 $datas, 1427 array( 1428 'id' => $item['element_id'], 1429 'average_rate' => $item['average_rate'] 1430 ) 1431 ); 1432 } 1433 $fields = array('primary' => array('id'), 'update' => array('average_rate')); 1434 mass_updates(IMAGES_TABLE, $fields, $datas); 1435 } 1436 1437 /** 1438 * change the parent category of the given category. The category is 1439 * supposed virtual. 1440 * 1441 * @param int category identifier 1442 * @param int parent category identifier 1443 * @return void 1444 */ 1445 function move_category($category_id, $new_parent = -1) 1446 { 1447 // verifies if the move is necessary 1448 $query = ' 1449 SELECT id_uppercat, status 1450 FROM '.CATEGORIES_TABLE.' 1451 WHERE id = '.$category_id.' 1452 ;'; 1453 list($old_parent, $status) = mysql_fetch_row(pwg_query($query)); 1454 1455 $old_parent = empty($old_parent) ? 'NULL' : $old_parent; 1456 $new_parent = $new_parent < 1 ? 'NULL' : $new_parent; 1457 1458 if ($new_parent == $old_parent) 1459 { 1460 // no need to move ! 1461 return; 1462 } 1463 1464 $query = ' 1465 UPDATE '.CATEGORIES_TABLE.' 1466 SET id_uppercat = '.$new_parent.' 1467 WHERE id = '.$category_id.' 1468 ;'; 1469 pwg_query($query); 1470 1471 update_uppercats(); 1472 ordering(); 1473 update_global_rank(); 1474 1475 // status and related permissions management 1476 if ('NULL' == $new_parent) 1477 { 1478 $parent_status = 'public'; 1479 } 1480 else 1481 { 1482 $query = ' 1483 SELECT status 1484 FROM '.CATEGORIES_TABLE.' 1485 WHERE id = '.$new_parent.' 1486 ;'; 1487 list($parent_status) = mysql_fetch_row(pwg_query($query)); 1488 } 1489 1490 if ('private' == $parent_status) 1491 { 1492 switch ($status) 1493 { 1494 case 'public' : 1495 { 1496 set_cat_status(array($category_id), 'private'); 1497 break; 1498 } 1499 case 'private' : 1500 { 1501 $subcats = get_subcat_ids(array($category_id)); 1502 1503 $tables = 1504 array( 1505 USER_ACCESS_TABLE => 'user_id', 1506 GROUP_ACCESS_TABLE => 'group_id' 1507 ); 1508 1509 foreach ($tables as $table => $field) 1510 { 1511 $query = ' 1512 SELECT '.$field.' 1513 FROM '.$table.' 1514 WHERE category_id = '.$category_id.' 1515 ;'; 1516 $category_access = array_from_query($query, $field); 1517 1518 $query = ' 1519 SELECT '.$field.' 1520 FROM '.$table.' 1521 WHERE category_id = '.$new_parent.' 1522 ;'; 1523 $parent_access = array_from_query($query, $field); 1524 1525 $to_delete = array_diff($parent_access, $category_access); 1526 1527 if (count($to_delete) > 0) 1528 { 1529 $query = ' 1530 DELETE FROM '.$table.' 1531 WHERE '.$field.' IN ('.implode(',', $to_delete).') 1532 AND category_id IN ('.implode(',', $subcats).') 1533 ;'; 1534 pwg_query($query); 1535 } 1536 } 1537 break; 1538 } 1539 } 1540 } 1255 1541 } 1256 1542 ?> -
trunk/admin/picture_modify.php
r801 r809 235 235 ;'; 236 236 display_select_cat_wrapper($query,array(),'dissociated_option'); 237 237 238 // representing 238 239 $query = ' … … 246 247 SELECT id,name,uppercats,global_rank 247 248 FROM '.CATEGORIES_TABLE.' 248 WHERE id IN ('.implode(',', $associateds).')249 AND representative_picture_id != '.$_GET['image_id'].'249 WHERE representative_picture_id != '.$_GET['image_id'].' 250 OR representative_picture_id IS NULL 250 251 ;'; 251 252 display_select_cat_wrapper($query,array(),'dismissed_option'); -
trunk/doc/ChangeLog
r808 r809 1 2005-09-13 Pierrick LE GALL 2 3 * new : maintenance screen in administration. There you can update 4 categories informations (number of images, date of the last added 5 element), update images informations (path, average rate), purge 6 obsolete sessions, purge history. 7 8 * new : ability to have random representative for categories. This 9 configuration parameter is set to false by default. 10 11 * new : ability to set an element as representative of a category 12 without belonging to the category. Thus, administrator can choose 13 representative even for empty categories. 14 15 * improvement : semantically superior design for category edition 16 screen by regrouping fields in fieldsets. The improved screen 17 contains action buttons as in category list screen. 18 19 * new : ability to move a virtual category (ie change its parent 20 category). 21 22 * bug fixed : the sync_users function checks all user children 23 tables (access, cache, group association). 24 1 25 2005-08-08 Pierrick LE GALL 2 26 -
trunk/include/category_subcats.inc.php
r760 r809 33 33 34 34 $query = ' 35 SELECT id, name, date_last 35 SELECT id, name, date_last, representative_picture_id 36 36 FROM '.CATEGORIES_TABLE.' 37 37 WHERE id_uppercat '; … … 44 44 $query.= '= '.$page['cat']; 45 45 } 46 // we must not show pictures of a forbidden category 47 if ($user['forbidden_categories'] != '') 48 { 49 $query.= ' AND id NOT IN ('.$user['forbidden_categories'].')'; 50 } 51 $query.= ' 46 $query.= ' 47 AND id NOT IN ('.$user['forbidden_categories'].') 52 48 ORDER BY rank 53 49 ;'; 54 50 $result = pwg_query($query); 55 51 56 // template thumbnail initialization 57 if (mysql_num_rows($result) > 0) 52 // $conf['allow_random_representative'] 53 54 $cat_thumbnails = array(); 55 56 while ($row = mysql_fetch_array($result)) 58 57 { 58 if (isset($row['representative_picture_id']) 59 and is_numeric($row['representative_picture_id'])) 60 { 61 // if a representative picture is set, it has priority 62 $image_id = $row['representative_picture_id']; 63 } 64 else if ($conf['allow_random_representative']) 65 { 66 // searching a random representant among elements in sub-categories 67 $query = ' 68 SELECT image_id 69 FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic 70 ON ic.category_id = c.id 71 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' 72 AND c.id NOT IN ('.$user['forbidden_categories'].') 73 ORDER BY RAND() 74 LIMIT 0,1 75 ;'; 76 $subresult = pwg_query($query); 77 if (mysql_num_rows($result) > 0) 78 { 79 list($image_id) = mysql_fetch_row($subresult); 80 } 81 } 82 else 83 { 84 // searching a random representant among representant of sub-categories 85 $query = ' 86 SELECT representative_picture_id 87 FROM '.CATEGORIES_TABLE.' 88 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' 89 AND id NOT IN ('.$user['forbidden_categories'].') 90 AND representative_picture_id IS NOT NULL 91 ORDER BY RAND() 92 LIMIT 0,1 93 ;'; 94 $subresult = pwg_query($query); 95 if (mysql_num_rows($subresult) > 0) 96 { 97 list($image_id) = mysql_fetch_row($subresult); 98 } 99 } 100 101 if (isset($image_id)) 102 { 103 array_push( 104 $cat_thumbnails, 105 array( 106 'category' => $row['id'], 107 'picture' => $image_id, 108 'name' => $row['name'], 109 'date_last' => @$row['date_last'] 110 ) 111 ); 112 } 113 114 unset($image_id); 115 } 116 117 if (count($cat_thumbnails) > 0) 118 { 119 $images = array(); 120 121 foreach ($cat_thumbnails as $item) 122 { 123 $images[$item['picture']] = ''; 124 } 125 126 $query = ' 127 SELECT id, path, tn_ext 128 FROM '.IMAGES_TABLE.' 129 WHERE id IN ('.implode(',', array_keys($images)).') 130 ;'; 131 $result = pwg_query($query); 132 while ($row = mysql_fetch_array($result)) 133 { 134 $images[$row['id']] = get_thumbnail_src($row['path'], @$row['tn_ext']); 135 } 136 59 137 $template->assign_block_vars('thumbnails', array()); 60 138 // first line … … 62 140 // current row displayed 63 141 $row_number = 0; 64 } 142 143 foreach ($cat_thumbnails as $item) 144 { 145 $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id']; 65 146 66 while ($row = mysql_fetch_array($result)) 67 { 68 $query = ' 69 SELECT path, tn_ext 70 FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i 71 ON i.id = c.representative_picture_id 72 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\''; 73 // we must not show pictures of a forbidden category 74 if ($user['forbidden_categories'] != '') 75 { 76 $query.= ' 77 AND c.id NOT IN ('.$user['forbidden_categories'].')'; 78 } 79 $query.= ' 80 ORDER BY RAND() 81 LIMIT 0,1 82 ;'; 83 $element_result = pwg_query($query); 84 if (mysql_num_rows($element_result) == 0) 85 { 86 continue; 87 } 88 $element_row = mysql_fetch_array($element_result); 89 90 $thumbnail_link = get_thumbnail_src($element_row['path'], 91 @$element_row['tn_ext']); 92 93 $thumbnail_title = $lang['hint_category']; 94 95 $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id']; 96 97 $template->assign_block_vars( 98 'thumbnails.line.thumbnail', 99 array( 100 'IMAGE' => $thumbnail_link, 101 'IMAGE_ALT' => $row['name'], 102 'IMAGE_TITLE' => $thumbnail_title, 103 'IMAGE_TS' => get_icon(@$row['date_last']), 104 105 'U_IMG_LINK' => add_session_id($url_link) 106 ) 107 ); 108 109 $template->assign_block_vars( 110 'thumbnails.line.thumbnail.category_name', 111 array( 112 'NAME' => $row['name'] 113 ) 114 ); 115 116 // create a new line ? 117 if (++$row_number == $user['nb_image_line']) 118 { 119 $template->assign_block_vars('thumbnails.line', array()); 120 $row_number = 0; 147 $template->assign_block_vars( 148 'thumbnails.line.thumbnail', 149 array( 150 'IMAGE' => $images[$item['picture']], 151 'IMAGE_ALT' => $item['name'], 152 'IMAGE_TITLE' => $lang['hint_category'], 153 'IMAGE_TS' => get_icon(@$item['date_last']), 154 'U_IMG_LINK' => 155 add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$item['category']) 156 ) 157 ); 158 159 $template->assign_block_vars( 160 'thumbnails.line.thumbnail.category_name', 161 array( 162 'NAME' => $item['name'] 163 ) 164 ); 165 166 // create a new line ? 167 if (++$row_number == $user['nb_image_line']) 168 { 169 $template->assign_block_vars('thumbnails.line', array()); 170 $row_number = 0; 171 } 121 172 } 122 173 } -
trunk/include/config_default.inc.php
r808 r809 253 253 // guest_id : id of the anonymous user 254 254 $conf['guest_id'] = 2; 255 256 // allow_random_representative : do you wish PhpWebGallery to search among 257 // categories elements a new representative at each reload ? 258 // 259 // If false, an element is randomly or manually chosen to represent its 260 // category and remains the representative as long as an admin does not 261 // change it. 262 // 263 // Warning : setting this parameter to true is CPU consuming. Each time you 264 // change the value of this parameter from false to true, an administrator 265 // must update categories informations in screen [Admin > General > 266 // Maintenance]. 267 $conf['allow_random_representative'] = false; 255 268 ?> -
trunk/template/default/admin.tpl
r792 r809 21 21 <li><a class="adminMenu" href="{U_HISTORY}">{L_HISTORY}</a></li> 22 22 <li><a class="adminMenu" href="{U_CAT_UPDATE}">{L_UPDATE}</a></li> 23 <li><a class="adminMenu" href="{U_MAINTENANCE}">{lang:Maintenance}</a></li> 23 24 </ul> 24 25 </div> … … 42 43 <li><a class="adminMenu" href="{U_CAT_VISIBLE}">{L_CAT_VISIBLE}</a></li> 43 44 <li><a class="adminMenu" href="{U_CAT_STATUS}">{L_CAT_STATUS}</a></li> 45 <!-- BEGIN representative --> 46 <li><a class="adminMenu" href="{representative.URL}">{lang:Representatve}</a></li> 47 <!-- END representative --> 44 48 </ul> 45 49 </div> … … 92 96 </div> 93 97 <!-- END infos --> 94 95 <div align="center">{ADMIN_CONTENT}{ADMIN_CONTENT_2}</div> 98 <div id="adminMain"> 99 {ADMIN_CONTENT}{ADMIN_CONTENT_2} 100 </div> 96 101 </div> 97 102 </td> -
trunk/template/default/admin/cat_modify.tpl
r792 r809 1 <div class="admin">{CATEGORIES_NAV}</div> 1 <h2>{CATEGORIES_NAV}</h2> 2 3 <ul class="categoryActions"> 4 <li><a href="{U_JUMPTO}" title="{lang:jump to category}"><img src="./template/default/theme/category_jump-to.png" alt="{lang:jump to}" /></a></li> 5 <!-- BEGIN elements --> 6 <li><a href="{elements.URL}" title="{lang:manage category elements}"><img src="./template/default/theme/category_elements.png" alt="{lang:elements}" /></a></li> 7 <!-- END elements --> 8 <li><a href="{U_CHILDREN}" title="{lang:manage sub-categories}"><img src="./template/default/theme/category_children.png" alt="{lang:sub-categories}" /></a></li> 9 <!-- BEGIN permissions --> 10 <li><a href="{permissions.URL}" title="{lang:edit category permissions}" ><img src="./template/default/theme/category_permissions.png" alt="{lang:permissions}" /></a></li> 11 <!-- END permissions --> 12 <!-- BEGIN delete --> 13 <li><a href="{delete.URL}" title="{lang:delete category}"><img src="./template/default/theme/category_delete.png" alt="{lang:delete}" /></a></li> 14 <!-- END delete --> 15 </ul> 16 2 17 <form action="{F_ACTION}" method="POST"> 3 <table style="width:100%;"> 4 <!-- BEGIN representant --> 5 <tr> 6 <td style="width:50%;" align="center"> 7 <a href="{representant.URL}"><img src="{representant.SRC}" alt="" class="miniature" /></a> 8 </td> 9 <td class="row1"><input type="submit" name="set_random_representant" value="{L_SET_RANDOM_REPRESENTANT}" class="bouton" /></td> 10 </tr> 11 <!-- END representant --> 12 </table> 13 </form> 14 <form action="{F_ACTION}" method="POST"> 15 <table style="width:100%;"> 18 19 <fieldset> 20 <legend>{lang:Informations}</legend> 21 <table> 16 22 <!-- BEGIN server --> 17 23 <tr> 18 <td style="width:50%;"><strong>{L_REMOTE_SITE}</strong></td>19 <td class="row1">{server.SITE_URL}</td>24 <td><strong>{L_REMOTE_SITE}</strong></td> 25 <td>{server.SITE_URL}</td> 20 26 </tr> 21 27 <!-- END server --> 28 <!-- BEGIN storage --> 22 29 <tr> 23 <td style="width:50%;"><strong>{L_EDIT_NAME}</strong></td> 24 <td class="row1"> 30 <td><strong>{L_STORAGE}</strong></td> 31 <td class="row1">{storage.CATEGORY_DIR}</td> 32 </tr> 33 <!-- END storage --> 34 <tr> 35 <td><strong>{L_EDIT_NAME}</strong></td> 36 <td> 25 37 <input type="text" name="name" value="{CAT_NAME}" maxlength="60"/> 26 38 </td> 27 39 </tr> 28 <!-- BEGIN storage -->29 <tr>30 <td><strong>{L_STORAGE}</strong></td>31 <td class="row1">{storage.CATEGORY_DIR}</td>32 </tr>33 <!-- END storage -->34 40 <tr> 35 41 <td><strong>{L_EDIT_COMMENT}</strong></td> 36 <td class="row1">42 <td> 37 43 <textarea name="comment" rows="3" cols="50" >{CAT_COMMENT}</textarea> 38 44 </td> 39 45 </tr> 40 <tr class="admin"> 41 <th colspan="2">{L_EDIT_CAT_OPTIONS}</th> 42 </tr> 46 </table> 47 </fieldset> 48 49 <!-- BEGIN move --> 50 <fieldset> 51 <legend>{lang:Move}</legend> 52 {lang:Parent category} 53 <select name="parent"> 54 <!-- BEGIN parent_option --> 55 <option class="{move.parent_option.CLASS}" {move.parent_option.SELECTED} value="{move.parent_option.VALUE}">{move.parent_option.OPTION}</option> 56 <!-- END parent_option --> 57 </select> 58 </fieldset> 59 <!-- END move --> 60 61 <fieldset> 62 <legend>{lang:Options}</legend> 63 <table> 43 64 <tr> 44 <td><strong>{L_EDIT_STATUS} :</strong><br /><span class="small">{L_EDIT_STATUS_INFO}</span></td>45 <td class="row1">46 <input type="radio" class="radio" name="status" value="public" {STATUS_PUBLIC} />{L_STATUS_PUBLIC} 47 <input type="radio" class="radio"name="status" value="private" {STATUS_PRIVATE} />{L_STATUS_PRIVATE}65 <td><strong>{L_EDIT_STATUS}</strong><br /><span class="small">{L_EDIT_STATUS_INFO}</span></td> 66 <td> 67 <input type="radio" name="status" value="public" {STATUS_PUBLIC} />{L_STATUS_PUBLIC} 68 <input type="radio" name="status" value="private" {STATUS_PRIVATE} />{L_STATUS_PRIVATE} 48 69 </td> 49 70 </tr> 50 71 <tr> 51 <td><strong>{L_EDIT_LOCK} :</strong><br /><span class="small">{L_EDIT_LOCK_INFO}</span></td>52 <td class="row1">53 <input type="radio" class="radio" name="visible" value="false" {LOCKED} />{L_YES} 54 <input type="radio" class="radio"name="visible" value="true" {UNLOCKED} />{L_NO}72 <td><strong>{L_EDIT_LOCK}</strong><br /><span class="small">{L_EDIT_LOCK_INFO}</span></td> 73 <td> 74 <input type="radio" name="visible" value="false" {LOCKED} />{L_YES} 75 <input type="radio" name="visible" value="true" {UNLOCKED} />{L_NO} 55 76 </td> 56 77 </tr> 57 78 <tr> 58 <td><strong>{L_EDIT_COMMENTABLE} :</strong><br /><span class="small">{L_EDIT_COMMENTABLE_INFO}</span></td>59 <td class="row1">60 <input type="radio" class="radio" name="commentable" value="true" {COMMENTABLE_TRUE} />{L_YES} 61 <input type="radio" class="radio"name="commentable" value="false" {COMMENTABLE_FALSE} />{L_NO}79 <td><strong>{L_EDIT_COMMENTABLE}</strong><br /><span class="small">{L_EDIT_COMMENTABLE_INFO}</span></td> 80 <td> 81 <input type="radio" name="commentable" value="true" {COMMENTABLE_TRUE} />{L_YES} 82 <input type="radio" name="commentable" value="false" {COMMENTABLE_FALSE} />{L_NO} 62 83 </td> 63 84 </tr> 64 85 <!-- BEGIN upload --> 65 86 <tr> 66 <td><strong>{L_EDIT_UPLOADABLE} :</strong><br /><span class="small">{L_EDIT_UPLOADABLE_INFO}</span></td>67 <td class="row1">68 <input type="radio" class="radio" name="uploadable" value="true" {UPLOADABLE_TRUE} />{L_YES} 69 <input type="radio" class="radio"name="uploadable" value="false" {UPLOADABLE_FALSE} />{L_NO}87 <td><strong>{L_EDIT_UPLOADABLE}</strong><br /><span class="small">{L_EDIT_UPLOADABLE_INFO}</span></td> 88 <td> 89 <input type="radio" name="uploadable" value="true" {UPLOADABLE_TRUE} />{L_YES} 90 <input type="radio" name="uploadable" value="false" {UPLOADABLE_FALSE} />{L_NO} 70 91 </td> 71 92 </tr> 72 93 <!-- END upload --> 94 </table> 95 </fieldset> 96 97 <p style="text-align:center;"> 98 <input type="submit" value="{L_SUBMIT}" name="submit" /> 99 <input type="reset" value="{lang:Reset}" name="reset" /> 100 </p> 101 102 <!-- BEGIN representant --> 103 <fieldset> 104 <legend>{lang:Representant}</legend> 105 <table> 73 106 <tr> 74 <td colspan="2"> </td> 75 </tr> 76 <tr> 77 <td colspan="2" align="center"> 78 <input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" /> 107 <td align="center"> 108 <!-- BEGIN picture --> 109 <a href="{representant.picture.URL}"><img src="{representant.picture.SRC}" alt="" class="miniature" /></a> 110 <!-- END picture --> 111 112 <!-- BEGIN random --> 113 <img src="./template/default/theme/category_representant_random.png" alt="{lang:Random picture}" class="miniature" /> 114 <!-- END random --> 115 </td> 116 <td> 117 <!-- BEGIN set_random --> 118 <p><input type="submit" name="set_random_representant" value="{L_SET_RANDOM_REPRESENTANT}" /></p> 119 <!-- END set_random --> 120 121 <!-- BEGIN delete_representant --> 122 <p><input type="submit" name="delete_representant" value="{lang:Delete Representant}" /></p> 123 <!-- END delete_representant --> 79 124 </td> 80 125 </tr> 81 126 </table> 127 </fieldset> 128 <!-- END representant --> 129 82 130 </form> -
trunk/template/default/default.css
r803 r809 48 48 line-height: 120%; 49 49 font-size:18px; 50 font-weight: bold;51 }52 53 h2 /* H2 tag style (admin side only) */54 {55 font-family: Arial, Helvetica, sans-serif;56 text-decoration:none;57 line-height: 120%;58 font-size:12px;59 50 font-weight: bold; 60 51 } … … 366 357 } 367 358 359 div#adminMain { 360 text-align: left; 361 } 362 363 div#adminMain h2 { 364 background-color: #3f3f3f; 365 text-align: center; 366 font-size: 120%; 367 } 368 368 369 div.adminMenu{ margin:10px 50px 10px 50px; } 369 370 … … 412 413 float: right; 413 414 margin-top: 5px; 415 } 416 417 div#adminMain>ul.categoryActions { 418 text-align: center; 414 419 } 415 420 … … 491 496 white-space: nowrap; 492 497 } 498 499 fieldset { 500 border: 1px solid gray; 501 } 502 503 fieldset>legend { 504 margin: 5px; 505 }
Note: See TracChangeset
for help on using the changeset viewer.