[GRASS-SVN] r33071 - grass-web/trunk

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 25 16:09:54 EDT 2008


Author: neteler
Date: 2008-08-25 16:09:54 -0400 (Mon, 25 Aug 2008)
New Revision: 33071

Modified:
   grass-web/trunk/grassmodules.php
Log:
Francesco Pirotti: module of the day now day-random

Modified: grass-web/trunk/grassmodules.php
===================================================================
--- grass-web/trunk/grassmodules.php	2008-08-25 18:08:57 UTC (rev 33070)
+++ grass-web/trunk/grassmodules.php	2008-08-25 20:09:54 UTC (rev 33071)
@@ -1,50 +1,58 @@
 <?php
- # Written 2008 by francesco <francesco.pirotti AT unipd it>
 
- function getmodule(){ 
  # The index directory where all modules man pages are
-  $fullindex_directory="grass64/manuals/html64_user";
+  $GLOBALS['fullindex_directory']="grass64/manuals/html64_user";
  # The index page with complete list of modules
-  $fullindex= $fullindex_directory . '/full_index.html' ; 
+  $GLOBALS['fullindex'] = $GLOBALS['fullindex_directory'] . '/full_index.html' ; 
+  
+ function getmodule(){ 
  # Type of choice of module: 'random' is different module each time page is loaded while 'day'  is daily module.  
-  //$type='random';
-  $type='day';
+  $type='dayrandom';
+  //$type='dayrandom';
   
-  ob_start();
-  include($fullindex);
-  $buffer=  ob_get_contents();
-  ob_end_clean();
-  $a=explode("\n", $buffer);
-  
-  $cc=0;
+  	if(is_file("moduleoftheday_init.txt"))
+  		$newa=file("moduleoftheday_init.txt");
+  	else
+  	  {
+		  ob_start();
+		  include($GLOBALS['fullindex']);
+		  $buffer=  ob_get_contents();
+		  ob_end_clean();
+		  $a=explode("\n", $buffer);
+		  $cc=0;
+		  $newa=array();
+		  foreach($a as $bb)
+			  {
+			  if(substr($bb, 0, 27)!="<tr><td valign=top><small><a href=")
+			    continue;
+			  else
+			    $newa[]=$bb;
+			  }
+			  shuffle($newa);
+		  file_put_contents("moduleoftheday_init.txt", implode("
+", $newa));
+  	  }
+ 
+
   if($type=='random'){
-    $ra=rand(0,1000);
-    while(substr($a[$ra], 0, 27)!="<tr><td valign=top><a href="){
-      $ra=rand(0,1000);
-	  $cc++;
-	  if($cc>20){
-	    $a[$ra]='<tr><td valign=top><small><a href="r.average.html">r.average</a></small></td> <td><small>Finds the average of values in a cover map within areas assigned the same category value in a user-specified base map.</small></td></tr>';
-	    break;
-	    }
-	  }
+    $ra=rand(0,count($newa));
+		$chosen_line=$newa[$ra];
 	}
 	
-  else if($type=='day'){
-    $ra=date("z")+75;
-    while(substr($a[$ra], 0, 27)!="<tr><td valign=top><a href="){
-      $ra=date("z")+$cc;
-	  $cc++;
-	  if($cc>20){
-	    $a[$ra]='<tr><td valign=top><small><a href="r.average.html">r.average</a></small></td> <td><small>Finds the average of values in a cover map within areas assigned the same category value in a user-specified base map.</small></td></tr>';
-	    break;
-	    }
-	  }
+  else if($type=='dayrandom'){   
+    $ra=date("z") + date("w");
+    $spano=count($newa)/377;
+    //echo $spano;
+    $ra=$spano*$ra;
+		$chosen_line=$newa[$ra];
 	}
+	
 	else
-	 $a[$ra]="Error in module";
-$what=array("<tr><td valign=top><a href=\"","</a>", "<td>", "</td>");
-$with=array("<tr><td valign=top><small><a href=\"$fullindex_directory/","</a></small>", "<td><small>", "</small></td>");	 
-  return "<table>" . str_replace($what, $with, $a[$ra]) . "</table>";
+		$chosen_line="<tr><td valign=top><small><a href=\"r.describe.html\">r.describe</a></small></td> <td><small>Prints terse list of category values found in a raster map layer.</small></td></tr>
+";
+	
+	
+return "<table>" . str_replace("href=\"", "href=\"{$GLOBALS['fullindex_directory']}/", $chosen_line) . "</table>";
 }
 
 



More information about the grass-commit mailing list