Files
cwsvJudo/homepage/redesign2018/markdownExperiment/phpLib/imgGallery/index.php.tmpl
marko 1f811930f3 Bildergalerie als Backup von der bplaced-Seite
neue Datei:     phpLib/imgGallery/imgPicker.php
	neue Datei:     phpLib/imgGallery/index.php.tmpl
	neue Datei:     phpLib/imgGallery/indexDev.php.tmpl
	neue Datei:     phpLib/imgGallery/view.php.tmpl
2018-07-01 15:01:09 +02:00

366 lines
13 KiB
Cheetah
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// Daten der Datenbank laden
require_once($_SERVER['DOCUMENT_ROOT']."/bonus/db.inc");
function startsWith($haystack, $needle){
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
/// Abfrage der ausgewählten Bilder einer Galerie
function getPickedImages($aMysqlConn, $aGalId){
$retPickedImages = array();
/// Erstmal bisher ausgewählte Bilder abfragen ...
$queryPickedImages = sprintf(
"SELECT * FROM cwsvjudo.galImgPicker WHERE galId = '%s';",
$aMysqlConn->real_escape_string($aGalId)
);
// die($queryPickedImages);
$resultsPickedImages = $aMysqlConn->query($queryPickedImages);
/// @todo Wie kann ich hier sinnvoll einen Fehler zurückliefern? Nullpointer?
if( !$resultsPickedImages ){
$retMessage['error'] .= "Fehler ('".$aMysqlConn->error."') bei Datenbankabfrage '".$queryPickedImages."'<br />";
die( "Fehler ('".$aMysqlConn->error."') bei Datenbankabfrage '".$queryPickedImages."'<br />");
}
else{
while( $pickedImagesResult = $resultsPickedImages->fetch_assoc() ){
$retPickedImages = array_merge($retPickedImages, explode(',', $pickedImagesResult['pickedImages']) );
}
}
//echo("retPickedImages: ");print_r($retPickedImages); die();
return array_unique( $retPickedImages );
}/// Ende getPickedImages
/// Hilfsfunktion zum Anpassen der htmlDescription
function descrName($aName){
$retVal = "Bilder der Judoka des Chemnitzer WSV beim Wettkampf ".$aName;
if( strpos($aName, "Sommerabschlussgrillen") >= 0 ) $retVal = "Bilder der Judoka des Chemnitzer WSV beim ".$aName;
if( strpos($aName, "Jahrendefeier") >= 0 ) $retVal = "Bilder der Judoka des Chemnitzer WSV bei der ".$aName;
return $retVal;
}/// Ende descrName
$loginStatus = "false";
$chooseMode = "false";
$showAllMode = "false";
$messages = array();
$galleryId = "0";
$pickedImages = array();
// echo("imgList: "); print_r($imgList);
// foreach($imgList as $img){
// echo(" ".$img." startsWith images/ :".startsWith($img, "images/")."\n");
// }
/// Übergebene galleryId abfragen
if( !empty($_GET['galId'] ) ) $galleryId = $_GET['galId'];
/// @todo Woher erhalte ich die galleryID, wenn sie nicht übergeben wird?
/// Nachschauen, ob alle Bilder gezeigt werden sollen
if( $_GET['showAll'] == "true" )
$showAllMode = "true";
// Testen, ob wir im Bilderauswahlmodus sind...
if($_GET['chooseMode'] == "true"){
$showAllMode = "true"; // Im Bildauswahlmodus sollten auch alle Bilder angezeigt werden
$chooseMode = "true";
// Falls ja, dann teste, ob man angemeldet ist
/// @todo brauche ich das, wenn ich nur testen will, ob bereits angemeldet ist? -> anscheinend ja!
session_start();
session_regenerate_id();
// Falls der serverseitige Logincookie nicht gesetzt ist
if( empty($_SESSION['login']) ){
$loginStatus = "false";
$messages['info'] .= "Info: Der Bilderauswahlmodus ist nur möglich, wenn man angemeldet ist!<br />";
}
else{
$loginStatus = "true";
/// @todo Testen, ob eine intZahl vorliegt
/// @todo Testen, ob wir in der richtigen Galerie sind
$messages['info'] .= "Info: Der Bilderauswahlmodus für Galerie ".$galleryId." ist aktiv!<br />";
}
}
$mysqlConn = @new mysqli($db_server, $db_user, $db_password, $db_name);
if($mysqlConn->connect_error){
$message['error'] .= "Fehler: Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "<br />";
}
else{
$pickedImages = getPickedImages( $mysqlConn, $galleryId );
$mysqlConn->close();
}
/// Überschreiben der imgList mit den ausgewählten Bildern
$allImgList = $imgList; // Sicherungskopie
//echo("imgList:");print_r($imgList);
// echo("pickedImages: "); print_r($pickedImages);
if( count($pickedImages) > 24 )
$pickedImages = array_rand( $pickedImages, 24);
else{
$restImages = array_diff( $allImgList, $pickedImages );
//echo("restImages: "); print_r($restImages);
//echo("count(restImages): ".count($restImages));
//echo("count(24-count($pickedImages)): ".(24-count($pickedImages)));
foreach( array_rand( $restImages, min(24, count($restImages))-count($pickedImages) ) as $k ) {
$pickedImages[] = $restImages[$k];
}
// echo("pickedImages: "); print_r($pickedImages);
}
$imgList = $pickedImages;
// echo("imgList: "); print_r($imgList);
/// @todo ein Sortieren nach dem ursprünglichen Index fehlt
usort($imgList, function($a, $b) use($allImgList){return array_search($a, $allImgList) > array_search($b, $allImgList);} );
$imgList = array_values( $imgList );// Zum reNummerieren
// echo("imgList: "); print_r($imgList);
if( $showAllMode == "true") $imgList = $allImgList;
$imgInfos = array();
foreach( $imgList as $imgName ){
if(startsWith($imgName, "images/")){
array_push( $imgInfos, @getimagesize(str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgName))));
}
else{
array_push( $imgInfos, @getimagesize("thumbs/".str_replace(".jpg", ".png", $imgName)));
}
}
?>
<!DOCTYPE HTML>
<html lang="de">
<head>
<title><?php echo $wkName?> - Bilderalbum<?php echo( !empty($showAllMode)?($showAllMode == "true" ? " - alle Bilder" : "") : "");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="
<?php
echo descrName($wkName);
echo( !empty($showAllMode)?($showAllMode == "true" ? " - alle Bilder" : "") : "");
?>
">
<meta name="keywords" content="Album, Fotos">
<!-- BluimpGallery Zeug -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-indicator.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-video.css">
<!-- favIcon und Co nach der empfehlung von https://github.com/audreyr/favicon-cheat-sheet -->
<link rel="shortcut icon" type="image/x-icon" sizes="16x16 32x32 48x48 64x64" href="/ressourcen/graphiken/logos/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="152x152" href="/ressourcen/graphiken/logos/apple-touch-icon/apple-touch-icon-152.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/ressourcen/graphiken/logos/apple-touch-icon/apple-touch-icon-180.png" />
<link rel="manifest" href="/manifest.json">
<link rel="canonical" href="http://cwsvjudo.bplaced.net<?php echo $_SERVER['REQUEST_URI']?>" />
<script type="text/javascript" src="/ressourcen/jsLib/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="/ressourcen/jsLib/jquery.lazyload.min.js"></script>
<style>
.lazy{ display: none;}
.smallFont{font-size: small;}
.centerText{text-align: center;}
.navButton{
box-sizing: border-box;
border-color: white;
border-style: outset;
border-radius: 1em;
text-align: center;
text-decoration: none;
cursor: pointer;
display: inline-block;
padding-left: .5em;
padding-right: .5em;
padding: 0;
margin: 0;
}
</style>
</head>
<body style="color: #000000; background-color: #FFAE00" >
<a title="Galerien der Judoka des Chemnitzer WSV" href="/galerien">Zur Galerieübersicht</a>
<?php
// require_once( $_SERVER['DOCUMENT_ROOT'].'/ressourcen/phpLib/is_mobile.php');
// if(is_mobile()) echo "<a title=\"Galerien der Judoka des Chemnitzer WSV\" href=\"/pages/mobile/verein.wettkampfgalerien.php\">Zur Galerieübersicht</a>";
// else echo "<a title=\"Galerien der Judoka des Chemnitzer WSV\" href=\"/pages/desktop/verein.galerien.php\">Zur Galerieübersicht</a>";
?>
<?php
/// Eine kleine Messagebox
if( !empty($messages) ){
?>
<div style="border: 1px solid black">
<?php
if( !empty( $messages['info'] ) ) echo( $messages['info'] );
?>
</div>
<?php
}
// echo("pickedImages: "); print_r($pickedImages);
/// Ende MessageBox
?>
<h1 class="centerText" >
Photoalbum [<b><?php echo $wkName?></b>]
</h1>
<?php
if( $showAllMode == "true" ){
?>
<p class="centerText smallFont">
[<?php echo count($imgList)?> Bilder]
</p>
<?php
}
else{
?>
<a href=<?php echo( "\"?galId=".(empty($galleryId)?"0":$galleryId)."&showAll=true".($chooseMode=="true"?"&chooseMode=true":"")."\"");?>><div class="navButton" style="width: 100%;">Alle Bilder einblenden </div></a>
<?php
}
?>
<p class="centerText smallFont">
Auf die jeweiligen Bilder klicken um eine größere Ansicht zu bekommen.
</p>
<hr/>
<style type="text/css">
.galImgList{
/*flex: auto;*/
display: flex;
flex-flow: row wrap;
justify-content: space-around;
align-items: center;
}
</style>
<!-- The container for the list of example images -->
<?php
if( $chooseMode == "true" ){
echo( "<form action=\"http://cwsvjudo.bplaced.net/ressourcen/phpLib/imgGallery/imgPicker.php\" method=\"post\">" );
echo( "<input type=\"hidden\" name=\"galId\" value=\"".$galleryId."\" />" );
}
?>
<div id="links" class="galImgList">
<?php
$imgSize = count( $imgList );
for( $imgIndex = 0; $imgIndex < $imgSize; ++$imgIndex){
echo( "<div ".( ($chooseMode=="true")?"style=\"border: 1px solid black;\"":"" ).">" );
if( $chooseMode == "true" ){
echo("<label>");
echo( "<input type=\"checkbox\" name=\"pickedImages[]\" value=\"".$imgList[$imgIndex]."\" />" );
}
echo "<img class=\"lazy\" ".
"id=\"Image".( $imgIndex )."\" ".
// "data-original=\"./thumbs/".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images/", "", str_replace(".jpg", ".png", $imgName)):str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
// "data-original=\"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex])."\" ".
"data-original=\"".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgList[$imgIndex])):"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
$imgInfos[$imgIndex][3]." ".
"alt=\"[".( $imgIndex )."/".( $imgSize )."]\" ".
"title=\"".( $wkName )." Bild ".( $imgIndex +1 )." von ".( $imgSize )."\" ".
"onclick=\"startGalleryShow(" . $imgIndex . ");\"".
" />";
if( $chooseMode == "true" ) echo( "</label>" );
echo("</div>");
}
?>
</div><!-- Ende galImgList -->
<?php
if( $chooseMode == "true" ){
echo( "<button type=\"submit\">Eingaben absenden</button>" );
echo( "</form>" );
}
?>
<noscript>
<div id="links" class="galImgList">
<?php
$imgSize = count( $imgList );
//echo("imgList: ");print_r($imgList);
for( $imgIndex = 0; $imgIndex < $imgSize; ++$imgIndex){
echo
"\t\t\t\t<span>".
"<a href=\"view.php?index=".( $imgIndex )."\" >".
"<img id=\"Image".( $imgIndex + 1)."\" ".
// "src=\"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex])."\" ".
// "src=\"./thumbs/r_".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgName)):str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
"src=\"".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgList[$imgIndex])):"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
"alt=\"[".( $imgIndex )."/".( $imgSize )."]\" ".
"title=\"".( $wkName )." Bild ".( $imgIndex + 1 )." von ".( $imgSize )."\" ".
"/>".
"</a>".
"</span>\n";
}
?>
</div>
</noscript>
</div>
<script type="text/javascript" charset="utf-8">
$(function() {
$("img.lazy").show().lazyload();
// $("img.lazy").lazyload();
});
</script>
<!-- BluimpGalerry Lightbox Version -->
<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
<div class="slides"></div>
<h2 class="title"><?php echo $wkName?></h2>
<a class="prev"></a>
<a class="next"></a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<script type="text/javascript" src="/ressourcen/blueimpGallery/js/blueimp-gallery.min.js"></script>
<script type="text/javascript" src="/ressourcen/blueimpGallery/js/jquery.blueimp-gallery.min.js"></script>
<script>
function startGalleryShow(startIndex = 0){
var imgList = [
<?php
$imgSize = count( $imgList );
for( $imgIndex = 0; $imgIndex < $imgSize; ++$imgIndex){
echo "\"".( $imgList[ $imgIndex ] )."\", ";
}
?>];
var gallery = blueimp.Gallery(
imgList,
{
onslide: function (index, slide) {
var counterUrl = "/expCounter/counter.php";
var pageUrl = encodeURIComponent( window.location.href ) + "?index=" + index.toString();
var pageTitle = document.title + " [" + index.toString() + "]";
var callUrl = counterUrl + "?jscode_version=1.2&chCounter_mode=js&status=active&visible=0&page_title=" + pageTitle + "&page_url=" + pageUrl;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", callUrl, true); // true for asynchronous
xmlHttp.send(null);
},
startSlideshow: true,
stretchImages: true,
index: startIndex,
}
);
};
window.onload = function () {
startGalleryShow();
};
// startGalleryShow();
</script>
<hr/>
<!--Beginn der Einbindung des Counters-->
<?php
$chCounter_template = <<<TEMPLATE
<table>
<tr>
<td>Besucher online: {V_VISITORS_CURRENTLY_ONLINE}</td>
<td>Besucher bisher: {V_PAGE_VIEWS_THIS_PAGE}</td>
</tr>
</table>
TEMPLATE;
$chCounter_page_title = "Photoalbum ".$wkName;
$chCounter_visible=1; include( $_SERVER['DOCUMENT_ROOT'].'/expCounter/counter.php');?>
<!--Ende der Einbindung des Counters-->
</body>
</html>