\$LinkText"); Markup('Gallery','>include',"/\\(:Gallery\\s(.*?):\\)/e","Gallery('$1')"); function Gallery($gallery) { global $pagename; global $PageNotFoundHeaderFmt; global $DefaultPageTextFmt; # Language stuff $DefaultPageTextFmt=''; $PageNotFoundHeaderFmt=''; $next="Volgende"; $previous="Vorige"; $thumbnails="Overzicht"; $thumbstart="Begin van dit album"; $gallerypage = ReadPage($gallery); global $HTMLStylesFmt; global $DefaultName; global $_REQUEST; if (!$gallerypage) return false; $Maxcol=5; $picture_found=-1; $Title="Gallery"; $Thumb="thumb/"; $Width="144"; $Height="106"; $Limit="25"; $GalleryStart=0; if ( isset ($_REQUEST['GalleryStart'] ) ) { $GalleryStart= $_REQUEST['GalleryStart'] ; } ; if ($GalleryStart < 0 ) $GalleryStart=0; $keys=array('Location','Thumb','Title','Maxcol','Width','Height','Limit'); foreach(explode("\n",@$gallerypage['text']) as $x) { foreach ($keys as $k) { if (preg_match("/^\*?$k:(.*)$/",$x,$match) ){ $$k=$match[1]; } } if (preg_match("/\*?([^.]+).jpg:?(.*)/",$x,$match) ){ $pictures[]=$match[1]; if ( $match[2] ) { $title[$match[1]]=$match[2]; } else { $title[$match[1]]=$match[1]; } if ( stristr($pagename,preg_replace("/[_ ]/",'',$match[1])) ) { $picture_found=count($pictures)-1; } } } $num_of_pictures=count ($pictures); if ( ! $pictures ) { return "";}; if ( $picture_found > -1 ) { $next_picture=""; $previous_picture=""; $this_picture=$pictures[$picture_found]; if ( $picture_found > 0 ) { $previous_picture=$pictures[$picture_found-1]; } else { $previous_picture=$pictures[$num_of_pictures-1]; } if ( $picture_found +1 < $num_of_pictures ) { $next_picture=$pictures[$picture_found+1]; } else { $next_picture=$pictures[0]; } # # It would be much nicer if this could be done in the wiki # Something like: # ||{$previous_image}||{$up}||{$next_image}|| # ||{$this_image}|||||| # ||{$this_text}|||||| # ToDo # Main question is how to disable the page-does-not-exist type of link? $out .="\n(:table width=99%:)\n"; $out .="(:cellnr width=33%:)\n"; $out .="%left%" . Keep(MakeLink($pagename,PSS("$previous_picture"),PSS("$Location$Thumb$previous_picture.jpg\"$previous\""),'',$GLOBALS['LinkGalleryFmt']),'L'); $out .= "\n "; $out .="\n(:cell width=33%:)\n"; $whereami=(floor ($picture_found / $Limit)) * $Limit; $out .= "%center%[[$DefaultName?GalleryStart=$whereami|$thumbnails]]"; $out .="\n(:cell:)\n"; $out .="%right%" . Keep(MakeLink($pagename,PSS("$next_picture"),PSS("$Location$Thumb$next_picture.jpg\"$next\"") ,'',$GLOBALS['LinkGalleryFmt']),'L'); $out .= " "; $out .="\n(:cellnr colspan=3 style='text-align:center' :)\n"; $out .= "%center%$Location$this_picture.jpg\"$title[$this_picture]\"\\\\\n"; $out .= "%center%'''[= $this_picture : $title[$this_picture]=]'''\\\\\n"; # preload next image if ( $next_picture ) { $out .= "%width=1%$Location$next_picture.jpg\\\\\n"; } $out .="\n(:tableend:)\n"; } else { # $out.= "\n(:table:)\n"; if ( $GalleryStart > $num_of_pictures ) { $GalleryStart=$num_of_pictures-$Limit; } if (( $GalleryStart > $Limit ) ||(($GalleryStart > 0) && ($GalleryStart < $Limit) )) { $out .= "\n\n%center%[[$DefaultName|$thumbstart]]\n\\\\\n%%"; } if (( $GalleryStart >= $Limit ) ) { $whereami=$GalleryStart-$Limit; $out .= "\n%center%[[$DefaultName?GalleryStart=$whereami|$previous]]\n\\\\\n\n%%\n\\\\\n"; } $out .="\n"; foreach (array_slice($pictures,$GalleryStart,$Limit) as $k ) { $out .=Keep(MakeLink($pagename,PSS("$k"),PSS("$Location$Thumb$k.jpg\"$title[$k]\""),'',$GLOBALS['LinkGalleryFmt']),'L'); } if (( $GalleryStart < ($num_of_pictures - $Limit ) ) ) { $whereami=$GalleryStart+$Limit; $out .= "\n\n%center%[[$DefaultName?GalleryStart=$whereami|$next]]\n"; } } $out .= "(:title $Title:)\n"; $out .= "\n----\n"; $HTMLStylesFmt['gallerylink'] = "span.gallerylink {margin:5px;}" . "span.gallerylink img {width:".$Width."px;height:".$Height."px}"; return $out; } ?>