summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gallery_unit_test/controllers/test.php2
-rw-r--r--modules/tag/helpers/tag.php40
-rw-r--r--modules/tag/tests/Tag_Test.php4
-rw-r--r--modules/user/helpers/group.php2
4 files changed, 16 insertions, 32 deletions
diff --git a/modules/gallery_unit_test/controllers/test.php b/modules/gallery_unit_test/controllers/test.php
index f2b9838b..41da85ea 100644
--- a/modules/gallery_unit_test/controllers/test.php
+++ b/modules/gallery_unit_test/controllers/test.php
@@ -77,8 +77,8 @@ class Test_Controller extends Controller {
}
$installer_class = "{$module->name}_installer";
+ Kohana::log("debug", "$installer_class");
if (method_exists($installer_class, "uninstall")) {
- Kohana::log("debug", "method uninstall exists");
call_user_func_array(array($installer_class, "uninstall"), array());
}
}
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 2ff73e62..8057379b 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -19,7 +19,7 @@
*/
class tag_Core {
public static $NUMBER_OF_BUCKETS = 7;
-
+
/**
* Associate a tag with an item. Create the tag if it doesn't already exist.
*
@@ -55,45 +55,29 @@ class tag_Core {
* from: http://www.hawkee.com/snippet/1485/
*
* @return array List of tags each entry has the following format:
- * array("id" => "tag_id", "name" => "tag_name", "count" => "frequency",
- * "class" => "bucket")
+ * array("id" => "tag_id", "name" => "tag_name", "count" => "frequency",
+ * "class" => "bucket")
*/
public static function load_buckets() {
$tag_list = array();
$tags = ORM::factory("tag")
- ->orderby("count", "ASC")
- ->find_all()
- ->as_array();
- if (count($tags) > 0) {
- $min_tags = count($tags) / self::$NUMBER_OF_BUCKETS;
- $bucket_count = 0;
- $bucket_items = 0;
- $tags_set = 0;
-
+ ->orderby("count", "DESC")
+ ->limit(30)
+ ->find_all();
+ if ($tags->count() > 0) {
+ $max_count = $tags[0]->count;
foreach($tags as $key => $tag) {
- if (($bucket_items >= $min_tags) && $last_count != $tag->count &&
- $bucket_count < self::$NUMBER_OF_BUCKETS) {
- $bucket_count++;
- $bucket_items = 0;
-
- // Calculate a new minimum number if tags for the remaining classes.
- $remaining_tags = count($tags) - $tags_set;
- $min_tags = $remaining_tags / self::$NUMBER_OF_BUCKETS;
- }
-
// Set the tag to the current class
- $tag_list[$key] = array("id" => $tag->id, "name" => $tag->name, "count" => $tag->count,
- "class" => "$bucket_count");
- $bucket_items++;
- $tags_set++;
- $last_count = $tag->count;
+ $size = (int)(($tag->count / $max_count) * (self::$NUMBER_OF_BUCKETS - 1));
+ $tag_list[$key] = array("id" => $tag->id, "name" => $tag->name, "count" => $tag->count,
+ "class" => "$size");
}
usort($tag_list, array("tag", "alphasort"));
}
return $tag_list;
}
- public function alphasort($tag1, $tag2) {
+ public static function alphasort($tag1, $tag2) {
if ($tag1["name"] == $tag2["name"]) {
return 0;
}
diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php
index 1a4f7698..87c3a303 100644
--- a/modules/tag/tests/Tag_Test.php
+++ b/modules/tag/tests/Tag_Test.php
@@ -58,8 +58,8 @@ class Tag_Test extends Unit_Test_Case {
array("id" => "3", "name" => "tag2", "count" => 6, "class" => 4),
array("id" => "4", "name" => "tag3", "count" => 5, "class" => 3),
array("id" => "5", "name" => "tag4", "count" => 4, "class" => 2),
- array("id" => "6", "name" => "tag5", "count" => 3, "class" => 1),
- array("id" => "7", "name" => "tag6", "count" => 2, "class" => 0),
+ array("id" => "6", "name" => "tag5", "count" => 3, "class" => 2),
+ array("id" => "7", "name" => "tag6", "count" => 2, "class" => 1),
array("id" => "8", "name" => "tag7", "count" => 1, "class" => 0)
);
$this->assert_equal($expected_tag_list, $tag_list, "incorrect non filtered tag list");
diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php
index 2e6a3962..6073085d 100644
--- a/modules/user/helpers/group.php
+++ b/modules/user/helpers/group.php
@@ -57,7 +57,7 @@ class group_Core {
if ($group->loaded) {
// Drop the view column for this group in the items table.
- Database::instance()->query("ALTER TABLE `items` DROP `view_{$group->id}`");
+// Database::instance()->query("ALTER TABLE `items` DROP `view_{$group->id}`");
$group->delete();
}
}