Contents of file 'photoview.php':
1 <?php
2
3 function display_footer_banner($lang) {
4 $revision="1.0"; // Current revision number of PhotoView
5 $photoViewURL="http://www.jonsson.eu/programs/php/photoview/";
6 echo "<div class=\"clear\"></div>\n";
7 echo "<p class=\"footerBanner\">\n";
8 echo " Site powered by <a href=\"$photoViewURL\">PhotoView $revision</a>\n";
9 echo "</p>\n";
10 return;
11 }
12
13 function display_copyright() {
14 echo "<br />\n<span class=\"copyright\">";
15 echo "Copyright © 2006, Fredrik Jonsson";
16 echo "</span>\n";
17 return;
18 }
19
20 function get_filenames($directory) {
21 // Open specified directory
22 $dir = dir($directory);
23 // Read the file names in specified directory into an array 'filenames'
24 $k=1;
25 while (($file = $dir->read()) !== false)
26 {
27 $filenames[$k] = $file;
28 $k=$k+1;
29 }
30 $filenames[0]=$k-1; // This is the array size
31 $dir->close();
32 return $filenames;
33 }
34
35 function display_filenames($directory) {
36 $filenames=get_filenames($directory);
37 $kmax=$filenames[0];
38 $k=1;
39 while ($k <= $kmax) {
40 echo $filenames[$k]."<br />";
41 $k=$k+1;
42 }
43 return;
44 }
45
46 function get_image_filenames($directory,$suffix) {
47 // Open specified directory
48 $dir = dir($directory);
49 // Read the file names in specified directory into an array 'filenames'
50 $k=1;
51 while (($file = $dir->read()) !== false)
52 {
53 //
54 // The suffix comparison is performed as case insensitive, hence
55 // for example ".png" as well as ".PNG" files are recognised.
56 //
57 if (stristr($file,".".trim($suffix))!="") {
58 $filenames[$k] = $file;
59 $k=$k+1;
60 }
61 }
62 $filenames[0]=$k-1; // This is the array size
63 $dir->close(); // Close the directory handle
64 return $filenames;
65 }
66
67 function display_image_filenames($directory,$suffix) {
68 $filenames=get_image_filenames($directory,$suffix);
69 $kmax=$filenames[0];
70 $k=1;
71 while ($k <= $kmax) {
72 echo $filenames[$k]."<br />";
73 $k=$k+1;
74 }
75 return;
76 }
77
78 function is_directory($file) {
79 if (@dir($file)!==false) {
80 return true;
81 } else {
82 return false;
83 }
84 }
85
86 //
87 // The get_directorynames($directory) function scans for all sub-directories
88 // present in the supplied directory name $directory, and returns the names
89 // of the sub-directories as an array, with the length of the array given by
90 // element [0]. The returned array of sub-directory names does not include the
91 // current (".") or parent ("..") directories.
92 //
93 function get_directorynames($directory) {
94 $filenames=get_filenames($directory);
95 $kmax=$filenames[0];
96 $j=1;
97 $k=1;
98 while ($k <= $kmax) {
99 if (is_directory($filenames[$k])) {
100 if (($filenames[$k]!==".")&&($filenames[$k]!=="..")) {
101 $dirnames[$j]=$filenames[$k];
102 $j++;
103 }
104 }
105 $k++;
106 }
107 $dirnames[0]=$j-1;
108 return $dirnames;
109 }
110
111 function display_directorynames($directory) {
112 $dirnames=get_directorynames($directory);
113 $kmax=$dirnames[0];
114 $k=1;
115 while ($k <= $kmax) {
116 echo $dirnames[$k]."<br />";
117 $k=$k+1;
118 }
119 return;
120 }
121
122 function display_title($directory) {
123 if (file_exists($directory."/00-title.txt")) {
124 if (is_readable($directory."/00-title.txt")) {
125 $fp=fopen($directory."/00-title.txt",r);
126 while (!feof($fp)) {
127 echo trim(fgets($fp),"\n");
128 fgetc($fp);
129 }
130 fclose($fp);
131 } else {
132 echo "Warning: display_title(): Page title text file "
133 .$directory."/00-title.txt"
134 ." exists but is not readable.<br />\n";
135 }
136 }
137 return;
138 }
139
140 //
141 // The display_parent_directory_switch($lang) function generates the (X)HTML
142 // code for displaying a link for switching to the parent directory.
143 //
144 function display_parent_directory_switch($lang) {
145 echo "<p class=\"directorySwitch\">\n";
146 echo "<a href=\"../\">";
147 switch ($lang) {
148 case en:
149 echo "Up one directory";
150 break;
151 case sv:
152 echo "Upp en katalog";
153 break;
154 default:
155 echo "PHP Error: Language switch \"".$lang."\" is not recognized!\n";
156 }
157 echo "</a>\n";
158 echo "</p>\n";
159 return;
160 }
161
162 function get_image_orientation($filename) {
163 if (function_exists("exif_read_data")) {
164 //
165 // First, we try to extract EXIF information from the image file. This,
166 // however, requires EXIF support from the compiled PHP server, which is
167 // the reason why we first verify that the function exif_read_data()
168 // exists in the first place.
169 //
170 $exif = exif_read_data($filename,0,true);
171 $imageWidth=$exif['COMPUTED']['Width'];
172 $imageHeight=$exif['COMPUTED']['Height'];
173 if ($imageWidth<$imageHeight) {
174 $imageOrientation="portrait";
175 } else {
176 $imageOrientation="landscape";
177 }
178 } else {
179 //
180 // As a resort if no EXIF support is provided by PHP, the check if the
181 // filename contains the string "landscape" or "portrait".
182 //
183 if (stristr($filename,"landscape")!="") {
184 $imageOrientation="landscape";
185 } else if (stristr($filename,"portrait")!="") {
186 $imageOrientation="portrait";
187 } else {
188 $imageOrientation="landscape";
189 }
190 }
191 return $imageOrientation;
192 }
193
194 function display_slide_frame($k,$imgfilenames,$lang) {
195 $viewFileName=false;
196 $viewFileDate=true;
197 $verboseFileName=true;
198 $verboseFileDate=false;
199 echo "<div class=\"slide\">\n";
200 echo " <div class=\"slide-shadow\">\n";
201 echo " <div>\n";
202 echo " <div class=\"slideFrame\">\n";
203 echo " <a href=\"?view=slideshow&id=".$k."&lang=".$lang."\">\n";
204 echo " <img src=\"00-thumbs/".$imgfilenames[$k]."\"";
205 if (get_image_orientation("00-lores/".$imgfilenames[$k])=="portrait") {
206 echo " class=\"portrait\"";
207 } else {
208 echo " class=\"landscape\"";
209 }
210 echo " alt=\"".$imgfilenames[$k]."\" />\n";
211 echo " </a>\n";
212 //
213 // Check if the boolean parameter $viewFileDate is set to true; if so,
214 // then add the date of last modification of the image file to the
215 // information displayed in the caption.
216 //
217 if ($viewFileDate) {
218 echo " <p>"
219 .($verboseFileDate?"Date: ":"")
220 ."[".gmdate('d M Y',getlastmod($imgfilenames[$k]))."]"
221 ."</p>\n";
222 }
223 //
224 // Check if the boolean parameter $viewFileName is set to true; if so,
225 // then add the name of the file of the image.
226 //
227 if ($viewFileName) {
228 echo " <p>"
229 .($verboseFileName?"File: ":"")
230 .$imgfilenames[$k]
231 ."</p>\n";
232 }
233 echo " </div> <!-- end of slideFrame div -->\n";
234 echo " </div>\n";
235 echo " </div> <!-- end of slideShadow div -->\n";
236 echo "</div> <!-- end of slide div -->\n";
237 return;
238 }
239
240 function display_contact_sheet($directory,$lang,$suffix) {
241 // Get the names of the subdirectories of $directory
242 // display_directorynames($directory);
243 // $dirs=get_directorynames($directory);
244 //
245 // Define the level of details to be displayed in description of image files
246 //
247 $viewCaption=true;
248 //
249 // Check if a file named "00-title.txt" exists in the supplied directory.
250 // If so, then the text contained in "00-title.txt" will be used as header
251 // at <h2> level for the displayed page.
252 //
253 echo "<h2>";
254 display_title($directory);
255 echo "</h2>\n";
256 display_parent_directory_switch($lang);
257
258 //
259 // Scan the supplied directory for images of the format as specified by
260 // the supplied filename suffix ($suffix) and iterate the following
261 // (X)HTML-generating loop over all images found.
262 //
263 $imgfilenames=get_image_filenames($directory."/00-thumbs/",$suffix);
264 $kmax=$imgfilenames[0]; // $kmax is the total number of images found of the
265 // type specified by $suffix.
266 $k=1;
267 while ($k <= $kmax) {
268 //
269 // The base name of any file is here taken as the entire character
270 // string preceding the last period (.); hence the file name may
271 // include an arbitrary number of periods without causing problems.
272 // The $basefilenames array contains all base names of the image files
273 // found in the supplied directory.
274 //
275 $basefilenames[$k]=substr($imgfilenames[$k],0,
276 strrpos($imgfilenames[$k],"."));
277 display_slide_frame($k,$imgfilenames,$lang);
278
279 // echo " <p>\n";
280 // echo " <b>Image ".$k.".</b>\n";
281 // //
282 // // For each PNG file found, or equivalently every base name in the
283 // // $basenames array, we check if there is a text file with the same
284 // // base name but with the suffix ".txt" located in the "00-captions"
285 // // sub-folder. If the boolean parameter $viewCaption is set to true,
286 // // the contents of the text file corresponding to the PNG image will
287 // // be used as caption. In this, the text in the file needs to be
288 // // pre-formatted as HTML-conforming text, in particular concerning
289 // // any special characters which may be present, such as for example
290 // // "å", "ä" and "ö".
291 // //
292 // if ($viewCaption) {
293 // $textfilenames[$k]="00-captions/".$basefilenames[$k].".txt";
294 // if (file_exists($textfilenames[$k])) {
295 // if (is_readable($textfilenames[$k])) {
296 // $fp=fopen($textfilenames[$k],r);
297 // echo " <span class=\"imageCaption\">\n";
298 // while (!feof($fp)) {
299 // echo " ".fgets($fp);
300 // }
301 // echo "</span>\n";
302 // fclose($fp);
303 // } else {
304 // echo "Warning: Caption text file ".$textfilenames[$k].
305 // " exists but is not readable.<br />\n";
306 // }
307 // }
308 // }
309 // echo " </p>\n";
310 $k=$k+1;
311 // echo "</div>\n";
312 }
313 display_footer_banner($lang);
314 return;
315 }
316
317 function get_suffix($filename) {
318 $suffix=strrchr($filename,"."); // Get last substring preceded by a period
319 $suffix=trim($suffix,"."); // Remove the period preceding the suffix
320 return $suffix;
321 }
322
323 function display_exif_data($filename) {
324 //
325 // Define which parameters to display: 'true'=display; 'false'=do not display
326 //
327 $displayDateOfExposure=true; // Display original date of exposure
328 $displayExposureData=true; // Display shutter speed and f-number used
329 $displayCameraMakeModel=false; // Display make and model of camera used
330
331 //
332 // Read any EXIF data encoded in the image, using the built-in PHP function
333 // as described at http://uk2.php.net/exif_read_data. This requires a PHP
334 // version above 4.20, and also that the EXIF extension was included in the
335 // compilation. Hence, the following block of code starts with a verification
336 // that the function exif_read_data() is available in the first place;
337 // otherwise the EXIF extraction is ignored.
338 //
339 if (function_exists("exif_read_data")) {
340 $exif = exif_read_data($filename,0,true);
341 //========================================================================
342 // In order to display the entire set of EXIF data encoded in the image
343 // file, uncomment the following block:
344 // foreach ($exif as $key => $section) {
345 // foreach ($section as $name => $val) {
346 // echo "$key.$name: $val<br />\n";
347 // }
348 // }
349 //========================================================================
350 $cameraMake=$exif['IFD0']['Make'];
351 $cameraModel=$exif['IFD0']['Model'];
352 $originalExposureTimeStamp=$exif['EXIF']['DateTimeOriginal'];
353 $originalExposureTimeStamp=explode(":",$originalExposureTimeStamp);
354 $originalExposureYear=$originalExposureTimeStamp[0];
355 $originalExposureMonth=$originalExposureTimeStamp[1];
356 $originalExposureDateHour=explode(" ",$originalExposureTimeStamp[2]);
357 $originalExposureDate=$originalExposureDateHour[0];
358 $originalExposureHour=$originalExposureDateHour[1];
359 $originalExposureMinute=$originalExposureTimeStamp[3];
360 $originalExposureSecond=$originalExposureTimeStamp[4];
361 $originalExposureTimeStamp=strtotime("$originalExposureMonth/"
362 ."$originalExposureDate/$originalExposureYear");
363 $originalExposureTimeStamp=date('d F Y',$originalExposureTimeStamp);
364 $exposureTime=$exif['EXIF']['ExposureTime'];
365 $apertureFNumber=$exif['COMPUTED']['ApertureFNumber'];
366 echo " <span class=\"EXIFData\">";
367 if ($displayDateOfExposure==true)
368 echo "Date: $originalExposureTimeStamp. ";
369 if ($displayExposureData==true)
370 echo "Exposure: $exposureTime s, $apertureFNumber. ";
371 if ($displayCameraMakeModel==true)
372 echo "Camera: $cameraMake $cameraModel. ";
373 echo "</span>\n";
374 }
375 return;
376 }
377
378 function display_main_image($id,$imgfilenames,$lang) {
379 //
380 // Define the level of details to be displayed in description of image files
381 //
382 $viewCaption=true;
383 $viewFileName=false;
384 $viewFileDate=true;
385 $verboseFileName=true;
386 $verboseFileDate=false;
387 $displayExifData=true; // Display EXIF data extracted from the image file.
388 $displayCopyright=true; // Display copyright info in the caption.
389
390 $image_orientation=get_image_orientation("00-lores/".$imgfilenames[$id]);
391 echo "<div class=\"mainImage\">\n";
392 if ($image_orientation=="portrait") {
393 echo " <div class=\"img-wrapper-portrait\">\n";
394 } else {
395 echo " <div class=\"img-wrapper\">\n";
396 }
397 echo " <div>\n"
398 ." <img src=\"00-lores/".$imgfilenames[$id]."\"";
399 if ($image_orientation=="portrait") {
400 echo " class=\"portrait\"";
401 } else {
402 echo " class=\"landscape\"";
403 }
404 echo " alt=\"".$imgfilenames[$id]."\" />"
405 ."\n"
406 ." </div>\n"
407 ." </div>\n";
408 // echo " <div class=\"clear\"></div>\n";
409 echo " <p>\n";
410 echo " <b>Image ".$id." of ".$imgfilenames[0].".</b>\n";
411
412 if ($viewCaption) {
413 $suffix=get_suffix($imgfilenames[$id]);
414 $textfilenames[$id]="00-captions/"
415 .trim($imgfilenames[$id],".".trim($suffix)).".txt";
416 if (file_exists($textfilenames[$id])) {
417 if (is_readable($textfilenames[$id])) {
418 $fp=fopen($textfilenames[$id],r);
419 echo " <span class=\"imageCaption\">\n";
420 while (!feof($fp)) {
421 echo " ".fgets($fp);
422 }
423 echo "</span>\n";
424 fclose($fp);
425 } else {
426 echo "Warning: Caption text file ".$textfilenames[$id].
427 " exists but is not readable.<br />\n";
428 }
429 }
430 if ($displayExifData==true)
431 display_exif_data("00-hires/".$imgfilenames[$id]);
432 if ($displayCopyright==true)
433 display_copyright();
434 }
435 echo " </p>\n";
436 echo "</div><!-- End of mainImage div -->\n";
437 echo "<div class=\"clear\"></div>\n";
438 return;
439 }
440
441 function display_previous_image($id,$imgfilenames,$lang) {
442 echo "<div class=\"previousImage\">\n";
443 echo " <div class=\"slide\">\n";
444 echo " <div class=\"slide-shadow\">\n";
445 echo " <div>\n";
446 echo " <div class=\"slideFrame\">\n";
447 echo " <a href=\"?view=slideshow&id=".($id-1)."&lang=".$lang."\">\n";
448 echo " <img src=\"00-thumbs/".$imgfilenames[$id-1]."\"";
449 if (get_image_orientation("00-thumbs/".$imgfilenames[$id-1])=="portrait") {
450 echo " class=\"portrait\"";
451 } else {
452 echo " class=\"landscape\"";
453 }
454 echo " alt=\"".$imgfilenames[$id-1]."\" />\n";
455 echo " </a>\n";
456 echo " <p>".($id-1)." (".$imgfilenames[0].")</p>\n";
457 echo " </div>\n";
458 echo " </div>\n";
459 echo " </div>\n";
460 echo " <div class=\"clear\"></div>\n";
461 echo " <p class=\"backwardLink\">";
462 echo "<a href=\"?view=slideshow&id=".($id-1)."&lang=".$lang."\"><b>";
463 switch ($lang) {
464 case en:
465 echo "Previous image";
466 break;
467 case sv:
468 echo "Föregående bild";
469 break;
470 default:
471 echo "PHP Error: Language switch \"".$lang."\" is not recognized!\n";
472 }
473 echo "</b></a>";
474 echo "</p>\n";
475 echo " </div>\n";
476 echo "</div>\n";
477 return;
478 }
479
480 function display_next_image($id,$imgfilenames,$lang) {
481 echo "<div class=\"nextImage\">\n";
482 echo " <div class=\"slide\">\n";
483 echo " <div class=\"slide-shadow\">\n";
484 echo " <div>\n";
485 echo " <div class=\"slideFrame\">\n";
486 echo " <a href=\"?view=slideshow&id=".($id+1)."&lang=".$lang."\">\n";
487 echo " <img src=\"00-thumbs/".$imgfilenames[$id+1]."\"";
488 if (get_image_orientation("00-thumbs/".$imgfilenames[$id+1])=="portrait") {
489 echo " class=\"portrait\"";
490 } else {
491 echo " class=\"landscape\"";
492 }
493 echo " alt=\"".$imgfilenames[$id+1]."\" />\n";
494 echo " </a>\n";
495 echo " <p>".($id+1)." (".$imgfilenames[0].")</p>\n";
496 echo " </div>\n";
497 echo " </div>\n";
498 echo " </div>\n";
499 echo " <div class=\"clear\"></div>\n";
500 echo " <p class=\"forwardLink\">";
501 echo "<a href=\"?view=slideshow&id=".($id+1)."&lang=".$lang."\"><b>";
502 switch ($lang) {
503 case en:
504 echo "Next image";
505 break;
506 case sv:
507 echo "Nästa bild";
508 break;
509 default:
510 echo "PHP Error: Language switch \"".$lang."\" is not recognized!\n";
511 }
512 echo "</b></a>";
513 echo "</p>\n";
514 echo " </div>\n";
515 echo "</div>\n";
516 return;
517 }
518
519 function contact_sheet_switch($lang) {
520 echo "<div id=\"contactSheetSwitch\">\n";
521 echo " <p><a href=\"?view=contact&lang=".$lang."\">";
522 switch ($lang) {
523 case en:
524 echo " View contact sheet";
525 break;
526 case sv:
527 echo " Visa kontaktkarta";
528 break;
529 default:
530 echo "PHP Error: Language switch \"".$lang."\" is not recognized!\n";
531 }
532 echo " </a></p>\n";
533 echo "</div>\n";
534 return;
535 }
536
537 function display_slideshow($directory,$id,$lang,$suffix) {
538 $display_title=true;
539 //
540 // Check if a file named "00-title.txt" exists in the supplied directory.
541 // If so, then the text contained in "00-title.txt" will be used as header
542 // at <h2> level for the displayed page.
543 //
544 if ($display_title==true) {
545 echo "<h2>";
546 display_title($directory);
547 echo "</h2>\n";
548 }
549 contact_sheet_switch($lang);
550 display_parent_directory_switch($lang);
551
552 //
553 // Scan the supplied directory for PNG images and display the actual
554 // image with number as supplied as argument to the routine; also display
555 // any preceding and/or succeding images. [Q: CORRECT LANGUAGE?]
556 //
557 $imgfilenames=get_image_filenames($directory."/00-thumbs/",$suffix);
558 $kmax=$imgfilenames[0]; // This is the total number of images found
559 $k=1;
560 while ($k <= $kmax) {
561 //
562 // The base name of any file is here taken as the entire character
563 // string preceding the last period (.); hence the file name may
564 // include an arbitrary number of periods without causing problems.
565 // The $basefilenames array contains all base names of the image files
566 // found in the supplied directory.
567 //
568 $basefilenames[$k]=substr($imgfilenames[$k],0,
569 strrpos($imgfilenames[$k],"."));
570 // echo "<div class=\"contactSheetImage\">\n";
571 // echo " <div class=\"slide-shadow\">\n"
572 // ." <a href=\"?view=slideshow&id=".$k."\">"
573 // ."<img src=\"00-thumbs/".$imgfilenames[$k]."\""
574 // ." alt=\"".$basefilenames[$k]."\">"
575 // ."</a>\n"
576 // ." </div>\n";
577 // echo " <p>\n";
578 // echo " <b>Image ".$k.".</b>\n";
579 //
580 // For each PNG file found, or equivalently every base name in the
581 // $basenames array, we check if there is a text file with the same
582 // base name but with the suffix ".txt" located in the "00-captions"
583 // sub-folder. If the boolean parameter $viewCaption is set to true,
584 // the contents of the text file corresponding to the PNG image will
585 // be used as caption. In this, the text in the file needs to be
586 // pre-formatted as HTML-conforming text, in particular concerning
587 // any special characters which may be present, such as for example
588 // "å", "ä" and "ö".
589 //
590 // if ($viewCaption) {
591 // $textfilenames[$k]="00-captions/".$basefilenames[$k].".txt";
592 // if (file_exists($textfilenames[$k])) {
593 // if (is_readable($textfilenames[$k])) {
594 // $fp=fopen($textfilenames[$k],r);
595 // echo " <span class=\"imageCaption\">\n";
596 // while (!feof($fp)) {
597 // echo " ".fgets($fp);
598 // }
599 // echo "</span>\n";
600 // fclose($fp);
601 // } else {
602 // echo "Warning: Caption text file ".$textfilenames[$k].
603 // " exists but is not readable.<br />\n";
604 // }
605 // }
606 // }
607 //
608 // Check if the boolean parameter $viewFileDate is set to true; if so,
609 // then add the date of last modification of the image file to the
610 // information displayed in the caption.
611 //
612 // if ($viewFileDate) {
613 // echo " <span class=\"imageFileDate\">"
614 // .($verboseFileDate?"Date: ":"")
615 // ."[".gmdate('d M Y',getlastmod($imgfilenames[$k]))."]"
616 // ."</span>\n";
617 // }
618 //
619 // Check if the boolean parameter $viewFileName is set to true; if so,
620 // then add the name of the file of the PNG image.
621 //
622 // if ($viewFileName) {
623 // echo " <span class=\"imageFileName\">"
624 // .($verboseFileName?"File: ":"")
625 // .$imgfilenames[$k]
626 // ."</span>\n";
627 // }
628 // echo " </p>\n";
629 $k=$k+1;
630 // echo "</div>\n";
631 }
632
633 if ((1<=$id)&&($id<=$kmax)) {
634 if (1<$id) display_previous_image($id,$imgfilenames,$lang);
635 if ($id<$kmax) display_next_image($id,$imgfilenames,$lang);
636 display_main_image($id,$imgfilenames,$lang);
637 }
638 // echo "<div class=\"clear\"></div>\n";
639 // display_footer_banner($lang);
640 return;
641 }
642
643 //
644 // The image_directories_exist($directory) function scans the supplied
645 // directory for sub-directories named '00-thumbs', '00-lores' and
646 // '00-hires'. If these three sub-directories all are found to exist
647 // within the directory specified by the string $directory, then 'true'
648 // is returned; otherwise 'false' is returned.
649 //
650 function image_directories_exist($directory) {
651 $subdirs=get_directorynames($directory);
652 $thumbs_dir_exist=false;
653 $lores_dir_exist=false;
654 $hires_dir_exist=false;
655 for ($i=1; $i<=$subdirs[0]; $i++) {
656 if (!strcmp(trim($subdirs[$i]),"00-thumbs")) $thumbs_dir_exist=true;
657 if (!strcmp(trim($subdirs[$i]),"00-lores")) $lores_dir_exist=true;
658 if (!strcmp(trim($subdirs[$i]),"00-hires")) $hires_dir_exist=true;
659 }
660 if (($thumbs_dir_exist)&&($lores_dir_exist)&&($hires_dir_exist)) {
661 return true;
662 } else {
663 return false;
664 }
665 }
666
667 function display_catalogue_banner($directory,$lang,$suffix) {
668 $txtfile=trim($directory)."/00-title.txt";
669 $imgfile=trim($directory)."/00-title.jpg";
670 if (file_exists($txtfile)&&file_exists($imgfile)) {
671 echo "<div class=\"catalogueBanner\">\n";
672 echo " <div class=\"img-wrapper\">\n";
673 echo " <div>\n";
674 echo " <a href=\"./$directory/\">\n";
675 echo " <img src=\"$imgfile\" alt=\"$directory\" />\n";
676 echo " </a>\n";
677 echo " </div>\n";
678 echo " </div>\n";
679 echo " <p>";
680 display_title($directory);
681 $imgfilenames=get_image_filenames($directory."/00-thumbs/",$suffix);
682 $kmax=$imgfilenames[0]; // This is the total number of images found
683
684 echo " [$kmax images]\n";
685 echo "</p>\n";
686 echo "</div>\n";
687 }
688 return $kmax;
689 }
690
691 function display_catalogue_overview($directory,$lang,$suffix) {
692 display_parent_directory_switch($lang);
693 // Get the names of the subdirectories of $directory
694 $subdirs=get_directorynames($directory);
695 $nn=0;
696 for ($i=1; $i<=$subdirs[0]; $i++) {
697 $nn=$nn+display_catalogue_banner(trim($subdirs[$i]),$lang,$suffix);
698 }
699 echo "<div class=\"clear\"></div>\n";
700 return;
701 }
702
703 function photoview($directory,$lang,$suffix) {
704 $lang=$_GET["lang"]; // Extract any specification of language to use
705 if ($lang=="") $lang=en; // If no specification, use English as default
706 $view=$_GET["view"]; // Extract any specification of view to apply
707 $id=$_GET["id"]; // Extract any specification of which image to view
708 echo "<div id=\"photoview\"> ";
709 echo "<!-- Beginning of (X)HTML automatically generated by PhotoView -->\n";
710
711 //
712 // Before considering any statements supplied as parameters to the photoview
713 // script regarding mode of viewing, we perform a simple check to see if any
714 // directories named according to the conventions exist. If not, then simply
715 // ignore any view mode specification and instead go for a directory overview
716 // mode, displaying title images of sub-directories.
717 //
718 if (!image_directories_exist($directory)) {
719 display_catalogue_overview($directory,$lang,$suffix);
720 } else {
721 switch ($view) {
722 case contact:
723 display_contact_sheet($directory,$lang,$suffix);
724 break;
725 case slideshow:
726 display_slideshow($directory,$id,$lang,$suffix);
727 break;
728 default:
729 display_contact_sheet($directory,$lang,$suffix);
730 }
731 }
732 echo "</div> ";
733 echo "<!-- End of (X)HTML automatically generated by PhotoView -->\n";
734 return;
735 }
736
737 ?>
738
Generated by ::viewsrc::