- Timestamp:
- 12/28/09 14:24:37 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
common/db/tags.php (modified) (1 diff)
-
common/tags.php (modified) (1 diff)
-
www/controllers/task.php (modified) (3 diffs)
-
www/controllers/task_tags.php (modified) (2 diffs)
-
www/macros/macro_algorithmtags.php (modified) (2 diffs)
-
www/macros/macro_tasks.php (modified) (4 diffs)
-
www/static/css/screen.css (modified) (2 diffs)
-
www/static/css/sitewide.css (modified) (1 diff)
-
www/static/css/wick.css (modified) (1 diff)
-
www/views/header.php (modified) (2 diffs)
-
www/views/task_filter_results.php (modified) (4 diffs)
-
www/views/textblock_header.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/tags.php
r1089 r1099 60 60 // Return an array with id's of their parents 61 61 // Each parent id appears only once 62 function tag_get_parents($tag s) {62 function tag_get_parents($tag_ids) { 63 63 $query = sprintf("SELECT DISTINCT(`parent`) 64 64 FROM ia_tags 65 WHERE `id` IN (%s) ",66 implode(",", array_map('db_quote', $tag s))65 WHERE `id` IN (%s) AND `parent` != 0", 66 implode(",", array_map('db_quote', $tag_ids)) 67 67 ); 68 68 $result = db_fetch_all($query); 69 $ret = Array();69 $ret = array(); 70 70 foreach ($result as $row) { 71 71 $ret[] = $row['parent']; -
trunk/common/tags.php
r1089 r1099 52 52 } 53 53 54 // Receives a list of parent tags and children tags 55 // For each parent_tag adds an array 'sub_tags' containing 56 // an array with all his children tags 57 function build_tags_tree($parent_tags, $sub_tags) { 58 log_assert(is_array($parent_tags), "Parent tags is not an array"); 59 log_assert(is_array($sub_tags), "Children tags is not an array"); 54 // Receives a list of tags which will be arranged in a tree-like structure 55 // according to their respective parents. 56 function tag_build_tree($tags) { 57 log_assert(is_array($tags), "tag_build_tree expects an array of tags"); 58 $tags_by_id = array(); 59 // Group tags by id 60 foreach ($tags as &$tag) { 61 log_assert(is_tag($tag), "tag_build_tree expects an array of tags"); 62 log_assert(isset($tag["id"]), 63 "tag_build_tree expects an array of tags with id"); 60 64 61 $parent_tags_key = Array(); 62 foreach ($parent_tags as $key => $tag) { 63 $parent_tags[$key]['sub_tags'] = Array(); 64 $parent_tags_key[$tag['id']] = $key; 65 $tags_by_id[$tag["id"]] =& $tag; 65 66 } 66 67 67 foreach ($sub_tags as $tag) { 68 log_assert(isset($parent_tags_key[$tag['parent']]), "Child tag doesn't have a parent"); 69 $parent_tag_key = $parent_tags_key[$tag['parent']]; 70 $parent_tags[$parent_tag_key]['sub_tags'][] = $tag; 68 // Add 'sub_tags' attribute to all tags which have children. 69 $has_parent = array(); 70 foreach ($tags as &$tag) { 71 if (array_key_exists($tag["parent"], $tags_by_id)) { 72 $has_parent[$tag["id"]] = true; 73 74 if (!isset($tags_by_id[$tag["parent"]]["sub_tags"])) { 75 $tags_by_id[$tag["parent"]]["sub_tags"] = array(); 76 } 77 $tags_by_id[$tag["parent"]]["sub_tags"][] =& $tag; 78 } 71 79 } 72 80 73 return $parent_tags; 81 // Return only tree roots (tags which have no parents). 82 $roots = array(); 83 foreach ($tags_by_id as &$tag) { 84 if (!isset($has_parent[$tag["id"]])) { 85 $roots[] = $tag; 86 } 87 } 88 return $roots; 74 89 } 75 90 -
trunk/www/controllers/task.php
r1095 r1099 315 315 } 316 316 317 $tags = tag_get_all( Array('method') ); 318 $sub_tags = tag_get_all( Array('algorithm') ); 319 320 $tags_tree = build_tags_tree($tags, $sub_tags); 317 $tags_tree = tag_build_tree(tag_get_all(array("method", "algorithm"))); 321 318 322 319 // Get tags for task_id … … 336 333 $tags = request('tag_id', null); 337 334 if (is_null($tags)) { 338 $tags = Array();335 $tags = array(); 339 336 } 340 337 341 338 if (!is_array($tags)) { 342 flash_error("Url invalid"); 343 redirect(url_home()); 344 } 345 339 flash_error("Filtru invalid"); 340 redirect(url_home()); 341 } 346 342 foreach ($tags as $tag) { 347 343 if (!is_tag_id($tag)) { 348 flash_error(" Urlinvalid");344 flash_error("Filtru invalid"); 349 345 redirect(url_home()); 350 346 } … … 361 357 } 362 358 359 // Fetch the tags and all their parents so they can be displayed 360 // in a tree-like fashion 361 if (count($tags) > 0) { 362 while (( 363 $new_tags = array_unique(array_merge($tags, tag_get_parents($tags))) 364 ) != $tags) { 365 $tags = $new_tags; 366 } 367 $tags = tag_build_tree(tag_get_by_ids($tags)); 368 } 369 363 370 $view['title'] = "Rezultatele filtrării"; 364 371 $view['tasks'] = $tasks; 372 $view['tags'] = $tags; 365 373 execute_view_die('views/task_filter_results.php', $view); 366 374 } -
trunk/www/controllers/task_tags.php
r1094 r1099 1 1 <?php 2 require_once(IA_ROOT_DIR . "common/ db/tags.php");2 require_once(IA_ROOT_DIR . "common/tags.php"); 3 3 require_once(IA_ROOT_DIR . "common/string.php"); 4 4 … … 7 7 identity_require("task-tag"); 8 8 9 $categories = tag_ get_all(array("method"));9 $categories = tag_build_tree(tag_get_all(array("method", "algorithm"))); 10 10 foreach ($categories as &$category) { 11 // Get all sub tags for current category12 $category["sub_tags"] = tag_get_all(array("algorithm"),13 $category["id"]);14 11 foreach ($category["sub_tags"] as &$tag) { 15 12 $tag["task_count"] = tag_count_objects("task", array($tag["id"])); -
trunk/www/macros/macro_algorithmtags.php
r1096 r1099 17 17 $sub_tags = tag_get('task', $task_id, 'algorithm'); 18 18 19 $tags_tree = build_tags_tree($tags, $sub_tags);19 $tags_tree = tag_build_tree(array_merge($tags, $sub_tags)); 20 20 21 21 $task = task_get($task_id); … … 34 34 } 35 35 $html_code = "<div id=\"task_tags\">"; 36 $html_code .= "<h3> Indic aţii de rezolvare</h3>";36 $html_code .= "<h3> Indicii de rezolvare</h3>"; 37 37 $html_code .= '<a id="show_tags" href="javascript:show_tags()"> 38 38 Arată '.count($tags_tree).' '.$category_word.'</a>'; -
trunk/www/macros/macro_tasks.php
r1095 r1099 57 57 $tab_names = array(IA_TLF_ALL => 'Toate problemele', 58 58 IA_TLF_UNSOLVED => 'Nerezolvate', 59 IA_TLF_TRIED => ' Incercate',59 IA_TLF_TRIED => 'Încercate', 60 60 IA_TLF_SOLVED => 'Rezolvate'); 61 61 … … 141 141 if ($show_numbers) { 142 142 $column_infos[] = array( 143 'title' => 'Num ar',143 'title' => 'Număr', 144 144 'css_class' => 'number', 145 145 'rowform' => create_function_cached('$row', … … 161 161 if ($show_sources) { 162 162 $column_infos[] = array( 163 'title' => 'Surs a',163 'title' => 'Sursă', 164 164 'css_class' => 'source', 165 165 'key' => 'source', … … 168 168 if (!is_null($user_id)) { 169 169 $column_infos[] = array ( 170 'title' => 'Scorul t au',170 'title' => 'Scorul tău', 171 171 'css_class' => 'number score', 172 172 'key' => 'score', -
trunk/www/static/css/screen.css
r1090 r1099 549 549 550 550 input[type='text'], input[type='password'], select { 551 width: 2 50px;551 width: 200px; 552 552 } 553 553 … … 1536 1536 width: 25%; 1537 1537 } 1538 1539 /* Task filter by tag page */ 1540 .filter_results { 1541 line-height: 2em; 1542 } 1543 1544 ul.tag_filters { 1545 line-height: 1.5em; 1546 margin: 0 .5em .5em 2em; 1547 } -
trunk/www/static/css/sitewide.css
r1096 r1099 355 355 font-size: 10px; 356 356 } 357 358 table.filter_results {359 width: 99%;360 }361 362 table.filter_results td, th {363 padding: 3px;364 } -
trunk/www/static/css/wick.css
r1083 r1099 28 28 color:black; 29 29 padding: 0; 30 width: 2 57px;30 width: 207px; 31 31 } 32 32 -
trunk/www/views/header.php
r1088 r1099 99 99 <li><a href="<?= html_escape(url_home()) ?>">Home</a></li> 100 100 <li><?= format_link_access(url_textblock('arhiva'), "Arhiva de probleme", 'a') ?></li> 101 <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educational a</a></li>101 <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educatională</a></li> 102 102 <li><a href="<?= html_escape(url_textblock('concursuri')) ?>">Concursuri</a></li> 103 103 <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>">Concursuri virtuale<span style="color: red; font-weight:bold;"><sup>nou!</sup></span></a></li> … … 106 106 <li><a href="<?= html_escape(url_textblock('downloads')) ?>">Downloads</a></li> 107 107 <li><a href="<?= html_escape(url_textblock('links')) ?>">Links</a></li> 108 <li><a href="<?= html_escape(url_textblock('documentatie')) ?>">Documenta tie</a></li>108 <li><a href="<?= html_escape(url_textblock('documentatie')) ?>">Documentaţie</a></li> 109 109 <li><a href="<?= html_escape(url_textblock('despre-infoarena')) ?>">Despre infoarena</a></li> 110 110 <li class="separator"><hr/></li> 111 111 <li><?= format_link_access(url_monitor(array('user' => identity_get_username())), "Monitorul de evaluare", 'm') ?></li> 112 112 <?php if (!identity_is_anonymous()) { ?> 113 <li><a href="<?= html_escape(url_submit()) ?>"><strong>Trimite solu tii</strong></a></li>113 <li><a href="<?= html_escape(url_submit()) ?>"><strong>Trimite soluţii</strong></a></li> 114 114 <li><?= format_link_access(url_account(), "Contul meu", 'c') ?></li> 115 115 <?php } ?> -
trunk/www/views/task_filter_results.php
r1095 r1099 47 47 } 48 48 49 echo "<h1>Rezultatele Filtrarii</h1>"; 49 function tag_print($tags) { 50 if (count($tags) == 0) { 51 return ""; 52 } 53 54 $tag_types = array( 55 "author" => "Autor", 56 "contest" => "Concurs", 57 "year" => "Editie", 58 "round" => "Runda", 59 "age_group" => "Grupa de varsta", 60 "method" => "Categorie", 61 "algorithm" => "Algoritm", 62 "tag" => "Tag" 63 ); 64 $output = '<ul class="tag_filters">'; 65 foreach ($tags as $tag) { 66 $output .= sprintf("<li>%s%s</li>", 67 format_link(url_task_search(array($tag["id"])), sprintf("%s: %s", 68 $tag_types[$tag["type"]], $tag["name"])), 69 tag_print(getattr($tag, "sub_tags", array())) 70 ); 71 } 72 $output .= "</ul>"; 73 return $output; 74 } 75 76 echo "<h1>Rezultatele filtrării</h1>"; 77 echo tag_print($view["tags"]); 50 78 $tasks = $view['tasks']; 51 79 $options = pager_init_options(); 52 80 $options['total_entries'] = count($tasks); 53 81 $options['row_style'] = 'task_row_style'; 54 $options['css_class'] = 'tasks fil ter_results';82 $options['css_class'] = 'tasks fill-screen filter_results'; 55 83 $options['show_count'] = true; 56 84 $options['show_display_entries'] = false; … … 64 92 $column_infos = array(); 65 93 $column_infos[] = array( 66 'title' => 'Num ar',94 'title' => 'Număr', 67 95 'css_class' => 'number', 68 96 'rowform' => create_function_cached('$row', … … 75 103 $column_infos[] = array( 76 104 'title' => 'Autor(i)', 105 'css_class' => 'author', 77 106 'rowform' => 'format_authors'); 78 107 $column_infos[] = array( 79 'title' => 'Surs a',108 'title' => 'Sursă', 80 109 'css_class' => 'source', 81 'key' => 'round_title' ,);110 'key' => 'round_title'); 82 111 if (!is_null($user_id)) { 83 112 $column_infos[] = array ( 84 'title' => 'Scorul t au',113 'title' => 'Scorul tău', 85 114 'css_class' => 'number score', 86 115 'key' => 'score', … … 88 117 } 89 118 90 $task_chunks = array_chunk($tasks, $options['display_entries']); 91 $chunk = $task_chunks[$options['first_entry'] / $options['display_entries']]; 92 echo format_table($chunk, $column_infos, $options); 119 if (!count($tasks)) { 120 echo "Nicio problemă gasită."; 121 } else { 122 $task_chunks = array_chunk($tasks, $options['display_entries']); 123 $chunk = $task_chunks[$options['first_entry'] / $options['display_entries']]; 124 echo format_table($chunk, $column_infos, $options); 125 } 126 93 127 include('footer.php'); 94 128 ?> -
trunk/www/views/textblock_header.php
r1098 r1099 11 11 <ul> 12 12 <?php if (($task_id = textblock_security_is_task($textblock['security'])) && identity_can('task-edit', $task = task_get($task_id))) { ?> 13 <li><?= format_link_access(url_task_edit($task['id']), 'Editeaz aparametrii', 'p') ?></li>13 <li><?= format_link_access(url_task_edit($task['id']), 'Editează parametrii', 'p') ?></li> 14 14 <?php } ?> 15 15 <?php if ($task_id && identity_can('task-tag', $task)) { ?> 16 <li><?= format_link_access(url_task_edit_tags($task['id']), 'Editeaz atag-uri', 't') ?></li>16 <li><?= format_link_access(url_task_edit_tags($task['id']), 'Editează tag-uri', 't') ?></li> 17 17 <?php } ?> 18 18 <?php if (($round_id = textblock_security_is_round($textblock['security'])) && identity_can('round-edit', $round = round_get($round_id))) { ?> 19 <li><?= format_link_access(url_round_edit($round['id']), 'Editeaz aparametrii', 'p') ?></li>19 <li><?= format_link_access(url_round_edit($round['id']), 'Editează parametrii', 'p') ?></li> 20 20 <?php } ?> 21 21 <?php if (identity_can('textblock-edit', $textblock)) { ?> 22 <li><?= format_link_access(url_textblock_edit($textblock['name']), ($task_id) ? 'Editeaz a enunt' : 'Editeaza', 'e') ?></li>22 <li><?= format_link_access(url_textblock_edit($textblock['name']), ($task_id) ? 'Editează enunţ' : 'Editează', 'e') ?></li> 23 23 <?php } ?> 24 24 <?php if (identity_can('textblock-history', $textblock)) { ?> … … 26 26 <?php } ?> 27 27 <?php if (identity_can('textblock-move', $textblock)) { ?> 28 <li><?= format_link_access(url_textblock_move($textblock['name']), 'Mut a', 'u') ?></li>28 <li><?= format_link_access(url_textblock_move($textblock['name']), 'Mută', 'u') ?></li> 29 29 <?php } ?> 30 30 <?php if (identity_can('textblock-copy', $textblock)) { ?> 31 <li><?= format_link_access(url_textblock_copy($textblock['name']), 'Copiaz a', 'c') ?></li>31 <li><?= format_link_access(url_textblock_copy($textblock['name']), 'Copiază', 'c') ?></li> 32 32 <?php } ?> 33 33 <?php if (identity_can('textblock-delete', $textblock)) { ?> 34 34 <li><?= format_post_link( 35 35 url_textblock_delete($textblock['name']), 36 ' Sterge', array(), true, array('onclick' =>36 'Şterge', array(), true, array('onclick' => 37 37 "return confirm('Aceasta actiune este ireversibila! Doresti sa continui?')"), 38 ' s') ?>38 'r') ?> 39 39 </li> 40 40 <?php } ?> 41 41 <?php if (identity_can('textblock-attach', $textblock)) { ?> 42 <li><?= format_link_access(url_attachment_new($textblock['name']), 'Ata seaza', 'a') ?></li>42 <li><?= format_link_access(url_attachment_new($textblock['name']), 'Ataşează', 'a') ?></li> 43 43 <?php } ?> 44 44 <?php if (identity_can('textblock-list-attach', $textblock)) { ?> 45 <li><?= format_link_access(url_attachment_list($textblock['name']), 'Listeaz a atasamente', 'l') ?></li>45 <li><?= format_link_access(url_attachment_list($textblock['name']), 'Listează ataşamente', 'l') ?></li> 46 46 <?php } ?> 47 47 </ul>
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)