increase reusability of AppCards
This commit is contained in:
@@ -7,6 +7,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
|
||||
require_once("./lib/db.php");
|
||||
require_once("./lib/api.php");
|
||||
require_once("./lib/participoLib/participo.php");
|
||||
|
||||
require_once("./auth.php");
|
||||
|
||||
@@ -27,12 +28,14 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<!-- MaterializeCss Ressources -->
|
||||
<!-- - Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<!-- - Compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
|
||||
<!--Import Google Icon Font-->
|
||||
<!-- - Import Google Icon Font-->
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
|
||||
<!-- participo specific style adjustments -->
|
||||
<link rel="stylesheet" href="css/participo.css">
|
||||
|
||||
@@ -67,14 +70,14 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
</li>
|
||||
<li><?php require_once("sidenav/loginStatus.php");?></li>
|
||||
<li class="bold">
|
||||
<a class="waves-effect waves-teal" href="#AppList">Apps</a>
|
||||
<a class="waves-effect waves-teal right-align" href="#AppList">Apps</a>
|
||||
</li>
|
||||
<li class="bold">
|
||||
<a class="waves-effect waves-teal" href="#Configs">UserInfos</a>
|
||||
<a class="waves-effect waves-teal right-align" href="#Configs">UserInfos</a>
|
||||
</li>
|
||||
<?php if( isUserAdmin($dbConnection, $userData['id']) ){?>
|
||||
<li class="bold">
|
||||
<a class="waves-effect waves-teal" href="#Admin">adminStuff</a>
|
||||
<a class="waves-effect waves-teal right-align" href="#Admin">adminStuff</a>
|
||||
</li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
@@ -86,99 +89,67 @@ if($_SESSION['login']){
|
||||
<main>
|
||||
<!-- List of Mitmach-Apps -->
|
||||
<div class="row" id="AppList">
|
||||
<div style="padding:1%;" class="col s12 m6">
|
||||
<div style="margin:1%;" class="card blue-grey darken-1">
|
||||
<a href="kyu"><div class="card-content white-text">
|
||||
<span class="card-title">Kyu</span>
|
||||
<img style="max-height:10vh;" class="responsive-img" src="images/obi.svg" />
|
||||
<p>Die Prüfungsprogamme der einzelnen Gürtelstufen in Bild Ton und Text.</p>
|
||||
</div><a>
|
||||
<div class="card-action">
|
||||
<a href="kyu">Kuy-Programme</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding:1%;" class="col s12 m6">
|
||||
<div class="card blue-grey darken-1">
|
||||
<a href="/machs"><div class="card-content white-text">
|
||||
<span class="card-title">Mein Achievement System</span>
|
||||
<img style="max-height:10vh;" class="responsive-img" src="images/mountain-climber.svg" />
|
||||
<p>Ein kleines Achievementsystem für die tägliche Herausforderung</p>
|
||||
</div><a>
|
||||
<div class="card-action">
|
||||
<a href="/machs">mAchS</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding:1%;" class="col s12 m6">
|
||||
<div class="card blue-grey darken-1">
|
||||
<a href="/pages/desktop/wkParticipo"><div class="card-content white-text">
|
||||
<span class="card-title">Event-Planer</span>
|
||||
<img style="max-height:10vh;" class="responsive-img" src="/ressourcen/graphiken/icons/terminKalender.svg" />
|
||||
<p>Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.</p>
|
||||
</div><a>
|
||||
<div class="card-action">
|
||||
<a href="/pages/desktop/wkParticipo">Planer</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
echo(
|
||||
AppCard::fromArray([
|
||||
'link' => "kyu",
|
||||
'title' => "Kyu",
|
||||
'description'=> "Die Prüfungsprogamme der einzelnen Gürtelstufen in Bild, Ton und Text",
|
||||
'imgUrl' => "images/obi.svg",
|
||||
'actions' => [
|
||||
AppCardAction::fromArray(['caption'=>"Kyu-Programme", 'link'=>"kyu"]),
|
||||
],
|
||||
])->htmlCode().
|
||||
AppCard::fromArray([
|
||||
'link' => "/machs",
|
||||
'title' => "<strong>M</strong>ein <strong>Ach</strong>ievement <strong>S</strong>ystem",
|
||||
'description'=> "Ein kleines Achievementsystem für die tägliche Herausforderung",
|
||||
'imgUrl' => "images/mountain-climber.svg",
|
||||
'actions' => [
|
||||
AppCardAction::fromArray(['caption'=>"MAchS", 'link'=>"/machs"]),
|
||||
],
|
||||
])->htmlCode().
|
||||
AppCard::fromArray([
|
||||
'link' => "/pages/desktop/wkParticipo",
|
||||
'title' => "Event-Planer",
|
||||
'description'=> "Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.",
|
||||
'imgUrl' => "/ressourcen/graphiken/icons/terminKalender.svg",
|
||||
'actions' => [
|
||||
AppCardAction::fromArray(['caption'=>"Planer", 'link'=>"/pages/desktop/wkParticipo"]),
|
||||
],
|
||||
])->htmlCode()
|
||||
);
|
||||
?>
|
||||
</div><!-- End of MitmachApps -->
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<!-- List of ConfigStuff -->
|
||||
<div class="row" id="Configs">
|
||||
<div style="padding:1%;" class="col s12 m6">
|
||||
<div style="margin:1%;" class="card blue-grey darken-1">
|
||||
<a href="./user"><div class="card-content white-text">
|
||||
<span class="card-title">User-Infos</span>
|
||||
<img style="max-height:10vh;" class="responsive-img" src="images/account.svg" />
|
||||
<p>Einstellungen zum Benutzer</p>
|
||||
</div><a>
|
||||
<div class="card-action">
|
||||
<a href="./user">Einstellungen</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if( isUserAdmin($dbConnection, $userData['id']) ){?>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="row" id="Admin">
|
||||
<div style="padding:1%;" class="col s12 m6">
|
||||
<div style="margin:1%;" class="card blue-grey darken-1">
|
||||
<div class="card-content white-text">
|
||||
<span class="card-title">lastLogins</span>
|
||||
<img style="max-height:10vh;" class="responsive-img" src="images/account.svg" />
|
||||
<p>Die letzten Logins der einzelnen User</p>
|
||||
<?php $lastLogins=json_decode( file_get_contents("lastLogins.json"), true);?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>userName</th>
|
||||
<th>lastLogins</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach( $lastLogins as $userName => $lastLogins ){ ?>
|
||||
<tr>
|
||||
<td><?php echo( $userName );?></td>
|
||||
<td><?php echo( $lastLogins['lastLogins'][0] );?></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
|
||||
<?php
|
||||
echo(
|
||||
AppCard::fromArray([
|
||||
'link' => "user",
|
||||
'title' => "User-Config",
|
||||
'description' => "Einstellungen zum aktuellen Benutzer dessen Kindern",
|
||||
'imgUrl' => "images/account.svg",
|
||||
'actions' => [
|
||||
AppCardAction::fromArray(['caption'=>"Config", 'link'=>"user"]),
|
||||
],
|
||||
])->htmlCode()
|
||||
);
|
||||
// AdminStuff, thats only visible for Admins
|
||||
if( isUserAdmin($dbConnection, $userData['id']) ){
|
||||
echo(
|
||||
AppCard::fromArray([
|
||||
'title' =>"lastLogins",
|
||||
'description' => lastLoginTable()
|
||||
])->htmlCode()
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div><!-- End of ConfigStuff -->
|
||||
</main>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -1,4 +1,128 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Action element of an MaterializeCss (App-)card
|
||||
*/
|
||||
class AppCardAction{
|
||||
private $caption = null; //< Caption for the action
|
||||
private $link = "."; //< link for the action
|
||||
/**
|
||||
* Constructor for the AppAction
|
||||
*
|
||||
* @param string $caption caption for the action
|
||||
* @param string $link link to the action
|
||||
*/
|
||||
function __construct( $caption, $link = "." ){
|
||||
//! @todo input sanitation
|
||||
$this->link = $link;
|
||||
$this->caption = $caption;
|
||||
}
|
||||
/**
|
||||
* Create htmlCode for the action
|
||||
*
|
||||
* @return string with htmlCode of the action
|
||||
*/
|
||||
function htmlCode(){
|
||||
return "<a href=\"".$this->link."\">".$this->caption."</a>";
|
||||
}
|
||||
/**
|
||||
* Create AppCardAction from assoziative array
|
||||
*
|
||||
* @param array $member array with the member values
|
||||
* @return AppCardAction
|
||||
*/
|
||||
static public function fromArray($member){
|
||||
$caption = $member['caption'] ?? null;
|
||||
$link = $member['link'] ?? ".";
|
||||
return new AppCardAction($caption, $link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MaterializeCss card for an App
|
||||
*/
|
||||
class AppCard{
|
||||
private $title = ""; //< title of the card
|
||||
private $description = ""; //< description of the App
|
||||
private $link = null; //< link for the card-content
|
||||
private $imgUrl = null; //< url for an image right under the title
|
||||
private $actionList = []; //< list of actions for the bottom of the card
|
||||
/**
|
||||
* Constructor for the AppCard
|
||||
*
|
||||
* @param string $title title of the card
|
||||
* @param string $description description of the card
|
||||
* @param string $link link for the card-content
|
||||
* @param string $imgUrl url for an image right under the title
|
||||
* @param array $actionList list of actions at the bottom of the card
|
||||
*/
|
||||
function __construct($title, $description, $link=null, $imgUrl=null, $actionList=[]){
|
||||
//! @todo input sanitation
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->link = $link;
|
||||
$this->imgUrl = $imgUrl;
|
||||
$this->actionList = $actionList;
|
||||
}
|
||||
/**
|
||||
* Create htmlCode for the AppCard
|
||||
*
|
||||
* @return string html code for the AppCard
|
||||
*/
|
||||
public function htmlCode(){
|
||||
$actionListCode = "";
|
||||
foreach($this->actionList as $a){
|
||||
$actionListCode .= $a->htmlCode();
|
||||
}
|
||||
return
|
||||
"<div style=\"padding:1%;\" class=\"col s12 m6\">".
|
||||
"<div style=\"margin:1%;\" class=\"card blue-grey darken-1\">".
|
||||
(($this->link!=null)?("<a href=\"".$this->appLink."\">"):(""))."<div class=\"card-content white-text\">".
|
||||
"<span class=\"card-title\">".$this->title."</span>".
|
||||
(($this->imgUrl!=null)?("<img style=\"display:block;margin-left:auto;margin-right:auto;max-height:10vh;\" class=\"responsive-img\" src=\"".$this->imgUrl."\" />"):("")).
|
||||
"<p>".$this->description."</p>".
|
||||
"</div>".(($this->link!=null)?("<a>"):("")).
|
||||
"<div class=\"card-action\">".$actionListCode."</div>".
|
||||
"</div>".
|
||||
"</div>";
|
||||
}
|
||||
/**
|
||||
* Create AppCard from an associative array
|
||||
*
|
||||
* @param array $member array with member as keys and values as the member values
|
||||
* @return AppCard from array values
|
||||
*/
|
||||
static public function fromArray($member){
|
||||
$title = $member['title'] ?? "";
|
||||
$description = $member['description'] ?? "";
|
||||
$link = $member['link'] ?? null;
|
||||
$imgUrl = $member['imgUrl'] ?? null;
|
||||
$actionList = $member['actions'] ?? [];
|
||||
|
||||
return new AppCard($title, $description, $link, $imgUrl, $actionList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a html table of the last logins of the users
|
||||
*
|
||||
* @param string $jsonFileName path to the json file with the logged logins
|
||||
* @return string Html table of users last logins
|
||||
*/
|
||||
function lastLoginTable($jsonFileName="lastLogins.json"){
|
||||
$lastLogins=json_decode( file_get_contents($jsonFileName), true);
|
||||
$lastLoginsTable =
|
||||
"<table>".
|
||||
"<thead><tr><th>userName</th><th>lastLogins</th></tr></thead>".
|
||||
"<tbody>";
|
||||
foreach( $lastLogins as $userName => $lastLogins ){
|
||||
$lastLoginsTable .=
|
||||
"<tr><td>".$userName."</td><td>".$lastLogins['lastLogins'][0]."</td></tr>";
|
||||
}
|
||||
$lastLoginsTable .= "</tbody></table>";
|
||||
return $lastLoginsTable;
|
||||
}
|
||||
|
||||
/// Eine Fehler/Warnung/Notiz/Erfolgsmeldung als divBox im String zurückgeben
|
||||
function htmlRetMessage($anRetMessage){
|
||||
$retHtmlString = "";
|
||||
|
||||
Reference in New Issue
Block a user