screenshots.xml parsing in view_screenshots()
Paul van Schayck
info at wwwdesign.tmfweb.nl
Thu Feb 26 16:02:28 CST 2004
Hey,
Changelog:
- Adds lostwages/images/shots/screenshots.xml (with all current screens+few new descriptions)
- Adds parsing for screenshots.xml in lostwages/site. Total rewrite of view_screenshots()
Index: lostwages/site
===================================================================
RCS file: /home/wine/lostwages/site,v
retrieving revision 1.4
diff -u -r1.4 site
--- lostwages/site 25 Feb 2004 17:26:38 -0000 1.4
+++ lostwages/site 26 Feb 2004 21:37:57 -0000
@@ -208,53 +208,56 @@
function view_screenshots ($x)
{
global $file_root, $config, $html;
-
- // Grab list of images from screenshot dir
- $shots = get_files($file_root."/images/shots","png");
+
+ // Get the XML file and start parsing
+ $file = @fopen($file_root."/images/shots/screenshots.xml", "r");
+ $data = fread($file, filesize($file_root."/images/shots/screenshots.xml"));
+ @fclose($file);
+
+ preg_match_all("/<screenshot>(.*?)<\/screenshot>/is", $data, $screenshots);
+ // We need the [0] part returned by preg_match_all
+ $screenshots = $screenshots[0];
// setup vars
- $total = count($shots) + 1;
- $num = 0;
- $where = 0;
- $vars = array();
- $vars['next'] = " ";
+ $total = count($screenshots); // Total ammount of screens
+ $perpage = 9; // How many perpage
+ $screen = 0; // The number for the template
+ $real_num = $x - 1; // The start place for the $screenshots array. $x starts at 1, $screenshots at 0
+ $vars['next'] = " ";
$vars['prev'] = " ";
- // loop and display images
- for ($c = 1; $c < $total; $c++)
+ // loop and display images.
+ for($screen = 0; $screen <= $perpage; $screen++)
{
- // do not show images less than current pos
- if ($x != 1 and $x >= $c)
- continue;
-
+ // XML parsing
+ preg_match("/<thumb>(.*)<\/thumb>/i", $screenshots[$real_num], $thumb);
+ preg_match("/<large>(.*)<\/large>/i", $screenshots[$real_num], $large);
+ preg_match("/<description>(.*)<\/description>/i", $screenshots[$real_num], $description);
+
// display image
- $vars['im_'.$num] = $html->ahref($html->img($file_root.'/images/shots/wine_'.$c.'.png'), $file_root.'/images/shots/full/wine_'.$c.'.png');
+ $vars['im_'.$screen] = $html->ahref($html->img($file_root.'/images/shots/'.$thumb[1]), $file_root.'/images/shots/'.$large[1]);
// add description
- list($vars['ds_'.$num]) = get_xml_tags($file_root.'/images/shots/desc/wine_'.$c.'.xml',array('description'));
+ $vars['ds_'.$screen] = $description[1];
- // end at 9
- if ($num == 9 or $num == $total)
- {
- $where = $c;
+ // End of all screens. - 1 because $total started at 1. But $real_num at 0
+ if ($real_num == $total - 1)
break;
- }
-
- // count number of images displayed.
- $num++;
+
+ $real_num++;
}
-
- // display prev link
- if ($x > 1)
+
+ // display prev link
+ if ($x > $perpage)
{
- $prev = $total + 1 - $c;
+ $prev = $x - $perpage;
$vars['prev'] = $html->ahref("<< Previous Screenshots","?ss=".$prev,"class=menuItem");
}
// display next link
- if (($x + 9) < $total)
+ if (($x + $perpage) < $total)
{
- $next = $where;
+ $next = $x + $perpage;
$vars['next'] = $html->ahref("More Screenshots >>","?ss=".$next,"class=menuItem");
}
--- /dev/null 1994-07-18 01:46:18.000000000 +0200
+++ lostwages/images/shots/screenshots.xml 2004-02-26 22:28:16.000000000 +0100
@@ -0,0 +1,95 @@
+<screenshot>
+ <thumb>wine_1.png</thumb>
+ <large>full/wine_1.png</large>
+ <description>Powerpoint 2000, Internet Explorer 5.0, Notepad, and Solitare.</description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_2.png</thumb>
+ <large>full/wine_2.png</large>
+ <description>Word, Internet Explorer, Powerpoint and Excel</description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_3.png</thumb>
+ <large>full/wine_3.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_4.png</thumb>
+ <large>full/wine_4.png</large>
+ <description>Adope Photoshop</description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_5.png</thumb>
+ <large>full/wine_5.png</large>
+ <description>Quicken 2002</description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_6.png</thumb>
+ <large>full/wine_6.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_7.png</thumb>
+ <large>full/wine_7.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_8.png</thumb>
+ <large>full/wine_8.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_9.png</thumb>
+ <large>full/wine_9.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_10.png</thumb>
+ <large>full/wine_10.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_11.png</thumb>
+ <large>full/wine_11.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_12.png</thumb>
+ <large>full/wine_12.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_13.png</thumb>
+ <large>full/wine_13.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_14.png</thumb>
+ <large>full/wine_14.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_15.png</thumb>
+ <large>full/wine_15.png</large>
+ <description></description>
+</screenshot>
+
+<screenshot>
+ <thumb>wine_16.png</thumb>
+ <large>full/wine_16.png</large>
+ <description></description>
+</screenshot>
More information about the wine-patches
mailing list