neue Datei: admin/newsAdmin.php neue Datei: admin/phpcount/phpcountLog.php - die Originale der Wappen neue Datei: graphiken/cwsvJudoLogoWappen.xcf neue Datei: graphiken/cwsvLogoWappen.xcf - Entwicklung einer Galerieansicht innerhalb des reDesigns2018 neue Datei: yaml/galerie.subNav.yaml neue Datei: md/galerie.md - Erweiterung des Templates geändert: pandocTemplate/cwsvJudo.html5.pandocTemplate - zu Testzwecken das Originaltemplate neue Datei: pandocTemplate/html5.pandocTemplate - redirectFunktion für die Galerien neue Datei: phpLib/cwsvJudo/galleryRedirector.php
268 lines
8.5 KiB
PHP
268 lines
8.5 KiB
PHP
<?php
|
|
|
|
// Laden von Konfigurationsdaten
|
|
require_once("config.inc.php");
|
|
|
|
require_once($basePath."/bonus/db.inc");
|
|
|
|
require_once($basePath."/ressourcen/phpLib/cwsvJudo/newsLib.php");
|
|
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
|
|
|
|
require_once($basePath."/ressourcen/phpLib/parsedown/Parsedown.php");
|
|
|
|
|
|
$Parsedown = new Parsedown();
|
|
|
|
$defaultPromoImg['url'] = "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png";
|
|
$defaultPromoImg['width'] = "207";
|
|
$defaultPromoImg['height'] = "256";
|
|
|
|
|
|
/// Auslesen des Newsarrays
|
|
if( empty($_POST['nachrichtenPromoImgUrl']) )
|
|
//$newsArticle['promoImg'] = $defaultPromoImg;
|
|
$newsArticle['promoImg'] = null;
|
|
else{
|
|
$newsArticle['promoImg']['url'] = $_POST['nachrichtenPromoImgUrl'];
|
|
$promoImgPath = $basePath.urldecode(parse_url( $newsArticle['promoImg']['url'] )['path']);
|
|
if(file_exists( $promoImgPath ) ){
|
|
// $newsArticle['promoImg']['width'] = getimagesize( $promoImgPath )[0];
|
|
// $newsArticle['promoImg']['height'] = getimagesize( $promoImgPath )[1];
|
|
list(
|
|
$newsArticle['promoImg']['width'],
|
|
$newsArticle['promoImg']['height']
|
|
) = array_slice( getimagesize( $promoImgPath ), 0, 2);
|
|
}
|
|
else{
|
|
$newsArticle['promoImg'] = null;
|
|
}
|
|
}
|
|
// print_r($newsArticle['promoImg']);
|
|
// echo(json_encode($newsArticle['promoImg']));
|
|
// print_r(json_decode(json_encode($newsArticle['promoImg'])));
|
|
|
|
// @todo Validierung!
|
|
$newsArticle['datum'] = !empty($_POST['nachrichtenDatum']) ? $_POST['nachrichtenDatum'] : strftime ( "%F" );
|
|
$newsArticle['betreff'] = !empty($_POST['nachrichtenBetreff']) ? $_POST['nachrichtenBetreff'] : "Kein Betreff!";
|
|
$newsArticle['text'] = !empty($_POST['nachrichtenText']) ? $_POST['nachrichtenText'] : "Kein Text!";
|
|
$newsArticle['autor'] = !empty($_POST['nachrichtenAutor']) ? $_POST['nachrichtenAutor'] : "Kein Autor!";
|
|
|
|
if( !empty($_POST['action']) ){
|
|
if( $_POST['action'] == "submitToDb" ){
|
|
|
|
try{
|
|
$dbConnection = new PDO('mysql:host='.$db_server.';dbname='.$db_name, $db_user, $db_password);
|
|
// set the PDO error mode to exception
|
|
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
// prepare sql and bind parameters
|
|
$stmt = $dbConnection->prepare("INSERT INTO cwsvjudo.nachrichtenDev (datum, betreff, nachricht, autor, promoImg) VALUES (:datum, :betreff, :nachricht, :autor, :promoImg)");
|
|
$stmt->bindParam(':datum', $newsArticle['datum']);
|
|
$stmt->bindParam(':betreff', iconv("UTF-8", "ISO-8859-1", $newsArticle['betreff']));
|
|
$stmt->bindParam(':nachricht', iconv("UTF-8", "ISO-8859-1", $Parsedown->text( $newsArticle['text'] )));
|
|
// $stmt->bindParam(':nachricht', $Parsedown->text( htmlspecialchars( $newsArticle['text'] ) ));
|
|
// $stmt->bindParam(':nachricht', iconv("UTF-8", "ISO-8859-1", $Parsedown->text($newsArticle['text'])));
|
|
$stmt->bindParam(':autor', $newsArticle['autor']);
|
|
$stmt->bindParam(':promoImg', $newsArticle['promoImg']['url']);
|
|
// insert a row
|
|
$stmt->execute();
|
|
|
|
echo "New records created successfully";
|
|
}
|
|
catch(PDOException $e){
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
$dbConnection = null;
|
|
}
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Nachrichtenadministration</title>
|
|
<style>
|
|
body{
|
|
background-color: #FF8100;
|
|
}
|
|
|
|
.noDisplay{
|
|
display: none;
|
|
}
|
|
|
|
.fullWidth{
|
|
width: 100%;
|
|
}
|
|
.newsPromoImage{
|
|
float: left;
|
|
}
|
|
.newsFooter{
|
|
clear: both;
|
|
}
|
|
|
|
.newsSubmitForm{
|
|
width=100%;
|
|
}
|
|
|
|
.newsPreviewForm textarea{
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
<link rel="stylesheet" href="http://cwsvjudo.bplaced.net/pages/desktop2018/cwsvJudo-2018-news.css">
|
|
</head>
|
|
<body>
|
|
<?php echo(getHtmlNews(array(
|
|
'datum' => $newsArticle['datum'],
|
|
'betreff' => $newsArticle['betreff'],
|
|
'promoImg' => $newsArticle['promoImg']['url'],
|
|
'nachricht' => Parsedown::instance()->text($newsArticle['text']),
|
|
'autor' => $newsArticle['autor']
|
|
)));?>
|
|
<hr />
|
|
<form class="newsSubmitForm" action="newsAdmin.php" method="post" id="nachricht">
|
|
<input
|
|
id="nachrichtenDatum"
|
|
name="nachrichtenDatum"
|
|
type="hidden"
|
|
value="<?php echo($newsArticle['datum']);?>"
|
|
/>
|
|
<textarea class="noDisplay"
|
|
id="nachrichtenBetreff"
|
|
name="nachrichtenBetreff"
|
|
><?php echo( htmlentities($newsArticle['betreff']) );?></textarea>
|
|
<input
|
|
id="nachrichtenPromoImgUrl"
|
|
name="nachrichtenPromoImgUrl"
|
|
type="hidden"
|
|
value="<?php echo($newsArticle['promoImg']['url']);?>"
|
|
/>
|
|
<textarea class="noDisplay"
|
|
id="nachrichtenText"
|
|
name="nachrichtenText"
|
|
><?php echo( htmlentities($newsArticle['text']));//textarea ersetzt selbständig htmlEnt, ohne dass man es verhindern kann?></textarea>
|
|
<input
|
|
id="nachrichtenAutor"
|
|
name="nachrichtenAutor"
|
|
type="hidden"
|
|
value="<?php echo($newsArticle['autor']);?>"
|
|
/>
|
|
<input
|
|
id="action"
|
|
name="action"
|
|
type="hidden"
|
|
value="submitToDb"
|
|
/>
|
|
<div>
|
|
<button type="submit">In Datenbank eintragen</button>
|
|
</div>
|
|
</form>
|
|
|
|
<hr />
|
|
|
|
<form class="newsPreviewForm" action="newsAdmin.php" method="post" id="nachricht">
|
|
<label for="nachricht">Nachricht</label>
|
|
|
|
<div>
|
|
<label for="nachrichtenDatum">Nachrichtendatum</label>
|
|
<input id="nachrichtenDatum" name="nachrichtenDatum" type="text" value="<?php echo( $newsArticle['datum'] );?>" />
|
|
</div>
|
|
|
|
<div>
|
|
<label for="nachrichtenBetreff">Nachrichtenbetreff</label>
|
|
<!--Achtung: Textarea nimmt alle Zeilenumbrüche, Tabulatoren etc. mit! Also keine Quellcodeformatierung mit Einschüben. -->
|
|
<textarea id="nachrichtenBetreff" name="nachrichtenBetreff" rows="1" ><?php echo( htmlentities($newsArticle['betreff']) );?></textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="nachrichtenPromoImgUrl">Url des Nachrichtenbildes</label>
|
|
<input id="nachrichtenPromoImgUrl" name="nachrichtenPromoImgUrl" type="text" value="<?php echo( empty($newsArticle['promoImg'])?"":$newsArticle['promoImg']['url'] );?>"/>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="nachrichtenText">Nachrichtentext</label>
|
|
<textarea id="nachrichtenText" name="nachrichtenText" rows="12" ><?php echo( htmlentities($newsArticle['text']) );//textarea ersetzt selbständig htmlEnt, ohne dass man es verhindern kann?></textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="nachrichtenAutor">Nachrichtenautor</label>
|
|
<input id="nachrichtenAutor" name="nachrichtenAutor" type="text" value="<?php echo( $newsArticle['autor'] );?>" />
|
|
</div>
|
|
|
|
<div>
|
|
<button type="reset">Eingaben zurücksetzen</button>
|
|
<button type="submit">Vorschau</button>
|
|
</div>
|
|
</form>
|
|
|
|
<?php
|
|
try{
|
|
$dbConnection = new PDO('mysql:host='.$db_server.';dbname='.$db_name, $db_user, $db_password);
|
|
// set the PDO error mode to exception
|
|
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$newsList = getNews($dbConnection, array('limit'=>6));
|
|
}
|
|
catch(PDOException $e){
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
$dbConnection = null;
|
|
if(!empty($newsList))
|
|
foreach( $newsList as $news)
|
|
echo("<hr />".getHtmlNews($news));
|
|
else echo("Keine Nachrichten gefunden!")
|
|
?>
|
|
<!--
|
|
<div class="newsArtikel" >
|
|
<div class="newsPromoImg" >
|
|
<?php
|
|
if( filter_var($newsArticle['promoImg']['url'], FILTER_VALIDATE_URL) )
|
|
echo( "<img src=\"".$newsArticle['promoImg']['url']."\" />" );
|
|
?>
|
|
</div>
|
|
<div class="newsDatum" >
|
|
<?php
|
|
echo($newsArticle['datum']);
|
|
?>
|
|
</div>
|
|
<div class="newsBetreff" >
|
|
<?php
|
|
echo($newsArticle['betreff']);
|
|
?>
|
|
</div>
|
|
<div class="newsText" >
|
|
<?php
|
|
echo( $Parsedown->text( $newsArticle['text'] ) );
|
|
?>
|
|
</div>
|
|
<div class="newsAutor" >
|
|
<?php
|
|
echo( $newsArticle['autor'] );
|
|
?>
|
|
</div>
|
|
</div>
|
|
-->
|
|
<div>
|
|
<!--
|
|
<?php
|
|
print_r(parse_url( !empty($_POST['nachrichtenPromoImgUrl'])?$_POST['nachrichtenPromoImgUrl']:$defaultPromoImg['url']));
|
|
?>
|
|
</div>
|
|
<div>
|
|
<?php
|
|
print_r(getimagesize( $basePath.urldecode( parse_url( !empty($_POST['nachrichtenPromoImgUrl'])?$_POST['nachrichtenPromoImgUrl']:$defaultPromoImg['url'] )['path'] ) ) );
|
|
?>
|
|
</div>
|
|
|
|
<div>
|
|
<?php if( empty($_POST) ) echo("No POST!"); else print_r($_POST);?>
|
|
</div>
|
|
|
|
<hr />
|
|
<div><h1>POST</h1><?php var_dump($_POST);?></div>
|
|
<div><h1>News</h1><?php var_dump($newsArticle);?></div>
|
|
<div><?php print_r(parse_url( !empty($_POST['nachrichtenPromoImgUrl'])?$_POST['nachrichtenPromoImgUrl']:$defaultPromoImg['url']));?></div>
|
|
<div><?php print_r(getimagesize( $basePath.urldecode( parse_url( !empty($_POST['nachrichtenPromoImgUrl'])?$_POST['nachrichtenPromoImgUrl']:$defaultPromoImg['url'] )['path'] ) ) );?></div>
|
|
-->
|
|
</body>
|
|
</html>
|