diff options
author | Simon Rettberg | 2013-10-18 13:20:31 +0200 |
---|---|---|
committer | Simon Rettberg | 2013-10-18 13:20:31 +0200 |
commit | 044631ed2ac590a5e67ba4ac07267e790f814863 (patch) | |
tree | b92e817a5975c1db86b985303eac7ab37bb80750 | |
parent | Day 3 (diff) | |
download | slx-admin-044631ed2ac590a5e67ba4ac07267e790f814863.tar.gz slx-admin-044631ed2ac590a5e67ba4ac07267e790f814863.tar.xz slx-admin-044631ed2ac590a5e67ba4ac07267e790f814863.zip |
Show different content on main page depending on logged in/guest status
-rw-r--r-- | inc/message.inc.php | 25 | ||||
-rw-r--r-- | modules/main.inc.php | 9 | ||||
-rw-r--r-- | templates/main-menu.html | 2 | ||||
-rw-r--r-- | templates/messagebox-info.html | 1 | ||||
-rw-r--r-- | templates/messagebox-success.html | 1 | ||||
-rw-r--r-- | templates/messagebox-warning.html | 1 | ||||
-rw-r--r-- | templates/page-main-guest.html | 5 | ||||
-rw-r--r-- | templates/page-main.html | 1 |
8 files changed, 42 insertions, 3 deletions
diff --git a/inc/message.inc.php b/inc/message.inc.php index 9409db95..238ed939 100644 --- a/inc/message.inc.php +++ b/inc/message.inc.php @@ -18,8 +18,33 @@ class Message ); } + public static function addWarning($id) + { + self::$list[] = array( + 'type' => 'warning', + 'id' => $id + ); + } + + public static function addInfo($id) + { + self::$list[] = array( + 'type' => 'info', + 'id' => $id + ); + } + + public static function addSuccess($id) + { + self::$list[] = array( + 'type' => 'success', + 'id' => $id + ); + } + public static function renderList() { + global $error_text; foreach (self::$list as $item) { Render::addTemplate('messagebox-' . $item['type'], array('message' => $error_text[$item['id']])); } diff --git a/modules/main.inc.php b/modules/main.inc.php index fc6a9fac..007fb296 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -4,11 +4,16 @@ User::load(); function render_module() { - Render::setTitle('Wurstgesicht'); + // Render::setTitle('abc'); Render::openTag('h1', array('class' => 'wurst kacke')); Render::closeTag('h1'); - Render::addTemplate('helloworld', array('wurst' => 'käse & bier')); + if (!User::isLoggedIn()) { + Render::addTemplate('page-main-guest'); + return; + } + // Logged in here + Render::addTemplate('page-main', array('user' => User::getName())); } diff --git a/templates/main-menu.html b/templates/main-menu.html index 7e9c3bdc..0b2cdd7f 100644 --- a/templates/main-menu.html +++ b/templates/main-menu.html @@ -11,7 +11,7 @@ </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> - <li class="active"><a href="#">Home</a></li> + <li class="active"><a href="?do=main">Startseite</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> <li class="dropdown"> diff --git a/templates/messagebox-info.html b/templates/messagebox-info.html new file mode 100644 index 00000000..b4464094 --- /dev/null +++ b/templates/messagebox-info.html @@ -0,0 +1 @@ +<div class="alert alert-info">{{message}}</div> diff --git a/templates/messagebox-success.html b/templates/messagebox-success.html new file mode 100644 index 00000000..180a0466 --- /dev/null +++ b/templates/messagebox-success.html @@ -0,0 +1 @@ +<div class="alert alert-success">{{message}}</div> diff --git a/templates/messagebox-warning.html b/templates/messagebox-warning.html new file mode 100644 index 00000000..1ce2c0e4 --- /dev/null +++ b/templates/messagebox-warning.html @@ -0,0 +1 @@ +<div class="alert alert-warning">{{message}}</div> diff --git a/templates/page-main-guest.html b/templates/page-main-guest.html new file mode 100644 index 00000000..f580e9f5 --- /dev/null +++ b/templates/page-main-guest.html @@ -0,0 +1,5 @@ +<div class="jumbotron"> + <h1>Willkommen</h1> + <p>Dies ist das Administrations-Interface der lokalen bwLehrpool-Installation. Bitte authentifizieren Sie sich, um Einstellungen vorzunehmen.</p> + <p><a href="?do=session&action=login" class="btn btn-primary btn-lg">Anmelden »</a></p> +</div> diff --git a/templates/page-main.html b/templates/page-main.html new file mode 100644 index 00000000..3cb64449 --- /dev/null +++ b/templates/page-main.html @@ -0,0 +1 @@ +<h1>Willkommen, {{user}}</h1> |