Menu

[r24]: / website / classes / ExampleViewer.php  Maximize  Restore  History

Download this file

39 lines (33 with data), 976 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* viewer for the call graph examples
*/
class ExampleViewer {
public function __construct($dir = '.') {
$examples = $this->getExamples($dir);
$this->showExamples($examples, $dir);
}
public function getExamples($dir) {
$thumbnails = glob("$dir/resized_*.png");
foreach ($thumbnails as $thumbnail) {
$name = substr(basename($thumbnail, '.png'), 8);
$image = "$dir/$name.png";
$size = getimagesize($image);
if ($size[0] <= 980 and $size[1] <= 300) {
$thumbnail = $image;
}
$examples[$name] = $thumbnail;
}
return $examples;
}
public function showExamples($examples, $dir) {
echo "<nter>\n";
foreach ($examples as $name => $thumbnail) {
echo <<< EOF
<h2>$name</h2>
<a href="$dir/$name.png"><img src="$thumbnail" border="0"></a>
EOF;
}
echo "</center>\n";
}
}