Index: common/db/tags.php
===================================================================
--- common/db/tags.php	(revision 1098)
+++ common/db/tags.php	(working copy)
@@ -59,14 +59,14 @@
 // Receives an array of tag_id's
 // Return an array with id's of their parents
 // Each parent id appears only once
-function tag_get_parents($tags) {
+function tag_get_parents($tag_ids) {
     $query = sprintf("SELECT DISTINCT(`parent`)
             FROM ia_tags
-            WHERE `id` IN (%s)",
-            implode(",", array_map('db_quote', $tags))
+            WHERE `id` IN (%s) AND `parent` != 0",
+            implode(",", array_map('db_quote', $tag_ids))
         );
     $result = db_fetch_all($query);
-    $ret = Array();
+    $ret = array();
     foreach ($result as $row) {
         $ret[] = $row['parent'];
     }
Index: common/tags.php
===================================================================
--- common/tags.php	(revision 1098)
+++ common/tags.php	(working copy)
@@ -51,26 +51,41 @@
     return implode(", ", $tag_names);
 }
 
-// Receives a list of parent tags and children tags
-// For each parent_tag adds an array 'sub_tags' containing
-// an array with all his children tags
-function build_tags_tree($parent_tags, $sub_tags) {
-    log_assert(is_array($parent_tags), "Parent tags is not an array");
-    log_assert(is_array($sub_tags), "Children tags is not an array");
+// Receives a list of tags which will be arranged in a tree-like structure
+// according to their respective parents.
+function tag_build_tree($tags) {
+    log_assert(is_array($tags), "tag_build_tree expects an array of tags");
+    $tags_by_id = array();
+    // Group tags by id
+    foreach ($tags as &$tag) {
+        log_assert(is_tag($tag), "tag_build_tree expects an array of tags");
+        log_assert(isset($tag["id"]),
+            "tag_build_tree expects an array of tags with id");
 
-    $parent_tags_key = Array();
-    foreach ($parent_tags as $key => $tag) {
-        $parent_tags[$key]['sub_tags'] = Array();
-        $parent_tags_key[$tag['id']] = $key;
+        $tags_by_id[$tag["id"]] =& $tag;
     }
 
-    foreach ($sub_tags as $tag) {
-        log_assert(isset($parent_tags_key[$tag['parent']]), "Child tag doesn't have a parent");
-        $parent_tag_key = $parent_tags_key[$tag['parent']];
-        $parent_tags[$parent_tag_key]['sub_tags'][] = $tag;
+    // Add 'sub_tags' attribute to all tags which have children.
+    $has_parent = array();
+    foreach ($tags as &$tag) {
+        if (array_key_exists($tag["parent"], $tags_by_id)) {
+            $has_parent[$tag["id"]] = true;
+
+            if (!isset($tags_by_id[$tag["parent"]]["sub_tags"])) {
+                $tags_by_id[$tag["parent"]]["sub_tags"] = array();
+            }
+            $tags_by_id[$tag["parent"]]["sub_tags"][] =& $tag;
+        }
     }
 
-    return $parent_tags;
+    // Return only tree roots (tags which have no parents).
+    $roots = array();
+    foreach ($tags_by_id as &$tag) {
+        if (!isset($has_parent[$tag["id"]])) {
+            $roots[] = $tag;
+        }
+    }
+    return $roots;
 }
 
 // Receives a list of tags of a certain type and, optionally, with a
Index: www/controllers/task.php
===================================================================
--- www/controllers/task.php	(revision 1098)
+++ www/controllers/task.php	(working copy)
@@ -314,11 +314,8 @@
         flash("Tagurile au fost salvate cu succes");
     }
 
-    $tags = tag_get_all( Array('method') );
-    $sub_tags = tag_get_all( Array('algorithm') );
+    $tags_tree = tag_build_tree(tag_get_all(array("method", "algorithm")));
 
-    $tags_tree = build_tags_tree($tags, $sub_tags);
-
     // Get tags for task_id
     $task_tags = tag_get('task', $task_id, 'algorithm');
 
@@ -335,17 +332,16 @@
 function controller_task_search() {
     $tags = request('tag_id', null);
     if (is_null($tags)) {
-        $tags = Array();
+        $tags = array();
     }
 
     if (!is_array($tags)) {
-        flash_error("Url invalid");
+        flash_error("Filtru invalid");
         redirect(url_home());
     }
-
     foreach ($tags as $tag) {
         if (!is_tag_id($tag)) {
-            flash_error("Url invalid");
+            flash_error("Filtru invalid");
             redirect(url_home());
         }
     }
@@ -360,8 +356,20 @@
         $task['authors'] = task_get_authors($task['task_id']);
     }
 
+    // Fetch the tags and all their parents so they can be displayed
+    // in a tree-like fashion
+    if (count($tags) > 0) {
+        while ((
+            $new_tags = array_unique(array_merge($tags, tag_get_parents($tags)))
+        ) != $tags) {
+            $tags = $new_tags;
+        }
+        $tags = tag_build_tree(tag_get_by_ids($tags));
+    }
+
     $view['title'] = "Rezultatele filtrării";
     $view['tasks'] = $tasks;
+    $view['tags'] = $tags;
     execute_view_die('views/task_filter_results.php', $view);
 }
 
Index: www/controllers/task_tags.php
===================================================================
--- www/controllers/task_tags.php	(revision 1098)
+++ www/controllers/task_tags.php	(working copy)
@@ -1,16 +1,13 @@
 <?php
-require_once(IA_ROOT_DIR . "common/db/tags.php");
+require_once(IA_ROOT_DIR . "common/tags.php");
 require_once(IA_ROOT_DIR . "common/string.php");
 
 // Displays an interface in which admins can define algorithm tag categories
 function controller_task_tags() {
     identity_require("task-tag");
 
-    $categories = tag_get_all(array("method"));
+    $categories = tag_build_tree(tag_get_all(array("method", "algorithm")));
     foreach ($categories as &$category) {
-        // Get all sub tags for current category
-        $category["sub_tags"] = tag_get_all(array("algorithm"),
-            $category["id"]);
         foreach ($category["sub_tags"] as &$tag) {
             $tag["task_count"] = tag_count_objects("task", array($tag["id"]));
         }
Index: www/macros/macro_algorithmtags.php
===================================================================
--- www/macros/macro_algorithmtags.php	(revision 1098)
+++ www/macros/macro_algorithmtags.php	(working copy)
@@ -16,7 +16,7 @@
     $tags = tag_get('task', $task_id, 'method');
     $sub_tags = tag_get('task', $task_id, 'algorithm');
 
-    $tags_tree = build_tags_tree($tags, $sub_tags);
+    $tags_tree = tag_build_tree(array_merge($tags, $sub_tags));
 
     $task = task_get($task_id);
     if (!identity_can('task-view-tags', $task)) {
@@ -33,7 +33,7 @@
         $category_word = "categorie";
     }
     $html_code = "<div id=\"task_tags\">";
-    $html_code .= "<h3> Indicaţii de rezolvare</h3>";
+    $html_code .= "<h3> Indicii de rezolvare</h3>";
     $html_code .= '<a id="show_tags" href="javascript:show_tags()">
                 Arată '.count($tags_tree).' '.$category_word.'</a>';
 
Index: www/macros/macro_tasks.php
===================================================================
--- www/macros/macro_tasks.php	(revision 1098)
+++ www/macros/macro_tasks.php	(working copy)
@@ -56,7 +56,7 @@
 
     $tab_names = array(IA_TLF_ALL => 'Toate problemele',
                        IA_TLF_UNSOLVED => 'Nerezolvate',
-                       IA_TLF_TRIED => 'Incercate',
+                       IA_TLF_TRIED => 'Încercate',
                        IA_TLF_SOLVED => 'Rezolvate');
 
     foreach ($tab_names as $id => $text) {
@@ -140,7 +140,7 @@
     $column_infos = array();
     if ($show_numbers) {
         $column_infos[] = array(
-                'title' => 'Numar',
+                'title' => 'Număr',
                 'css_class' => 'number',
                 'rowform' => create_function_cached('$row',
                         'return str_pad($row["order"] - 1, 3, \'0\', STR_PAD_LEFT);'),
@@ -160,14 +160,14 @@
     }
     if ($show_sources) {
         $column_infos[] = array(
-                'title' => 'Sursa',
+                'title' => 'Sursă',
                 'css_class' => 'source',
                 'key' => 'source',
         );
     }
     if (!is_null($user_id)) {
         $column_infos[] = array (
-                'title' => 'Scorul tau',
+                'title' => 'Scorul tău',
                 'css_class' => 'number score',
                 'key' => 'score',
                 'valform' => 'format_score_column',
Index: www/static/css/screen.css
===================================================================
--- www/static/css/screen.css	(revision 1098)
+++ www/static/css/screen.css	(working copy)
@@ -548,7 +548,7 @@
 }
 
 input[type='text'], input[type='password'], select {
-    width: 250px;
+    width: 200px;
 }
 
 #sidebar input[type='text'], #sidebar input[type='password'], #sidebar select {
@@ -1535,3 +1535,13 @@
 .tag-table .tag-operations {
     width: 25%;
 }
+
+/* Task filter by tag page */
+.filter_results {
+    line-height: 2em;
+}
+
+ul.tag_filters {
+    line-height: 1.5em;
+    margin: 0 .5em .5em 2em;
+}
Index: www/static/css/sitewide.css
===================================================================
--- www/static/css/sitewide.css	(revision 1098)
+++ www/static/css/sitewide.css	(working copy)
@@ -354,11 +354,3 @@
 .show_tag_anchor {
     font-size: 10px;
 }
-
-table.filter_results {
-    width: 99%;
-}
-
-table.filter_results td, th {
-    padding: 3px;
-}
Index: www/static/css/wick.css
===================================================================
--- www/static/css/wick.css	(revision 1098)
+++ www/static/css/wick.css	(working copy)
@@ -27,7 +27,7 @@
     border:1px inset #979797;
     color:black;
     padding: 0;
-    width: 257px;
+    width: 207px;
 }
 
 .matchedSmartInputItem {
Index: www/views/header.php
===================================================================
--- www/views/header.php	(revision 1098)
+++ www/views/header.php	(working copy)
@@ -98,19 +98,19 @@
     <ul id="nav" class="clear">
         <li><a href="<?= html_escape(url_home()) ?>">Home</a></li>
         <li><?= format_link_access(url_textblock('arhiva'), "Arhiva de probleme", 'a') ?></li>
-        <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educationala</a></li>
+        <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educatională</a></li>
         <li><a href="<?= html_escape(url_textblock('concursuri')) ?>">Concursuri</a></li>
         <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>">Concursuri virtuale<span style="color: red; font-weight:bold;"><sup>nou!</sup></span></a></li> 
         <li><a href="<?= html_escape(url_textblock('clasament-rating')) ?>">Clasament</a></li>
         <li><a href="<?= html_escape(url_textblock('articole')) ?>">Articole</a></li>
         <li><a href="<?= html_escape(url_textblock('downloads')) ?>">Downloads</a></li>
         <li><a href="<?= html_escape(url_textblock('links')) ?>">Links</a></li>
-        <li><a href="<?= html_escape(url_textblock('documentatie')) ?>">Documentatie</a></li>
+        <li><a href="<?= html_escape(url_textblock('documentatie')) ?>">Documentaţie</a></li>
         <li><a href="<?= html_escape(url_textblock('despre-infoarena')) ?>">Despre infoarena</a></li>
         <li class="separator"><hr/></li>
         <li><?= format_link_access(url_monitor(array('user' => identity_get_username())), "Monitorul de evaluare", 'm') ?></li>
         <?php if (!identity_is_anonymous()) { ?>
-        <li><a href="<?= html_escape(url_submit()) ?>"><strong>Trimite solutii</strong></a></li>
+        <li><a href="<?= html_escape(url_submit()) ?>"><strong>Trimite soluţii</strong></a></li>
         <li><?= format_link_access(url_account(), "Contul meu", 'c') ?></li>
         <?php } ?>
         </ul>
Index: www/views/task_filter_results.php
===================================================================
--- www/views/task_filter_results.php	(revision 1098)
+++ www/views/task_filter_results.php	(working copy)
@@ -46,12 +46,40 @@
     }
 }
 
-echo "<h1>Rezultatele Filtrarii</h1>";
+function tag_print($tags) {
+    if (count($tags) == 0) {
+        return "";
+    }
+
+    $tag_types = array(
+        "author" => "Autor",
+        "contest" => "Concurs",
+        "year" => "Editie",
+        "round" => "Runda",
+        "age_group" => "Grupa de varsta",
+        "method" => "Categorie",
+        "algorithm" => "Algoritm",
+        "tag" => "Tag"
+    );
+    $output = '<ul class="tag_filters">';
+    foreach ($tags as $tag) {
+        $output .= sprintf("<li>%s%s</li>",
+            format_link(url_task_search(array($tag["id"])), sprintf("%s: %s",
+                $tag_types[$tag["type"]], $tag["name"])),
+            tag_print(getattr($tag, "sub_tags", array()))
+        );
+    }
+    $output .= "</ul>";
+    return $output;
+}
+
+echo "<h1>Rezultatele filtrării</h1>";
+echo tag_print($view["tags"]);
 $tasks = $view['tasks'];
 $options = pager_init_options();
 $options['total_entries'] = count($tasks);
 $options['row_style'] = 'task_row_style';
-$options['css_class'] = 'tasks filter_results';
+$options['css_class'] = 'tasks fill-screen filter_results';
 $options['show_count'] = true;
 $options['show_display_entries'] = false;
 
@@ -63,7 +91,7 @@
 
 $column_infos = array();
 $column_infos[] = array(
-        'title' => 'Numar',
+        'title' => 'Număr',
         'css_class' => 'number',
         'rowform' => create_function_cached('$row',
         'return str_pad($row["order"] - 1, 3, \'0\', STR_PAD_LEFT);'));
@@ -74,21 +102,27 @@
         'rowform' => 'format_title');
 $column_infos[] = array(
         'title' => 'Autor(i)',
+        'css_class' => 'author',
         'rowform' => 'format_authors');
 $column_infos[] = array(
-        'title' => 'Sursa',
+        'title' => 'Sursă',
         'css_class' => 'source',
-        'key' => 'round_title',);
+        'key' => 'round_title');
 if (!is_null($user_id)) {
     $column_infos[] = array (
-            'title' => 'Scorul tau',
+            'title' => 'Scorul tău',
             'css_class' => 'number score',
             'key' => 'score',
             'valform' => 'format_score_column');
 }
 
-$task_chunks = array_chunk($tasks, $options['display_entries']);
-$chunk = $task_chunks[$options['first_entry'] / $options['display_entries']];
-echo format_table($chunk, $column_infos, $options);
+if (!count($tasks)) {
+    echo "Nicio problemă gasită.";
+} else {
+    $task_chunks = array_chunk($tasks, $options['display_entries']);
+    $chunk = $task_chunks[$options['first_entry'] / $options['display_entries']];
+    echo format_table($chunk, $column_infos, $options);
+}
+
 include('footer.php');
 ?>
Index: www/views/textblock_header.php
===================================================================
--- www/views/textblock_header.php	(revision 1098)
+++ www/views/textblock_header.php	(working copy)
@@ -10,39 +10,39 @@
 <div id="wikiOps">
     <ul>
 <?php if (($task_id = textblock_security_is_task($textblock['security'])) && identity_can('task-edit', $task = task_get($task_id))) { ?>
-<li><?= format_link_access(url_task_edit($task['id']), 'Editeaza parametrii', 'p') ?></li>
+<li><?= format_link_access(url_task_edit($task['id']), 'Editează parametrii', 'p') ?></li>
 <?php } ?>
 <?php if ($task_id && identity_can('task-tag', $task)) { ?>
-<li><?= format_link_access(url_task_edit_tags($task['id']), 'Editeaza tag-uri', 't') ?></li>
+<li><?= format_link_access(url_task_edit_tags($task['id']), 'Editează tag-uri', 't') ?></li>
 <?php } ?>
 <?php if (($round_id = textblock_security_is_round($textblock['security'])) && identity_can('round-edit', $round = round_get($round_id))) { ?>
-<li><?= format_link_access(url_round_edit($round['id']), 'Editeaza parametrii', 'p') ?></li>
+<li><?= format_link_access(url_round_edit($round['id']), 'Editează parametrii', 'p') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-edit', $textblock)) { ?>
-<li><?= format_link_access(url_textblock_edit($textblock['name']), ($task_id) ? 'Editeaza enunt' : 'Editeaza', 'e') ?></li>
+<li><?= format_link_access(url_textblock_edit($textblock['name']), ($task_id) ? 'Editează enunţ' : 'Editează', 'e') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-history', $textblock)) { ?>
 <li><?= format_link_access(url_textblock_history($textblock['name']), 'Istoria', 'i') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-move', $textblock)) { ?>
-<li><?= format_link_access(url_textblock_move($textblock['name']), 'Muta', 'u') ?></li>
+<li><?= format_link_access(url_textblock_move($textblock['name']), 'Mută', 'u') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-copy', $textblock)) { ?>
-<li><?= format_link_access(url_textblock_copy($textblock['name']), 'Copiaza', 'c') ?></li>
+<li><?= format_link_access(url_textblock_copy($textblock['name']), 'Copiază', 'c') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-delete', $textblock)) { ?>
 <li><?= format_post_link(
     url_textblock_delete($textblock['name']),
-    'Sterge', array(), true, array('onclick' =>
+    'Şterge', array(), true, array('onclick' =>
     "return confirm('Aceasta actiune este ireversibila! Doresti sa continui?')"),
-    's') ?>
+    'r') ?>
 </li>
 <?php } ?>
 <?php if (identity_can('textblock-attach', $textblock)) { ?>
-<li><?= format_link_access(url_attachment_new($textblock['name']), 'Ataseaza', 'a') ?></li>
+<li><?= format_link_access(url_attachment_new($textblock['name']), 'Ataşează', 'a') ?></li>
 <?php } ?>
 <?php if (identity_can('textblock-list-attach', $textblock)) { ?>
-<li><?= format_link_access(url_attachment_list($textblock['name']), 'Listeaza atasamente', 'l') ?></li>
+<li><?= format_link_access(url_attachment_list($textblock['name']), 'Listează ataşamente', 'l') ?></li>
 <?php } ?>
      </ul>
 </div>
