Index: common/tags.php
===================================================================
--- common/tags.php	(revision 1072)
+++ common/tags.php	(working copy)
@@ -4,7 +4,8 @@
 require_once(IA_ROOT_DIR."common/db/tags.php");
 
 function tag_split($tag_data) {
-    $tags = explode(",", trim($tag_data));
+    $tags = explode(",", $tag_data);
+    array_walk($tags, 'trim');
     $result = array();
     foreach ($tags as &$tag) {
         $tag = trim($tag);
@@ -29,20 +30,25 @@
     }
 }
 
-function tag_build_list($obj, $obj_id, $type) {
+function tag_build_list($obj, $obj_id, $type, $remove_prefix = true) {
     $tag_list = tag_get($obj, $obj_id, $type);
     $tag_names = array();
     foreach ($tag_list as $tag) {
-        $tag_names[] = $tag['tag_name'];
+        if ($remove_prefix) {
+            $tag_parts = explode('@', $tag['tag_name']);
+            $tag_names[] = trim($tag_parts[ count($tag_parts) - 1 ]);
+        } else {
+            $tag_names[] = $tag['tag_name'];
+        }
     }
     return implode(", ", $tag_names);
 }
 
-function tag_update($obj, $obj_id, $type, $tag_data) {
+function tag_update($obj, $obj_id, $type, $tag_data, $tag_prefix = "") {
     tag_clear($obj, $obj_id, $type);
     $tag_data = tag_split($tag_data);
     foreach ($tag_data as $tag_name) {
-        $tag_id = tag_assign_id(array("name" => $tag_name, "type" => $type));
+        $tag_id = tag_assign_id(array("name" => $tag_prefix.$tag_name, "type" => $type));
         tag_add($obj, $obj_id, $tag_id);
     }
 }
Index: www/controllers/task.php
===================================================================
--- www/controllers/task.php	(revision 1072)
+++ www/controllers/task.php	(working copy)
@@ -64,8 +64,20 @@
     }
 
     // Tag data
-    $values['tags'] = request('tags', tag_build_list("task", $task_id, "tag"));
+    $tag_types = Array('author', 'contest', 'year', 'round', 'age_group', 'method', 'algorithm');
+    $tag_parents = Array('year' => 'contest', 'round' => 'year', 'age_group' => 'contest');
 
+    // FIXME: tags that have children such as contest, year or round should have only one tag
+    foreach ($tag_types as $type) {
+        $remove_prefix = isset($tag_parents[$type]);
+        $values['tag_'.$type] = request('tag_'.$type, tag_build_list('task', $task_id, $type, $remove_prefix));
+        $prefix['tag_'.$type] = '';
+        if (isset($tag_parents[$type])) {
+            $parent_type = $tag_parents[$type];
+            $prefix['tag_'.$type] = $prefix['tag_'.$parent_type].$values['tag_'.$parent_type]."@";
+        }
+    }
+
     // Task owner
     if (identity_can('task-edit-owner', $task)) {
         if ($task["user_id"]) {
@@ -137,7 +149,9 @@
             task_update($new_task);
 
             if (identity_can('task-tag', $new_task)) {
-                tag_update("task", $new_task['id'], "tag", $values['tags']);
+                foreach ($tag_types as $type) {
+                    tag_update('task', $new_task['id'], $type, $values['tag_'.$type], $prefix['tag_'.$type]);
+                }
             }
 
             flash("Task-ul a fost modificat cu succes.");
Index: www/views/account.php
===================================================================
--- www/views/account.php	(revision 1072)
+++ www/views/account.php	(working copy)
@@ -67,7 +67,7 @@
     <legend>Schimba informatii personale</legend>
     <ul class="form">
     <?php if (identity_can('user-tag', $view['user'])) { ?>
-        <?= tag_format_input_box(fval('tags')) ?>
+        <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?>
     <?php } ?>
         </li>
             <label for="form_name">Nume complet</label>
Index: www/views/round_edit.php
===================================================================
--- www/views/round_edit.php	(revision 1072)
+++ www/views/round_edit.php	(working copy)
@@ -92,7 +92,7 @@
    <?= view_form_field_li($form_fields['page_name'], 'page_name') ?>
    <?= view_form_field_li($form_fields['start_time'], 'start_time') ?>
    <?php if ($can_tag) { ?>
-      <?= tag_format_input_box(fval('tags')) ?>
+      <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?>
    <?php } ?>
    <?= view_form_field_li($form_fields['tasks'], 'tasks') ?>
   </ul>
Index: www/views/tags_header.php
===================================================================
--- www/views/tags_header.php	(revision 1072)
+++ www/views/tags_header.php	(working copy)
@@ -8,12 +8,12 @@
 
 // Format a tag input box
 // FIXME: Width parameter does not work, I hate CSS
-function tag_format_input_box($value = null, $width = "50", $name = "tags") {
-    $esc_name = html_escape($name);
+function tag_format_input_box($field, $value = null, $width = "50", $name = "tags") {
+    $esc_name = html_escape($field['name']);
     $esc_width = html_escape($width);
     // presume $value is html-escaped
 
-    $output = '<li><label for="form_'.$esc_name.'">Tag-uri</label>';
+    $output = '<li><label for="form_'.$esc_name.'">'.$field['label'].'</label>';
     $output .= ferr_span($name);
     $output .= '<input class="wickEnabled" type="text" name="'.$esc_name.
                '" id="form_'.$esc_name.'"';
@@ -24,8 +24,8 @@
         $output .= ' value="'.$value.'"';
     }
     $output .= ' />';
-    $output .= '<script type="text/javascript" language="JavaScript" src="'.
-                html_escape(url_static("js/wick.js")).'"></script>';
+//    $output .= '<script type="text/javascript" language="JavaScript" src="'.
+//                html_escape(url_static("js/wick.js")).'"></script>';
     $output .= "</li>";
     return $output;
 }
Index: www/views/task_edit.php
===================================================================
--- www/views/task_edit.php	(revision 1072)
+++ www/views/task_edit.php	(working copy)
@@ -124,12 +124,41 @@
         <?php if (identity_can('task-change-security', $task)) { ?>
            <?= view_form_field_li($form_fields['hidden'], 'hidden') ?>
         <?php } ?>
-        <?php if (identity_can('task-tag', $task)) { ?>
-           <?= tag_format_input_box(fval('tags')) ?>
-        <?php } ?>
-    </ul>
+   </ul>
     </fieldset>
 
+    <?php if (identity_can('task-tag', $task)) {
+        $tag_fields = Array('author' => Array("label" => "Autor",
+                                                "name" => "tag_author"),
+                            'contest' => Array("label" => "Concurs",
+                                                "name" => "tag_contest"),
+                            'year' => Array("label" => "Anul",
+                                            "name" => "tag_year"),
+                            'round' => Array("label" => "Runda",
+                                            "name" => "tag_round"),
+                            'age_group' => Array("label" => "Grupa de varsta",
+                                        "name" => "tag_age_group"),
+                            'method' => Array("label" => "Metoda de programare",
+                                        "name" => "tag_method"),
+                            'algorithm' => Array("label" => "Algoritm",
+                                        "name" => "tag_algorithm")
+                        );
+    ?>
+        <fieldset>
+            <legend>Taguri</legend>
+            <ul class="form">
+                <?= tag_format_input_box($tag_fields['author'], fval('tag_author')); ?>
+                <?= tag_format_input_box($tag_fields['contest'], fval('tag_contest')); ?>
+                <?= tag_format_input_box($tag_fields['year'], fval('tag_year')); ?>
+                <?= tag_format_input_box($tag_fields['round'], fval('tag_round')); ?>
+                <?= tag_format_input_box($tag_fields['age_group'], fval('tag_age_group')); ?>
+                <?= tag_format_input_box($tag_fields['method'], fval('tag_method')); ?>
+                <?= tag_format_input_box($tag_fields['algorithm'], fval('tag_algorithm')); ?>
+            </ul>
+        </fieldset>
+    <?php } ?>
+
+
 <?php
 // FIXME: Field should be generated from task_get_types()
 ?>
Index: www/views/textblock_edit.php
===================================================================
--- www/views/textblock_edit.php	(revision 1072)
+++ www/views/textblock_edit.php	(working copy)
@@ -44,7 +44,7 @@
     <?php } ?>
 
     <?php if (identity_can('textblock-tag', $view['page'])) { ?>
-       <?= tag_format_input_box(fval('tags')) ?>
+       <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?>
     <?php } ?>
 
     <?php if (array_key_exists('security', $form_values)) { ?>
