[Scummvm-cvs-logs] SF.net SVN: scummvm: [27858] web/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Jul 2 22:33:49 CEST 2007


Revision: 27858
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27858&view=rev
Author:   fingolfin
Date:     2007-07-02 13:33:49 -0700 (Mon, 02 Jul 2007)

Log Message:
-----------
Updated screenshot JavaScript code, added a new scr_table var mapping screenshot ids to caption, image path, thumbnail path

Modified Paths:
--------------
    web/trunk/include/screenshots.php
    web/trunk/index.php

Modified: web/trunk/include/screenshots.php
===================================================================
--- web/trunk/include/screenshots.php	2007-07-02 20:21:27 UTC (rev 27857)
+++ web/trunk/include/screenshots.php	2007-07-02 20:33:49 UTC (rev 27858)
@@ -1,18 +1,18 @@
 <?php
 
 function screenshot_path ($id) {
-	global $file_root;
-	return $file_root . "/screenshots/bigscummvm_" . $id . ".png";
+	global $scr_table;
+	return $scr_table[$id]["path"];
 }
 
 function screenshot_thumb_path ($id) {
-	global $file_root;
-	return $file_root . "/screenshots/scummvm_" . $id . ".jpg";
+	global $scr_table;
+	return $scr_table[$id]["thumb"];
 }
 
 function screenshot_caption ($id) {
-	global $scrcaption;
-	return $scrcaption[$id];
+	global $scr_table;
+	return $scr_table[$id]["caption"];
 }
 
 function screenshot_previewer_link ($id, $content) {
@@ -30,8 +30,10 @@
 function read_screenshot_list($fname) {
 	global $screenshots;
 	global $scrcatnums;
-	global $scrcaption;
+	global $scr_table;
 
+	global $file_root;
+
 	if(!is_readable($fname)) {
 		echo "No read permission for $fname !";
 		exit;
@@ -45,7 +47,7 @@
 
 	$screenshots = array();
 	$scrcatnums = array();
-	$scrcaption = array();
+	$scr_table = array();
 
 	while (!feof($fp)) {
 		$line = trim(fgets($fp));
@@ -64,7 +66,10 @@
 			array_push($screenshots, $id);
 			
 			// Store the screenshot caption from $data[4]
-			$scrcaption[$id] = $data[4];
+			$scr_table[$id] = array("caption" => $data[4],
+						"path" => $file_root . "/screenshots/bigscummvm_" . $id . ".png",
+						"thumb" => $file_root . "/screenshots/scummvm_" . $id . ".jpg"
+					);
 
 			// Insert into a table of screenshots which is indexed by category & subcategory.
 			if (!isset($scrcatnums[$data[0]][$data[1]]))

Modified: web/trunk/index.php
===================================================================
--- web/trunk/index.php	2007-07-02 20:21:27 UTC (rev 27857)
+++ web/trunk/index.php	2007-07-02 20:33:49 UTC (rev 27858)
@@ -27,16 +27,15 @@
 } else {
   $randImg = $lastLECshot + rand(0, count($screenshots) - $lastLECshot - 1);
 }
-
-// TODO: The screenshotIds should contain tuples:
-//   The path to the thumb, *plus* the category triple used to identify the screenshot
 ?>
 
 <script type="text/javascript">
 
 <?php
   echo "screenshotIds = [\n";
-  echo '"' . join('", "', $screenshots) . '"' . "\n";
+  foreach ($screenshots as $s) {
+    echo " [\"$s\", \"" . screenshot_thumb_path($s) . "\"],\n";
+  }
   echo "];\n";
 
   echo "var curScreenshotId = $randImg;\n";
@@ -48,7 +47,7 @@
   if (curScreenshotId >= screenshotIds.length) curScreenshotId = 0;
   if (curScreenshotId < 0) curScreenshotId = screenshotIds.length-1;
 
-  document['curScreenshot'].src = "<?=screenshot_thumb_path('" + screenshotIds[curScreenshotId] + "')?>";
+  document['curScreenshot'].src = screenshotIds[curScreenshotId][1];
 }
 </script>
 
@@ -71,7 +70,7 @@
 <table border="0" cellpadding="0" cellspacing="0" align="center">
 <tr><td>
 <?php
-echo screenshot_previewer_link("screenshotIds[curScreenshotId]", 
+echo screenshot_previewer_link("screenshotIds[curScreenshotId][0]", 
 	'<img src="' . screenshot_thumb_path($screenshots[$randImg]) . '" width=128 height=96 '.
 	'style="margin: 5px" ' .
 	'name="curScreenshot" title="Click to view Full Size" alt="Random screenshot">');


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list