Changeset 1651
- Timestamp:
- Dec 13, 2006, 1:05:16 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/category_cats.inc.php
r1648 r1651 56 56 WHERE id_uppercat '. 57 57 (!isset($page['category']) ? 'is NULL' : '= '.$page['category']); 58 if ($page['filter_ mode'])58 if ($page['filter_local_mode']) 59 59 { 60 60 $query.= ' … … 86 86 FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic 87 87 ON ic.category_id = c.id'; 88 if ($page['filter_ mode'])88 if ($page['filter_local_mode'] or $user['filter_global_mode']) 89 89 { 90 90 $query.= ' … … 94 94 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' 95 95 AND c.id NOT IN ('.$user['forbidden_categories'].')'; 96 if ($page['filter_ mode'])96 if ($page['filter_local_mode'] or $user['filter_global_mode']) 97 97 { 98 98 $query.= ' … … 118 118 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' 119 119 AND representative_picture_id IS NOT NULL'; 120 if ($page['filter_ mode'])120 if ($page['filter_local_mode'] or $user['filter_global_mode']) 121 121 { 122 122 $query.= ' -
trunk/include/category_default.inc.php
r1648 r1651 48 48 FROM '.IMAGES_TABLE.' 49 49 WHERE id IN ('.implode(',', $selection).')'; 50 if ($page['filter_ mode'])50 if ($page['filter_local_mode'] or $user['filter_global_mode']) 51 51 { 52 52 $query.= ' -
trunk/include/functions_category.inc.php
r1648 r1651 68 68 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 69 69 ON id = cat_id and user_id = '.$user['id']; 70 if ($page['filter_ mode'])70 if ($page['filter_local_mode']) 71 71 { 72 72 $query.= ' … … 76 76 else 77 77 { 78 // Always expand when filter_ mode is activated79 if (!$user['expand'] )78 // Always expand when filter_local_mode is activated 79 if (!$user['expand'] and !$user['filter_global_mode']) 80 80 { 81 81 $query.= ' -
trunk/include/functions_user.inc.php
r1641 r1651 144 144 } 145 145 146 function build_user( $user_id, $use_cache )146 function build_user( $user_id, $use_cache, $filter_global_mode = false ) 147 147 { 148 148 global $conf; 149 149 150 $user['id'] = $user_id; 150 $user = array_merge( $user, getuserdata($user_id, $use_cache ) );151 $user = array_merge( $user, getuserdata($user_id, $use_cache, $filter_global_mode) ); 151 152 if ( $user['id'] == $conf['guest_id']) 152 153 { … … 167 168 $user['is_the_guest']=false; 168 169 } 170 169 171 // calculation of the number of picture to display per page 170 172 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; … … 197 199 * @param array 198 200 */ 199 function getuserdata($user_id, $use_cache )201 function getuserdata($user_id, $use_cache, $filter_global_mode = false ) 200 202 { 201 203 global $conf; … … 266 268 if ($use_cache) 267 269 { 270 $userdata['filter_global_mode'] = $filter_global_mode; 271 268 272 if (!isset($userdata['need_update']) 269 273 or !is_bool($userdata['need_update']) 270 or $userdata['need_update'] == true) 274 or $userdata['need_update'] == true 275 or $filter_global_mode // not optimize condition RubTag 276 ) 271 277 { 272 278 $userdata['forbidden_categories'] = 273 279 calculate_permissions($userdata['id'], $userdata['status']); 274 280 275 update_user_cache_categories($userdata ['id'], $userdata['forbidden_categories']);281 update_user_cache_categories($userdata); 276 282 277 283 // Set need update are done 278 $userdata['need_update'] = false;284 $userdata['need_update'] = $userdata['filter_global_mode']; // for draft always update RubTag 279 285 280 286 $query = ' … … 493 499 * update data of user_cache_categories 494 500 * 495 * @param int user_id501 * @param array userdata 496 502 * @return null 497 503 */ 498 function update_user_cache_categories( $user_id, $user_forbidden_categories)504 function update_user_cache_categories(&$userdata) 499 505 { 500 506 // delete user cache 501 507 $query = ' 502 508 DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.' 503 WHERE user_id = '.$user _id.'509 WHERE user_id = '.$userdata['id'].' 504 510 ;'; 505 511 pwg_query($query); 506 512 507 $query = '513 /*$query = ' 508 514 SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank 509 515 FROM '.CATEGORIES_TABLE; 510 if ($user _forbidden_categories!= '')516 if ($userdata['forbidden_categories'] != '') 511 517 { 512 518 $query.= ' 513 WHERE id NOT IN ('.$user_forbidden_categories.')'; 519 WHERE id NOT IN ('.$userdata['forbidden_categories'].')'; 520 } 521 $query.= ';';*/ 522 523 524 $query = ' 525 SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank'; 526 527 if (!$userdata['filter_global_mode']) 528 { 529 $query.= ' 530 FROM '.CATEGORIES_TABLE.' as C'; 531 } 532 else 533 { 534 // Count by date_available to avoid count null 535 $query.= ', count(date_available) filtered_count_images, max(date_available) max_date_available 536 FROM '.CATEGORIES_TABLE.' as C 537 LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic 538 ON ic.category_id = c.id LEFT JOIN '.IMAGES_TABLE.' AS i 539 ON ic.image_id = i.id AND i.date_available > SUBDATE( 540 CURRENT_DATE,INTERVAL '.$userdata['recent_period'].' DAY)'; 541 } 542 543 if ($userdata['forbidden_categories'] != '') 544 { 545 $query.= ' 546 WHERE C.id NOT IN ('.$userdata['forbidden_categories'].')'; 547 } 548 549 if ($userdata['filter_global_mode']) 550 { 551 $query.= ' 552 GROUP BY c.id'; 514 553 } 515 554 $query.= ';'; … … 520 559 while ($row = mysql_fetch_assoc($result)) 521 560 { 522 $row['user_id'] = $user _id;561 $row['user_id'] = $userdata['id']; 523 562 $row['count_categories'] = 0; 563 if ($userdata['filter_global_mode']) 564 { 565 $row['count_images'] = $row['filtered_count_images']; 566 $row['max_date_last'] = $row['max_date_available']; 567 } 524 568 $cats += array($row['cat_id'] => $row); 525 569 } … … 548 592 $level = 1; 549 593 compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level); 594 595 if ($userdata['filter_global_mode']) 596 { 597 $forbidden_cats = array(); 598 $forbidden_cats = explode(',', $userdata['forbidden_categories']); 599 $cat_tmp = $cats; 600 $cats = array(); 601 602 foreach ($cat_tmp as $cat_id => $category) 603 { 604 if (empty($category['max_date_last'])) 605 { 606 array_push($forbidden_cats, $category['cat_id']); 607 } 608 else 609 { 610 array_push($cats, $category); 611 } 612 } 613 $userdata['forbidden_categories'] = implode(',', array_unique($forbidden_cats)); 614 } 550 615 551 616 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); -
trunk/include/user.inc.php
r1623 r1651 70 70 } 71 71 } 72 73 if (isset($_GET['filter_global_mode'])) 74 { 75 $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start'); 76 pwg_set_session_var('filter_global_mode', $user['filter_global_mode']); 77 } 78 else 79 { 80 $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false); 81 } 82 72 83 $user = build_user( $user['id'], 73 ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ? 84 ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true, // use cache ? 85 $user['filter_global_mode'] // filter_global_mode ? 74 86 ); 75 87 -
trunk/index.php
r1648 r1651 107 107 } 108 108 109 if (isset($_GET['filter_mode'])) 110 { 111 $page['filter_mode'] = ($_GET['filter_mode'] == 'start'); 112 pwg_set_session_var('filter_mode', $page['filter_mode']); 113 } 114 else 115 { 116 $page['filter_mode'] = pwg_get_session_var('filter_mode', false); 117 } 118 119 if ($page['filter_mode']) 120 { 121 $template->assign_block_vars( 122 'stop_filter_mode', 123 array( 124 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'stop')) 125 ) 126 ); 127 } 128 else 129 { 130 $template->assign_block_vars( 131 'start_filter_mode', 132 array( 133 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'start')) 109 if (isset($_GET['filter_local_mode'])) 110 { 111 $page['filter_local_mode'] = ($_GET['filter_local_mode'] == 'start'); 112 } 113 else 114 { 115 $page['filter_local_mode'] = pwg_get_session_var('filter_local_mode', false); 116 } 117 118 $page['filter_local_mode'] = (($page['filter_local_mode']) and 119 ($page['section'] == 'categories') and 120 (!isset($page['chronology_field']))); 121 pwg_set_session_var('filter_local_mode', $page['filter_local_mode']); 122 123 if ($page['filter_local_mode']) 124 { 125 $template->assign_block_vars( 126 'stop_filter_local_mode', 127 array( 128 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'stop')) 129 ) 130 ); 131 } 132 else 133 { 134 $template->assign_block_vars( 135 'start_filter_local_mode', 136 array( 137 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'start')) 138 ) 139 ); 140 } 141 142 if (isset($_GET['filter_global_mode'])) 143 { 144 $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start'); 145 pwg_set_session_var('filter_global_mode', $user['filter_global_mode']); 146 } 147 else 148 { 149 $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false); 150 } 151 152 if ($user['filter_global_mode']) 153 { 154 $template->assign_block_vars( 155 'stop_filter_global_mode', 156 array( 157 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'stop')) 158 ) 159 ); 160 } 161 else 162 { 163 $template->assign_block_vars( 164 'start_filter_global_mode', 165 array( 166 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'start')) 134 167 ) 135 168 ); -
trunk/language/en_UK.iso-8859-1/common.lang.php
r1648 r1651 491 491 $lang['maxwidth'] = 'Maximum width of the pictures'; 492 492 $lang['maxwidth_error'] = 'Maximum width must be a number superior to 50'; 493 $lang['start_filter_mode_hint'] = 'displays only recent elements'; 494 $lang['stop_filter_mode_hint'] = 'return to display all elements'; 493 $lang['start_filter_local_mode_hint'] = '[local] displays only recent elements'; 494 $lang['stop_filter_local_mode_hint'] = '[local] return to display all elements'; 495 $lang['start_filter_global_mode_hint'] = '[global] displays only recent elements'; 496 $lang['stop_filter_global_mode_hint'] = '[global] return to display all elements'; 495 497 $lang['mode_created_hint'] = 'displays a calendar by creation date'; 496 498 $lang['mode_normal_hint'] = 'return to normal view mode'; -
trunk/language/fr_FR.iso-8859-1/common.lang.php
r1648 r1651 491 491 $lang['maxwidth'] = 'Largeur maximum des images'; 492 492 $lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50'; 493 $lang['start_filter_local_mode_hint'] = '[local] afficher que les éléments récents'; 494 $lang['stop_filter_local_mode_hint'] = '[local] retourner à l\'affichage de tous les éléments'; 495 $lang['start_filter_global_mode_hint'] = '[global] afficher que les éléments récents'; 496 $lang['stop_filter_global_mode_hint'] = '[global] retourner à l\'affichage de tous les éléments'; 493 497 $lang['mode_created_hint'] = 'afficher un calendrier par date de création'; 494 $lang['start_filter_mode_hint'] = 'afficher que les éléments récents';495 $lang['stop_filter_mode_hint'] = 'retourner à l\'affichage de tous les éléments';496 498 $lang['mode_normal_hint'] = 'retourner à la vue normale'; 497 499 $lang['mode_posted_hint'] = 'afficher un calendrier par date d\'ajout'; -
trunk/template/yoga/index.tpl
r1648 r1651 28 28 <!-- END search_rules --> 29 29 30 <!-- BEGIN start_filter_ mode -->31 <li><a href="{start_filter_ mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_mode_hint}"></a></li>32 <!-- END start_filter_ mode -->33 <!-- BEGIN stop_filter_ mode -->34 <li><a href="{stop_filter_ mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_mode_hint}"></a></li>35 <!-- END stop_filter_ mode -->30 <!-- BEGIN start_filter_local_mode --> 31 <li><a href="{start_filter_local_mode.URL}" title="{lang:start_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_local_mode_hint}"></a></li> 32 <!-- END start_filter_local_mode --> 33 <!-- BEGIN stop_filter_local_mode --> 34 <li><a href="{stop_filter_local_mode.URL}" title="{lang:stop_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_local_mode_hint}"></a></li> 35 <!-- END stop_filter_local_mode --> 36 36 37 37 <!-- BEGIN mode_normal --> -
trunk/template/yoga/menubar.tpl
r1650 r1651 14 14 <!-- END links --> 15 15 <dl id="mbCategories"> 16 <!-- BEGIN start_filter_ mode -->17 <a href="{start_filter_ mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="buttonmenu" alt="{lang:start_filter_mode_hint}"></a>18 <!-- END start_filter_ mode -->19 <!-- BEGIN stop_filter_ mode -->20 <a href="{stop_filter_ mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="buttonmenu" alt="{lang:stop_filter_mode_hint}"></a>21 <!-- END stop_filter_ mode -->16 <!-- BEGIN start_filter_global_mode --> 17 <a href="{start_filter_global_mode.URL}" title="{lang:start_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="buttonmenu" alt="{lang:start_filter_global_mode_hint}"></a> 18 <!-- END start_filter_global_mode --> 19 <!-- BEGIN stop_filter_global_mode --> 20 <a href="{stop_filter_global_mode.URL}" title="{lang:stop_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="buttonmenu" alt="{lang:stop_filter_global_mode_hint}"></a> 21 <!-- END stop_filter_global_mode --> 22 22 <dt><a href="{U_HOME}">{lang:Categories}</a></dt> 23 23 <dd>
Note: See TracChangeset
for help on using the changeset viewer.