Author: akara
Date: Tue Jan 27 01:04:31 2009
New Revision: 737954
URL: http://svn.apache.org/viewvc?rev=737954&view=rev
Log:
Fix for issue OLIO-46: Access $tags only if rows found. Having a $rowsFound
variable to control such access solves the issue.
Modified:
incubator/olio/webapp/php/trunk/controllers/Tags_Controller.php
Modified: incubator/olio/webapp/php/trunk/controllers/Tags_Controller.php
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/controllers/Tags_Controller.php?rev=737954&r1=737953&r2=737954&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/controllers/Tags_Controller.php (original)
+++ incubator/olio/webapp/php/trunk/controllers/Tags_Controller.php Tue Jan 27
01:04:31 2009
@@ -15,58 +15,59 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
+ */
+
/**
* PHP Template.
* Author: Sheetal Patil. Sun Microsystems, Inc.
- *
- * This is Tags Controller. This computes the tagcloud
+ *
+ * This is Tags Controller. This computes the tagcloud
* that needs to be displayed on the homepage.
*/
class Tags_Controller {
function getHomePageTagCloud($connection) {
- //$cloudquery = "(SELECT st.tag as tag,st.refcount as count from
SOCIALEVENTTAG as st where st.refcount>100 limit 50) order by tag ASC";
- $cloudquery = "(SELECT st.tag as tag,st.refcount as count from
SOCIALEVENTTAG as st order by st.refcount desc limit 50) order by tag asc";
- $cloudresult =$connection->query($cloudquery);
- $rowsFound = false;
- while ($row = $cloudresult->getArray()) {
- $rowsFound = true;
- $tags[$row['tag']] = $row['count'];
- }
- if ($rowsFound) {
- // change these font sizes if you will
- $max_size = 250; // max font size in %
- $min_size = 100; // min font size in %
-
- // get the largest and smallest array values
- $max_count = max(array_values($tags));
- $min_count = min(array_values($tags));
-
- // find the range of values
- $spread = $max_count - $min_count;
- if (0 == $spread) { // we don't want to divide by zero
- $spread = 1;
- }
-
- // determine the font-size increment
- // this is the increase per tag count (times used)
- $step = ($max_size - $min_size)/($spread);
-
- // loop through our tag array
- foreach ($tags as $key => $value) {
- $size = $min_size + (($value - $min_count) * $step);
- // uncomment if you want sizes in whole %:
- $size = ceil($size);
- $homePageTagCloud = $homePageTagCloud." ".'<a
href="taggedEvents.php?tag='.$key.'&count='.$value.'"
style="font-size:'.$size.'%" title="'.$value.' events tagged with '.$key.'"
>'.$key.'</a> ';
- }
- }
-
- return $homePageTagCloud;
+ //$cloudquery = "(SELECT st.tag as tag,st.refcount as count from
SOCIALEVENTTAG as st where st.refcount>100 limit 50) order by tag ASC";
+ $cloudquery = "(SELECT st.tag as tag,st.refcount as count from
SOCIALEVENTTAG as st order by st.refcount desc limit 50) order by tag asc";
+ $cloudresult =$connection->query($cloudquery);
+ $rowsFound = false;
+ while ($row = $cloudresult->getArray()) {
+ $rowsFound = true;
+ $tags[$row['tag']] = $row['count'];
+ }
+ unset($cloudresult);
+ if ($rowsFound) {
+ // change these font sizes if you will
+ $max_size = 250; // max font size in %
+ $min_size = 100; // min font size in %
+
+ // get the largest and smallest array values
+ $max_count = max(array_values($tags));
+ $min_count = min(array_values($tags));
+
+ // find the range of values
+ $spread = $max_count - $min_count;
+ if (0 == $spread) { // we don't want to divide by zero
+ $spread = 1;
+ }
+
+ // determine the font-size increment
+ // this is the increase per tag count (times used)
+ $step = ($max_size - $min_size)/($spread);
+
+ // loop through our tag array
+ foreach ($tags as $key => $value) {
+ $size = $min_size + (($value - $min_count) * $step);
+ // uncomment if you want sizes in whole %:
+ $size = ceil($size);
+ $homePageTagCloud = $homePageTagCloud." ".'<a
href="taggedEvents.php?tag='.$key.'&count='.$value.'"
style="font-size:'.$size.'%" title="'.$value.' events tagged with '.$key.'"
>'.$key.'</a> ';
+ }
+ }
+
+ return $homePageTagCloud;
}
function getEventsPageTagCloud($connection,$se) {
- $cloudquery = "select tag, refcount as count ".
+ $cloudquery = "select tag, refcount as count ".
"from SOCIALEVENTTAG a, ".
"SOCIALEVENTTAG_SOCIALEVENT b ".
"where a.socialeventtagid = b.socialeventtagid ".
@@ -74,40 +75,43 @@
"and a.refcount > 0 ".
"order by tag ASC";
- $cloudresult = $connection->query($cloudquery);
- while ($row = $cloudresult->getArray()) {
- $tags[$row['tag']] = $row['count'];
- }
- unset($cloudresult);
-
- // change these font sizes if you will
- $max_size = 250; // max font size in %
- $min_size = 100; // min font size in %
-
- // get the largest and smallest array values
- $max_count = max(array_values($tags));
- $min_count = min(array_values($tags));
-
- // find the range of values
- $spread = $max_count - $min_count;
- if (0 == $spread) { // we don't want to divide by zero
- $spread = 1;
- }
-
- // determine the font-size increment
- // this is the increase per tag count (times used)
- $step = ($max_size - $min_size)/($spread);
-
- // loop through our tag array
- foreach ($tags as $key => $value) {
- $size = $min_size + (($value - $min_count) * $step);
- // uncomment if you want sizes in whole %:
- $size = ceil($size);
- $eventTagCloud = $eventTagCloud." ".'<a
href="taggedEvents.php?tag='.$key.'" style="font-size:'.$size.'%"
title="'.$value.' events tagged with '.$key.'" >'.$key.'</a> ';
- }
- return $eventTagCloud;
+ $cloudresult = $connection->query($cloudquery);
+ while ($row = $cloudresult->getArray()) {
+ $rowsFound = true;
+ $tags[$row['tag']] = $row['count'];
+ }
+ unset($cloudresult);
+
+ if ($rowsFound) {
+ // change these font sizes if you will
+ $max_size = 250; // max font size in %
+ $min_size = 100; // min font size in %
+
+ // get the largest and smallest array values
+ $max_count = max(array_values($tags));
+ $min_count = min(array_values($tags));
+
+ // find the range of values
+ $spread = $max_count - $min_count;
+ if (0 == $spread) { // we don't want to divide by zero
+ $spread = 1;
+ }
+
+ // determine the font-size increment
+ // this is the increase per tag count (times used)
+ $step = ($max_size - $min_size)/($spread);
+
+ // loop through our tag array
+ foreach ($tags as $key => $value) {
+ $size = $min_size + (($value - $min_count) * $step);
+ // uncomment if you want sizes in whole %:
+ $size = ceil($size);
+ $eventTagCloud = $eventTagCloud." ".'<a
href="taggedEvents.php?tag='.$key.'" style="font-size:'.$size.'%"
title="'.$value.' events tagged with '.$key.'" >'.$key.'</a> ';
+ }
+ }
+ return $eventTagCloud;
}
-
+
static function getInstance() {
$instance = new Tags_Controller();
return $instance;