Changeset 1085
- Timestamp:
- 12/22/09 14:06:43 (2 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
common/db/tags.php (modified) (2 diffs)
-
config.php.sample (modified) (1 diff)
-
scripts/migrate-authors-to-task-tags (modified) (1 diff)
-
www/controllers/task_tags.php (modified) (3 diffs)
-
www/static/js/inline_form.js (modified) (1 diff)
-
www/views/task_tags.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/tags.php
r1084 r1085 3 3 require_once(IA_ROOT_DIR."common/db/db.php"); 4 4 require_once(IA_ROOT_DIR."common/common.php"); 5 require_once(IA_ROOT_DIR."common/cache.php"); 5 6 6 7 // Get list of all tag names, filtered by type and parent … … 183 184 184 185 // Count the number of objects containing all tags from a list of tag ids 185 function tag_count_objects($obj, $tag_ids ) {186 function tag_count_objects($obj, $tag_ids, $no_cache=false) { 186 187 log_assert(is_taggable($obj)); 187 188 log_assert(is_array($tag_ids)); 189 // Cache object count for single tags. 190 if (!$no_cache && count($tag_ids) == 1) { 191 $result = mem_cache_get("$obj-count-with-tag:".$tag_ids[0]); 192 if ($result !== false) { 193 return $result; 194 } 195 } 188 196 $query = sprintf("SELECT COUNT(*) as `cnt` FROM ia_%s WHERE %s", db_escape($obj), 189 197 tag_build_where($obj, $tag_ids)); 190 198 $result = db_fetch($query); 191 return $result['cnt']; 199 $result = $result['cnt']; 200 if (count($tag_ids) == 1) { 201 mem_cache_set("$obj-count-with-tag:".$tag_ids[0], $result, 202 IA_MEM_CACHE_TAGS_EXPIRATION); 203 } 204 return $result; 192 205 } 193 206 -
trunk/config.php.sample
r987 r1085 129 129 define("IA_MEM_CACHE_TASK_EXPIRATION", 10); 130 130 131 // TTL for tag caches. 132 define("IA_MEM_CACHE_TAGS_EXPIRATION", 600); 133 131 134 // Logging options. Anything else in normal operation is a bug. 132 135 // Filling error_log on a production machine sucks. -
trunk/scripts/migrate-authors-to-task-tags
r1084 r1085 9 9 $tasks = task_get_all(); 10 10 $author_tags = array(); 11 foreach($tasks as $task) {11 foreach($tasks as &$task) { 12 12 // Special cases to make my life easier. 13 13 if ($task["author"] == "") { -
trunk/www/controllers/task_tags.php
r1083 r1085 17 17 } 18 18 19 $authors = tag_get_all(array("author")); 20 foreach ($authors as &$author) { 21 $author["task_count"] = tag_count_objects("task", array($author["id"])); 22 } 23 19 24 // Create view. 20 25 $view = array(); 21 26 $view['title'] = "Tag-uri probleme"; 22 27 $view['categories'] = $categories; 28 $view['authors'] = $authors; 23 29 execute_view_die("views/task_tags.php", $view); 24 30 } … … 73 79 74 80 // Do not delete tags if they have been added to tasks. 75 if ($tag["type"] == "algorithm") { 76 $task_count = tag_count_objects("task", array($tag_id)); 77 } else if ($tag["type"] == "method") { 78 $task_count = 0; 79 $sub_tags = tag_get_all(array("algorithm"), $tag_id); 80 foreach ($sub_tags as $sub_tag) { 81 $task_count += tag_count_objects("task", array($sub_tag["id"])); 82 } 83 } 81 $task_count = tag_count_objects("task", array($tag_id), true); 84 82 if ($task_count != 0) { 85 83 flash_error("Nu poti sterge un tag care a fost asociat deja unei probleme."); … … 116 114 117 115 $tag["name"] = $new_name; 116 if (tag_get_id($tag)) { 117 flash_error("Tagul deja exista."); 118 redirect(url_task_tags()); 119 } 118 120 tag_update_by_id($tag_id, $tag); 119 121 flash("Tag-ul a fost redenumit."); -
trunk/www/static/js/inline_form.js
r1083 r1085 11 11 // Display inline form and replace toggleElement with "Anuleaza" 12 12 formElement.style.display = "inline"; 13 toggleElement.innerHTML = "Anuleaz a";13 toggleElement.innerHTML = "Anulează"; 14 14 // Hide original content if specified 15 15 if (typeof(originalElement) != "undefined") { -
trunk/www/views/task_tags.php
r1083 r1085 9 9 $tag = inline_post_form(url_task_tags_rename(), 10 10 array( 11 "type" => "algorithm",12 11 "old_name" => $row["name"], 12 "type" => $row["type"], 13 13 "parent" => $row["parent"] 14 14 ), 15 $row["name"], "Redenume ste");15 $row["name"], "Redenumește"); 16 16 $tag .= ' <a class="algorithm_tag" href="#">' . html_escape($row["name"]) . '</a>'; 17 17 return $tag; … … 20 20 // Returns a delete tag link and a toggle rename form link 21 21 function format_operations($row) { 22 $delete = format_post_link(url_task_tags_delete(), " Sterge",22 $delete = format_post_link(url_task_tags_delete(), "Șterge", 23 23 array( 24 "name" => $row["name"], 24 25 "type" => $row["type"], 25 "name" => $row["name"],26 26 "parent" => $row["parent"] 27 27 ) 28 28 ); 29 $rename = '<a href="#" class="toggle_rename">Redenume ste</a>';29 $rename = '<a href="#" class="toggle_rename">Redenumește</a>'; 30 30 return sprintf("[%s] [%s]", $delete, $rename); 31 31 } … … 50 50 ), 51 51 array( 52 'title' => 'Num ar probleme',52 'title' => 'Număr probleme', 53 53 'key' => 'task_count', 54 54 'css_class' => 'tag-task-count', 55 55 ), 56 56 array( 57 'title' => 'Opera tii',57 'title' => 'Operații', 58 58 'rowform' => 'format_operations', 59 59 'css_class' => 'tag-operations', … … 65 65 <h1>Editare taguri algoritmi</h1> 66 66 <div id="add_category" class="task-tag-actions"> 67 [<a href="#">Adaug a categorie noua</a><?php68 echo inline_post_form(url_task_tags_add(), array("type" => "method"), "", "Adaug a");67 [<a href="#">Adaugă categorie nouă</a><?php 68 echo inline_post_form(url_task_tags_add(), array("type" => "method"), "", "Adaugă"); 69 69 ?>] 70 70 </div> … … 74 74 <h2><?php echo html_escape($category["name"]); ?></h2> 75 75 <ul class="task-tag-actions"> 76 <li class="algorithm_tag_add">[<a class="toggle_add" href="#">Adaug atag nou</a><?php76 <li class="algorithm_tag_add">[<a class="toggle_add" href="#">Adaugă tag nou</a><?php 77 77 echo inline_post_form(url_task_tags_add(), 78 78 array("type" => "algorithm", "parent" => $category["id"]), 79 "", "Adaug a");79 "", "Adaugă"); 80 80 ?>]</li> 81 <li class="delete_method">[<?php echo format_post_link(url_task_tags_delete(), " Sterge categorie",81 <li class="delete_method">[<?php echo format_post_link(url_task_tags_delete(), "Șterge categorie", 82 82 array("type" => "method", "name" => $category["name"])); ?>]</li> 83 <li class="rename_method">[<a class="toggle_rename" href="#">Redenume ste categorie</a><?php83 <li class="rename_method">[<a class="toggle_rename" href="#">Redenumește categorie</a><?php 84 84 echo inline_post_form(url_task_tags_rename(), 85 85 array("type" => "method", "old_name" => $category["name"]), 86 $category["name"], "Redenume ste");86 $category["name"], "Redenumește"); 87 87 ?>]</li> 88 88 </ul> … … 94 94 } 95 95 ?> 96 <h1>Editare taguri autori</h1> 97 <div id="add_author" class="task-tag-actions">[<a class="toggle_add" href="#">Adaugă tag nou</a><?php 98 echo inline_post_form(url_task_tags_add(), 99 array("type" => "author"), 100 "", "Adaugă"); 101 ?>]</div> 102 <?php 103 echo format_table($authors, $column_infos, 104 array('css_class' => 'category fill-screen tag-table')); 105 ?> 96 106 <script type="text/javascript" src="<?= html_escape(url_static('js/inline_form.js')) ?>"></script> 97 107 <script type="text/javascript"> … … 100 110 addLoadEvent(function() { 101 111 bindToggleLinkToForm($$("#add_category > a")[0], $$("#add_category > form")[0]); 112 }); 113 114 // Bind add author link to form 115 addLoadEvent(function() { 116 bindToggleLinkToForm($$("#add_author > a")[0], $$("#add_author > form")[0]); 102 117 }); 103 118
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)