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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 27 05:57:37 EDT 2008


Author: neteler
Date: 2008-08-27 05:57:37 -0400 (Wed, 27 Aug 2008)
New Revision: 33115

Modified:
   grass-web/trunk/grassmodules.php
Log:
reverted last change as failing

Modified: grass-web/trunk/grassmodules.php
===================================================================
--- grass-web/trunk/grassmodules.php	2008-08-27 09:30:37 UTC (rev 33114)
+++ grass-web/trunk/grassmodules.php	2008-08-27 09:57:37 UTC (rev 33115)
@@ -1,58 +1,50 @@
 <?php
+ # Written 2008 by francesco <francesco.pirotti AT unipd it>
 
+ function getmodule(){ 
  # The index directory where all modules man pages are
-  $GLOBALS['fullindex_directory']="grass64/manuals/html64_user";
+  $fullindex_directory="grass64/manuals/html64_user";
  # The index page with complete list of modules
-  $GLOBALS['fullindex'] = $GLOBALS['fullindex_directory'] . '/full_index.html' ; 
-  
- function getmodule(){ 
+  $fullindex= $fullindex_directory . '/full_index.html' ; 
  # Type of choice of module: 'random' is different module each time page is loaded while 'day'  is daily module.  
-  $type='dayrandom';
-  //$type='dayrandom';
+  //$type='random';
+  $type='day';
   
-  	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));
-  	  }
- 
-
+  ob_start();
+  include($fullindex);
+  $buffer=  ob_get_contents();
+  ob_end_clean();
+  $a=explode("\n", $buffer);
+  
+  $cc=0;
   if($type=='random'){
-    $ra=rand(0,count($newa));
-		$chosen_line=$newa[$ra];
+    $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;
+	    }
+	  }
 	}
 	
-  else if($type=='dayrandom'){   
-    $ra=date("z") + date("w");
-    $spano=count($newa)/377;
-    //echo $spano;
-    $ra=$spano*$ra;
-		$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
-		$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>";
+	 $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>";
 }
 
 



More information about the grass-commit mailing list