Revision c0db737e
ID | c0db737e4abb99633a1c71d1e28332fa2814347a |
Parent | 135e59fc |
Child | 08052267 |
separate function for listing available images
Files
- added
- modified
- copied
- renamed
- deleted
Changesets
class/utils.class.php | ||
---|---|---|
15 | 15 |
set_error_handler('errorToException'); |
16 | 16 |
} |
17 | 17 |
|
18 |
static public function list_available_panos($base_dir) { |
|
19 |
$dir = opendir($base_dir); |
|
20 |
$ret = array(); |
|
21 |
$finfo = finfo_open(FILEINFO_MIME_TYPE); // Retourne le type mime du fichier |
|
22 |
|
|
23 |
while(false !== ($filename = readdir($dir))) { |
|
24 |
if (!preg_match('/^\.\.?$/', $filename)) { |
|
25 |
$ftype = finfo_file($finfo, $base_dir.'/'.$filename); |
|
26 |
if (isset($ftype)) { |
|
27 |
$pano = array( |
|
28 |
'comment' => $filename, |
|
29 |
'title' => sprintf('fichier de type %s', $ftype) |
|
30 |
); |
|
31 |
} else { |
|
32 |
$pano = array( |
|
33 |
'comment' => sprintf('<samp>%s</samp>', $filename), |
|
34 |
'title' => '' |
|
35 |
); |
|
36 |
} |
|
37 |
$pano['filename'] = $filename; |
|
38 |
$ret[] = $pano; |
|
39 |
} |
|
40 |
} |
|
41 |
return $ret; |
|
42 |
} |
|
18 | 43 |
} |
44 |
|
|
45 |
?> |
creerPano.php | ||
---|---|---|
16 | 16 |
utils::init(); |
17 | 17 |
|
18 | 18 |
if(isset($_GET['dir']) && is_dir($_GET['dir'])) { |
19 |
$base_dir = $_GET['dir'];
|
|
19 |
$base_dir = $_GET['dir']; |
|
20 | 20 |
} else { |
21 | 21 |
$base_dir='upload'; |
22 | 22 |
} |
23 | 23 |
|
24 |
try { |
|
25 |
$finfo = finfo_open(FILEINFO_MIME_TYPE); // Retourne le type mime du fichier |
|
26 |
$did = opendir($base_dir); |
|
27 |
|
|
24 |
//try { |
|
28 | 25 |
echo "<ul id=\"pano-list\">\n"; |
29 |
|
|
30 |
while(false !== ($filename = readdir($did))) { |
|
31 |
if (!preg_match('/^\.\.?$/', $filename)) { |
|
32 |
$ftype = finfo_file($finfo, $base_dir.'/'.$filename); |
|
33 |
if (isset($ftype)) { |
|
34 |
$cmt = $filename; |
|
35 |
$title = sprintf(' title="fichier de type %s"', $ftype); |
|
36 |
} else { |
|
37 |
$cmt = sprintf('<samp>%s</samp>', $filename); |
|
38 |
$title = ''; |
|
39 |
} |
|
40 |
printf ('<li%s><a href="genererPano.php?dir=%s&name=%s">%s</a></li>'."\n", $title, $base_dir, $filename, $cmt); |
|
41 |
} |
|
26 |
|
|
27 |
|
|
28 |
$panos = utils::list_available_panos($base_dir); |
|
29 |
foreach ($panos as $pano) { |
|
30 |
printf ('<li title="%s"><a href="genererPano.php?dir=%s&name=%s">%s</a></li>'."\n", |
|
31 |
$pano['title'], $base_dir, $pano['filename'], $pano['comment']); |
|
42 | 32 |
} |
33 |
|
|
43 | 34 |
echo "</ul>\n"; |
44 | 35 |
finfo_close($finfo); |
45 |
} catch (Exception $e) { |
|
36 |
//} catch (Exception $e) {
|
|
46 | 37 |
printf("<h3 class=\"warning\">désolé mais aucun site n'est disponible...</h3>\n"); |
47 |
} |
|
38 |
//}
|
|
48 | 39 |
?> |
49 | 40 |
<p id="interaction"> |
50 | 41 |
<a href="." title="Revenir à la liste des panoramas">Retour</a> |