WIP: newssection index
This commit is contained in:
@@ -1,48 +1,72 @@
|
||||
<?php
|
||||
/// Ausgabe einer newsTabelle
|
||||
|
||||
function echoNewsTableHtml($someOptions){
|
||||
global $cwsvJudoConfig;
|
||||
global $basePath;
|
||||
function echoNewsTableHtml($someOptions)
|
||||
{
|
||||
global $cwsvJudoConfig;
|
||||
global $basePath;
|
||||
|
||||
// Sammlung von Fehlermeldungen o.ä.
|
||||
$message = array();
|
||||
// Sammlung von Fehlermeldungen o.ä.
|
||||
$message = [];
|
||||
|
||||
$limit = is_positive_integer($someOptions['limit'])?$someOptions['limit']:1;
|
||||
$limit = is_positive_integer($someOptions["limit"])
|
||||
? $someOptions["limit"]
|
||||
: 1;
|
||||
|
||||
$headerRootLevel = is_positive_integer($someOptions['headerRootLevel'])?$someOptions['headerRootLevel']:1;
|
||||
$headerRootLevel = is_positive_integer($someOptions["headerRootLevel"])
|
||||
? $someOptions["headerRootLevel"]
|
||||
: 1;
|
||||
|
||||
/// Eine Datenbankverbindung (über pdo) erstellen
|
||||
try{
|
||||
$db_connection = new PDO(
|
||||
"mysql:host=".$cwsvJudoConfig["db"]["host"].";"."dbname=".$cwsvJudoConfig["db"]["name"],
|
||||
$cwsvJudoConfig["db"]["user"],
|
||||
$cwsvJudoConfig["db"]["password"]
|
||||
);
|
||||
}
|
||||
catch(PDOException $db_error){
|
||||
$messages['errors'][] = "Error: " . $db_error->getMessage();
|
||||
}
|
||||
/// Eine Datenbankverbindung (über pdo) erstellen
|
||||
try {
|
||||
$db_connection = new PDO(
|
||||
"mysql:host=" .
|
||||
$cwsvJudoConfig["db"]["host"] .
|
||||
";" .
|
||||
"dbname=" .
|
||||
$cwsvJudoConfig["db"]["name"],
|
||||
$cwsvJudoConfig["db"]["user"],
|
||||
$cwsvJudoConfig["db"]["password"]
|
||||
);
|
||||
} catch (PDOException $db_error) {
|
||||
$messages["errors"][] = "Error: " . $db_error->getMessage();
|
||||
}
|
||||
|
||||
// News abfragen
|
||||
// @todo: woher das limit nehmen?
|
||||
// $newsList = getNews($db_connection, array('limit'=>$limit));
|
||||
$newsList = getNews($db_connection, $someOptions);
|
||||
// News abfragen
|
||||
// @todo: woher das limit nehmen?
|
||||
// $newsList = getNews($db_connection, array('limit'=>$limit));
|
||||
$newsList = getNews(aMysqlConn: $db_connection, optionsArray: $someOptions);
|
||||
|
||||
$newsHeading = "Aktuelle Meldungen";
|
||||
$newsHeading = "Aktuelle Meldungen";
|
||||
|
||||
if($someOptions['newsId']??false) $newsHeading=$newsList[0]['betreff'];
|
||||
if($someOptions['jahr']??false) $newsHeading="Nachrichten des Jahres ".$someOptions['jahr'];
|
||||
if ($someOptions["newsId"] ?? false) {
|
||||
$newsHeading = $newsList[0]["betreff"];
|
||||
}
|
||||
if ($someOptions["jahr"] ?? false) {
|
||||
$newsHeading = "Nachrichten des Jahres " . $someOptions["jahr"];
|
||||
}
|
||||
|
||||
echo("<h".strval($headerRootLevel).">".$newsHeading."</h".$headerRootLevel.">");
|
||||
if( is_array( $newsList ) || is_object( $newsList ) )
|
||||
foreach($newsList as $news)
|
||||
echo( getHtmlNews($news, "headingLevel=".strval($headerRootLevel+1))."<hr />" );
|
||||
else
|
||||
$messages['errors'][] = "Fehler: Keine Neuigkeiten gefunden!";
|
||||
echo "<h" .
|
||||
strval($headerRootLevel) .
|
||||
">" .
|
||||
$newsHeading .
|
||||
"</h" .
|
||||
$headerRootLevel .
|
||||
">";
|
||||
if (is_array($newsList) || is_object($newsList)) {
|
||||
foreach ($newsList as $news) {
|
||||
echo getHtmlNews(
|
||||
$news,
|
||||
"headingLevel=" . strval($headerRootLevel + 1)
|
||||
) . "<hr />";
|
||||
};
|
||||
} else {
|
||||
$messages["errors"][] = "Fehler: Keine Neuigkeiten gefunden!";
|
||||
}
|
||||
|
||||
// @todo: besser machen!
|
||||
if(!empty($messages))
|
||||
var_dump($messages);
|
||||
return;
|
||||
// @todo: besser machen!
|
||||
if (!empty($messages)) {
|
||||
var_dump($messages);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?
|
||||
<?php
|
||||
/**
|
||||
* home directory on the server
|
||||
* - meaning the users home directory (aka ~) in the environment, not the directory served via http
|
||||
*/
|
||||
$home = "/home/cwsvjudo.helioho.st";
|
||||
$home = "/home/cwsvjudo.helioho.st";
|
||||
|
||||
@@ -45,7 +45,7 @@ $wallpapers = [
|
||||
];
|
||||
|
||||
// helper functions
|
||||
// -html output
|
||||
// - html output
|
||||
|
||||
/**
|
||||
* Inject the html code for the nav targets
|
||||
@@ -153,18 +153,22 @@ function main($sections, $wallpapers)
|
||||
<!-- - materialize framework -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const elems = document.querySelectorAll('.parallax');
|
||||
const instances = M.Parallax.init(elems, {
|
||||
// specify options here
|
||||
});
|
||||
|
||||
// const elems = document.querySelectorAll('.carousel');
|
||||
// const instances = M.Carousel.init(elems, {
|
||||
// // fullWidth: true,
|
||||
// // indicators: true,
|
||||
// // noWrap: true,
|
||||
// // numVisible: 6,
|
||||
// });
|
||||
const instances = {
|
||||
parallax : M.Parallax.init(
|
||||
document.querySelectorAll('.parallax'), {
|
||||
// specify options here
|
||||
}
|
||||
),
|
||||
carousels: M.Carousel.init(
|
||||
document.querySelectorAll('.carousel'), {
|
||||
dist: -50,
|
||||
fullWidth: true,
|
||||
indicators: true,
|
||||
noWrap: true,
|
||||
numVisible: 1,
|
||||
}
|
||||
),
|
||||
} // end instances
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -91,9 +91,20 @@ class PromoImage
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function as_html()
|
||||
{
|
||||
return '<img src="' .
|
||||
$this->src .
|
||||
'" width="' .
|
||||
$this->width .
|
||||
'" heigth="' .
|
||||
$this->height .
|
||||
'" >';
|
||||
}
|
||||
|
||||
private string $src;
|
||||
private int $width;
|
||||
private int $height;
|
||||
private ?int $width;
|
||||
private ?int $height;
|
||||
|
||||
public array $data;
|
||||
}
|
||||
@@ -110,13 +121,20 @@ class Entry
|
||||
$this->title = $data["betreff"];
|
||||
$this->content = $data["nachricht"];
|
||||
$this->author = $data["autor"];
|
||||
// $this->promo = new PromoImage(
|
||||
// json_encode($data["promoImg"]));
|
||||
$this->promo = new PromoImage(
|
||||
json_decode($data["promoImg"], associative: true)
|
||||
);
|
||||
}
|
||||
|
||||
function as_card(): string
|
||||
{
|
||||
return '<div class="col s12 m6 l3"><div class="card">' .
|
||||
return '<div class="card horizontal">' .
|
||||
'<div class="card-image">' .
|
||||
'<span class="card-title">' .
|
||||
$this->title .
|
||||
"</span>" .
|
||||
$this->promo->as_html() .
|
||||
"</div>" .
|
||||
'<div class="card-content">' .
|
||||
'<span class="card-title">' .
|
||||
$this->title .
|
||||
@@ -125,7 +143,7 @@ class Entry
|
||||
$this->content .
|
||||
"</p>" .
|
||||
"</div>" .
|
||||
"</div></div>";
|
||||
"</div>";
|
||||
}
|
||||
// private
|
||||
// - member variables
|
||||
@@ -207,15 +225,15 @@ function getNews(
|
||||
|
||||
function newsBoard(\CwsvJudo\Db\Connector $dbHandle, array $options): string
|
||||
{
|
||||
$boardHtml = '<div class="container"><div class="row">';
|
||||
$boardHtml = '<div class=""><h2>Neuigkeiten</h2>';
|
||||
$entries = getNews(dbHandle: $dbHandle, options: $options);
|
||||
if (!is_null($entries)) {
|
||||
foreach ($entries as $entryData) {
|
||||
$entry = new \CwsvJudo\News\Entry($entryData);
|
||||
$boardHtml .= $entry->as_card();
|
||||
$boardHtml .= '<div class="">' . $entry->as_card() . "</div>";
|
||||
}
|
||||
}
|
||||
$boardHtml .= "</div></div>";
|
||||
$boardHtml .= "</div> ";
|
||||
|
||||
return $boardHtml;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
namespace cwsvJudo\news;
|
||||
|
||||
Reference in New Issue
Block a user