add additional pages and handle introduction page as ?system? page

This commit is contained in:
oliver 2015-10-30 22:45:05 +01:00
parent 02e7665fb7
commit 8c5c7e0b13
15 changed files with 812 additions and 44 deletions

View file

@ -0,0 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
/**
* Agent to manage additional pages.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PagesAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -313,6 +313,8 @@
array('^library/([^/]+)/([^/]+)/(edit|delete|manage)/?$', 'library/$3/$1/$2', true),
array('^map/([^/]+)/?$', 'map/index/$1', true),
array('^map/([^/]+)/(edit)/?$', 'map/$2/$1', true),
array('^pages/([^/]+)/(edit|delete)$', 'pages/$2/$1', true),
array('^pages/(?!(create|edit|delete))/?', 'pages/page/$1', true),
array('^media/(.*)$', 'media/$1?layout=binary', false),
array('^uploads/(.*)$', 'uploads/$1?layout=binary', false)
);
@ -364,7 +366,9 @@
array('^library/topic/([^/]+)/([^/]+)/?$', 'library/$1/$2', true),
array('^library/(edit|delete|manage)/([^/]+)/([^/]+)/?$', 'library/$2/$3/$1', true),
array('^map/index/(.*)$', 'map/$1', true),
array('^map/(edit)/(.*)$', 'map/$2/$1', true)
array('^map/(edit)/(.*)$', 'map/$2/$1', true),
array('^pages/page/(.*+)$', 'pages/$1', true),
array('^pages/(edit|delete)/([^/]+)$', 'pages/$2/$1', true)
);

View file

@ -19,6 +19,12 @@
*/
class IntroductionController extends \hhu\z\controllers\IntermediateController
{
/**
* Required models
*
* @var array
*/
public $models = array('pages');
@ -28,8 +34,60 @@
*/
public function index()
{
// Get introduction text
$page = $this->Pages->getPageByUrl(\hhu\z\models\PagesModel::PAGEURL_INTRODUCTION);
$text = (!is_null($page)) ? $page['text'] : null;
// Pass data to view
$this->set('userId', $this->Auth->getUserId());
$this->set('text', $text);
}
/**
* Action: edit.
*/
public function edit()
{
// Get page
$page = $this->Pages->getPageByUrl(\hhu\z\models\PagesModel::PAGEURL_INTRODUCTION);
// Values
$text = (!is_null($page)) ? $page['text'] : null;
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
if(!is_null($this->request->getPostParam('edit')))
{
// Get values
$text = $this->request->getPostParam('text');
// Create page if necessary
if(is_null($page)) {
$pageId = $this->Pages->createPage(
$this->Auth->getUserId(),
\hhu\z\models\PagesModel::PAGEURL_INTRODUCTION
);
$page = $this->Pages->getPageById($pageId);
}
// Save text
$this->Pages->editPage(
$page['id'],
$page['title'],
$text
);
}
// Redirect
$this->redirect($this->linker->link(array('index'), 1));
}
// Pass data to view
$this->set('text', $text);
}
}

View file

@ -19,6 +19,12 @@
*/
class MenuController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('pages');
@ -45,6 +51,12 @@
*/
public function index()
{
// Get additional pages
$pages = $this->Pages->getPages();
// Pass data to view
$this->set('pages', $pages);
}
}

View file

@ -0,0 +1,237 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
/**
* Controller of the PagesAgent to manage additional pages.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PagesController extends \hhu\z\controllers\IntermediateController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('pages');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin')
/*
'create' => array('admin', 'moderator'),
'edit' => array('admin', 'moderator'),
'delete' => array('admin')
*/
);
/**
* Action: index.
*
* List all registered pages.
*/
public function index()
{
// Get registered pages
$pages = $this->Pages->getPages();
// Pass data to view
$this->set('pages', $pages);
}
/**
* Action: page.
*
* Show a page.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $pageUrl URL of page to show
*/
public function page($pageUrl)
{
// Get page
$page = $this->Pages->getPageByUrl($pageUrl);
// Pass data to view
$this->set('page', $page);
}
/**
* Action: create.
*
* Create a new page.
*/
public function create()
{
// Values
$title = '';
$fields = array('title');
$validation = array();
// Create new page
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$title = $this->request->getPostParam('title');
if($this->Pages->titleExists($title)) {
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
}
// Create
if($validation === true)
{
$pageId = $this->Pages->createPage(
$this->Auth->getUserId(),
$title
);
// Redirect to page
$page = $this->Pages->getPageById($pageId);
$this->redirect($this->linker->link(array('page', $page['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Pass data to view
$this->set('title', $title);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: edit.
*
* Edit page.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $pageUrl URL of page to edit
*/
public function edit($pageUrl)
{
// Get page
$page = $this->Pages->getPageByUrl($pageUrl);
// Values
$title = $page['title'];
$text = $page['text'];
$fields = array('title');
$validation = array();
// Edit content
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('save')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$title = $this->request->getPostParam('title');
if($this->Pages->titleExists($title, $page['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
}
$text = $this->request->getPostParam('text');
var_dump($text);
// Edit
if($validation === true)
{
$this->Pages->editPage(
$page['id'],
$title,
$text
);
// Redirect to entry
$this->redirect($this->linker->link(array('page', $page['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Pass data to view
$this->set('page', $page);
$this->set('title', $title);
$this->set('text', $text);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: delete.
*
* Delete a page.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $pageUrl URL of page to delete
*/
public function delete($pageUrl)
{
// Get page
$page = $this->Pages->getPageByUrl($pageUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete page
$this->Pages->deletePage($page);
// Redirect to overview
$this->redirect($this->linker->link(null, 1));
}
// Redirect to entry
$this->redirect($this->linker->link(array('page', $page['url']), 1));
}
// Set titile
$this->addTitleLocalized('Delete page');
// Show confirmation
$this->set('page', $page);
}
}
?>

View file

@ -1,8 +1,8 @@
-- MySQL dump 10.15 Distrib 10.0.21-MariaDB, for Linux (x86_64)
-- MySQL dump 10.15 Distrib 10.0.22-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: z
-- ------------------------------------------------------
-- Server version 10.0.21-MariaDB-log
-- Server version 10.0.22-MariaDB-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@ -805,6 +805,29 @@ CREATE TABLE `media` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pages`
--
DROP TABLE IF EXISTS `pages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_user_id` int(11) NOT NULL,
`pos` int(11) NOT NULL,
`title` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`url` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`text` text COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`),
UNIQUE KEY `pos` (`pos`),
KEY `created_user_id` (`created_user_id`),
CONSTRAINT `pages_ibfk_1` FOREIGN KEY (`created_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `questgroups`
--
@ -2294,4 +2317,4 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-08-21 9:38:24
-- Dump completed on 2015-10-30 22:27:53

232
models/PagesModel.inc Normal file
View file

@ -0,0 +1,232 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Model to interact with Pages-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PagesModel extends \hhu\z\Model
{
/**
* URL for system page: Introduction
*/
const PAGEURL_INTRODUCTION = 'introduction';
/**
* Construct a new PagesModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get all registered pages (without system pages).
*
* @return array List of registered pages
*/
public function getPages() {
// Get pages
$data = $this->db->query(
'SELECT id, pos, url, title, text '.
'FROM pages '.
'ORDER BY pos'
);
// Remove system pages
$pages = array();
foreach($data as $page) {
if($page['url'] != self::PAGEURL_INTRODUCTION) {
$pages[] = $page;
}
}
// Return pages
return $pages;
}
/**
* Get a page by its ID.
*
* @param string $pageid ID of page to get
* @return array Page data
*/
public function getPageById($pageId)
{
$data = $this->db->query(
'SELECT id, url, title, pos, text '.
'FROM pages '.
'WHERE id = ?',
'i',
$pageId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Get a page by its URL.
*
* @param string $pageUrl URL of page to get
* @return array Page data
*/
public function getPageByUrl($pageUrl)
{
$data = $this->db->query(
'SELECT id, url, title, pos, text '.
'FROM pages '.
'WHERE url = ?',
's',
$pageUrl
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Check if a page title already exists.
*
* @param string $title Page title to check
* @param int $pageId Do not check this ID (for editing)
* @return boolean Whether title exists or not
*/
public function titleExists($title, $pageId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM pages '.
'WHERE title = ? OR url = ?',
'ss',
$title,
self::createLinkParam($title)
);
return (!empty($data) && (is_null($pageId) || $pageId != $data[0]['id']));
}
/**
* Create a new page.
*
* @param int $userId ID of creating user
* @param string $title Title of page to create
* @return int ID of the newly created page
*/
public function createPage($userId, $title)
{
// Create content
$this->db->query(
'INSERT INTO pages '.
'(created_user_id, pos, title, url) '.
'SELECT ?, IFNULL(MAX(pos),0)+1, ?, ? '.
'FROM pages',
'iss',
$userId,
$title,
self::createLinkParam($title)
);
return $this->db->getInsertId();
}
/**
* Edit data of a page.
*
* @param int $pageId ID of page to edit
* @param string $title New page title
* @param string $text New page text
*/
public function editPage($pageId, $title, $text)
{
$this->db->query(
'UPDATE pages '.
'SET title = ?, url = ?, text = ? '.
'WHERE id = ?',
'sssi',
$title,
self::createLinkParam($title),
$text,
$pageId
);
}
/**
* Delete page.
*
* @param array $page Page to delete
*/
public function deletePage($page)
{
$this->db->setAutocommit(false);
try {
// Delete page
$this->db->query('DELETE FROM pages WHERE id = ?', 'i', $page['id']);
// Correct position
$this->db->query(
'UPDATE pages '.
'SET pos = pos-1 '.
'WHERE pos > ?',
'i',
$page['pos']
);
}
catch(\nre\exceptions\DatamodelException $e) {
$this->db->rollback();
$this->db->setAutocommit(true);
throw $e;
}
$this->db->setAutocommit(true);
}
/*
* Mask parameters to be used in an URL.
*
* @param string $param1 First parameter
* @return string Masked parameters as string
*/
private static function createLinkParam($param)
{
return \nre\core\Linker::createLinkParam(mb_strtolower($param));
}
}
?>

View file

@ -0,0 +1,18 @@
<div class="moodpic">
<img src="<?=$linker->link(array('grafics','questlab.jpg'))?>" />
</div>
<h1><?=\nre\configs\AppConfig::$app['name']?></h1>
<form method="post">
<fieldset>
<legend><?=_('Introduction text')?></legend>
<textarea id="text" name="text" placeholder="<?=_('Please enter an introduction text')?>"><?=$text?></textarea>
</fieldset>
<input type="submit" name="edit" value="<?=_('save')?>" />
<input type="submit" name="cancel" value="<?=_('cancel')?>" />
</form>
<script>
$(function() {
$("#text").markItUp(mySettings);
});
</script>

View file

@ -4,47 +4,33 @@
<?php if(is_null($userId)) : ?>
<form method="post" action="<?=$linker->link(array('users','login'))?>" class="logreg front">
<fieldset>
<p><label for="username"><?=_('Username')?>:</label><input name="username" type="text" placeholder="<?=_('Username')?>" title="<?=_('Username')?>" required="required" autofocus="autofocus" /></p>
<p><label for="password"><?=_('Password')?>:</label><input name="password" type="password" placeholder="<?=_('Password')?>" title="<?=_('Password')?>" required="required" /></p>
<p>
<label for="username"><?=_('Username')?>:</label>
<input id="username" name="username" type="text" placeholder="<?=_('Username')?>" title="<?=_('Username')?>" required="required" autofocus="autofocus" />
</p>
<p>
<label for="password"><?=_('Password')?>:</label>
<input id="password" name="password" type="password" placeholder="<?=_('Password')?>" title="<?=_('Password')?>" required="required" />
</p>
<input type="submit" name="login" class="cta" value="<?=_('Login')?>" />
</fieldset>
<p class="register"><?=_('or')?> <a href="<?=$linker->link(array('users','register'))?>"><?=_('register yourself')?></a></p>
</form>
<?php endif ?>
<?php if(!is_null(\hhu\z\controllers\IntermediateController::$user) && in_array('admin',\hhu\z\controllers\IntermediateController::$user['roles'])) : ?>
<nav class="admin">
<li><a href="<?=$linker->link('edit', 1)?>"><?=_('edit')?></a></li>
</nav>
<?php endif ?>
<h1><?=\nre\configs\AppConfig::$app['name']?></h1>
<h2><?=_('Introduction')?></h2>
<p itemscope itemtype="http://schema.org/CollegeOrUniversity">Bereits im Sommersemester 2013 wurde das Projekt „Die Legende von Zyren“ unterstützt durch den Lehrförderungsfond der <a itemprop="name" href="http://www.uni-duesseldorf.de">Heinrich-Heine-Universität Düsseldorf</a> ins Leben gerufen, um die Inhalte der Vorlesung „Wissensrepräsentation“ den Studierenden des Faches Informationswissenschaft mit Hilfe von Spielelementen und -modellen zu vermitteln. Die innovative Lernumgebung besteht aus einem virtuellen Textadventure, dass über eine webbasierte Plattform zugänglich ist und realen Spielen in einer Präsenzveranstaltung, in denen die Studierenden unmittelbar in das Abenteuer eintauchen und in Teams spielerisch gegeneinander antreten.</p>
<p>Auf der Plattform spielt sich jeder der Studierenden mit seinem virtuellen Avatar durch das Reich von Zyren und erlernt und vertieft auf spielerische Weise die Inhalte der Vorlesung „Wissensrepräsentation“, die in Form von Herausforderungen oder Rätseln in das Abenteuer eingebunden wurden und über den Fortlauf und den Erfolg des Spiels entscheiden.</p>
<p>In der zusätzlichen Präsenzveranstaltung tauchen die Studierenden direkt in das Abenteuer ein und die vertiefen die Inhalte spielerisch. Hier schließen sich die Studierenden in Teams (Gilden) zusammen, müssen eigenverantwortlich Lerninhalte erarbeiten, Probleme lösen und in speziellen Gildenaufgaben gegen andere Teams antreten, um ihr kollaborativ erarbeitetes Wissen auf die Probe zu stellen.</p>
<p>Für jede erfolgreiche absolvierte Herausforderung auf der Plattform oder in der Übung erhalten die Studierenden Erfahrungspunkte und Belohnungen.</p>
<p>Um das Konzept auch anderen Fachbereichen und Lehrveranstaltungen zugänglich zu machen, wurde im Frühjahr 2014 das Projekt Questlab (Arbeitstitel „The Legend of Z“) gestartet um das Konzept zu generalisieren. Lehrende können die Plattform nun nutzen um eigene Aufgaben (Quests) zu kreieren und hochzuladen und sie optional in eine Geschichte einzubinden, die sie selbst gestalten können. Zudem wurde das Responsive Design überarbeitet und bietet nun optimalen Zugriff auf die Plattform über alle mobilen Endgeräte.</p>
<?php if(!empty($text)) : ?>
<?=$t->t($text)?>
<?php endif ?>
<h2>Die Legende von Zyren in der Presse</h2>
<ul>
<li><a href="http://www.uni-duesseldorf.de/home/nc/startseite/news-detailansicht/article/erstmals-an-einer-deutschen-hochschule-gamification-und-interaktive-textadventures.html">Pressemitteilung der Heinrich-Heine-Universität Düsseldorf vom 12.7.13</a></li>
<li><a href="">Artikel in der Rheinischen Post (Print-Version) vom 23.7.13</a></li>
<li><a href="http://www.welt.de/regionales/duesseldorf/article120340979/Mit-Computer-spielend-zum-Uni-Abschluss.html">Artikel in der Zeitschrift Welt (Print- und Online-Version) vom 24.9.13</a></li>
<li><a href="http://www.heise.de/tp/artikel/40/40838/1.html">Artikel auf Heise Online</a></li>
<li><a href="http://www.faz.net/aktuell/beruf-chance/fantasy-an-der-uni-spielend-durchs-studium-12735331.html">Artikel in der Frankfurter Allgemeinen Zeitung</a></li>
<li><a href="http://www.wdr5.de/sendungen/leonardo/rollenspieluniduesseldorf100.html">Radiobeitrag im Deutschlandfunk vom 5.8.13</a></li>
<li>Diverse Beiträge in Blogs, Wikis und anderen sozialen Plattformen, wie beispielweise <a href="http://www.mittelstandswiki.de/wissen/Gamification,_Teil_1">www.mittelstandswiki.de</a> oder <a href="http://www.scoop.it/t/digitale-spiel-und-lernwelten/p/4005676096/2013/08/05/die-legende-von-zyren">www.scoop.it</a></li>
<li>Teilnahme am Finale des studentischen Video-Wettbewerb der DINI „Study Fiction Videoclips zur Zukunft von Studium und Lehre“ mit dem Beitrag <a href="http://dini.de/wettbewerbe/study-fiction/preisverleihung/">„Always Online Die Zukunft des Lernens“</a></li>
</ul>
<h2>Das Team</h2>
<h3>Projektleitung:</h3>
<ul>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Kathrin Knautz</span></li>
</ul>
<h3>Entwicklung und Evaluation des Prototypens:</h3>
<ul>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Lisa Orszullok</span></li>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Simone Soubusta</span></li>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Julia Göretz</span></li>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Anja Wintermeyer</span></li>
</ul>
<h3>Entwicklung „Questlab“:</h3>
<ul>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Oliver Hanraths</span></li>
<li itemscope itemtype="http://schema.org/Person"><span itemprop="name">Daniel Miskovic</span></li>
</ul>
<hr />
<p><?=sprintf(
_('This application is powered by %s and is licensed under the %s'),
'<a href="http://www.questlab.zone">Questlab</a>',
'<a rel="license" href="http://www.gnu.org/licenses/gpl.html">GPL</a>'
)?>.</p>

View file

@ -1,7 +1,19 @@
<li><a href="<?=$linker->link(array(), 0, true, array(), true)?>"><?=\nre\configs\AppConfig::$app['name']?></a></li>
<?php if(!is_null($loggedUser) && count(array_intersect(array('admin','moderator'),$loggedUser['roles'])) > 0) : ?><li><a href="<?=$linker->link('users')?>"><?=_('Users')?></a></li><?php endif ?>
<?php if(!is_null($loggedUser)) : ?><li><a href="<?=$linker->link('seminaries')?>"><?=_('Seminaries')?></a></li><?php endif ?>
<?php if(!is_null($loggedCharacter) && count($loggedCharacter['characterroles']) > 0) : ?><?=$seminarymenu?><?php endif ?>
<?php if(!is_null($loggedUser) && count(array_intersect(array('admin','moderator'),$loggedUser['roles'])) > 0) : ?>
<li><a href="<?=$linker->link('users')?>"><?=_('Users')?></a></li>
<?php endif ?>
<?php if(!is_null($loggedUser)) : ?>
<li><a href="<?=$linker->link('seminaries')?>"><?=_('Seminaries')?></a></li>
<?php endif ?>
<?php if(!is_null($loggedCharacter) && count($loggedCharacter['characterroles']) > 0) : ?>
<?=$seminarymenu?>
<?php endif ?>
<?php if(!is_null($loggedUser) && in_array('admin',$loggedUser['roles'])) : ?>
<li><a href="<?=$linker->link('pages')?>"><?=_('Pages')?></a></li>
<?php endif ?>
<?php foreach($pages as &$page) : ?>
<li><a href="<?=$linker->link(array('pages','page',$page['url']))?>"><?=$page['title']?></a></li>
<?php endforeach ?>
<?php if(is_null($loggedUser)) : ?>
<li><a href="<?=$linker->link(array('users','login'))?>"><?=_('Login')?></a></li>
<?php else : ?>

View file

@ -0,0 +1,47 @@
<div class="moodpic">
<img src="<?=$linker->hardlink('/grafics/questlab.jpg')?>" />
</div>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link('index',1)?>"><?=_('Pages')?></a></li>
</ul>
<h1><?=_('Create page')?></h1>
<?php if($validation !== true && !empty($validation)) : ?>
<ul class="validation">
<?php foreach($validation as $field => &$settings) : ?>
<li>
<ul>
<?php foreach($settings as $setting => $value) : ?>
<li>
<?php switch($field) {
case 'title':
switch($setting) {
case 'minlength': printf(_('Title is too short (min. %d chars)'), $value);
break;
case 'maxlength': printf(_('Title is too long (max. %d chars)'), $value);
break;
case 'regex': echo _('Title contains illegal characters');
break;
case 'exist': echo _('Title already exists');
break;
default: echo _('Title invalid');
}
break;
default:
echo $exception->getMessage();
break;
} ?>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<form method="post" class="logreg">
<fieldset>
<label for="title"><?=_('Title')?>:</label>
<input id="title" name="title" type="text" placeholder="<?=_('Title')?>" title="<?=_('Title')?>" required="required" maxlength="<?=$validationSettings['title']['maxlength']?>" value="<?=$title?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
</fieldset>
<input type="submit" name="create" value="<?=_('create')?>" />
</form>

View file

@ -0,0 +1,13 @@
<div class="moodpic">
<img src="<?=$linker->hardlink('/grafics/questlab.jpg')?>" />
</div>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link(null,3)?>"><?=$page['title']?></a></li>
</ul>
<h1><?=_('Delete page')?></h1>
<?=sprintf(_('Should the page “%s” really be deleted?'), $page['title'])?>
<form method="post">
<input type="submit" name="delete" value="<?=_('delete')?>" />
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
</form>

56
views/html/pages/edit.tpl Normal file
View file

@ -0,0 +1,56 @@
<div class="moodpic">
<img src="<?=$linker->hardlink('/grafics/questlab.jpg')?>" />
</div>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link(null,3)?>"><?=$page['title']?></a></li>
</ul>
<h1><?=_('Edit page')?></h1>
<?php if($validation !== true && !empty($validation)) : ?>
<ul class="validation">
<?php foreach($validation as $field => &$settings) : ?>
<li>
<ul>
<?php foreach($settings as $setting => $value) : ?>
<li>
<?php switch($field) {
case 'title':
switch($setting) {
case 'minlength': printf(_('Title is too short (min. %d chars)'), $value);
break;
case 'maxlength': printf(_('Title is too long (max. %d chars)'), $value);
break;
case 'regex': echo _('Title contains illegal characters');
break;
case 'exist': echo _('Title already exists');
break;
default: echo _('Title invalid');
}
break;
default:
echo $exception->getMessage();
break;
} ?>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<form method="post">
<fieldset>
<label for="title"><?=_('Title')?>:</label>
<input id="title" name="title" type="text" placeholder="<?=_('Title')?>" title="<?=_('Title')?>" required="required" maxlength="<?=$validationSettings['title']['maxlength']?>" value="<?=$title?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
</fieldset>
<fieldset>
<legend><?=_('Text')?></legend>
<textarea id="text" name="text"><?=$text?></textarea>
</fieldset>
<input type="submit" name="save" value="<?=_('save')?>" />
</form>
<script>
$(function() {
$("#text").markItUp(mySettings);
});
</script>

View file

@ -0,0 +1,20 @@
<div class="moodpic">
<img src="<?=$linker->link(array('grafics','questlab.jpg'))?>" />
</div>
<h1><?=_('Pages')?></h1>
<ul>
<?php foreach($pages as &$page) : ?>
<li>
<a href="<?=$linker->link(array('page',$page['url']),1)?>">
<?=$page['title']?>
</a>
</li>
<?php endforeach ?>
<li>
<form method="post" action="<?=$linker->link('create',1)?>">
<input type="text" name="title" placeholder="<?=_('New page')?>" />
<input type="submit" name="create" value="<?=_('create')?>" />
</form>
</li>
</ul>

12
views/html/pages/page.tpl Normal file
View file

@ -0,0 +1,12 @@
<div class="moodpic">
<img src="<?=$linker->link(array('grafics','questlab.jpg'))?>" />
</div>
<?php if(in_array('admin', \hhu\z\controllers\IntermediateController::$user['roles'])) : ?>
<nav class="admin">
<li><a href="<?=$linker->link(array('edit',$page['url']),1)?>"><?=_('Edit page')?></a></li>
<li><a href="<?=$linker->link(array('delete',$page['url']),1)?>"><?=_('Delete page')?></a></li>
</nav>
<?php endif ?>
<h1><?=$page['title']?></h1>
<?=$t->t($page['text'])?>