Changeset 1095
- Timestamp:
- 12/24/09 01:10:43 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
-
common/db/task.php (modified) (1 diff)
-
www/controllers/task.php (modified) (1 diff)
-
www/index.php (modified) (1 diff)
-
www/macros/macro_algorithmtags.php (modified) (2 diffs)
-
www/macros/macro_taskparam.php (modified) (1 diff)
-
www/macros/macro_tasks.php (modified) (2 diffs)
-
www/static/css/sitewide.css (modified) (2 diffs)
-
www/url.php (modified) (2 diffs)
-
www/views/task_filter_results.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/task.php
r1036 r1095 173 173 } 174 174 175 function task_get_authors($task_id, $no_cache = false) { 176 log_assert(is_task_id($task_id), 'Invalid task_id'); 177 178 $authors = false; 179 if (!$no_cache) { 180 $authors = mem_cache_get("task-authors-by-id:".$task_id); 181 } 182 183 if ($authors === false) { 184 $authors = tag_get("task", $task_id, "author"); 185 mem_cache_set("task-authors-by-id:".$task_id, $authors); 186 } 187 188 return $authors; 189 } 190 191 // Task filter 192 // Returns only tasks that contain all the tags 193 // and are in 'arhiva' or in 'arhiva-educationala' 194 // Task from 'arhiva-educationala' are shown first 195 function task_filter_by_tags($tag_ids, $scores = true, $user_id = null) { 196 log_assert(is_array($tag_ids), "tag_ids must be an array"); 197 foreach ($tag_ids as $tag_id) { 198 log_assert(is_tag_id($tag_id), "invalid tag id"); 199 } 200 201 if (count($tag_ids) > 0) { 202 $tag_filter = "AND ".tag_build_where('task', $tag_ids); 203 } else { 204 $tag_filter = ""; 205 } 206 207 if ($user_id == null || $scores == false) { 208 $join_score = ""; 209 $score_fields = ""; 210 } else { 211 $join_score = "LEFT JOIN ia_score ON ia_score.user_id = ".db_quote($user_id)." AND 212 ia_score.round_id = round.id AND 213 ia_score.task_id = ia_task.id AND 214 ia_score.name = 'score'"; 215 $score_fields = "ia_score.score,"; 216 } 217 218 $query = "SELECT ia_task.id AS task_id, 219 ia_task.title AS task_title, 220 ia_task.order AS 'order', 221 ia_task.page_name AS page_name, 222 ia_task.open_source AS open_source, 223 ia_task.open_tests AS open_tests, 224 round.id AS round_id, 225 $score_fields 226 round.title AS round_title 227 FROM ia_task 228 LEFT JOIN ia_round_task AS round_task ON round_task.task_id = ia_task.id 229 LEFT JOIN ia_round AS round ON round.id = round_task.round_id 230 $join_score 231 WHERE (round.id = 'arhiva' OR round.id = 'arhiva-educationala') 232 AND ia_task.hidden = '0' $tag_filter 233 ORDER BY round.id DESC, ia_task.order"; 234 $tasks = db_fetch_all($query); 235 236 return $tasks; 237 } 175 238 ?> -
trunk/www/controllers/task.php
r1094 r1095 330 330 } 331 331 332 // Gets a list of tags from request 333 // Prints a list of tasks that contain all those tags 334 // Tasks must be in 'arhiva' or in 'arhiva educationala' 335 function controller_task_search() { 336 $tags = request('tag_id', null); 337 if (is_null($tags)) { 338 $tags = Array(); 339 } 340 341 if (!is_array($tags)) { 342 flash_error("Url invalid"); 343 redirect(url_home()); 344 } 345 346 foreach ($tags as $tag) { 347 if (!is_tag_id($tag)) { 348 flash_error("Url invalid"); 349 redirect(url_home()); 350 } 351 } 352 353 if (identity_is_anonymous()) { 354 $user_id = null; 355 } else { 356 $user_id = identity_get_user_id(); 357 } 358 $tasks = task_filter_by_tags($tags, true, $user_id); 359 foreach ($tasks as &$task) { 360 $task['authors'] = task_get_authors($task['task_id']); 361 } 362 363 $view['title'] = "Rezultatele filtrării"; 364 $view['tasks'] = $tasks; 365 execute_view_die('views/task_filter_results.php', $view); 366 } 367 332 368 ?> -
trunk/www/index.php
r1086 r1095 83 83 } 84 84 85 // Task search 86 else if ($page == 'cauta-probleme') { 87 require_once(IA_ROOT_DIR.'www/controllers/task.php'); 88 controller_task_search(); 89 } 90 85 91 // Task detail editor 86 92 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'problema') { -
trunk/www/macros/macro_algorithmtags.php
r1093 r1095 51 51 $subtags_html = Array(); 52 52 foreach ($tag['sub_tags'] as $subtag) { 53 $subtags_html[] = '<div class="sub_tag_name">'.$subtag['name'].'</div>'; 53 $tag_link = format_link(url_task_search(array($tag_id)), $subtag['name'], true, 54 array('class' => "sub_tag_search_anchor")); 55 $subtags_html[] = '<div class="sub_tag_name">'.$tag_link.'</div>'; 54 56 } 55 57 56 58 $color_scheme = $tag_id % 6; 59 $tag_link = format_link(url_task_search(array($tag_id)), $tag_name, true, array('class' => 'tag_search_anchor')); 57 60 $html_code .= ' 58 61 <li style="display: none;" class="tags_list_item"> 59 <span class="tag_name color_scheme_'.$color_scheme.'">'. html_escape($tag_name).'</span>62 <span class="tag_name color_scheme_'.$color_scheme.'">'.$tag_link.'</span> 60 63 <a href="javascript:show_tag_list('.html_escape($tag_id).')" 61 64 id="tag_anchor_'.html_escape($tag_id).'" … … 66 69 <div style="display: none;" 67 70 id="tag_list_'.html_escape($tag_id).'" 68 > :69 '.implode(' ', $subtags_html).'71 > 72 '.implode(' ', $subtags_html).' 70 73 </div> 71 74 </li>'; -
trunk/www/macros/macro_taskparam.php
r1094 r1095 52 52 53 53 case 'author': 54 $authors = mem_cache_get("task-authors-by-id:".$task["id"]); 55 if ($authors === false) { 56 $authors = tag_get("task", $task["id"], "author"); 57 mem_cache_set("task-authors-by-id:".$task["id"], $authors); 58 } 54 $authors = task_get_authors($task['id']); 59 55 function format_author($tag) { 60 56 return format_link(url_task_search(array($tag["id"])), $tag["name"]); -
trunk/www/macros/macro_tasks.php
r1094 r1095 5 5 require_once(IA_ROOT_DIR . "www/format/pager.php"); 6 6 require_once(IA_ROOT_DIR . "common/db/round.php"); 7 require_once(IA_ROOT_DIR . "common/db/task.php"); 7 8 require_once(IA_ROOT_DIR . "common/round.php"); 8 9 … … 28 29 return format_link(url_task_search(array($tag["id"])), $tag["name"]); 29 30 } 31 30 32 function format_author($row) { 31 $authors = mem_cache_get("task-authors-by-id:".$row["id"]); 32 if ($authors === false) { 33 $authors = tag_get("task", $row["id"], "author"); 34 mem_cache_set("task-authors-by-id:".$row["id"], $authors); 35 } 33 $authors = task_get_authors($row['id']); 36 34 return implode(", ", array_map('format_single_author', $authors)); 37 35 } -
trunk/www/static/css/sitewide.css
r1089 r1095 310 310 } 311 311 312 a.sub_tag_search_anchor { 313 color: #000000; 314 outline-style: none; 315 } 316 317 a.sub_tag_search_anchor:hover { 318 text-decoration: none; 319 } 320 321 a.tag_search_anchor { 322 color: #FFF0E1; 323 outline-style: none; 324 } 325 326 a.tag_search_anchor:hover { 327 text-decoration: none; 328 } 329 312 330 .tag_name.color_scheme_0 { 313 331 background-color: rgb(204, 0, 0); … … 337 355 font-size: 10px; 338 356 } 357 358 table.filter_results { 359 width: 99%; 360 } -
trunk/www/url.php
r1094 r1095 52 52 } 53 53 if ($k != 'page') { 54 $url .= ($first ? "?" : "&"); 55 $first = false; 56 $url .= $k . '=' . urlencode($v); 54 if (is_array($v)) { 55 foreach ($v as $sv) { 56 $url .= ($first ? "?" : "&"); 57 $first = false; 58 $url .= $k. '[]=' . urlencode($sv); 59 } 60 } else { 61 $url .= ($first ? "?" : "&"); 62 $first = false; 63 $url .= $k . '=' . urlencode($v); 64 } 57 65 } 58 66 } 59 60 67 return $url; 61 68 } … … 267 274 268 275 function url_task_search($tag_ids) { 269 // STUB270 return "#" . implode("#", array_map('html_escape',$tag_ids));276 log_assert(is_array($tag_ids), "Tag ids must be an array"); 277 return url_complex("cauta-probleme", array("tag_id" => $tag_ids)); 271 278 } 272 279
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)