nav.inc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <div class="example-nav">
  2. <?php
  3. $tmpnames = scandir('./');
  4. $skip = array('opener.php', 'bodyOpener.php', 'nav.php', 'closer.html', 'commonScripts.html', 'topbanner.html');
  5. foreach( $tmpnames as $value) {
  6. if (preg_match('/^[a-z0-9][a-z0-9_\-]+\.(html|php)$/i', $value)) {
  7. if (! in_array($value, $skip)) {
  8. $files[] = $value;
  9. }
  10. }
  11. }
  12. $fcount = count($files);
  13. $parts = explode("/", $_SERVER['SCRIPT_NAME']);
  14. $curfile = end($parts);
  15. $prevfile = '';
  16. $nextfile = '';
  17. // print_r($files);
  18. for ($i=0; $i<$fcount; $i++) {
  19. if ($curfile == $files[$i]) {
  20. if ($i == 0) {
  21. $prevfile = $files[$fcount-1];
  22. $nextfile = $files[1];
  23. }
  24. elseif ($i == $fcount-1) {
  25. $prevfile = $files[$i-1];
  26. $nextfile = $files[0];
  27. }
  28. else {
  29. $prevfile = $files[$i-1];
  30. $nextfile = $files[$i+1];
  31. }
  32. }
  33. }
  34. echo '<a href="'.$prevfile.'">Previous</a> <a href="./">Examples</a> <a href="'.$nextfile.'">Next</a>';
  35. ?>
  36. </div>