From d554adc484faa8bd605d230f49b8e3db2bc595b9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 25 Nov 2008 18:14:52 +0000 Subject: 1) Changed how the test tags are generated to be able to create a better distribution 2) Added a new helper function "load_buckets" assign the class suffix to each tag 3) Created a unit test to test the load_buckets function --- core/controllers/welcome.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 95013cfa..83e6a608 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -218,12 +218,7 @@ class Welcome_Controller extends Template_Controller { $items = ORM::factory("item")->find_all()->as_array(); if (!empty($items)) { - $tags = array( - "animation", "art", "blind", "blog", "bug-tracker", "bugs20", "canvas", - "classification", "cocktail", "exhibtion", "forum", "geo-tagging", "german", "germany", - "glaser", "graffiti", "illustration", "ITP", "javascript", "miami", "miknow", "nyc", "NYU", - "ontology", "open-source", "project", "school-of-information", "screenshot", "shiftspace", - "shop", "tagging", "talkingpoints", "university-of-michigan", "usability", "writing"); + $tags = $this->_generateTags($count); while ($count-- > 0) { $tag_name = $tags[array_rand($tags)]; @@ -236,6 +231,27 @@ class Welcome_Controller extends Template_Controller { url::redirect("welcome"); } + private function _generateTags($number){ + + list($usec, $sec) = explode(' ', microtime()); + srand((float) $sec + ((float) $usec * 100000)); + + $validchars = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + $tags = array(); + + for ($tag_count = 0; $tag_count < $number; $tag_count++) { + $tag = ""; + $tag_length = rand(3, 16); + for ($counter = 0; $counter < $tag_length; $counter++) { + $tag .= substr($validchars, rand(0, strlen($validchars)-1), 1);; + } + $tags[] = $tag; + } + + return $tags; + } + public function session($key) { Session::instance()->set($key, $this->input->get("value", false)); $this->auto_render = false; @@ -394,4 +410,5 @@ class Welcome_Controller extends Template_Controller { ORM::factory("group")->where("name", $name)->find()->delete(); url::redirect("welcome"); } + } -- cgit v1.2.3