[pLog-svn] r5093 - plugins/branches/lifetype-1.2/tagcloud
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Thu Mar 15 02:53:12 EDT 2007
Author: pwestbro
Date: 2007-03-15 02:53:11 -0400 (Thu, 15 Mar 2007)
New Revision: 5093
Modified:
plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php
Log:
Optimized memory usage when generating the tagcloud.
Modified: plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php
===================================================================
--- plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php 2007-03-15 06:27:30 UTC (rev 5092)
+++ plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php 2007-03-15 06:53:11 UTC (rev 5093)
@@ -187,29 +187,28 @@
$maxValue = 1;
// Create the Cloud
- $Cloud = '';
- foreach( $new_acv as $k=>$v) {
-
- $value = $v - $minValue;
-
- $size = (($value *$maxSize)/$maxValue) + $minSize;
- $weight = (($value *$maxWeight)/$maxValue) + $minWeight;
-
- if ($size > $maxSize) $size = $maxSize;
- if ($weight > $maxWeight) $weight = $maxWeight;
- $weight = floor($weight / 100) * 100;
-
+ $saveFile = $this->cacheFolder."/tagcloud";
+ $fh = fopen( $saveFile, "w");
+
+ if ($fh) {
$rg = $this->blogInfo->getBlogRequestGenerator();
$baseUrl = $rg->getBaseUrl();
- $Cloud .= "<a rel=\"nofollow\" href=\"{$baseUrl}?searchTerms=$k&op=Search&blogId={$blogId}\" style=\"font-size: {$size}em; font-weight: {$weight}; line-height: 90%\" title=\"$k\">$k</a>\n";
- }
-
- $saveFile = $this->cacheFolder."/tagcloud";
+
+ foreach( $new_acv as $k=>$v) {
+
+ $value = $v - $minValue;
+
+ $size = (($value *$maxSize)/$maxValue) + $minSize;
+ $weight = (($value *$maxWeight)/$maxValue) + $minWeight;
+
+ if ($size > $maxSize) $size = $maxSize;
+ if ($weight > $maxWeight) $weight = $maxWeight;
+ $weight = floor($weight / 100) * 100;
+
+ $tag = "<a rel=\"nofollow\" href=\"{$baseUrl}?searchTerms=$k&op=Search&blogId={$blogId}\" style=\"font-size: {$size}em; font-weight: {$weight}; line-height: 90%\" title=\"$k\">$k</a>\n";
+ fwrite($fh, $tag);
+ }
- $fh = fopen( $saveFile, "w");
- if ($fh)
- {
- fwrite($fh, $Cloud);
fclose($fh);
File::chMod($saveFile, 0644);
}
More information about the pLog-svn
mailing list