- Timestamp:
- 12/13/09 19:17:05 (2 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
common/tags.php (modified) (2 diffs)
-
www/controllers/task.php (modified) (2 diffs)
-
www/views/account.php (modified) (1 diff)
-
www/views/round_edit.php (modified) (1 diff)
-
www/views/tags_header.php (modified) (2 diffs)
-
www/views/task_edit.php (modified) (1 diff)
-
www/views/textblock_edit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/tags.php
r1069 r1077 5 5 6 6 function tag_split($tag_data) { 7 $tags = explode(",", trim($tag_data)); 7 $tags = explode(",", $tag_data); 8 array_walk($tags, 'trim'); 8 9 $result = array(); 9 10 foreach ($tags as &$tag) { … … 30 31 } 31 32 32 function tag_build_list($obj, $obj_id, $type ) {33 function tag_build_list($obj, $obj_id, $type, $remove_prefix = true) { 33 34 $tag_list = tag_get($obj, $obj_id, $type); 34 35 $tag_names = array(); 35 36 foreach ($tag_list as $tag) { 36 $tag_names[] = $tag['tag_name']; 37 if ($remove_prefix) { 38 $tag_parts = explode('@', $tag['tag_name']); 39 $tag_names[] = trim($tag_parts[ count($tag_parts) - 1 ]); 40 } else { 41 $tag_names[] = $tag['tag_name']; 42 } 37 43 } 38 44 return implode(", ", $tag_names); 39 45 } 40 46 41 function tag_update($obj, $obj_id, $type, $tag_data ) {47 function tag_update($obj, $obj_id, $type, $tag_data, $tag_prefix = "") { 42 48 tag_clear($obj, $obj_id, $type); 43 49 $tag_data = tag_split($tag_data); 44 50 foreach ($tag_data as $tag_name) { 45 $tag_id = tag_assign_id(array("name" => $tag_ name, "type" => $type));51 $tag_id = tag_assign_id(array("name" => $tag_prefix.$tag_name, "type" => $type)); 46 52 tag_add($obj, $obj_id, $tag_id); 47 53 } -
trunk/www/controllers/task.php
r1069 r1077 65 65 66 66 // Tag data 67 $values['tags'] = request('tags', tag_build_list("task", $task_id, "tag")); 67 $tag_types = Array('author', 'contest', 'year', 'round', 'age_group', 'method', 'algorithm'); 68 $tag_parents = Array('year' => 'contest', 'round' => 'year', 'age_group' => 'contest'); 69 70 // FIXME: tags that have children such as contest, year or round should have only one tag 71 foreach ($tag_types as $type) { 72 $remove_prefix = isset($tag_parents[$type]); 73 $values['tag_'.$type] = request('tag_'.$type, tag_build_list('task', $task_id, $type, $remove_prefix)); 74 $prefix['tag_'.$type] = ''; 75 if (isset($tag_parents[$type])) { 76 $parent_type = $tag_parents[$type]; 77 $prefix['tag_'.$type] = $prefix['tag_'.$parent_type].$values['tag_'.$parent_type]."@"; 78 } 79 } 68 80 69 81 // Task owner … … 138 150 139 151 if (identity_can('task-tag', $new_task)) { 140 tag_update("task", $new_task['id'], "tag", $values['tags']); 152 foreach ($tag_types as $type) { 153 tag_update('task', $new_task['id'], $type, $values['tag_'.$type], $prefix['tag_'.$type]); 154 } 141 155 } 142 156 -
trunk/www/views/account.php
r934 r1077 68 68 <ul class="form"> 69 69 <?php if (identity_can('user-tag', $view['user'])) { ?> 70 <?= tag_format_input_box( fval('tags')) ?>70 <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?> 71 71 <?php } ?> 72 72 </li> -
trunk/www/views/round_edit.php
r1009 r1077 93 93 <?= view_form_field_li($form_fields['start_time'], 'start_time') ?> 94 94 <?php if ($can_tag) { ?> 95 <?= tag_format_input_box( fval('tags')) ?>95 <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?> 96 96 <?php } ?> 97 97 <?= view_form_field_li($form_fields['tasks'], 'tasks') ?> -
trunk/www/views/tags_header.php
r1069 r1077 9 9 // Format a tag input box 10 10 // FIXME: Width parameter does not work, I hate CSS 11 function tag_format_input_box($ value = null, $width = "50", $name = "tags") {12 $esc_name = html_escape($ name);11 function tag_format_input_box($field, $value = null, $width = "50", $name = "tags") { 12 $esc_name = html_escape($field['name']); 13 13 $esc_width = html_escape($width); 14 14 // presume $value is html-escaped 15 15 16 $output = '<li><label for="form_'.$esc_name.'"> Tag-uri</label>';16 $output = '<li><label for="form_'.$esc_name.'">'.$field['label'].'</label>'; 17 17 $output .= ferr_span($name); 18 18 $output .= '<input class="wickEnabled" type="text" name="'.$esc_name. … … 25 25 } 26 26 $output .= ' />'; 27 $output .= '<script type="text/javascript" language="JavaScript" src="'.28 html_escape(url_static("js/wick.js")).'"></script>';27 // $output .= '<script type="text/javascript" language="JavaScript" src="'. 28 // html_escape(url_static("js/wick.js")).'"></script>'; 29 29 $output .= "</li>"; 30 30 return $output; -
trunk/www/views/task_edit.php
r1055 r1077 125 125 <?= view_form_field_li($form_fields['hidden'], 'hidden') ?> 126 126 <?php } ?> 127 <?php if (identity_can('task-tag', $task)) { ?> 128 <?= tag_format_input_box(fval('tags')) ?> 129 <?php } ?> 130 </ul> 127 </ul> 131 128 </fieldset> 129 130 <?php if (identity_can('task-tag', $task)) { 131 $tag_fields = Array('author' => Array("label" => "Autor", 132 "name" => "tag_author"), 133 'contest' => Array("label" => "Concurs", 134 "name" => "tag_contest"), 135 'year' => Array("label" => "Anul", 136 "name" => "tag_year"), 137 'round' => Array("label" => "Runda", 138 "name" => "tag_round"), 139 'age_group' => Array("label" => "Grupa de varsta", 140 "name" => "tag_age_group"), 141 'method' => Array("label" => "Metoda de programare", 142 "name" => "tag_method"), 143 'algorithm' => Array("label" => "Algoritm", 144 "name" => "tag_algorithm") 145 ); 146 ?> 147 <fieldset> 148 <legend>Taguri</legend> 149 <ul class="form"> 150 <?= tag_format_input_box($tag_fields['author'], fval('tag_author')); ?> 151 <?= tag_format_input_box($tag_fields['contest'], fval('tag_contest')); ?> 152 <?= tag_format_input_box($tag_fields['year'], fval('tag_year')); ?> 153 <?= tag_format_input_box($tag_fields['round'], fval('tag_round')); ?> 154 <?= tag_format_input_box($tag_fields['age_group'], fval('tag_age_group')); ?> 155 <?= tag_format_input_box($tag_fields['method'], fval('tag_method')); ?> 156 <?= tag_format_input_box($tag_fields['algorithm'], fval('tag_algorithm')); ?> 157 </ul> 158 </fieldset> 159 <?php } ?> 160 132 161 133 162 <?php -
trunk/www/views/textblock_edit.php
r964 r1077 45 45 46 46 <?php if (identity_can('textblock-tag', $view['page'])) { ?> 47 <?= tag_format_input_box( fval('tags')) ?>47 <?= tag_format_input_box(array("label" => "Tag-uri", "name" => "tags"), fval('tags')) ?> 48 48 <?php } ?> 49 49
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)