add basic CRUD for Character groups Quest Stations

This commit is contained in:
oliver 2016-01-14 19:04:56 +01:00
parent 5f25a0a383
commit e03dea0d80
9 changed files with 816 additions and 11 deletions

View file

@ -35,7 +35,7 @@
/**
* Action: quest.
* Action: station.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
@ -46,6 +46,45 @@
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: create.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function create(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
// Add Moodpic
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
}
}
?>

View file

@ -305,8 +305,10 @@
array('^charactergroupsquests/([^/]+)/([^/]+)/create/?$', 'charactergroupsquests/create/$1/$2', true),
array('^charactergroupsquests/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsquests/quest/$1/$2/$3', true),
array('^charactergroupsquests/([^/]+)/([^/]+)/([^/]+)/(edit|delete|manage)/?$', 'charactergroupsquests/$4/$1/$2/$3', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/index/$1/$2/$3?layout=ajax', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/station/$1/$2/$3/$4', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/index/$1/$2/$3?layout=ajax', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/create/?$', 'charactergroupsqueststations/create/$1/$2/$3', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(edit|delete)/?$', 'charactergroupsqueststations/$5/$1/$2/$3/$4', true),
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/station/$1/$2/$3/$4', true),
array('^achievements/([^/]+)/(create|manage)/?$', 'achievements/$2/$1', true),
array('^achievements/([^/]+)/([^/]+)/(edit|conditions|moveup|movedown|delete)/?$', 'achievements/$3/$1/$2', true),
array('^achievements/([^/]+)/?$', 'achievements/index/$1', true),
@ -362,8 +364,9 @@
array('^charactergroupsquests/create/([^/]+)/([^/]+)/?$', 'charactergroupsquests/$1/$2/create', true),
array('^charactergroupsquests/quest/(.*)$', 'charactergroupsquests/$1', true),
array('^charactergroupsquests/(edit|delete|manage)/([^/]+)/([^/]+)/([^/]+)$', 'charactergroupsquests/$2/$3/$4/$1', true),
array('^charactergroupsqueststations/index/(.*)$', 'charactergroupsqueststations/$1', true),
array('^charactergroupsqueststations/station/(.*)$', 'charactergroupsqueststations/$1', true),
array('^charactergroupsqueststations/index/(.*)$', 'charactergroupsqueststations/$1', true),
array('^charactergroupsqueststations/station/(.*)$', 'charactergroupsqueststations/$1', true),
array('^charactergroupsqueststations/(create|edit|delete)/(.*)$', 'charactergroupsqueststations/$2/$1', true),
array('^achievements/index/(.*)$', 'achievements/$1', true),
array('^achievements/(create|manage)/(.*)$', 'achievements/$2/$1', true),
array('^achievements/(edit|conditions|moveup|movedown|delete)/(.*)$', 'achievements/$2/$1', true),

View file

@ -26,6 +26,12 @@
* @var array
*/
public $models = array('seminaries', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'stationtypes', 'media');
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* User permissions
*
@ -194,6 +200,421 @@
}
/**
* Action: create.
*
* Create a new Character groups Quest Station for a Character
* groups Quest.
*
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $questUrl URL-Title of a Character groups Quest
*/
public function create($seminaryUrl, $groupsgroupUrl, $questUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character groups-group Quests
$quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl);
// Get Quest types
$stationtypes = $this->Stationtypes->getStationtypes();
foreach($stationtypes as &$stationtype) {
$stationtype['selected'] = false;
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
// Values
$title = '';
$task = '';
$longitude = null;
$latitude = null;
$rightText = '';
$wrongText = '';
$fields = array('title');
$validation = array();
// Create a new Station
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->Charactergroupsqueststations->stationTitleExists($quest['id'], $title)) {
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
}
$task = $this->request->getPostParam('task');
$rightText = $this->request->getPostParam('rightText');
$wrongText = $this->request->getPostParam('wrongText');
// Validate Stationtype
$stationtypeIndex = null;
foreach($stationtypes as $index => &$stationtype)
{
$stationtype['selected'] = ($stationtype['url'] == $this->request->getPostParam('stationtype'));
if($stationtype['selected']) {
$stationtypeIndex = $index;
}
}
if(is_null($stationtypeIndex)) {
throw new \nre\exceptions\ParamsNotValidException($stationtype);
}
// Validate icon
$icon = null;
if(!empty($_FILES) && array_key_exists('icon', $_FILES) && $_FILES['icon']['error'] != UPLOAD_ERR_NO_FILE)
{
$icon = $_FILES['icon'];
// Check error
if($icon['error'] !== UPLOAD_ERR_OK) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'error', $icon['error']);
}
// Check mimetype
$mediaMimetype = null;
$icon['mimetype'] = \hhu\z\Utils::getMimetype($icon['tmp_name'], $icon['type']);
foreach($mimetypes as &$mimetype) {
if($mimetype['mimetype'] == $icon['mimetype']) {
$mediaMimetype = $mimetype;
break;
}
}
if(is_null($mediaMimetype)) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'mimetype', $icon['mimetype']);
}
elseif($icon['size'] > $mediaMimetype['size']) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'size', $mediaMimetype['size']);
}
}
// Create new Station
if($validation === true)
{
$stationId = $this->Charactergroupsqueststations->createStation(
$quest['id'],
$stationtypes[$stationtypeIndex]['id'],
$title,
$task,
$latitude,
$longitude,
$rightText,
$wrongText
);
$station = $this->Charactergroupsqueststations->getStationById($stationId);
// Upload icon
if(!is_null($icon))
{
$mediaId = $this->Media->createQuestMedia(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('charactergroupsqueststation-%s', $station['url']),
'',
$icon['mimetype'],
$icon['tmp_name']
);
if($mediaId !== false) {
$this->Charactergroupsqueststations->setPictureForStation($station['id'], $mediaId);
}
}
// Redirect to Station page
$this->redirect(
$this->linker->link(
array(
'station',
$seminary['url'],
$groupsgroup['url'],
$quest['url'],
$station['url']
),
1
)
);
}
}
// Set title
$this->addTitle(_('Create Station'));
$this->addTitle($quest['title']);
$this->addTitle($groupsgroup['name']);
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('groupsgroup', $groupsgroup);
$this->set('quest', $quest);
$this->set('title', $title);
$this->set('task', $task);
$this->set('longitude', $longitude);
$this->set('latitude', $latitude);
$this->set('righttext', $rightText);
$this->set('wrongtext', $wrongText);
$this->set('mimetypes', $mimetypes);
$this->set('stationtypes', $stationtypes);
$this->set('validation', $validation);
}
/**
* Action: edit.
*
* Edit a Station of a Character groups Quest.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $questUrl URL-Title of a Character groups Quest
* @param string $stationUrl URL of station
*/
public function edit($seminaryUrl, $groupsgroupUrl, $questUrl, $stationUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character groups-group Quests
$quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl);
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
// Get Quest types
$stationtypes = $this->Stationtypes->getStationtypes();
foreach($stationtypes as &$stationtype) {
$stationtype['selected'] = false;
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
// Values
$title = $station['title'];
$task = $station['task'];
$longitude = $station['longitude'];
$latitude = $station['latitude'];
$rightText = $station['righttext'];
$wrongText = $station['wrongtext'];
$fields = array('title');
$validation = array();
// Check request method
if($this->request->getRequestMethod() == 'POST' && (!is_null($this->request->getPostParam('edit')) || !is_null($this->request->getPostParam('edit-task'))))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$title = $this->request->getPostParam('title');
if($this->Charactergroupsqueststations->stationTitleExists($quest['id'], $title, $station['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'title', 'exist', true);
}
$task = $this->request->getPostParam('task');
$rightText = $this->request->getPostParam('rightText');
$wrongText = $this->request->getPostParam('wrongText');
// Validate Stationtype
$stationtypeIndex = null;
foreach($stationtypes as $index => &$stationtype)
{
$stationtype['selected'] = ($stationtype['url'] == $this->request->getPostParam('stationtype'));
if($stationtype['selected']) {
$stationtypeIndex = $index;
}
}
if(is_null($stationtypeIndex)) {
throw new \nre\exceptions\ParamsNotValidException($stationtype);
}
// Validate icon
$icon = null;
if(!empty($_FILES) && array_key_exists('icon', $_FILES) && $_FILES['icon']['error'] != UPLOAD_ERR_NO_FILE)
{
$icon = $_FILES['icon'];
// Check error
if($icon['error'] !== UPLOAD_ERR_OK) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'error', $icon['error']);
}
// Check mimetype
$mediaMimetype = null;
$icon['mimetype'] = \hhu\z\Utils::getMimetype($icon['tmp_name'], $icon['type']);
foreach($mimetypes as &$mimetype) {
if($mimetype['mimetype'] == $icon['mimetype']) {
$mediaMimetype = $mimetype;
break;
}
}
if(is_null($mediaMimetype)) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'mimetype', $icon['mimetype']);
}
elseif($icon['size'] > $mediaMimetype['size']) {
$validation = $this->Validation->addValidationResult($validation, 'icon', 'size', $mediaMimetype['size']);
}
}
// Edit Station
if($validation === true)
{
$this->Charactergroupsqueststations->editStation(
$station['id'],
$stationtypes[$stationtypeIndex]['id'],
$title,
$task,
$latitude,
$longitude,
$rightText,
$wrongText
);
$station = $this->Charactergroupsqueststations->getStationById($station['id']);
// Upload icon
if(!is_null($icon))
{
$mediaId = $this->Media->createQuestMedia(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('charactergroupsqueststation-%s', $station['url']),
'',
$icon['mimetype'],
$icon['tmp_name']
);
if($mediaId !== false) {
$this->Charactergroupsqueststations->setPictureForStation($station['id'], $mediaId);
}
}
// Redirect to Station page
$this->redirect(
$this->linker->link(
array(
'station',
$seminary['url'],
$groupsgroup['url'],
$quest['url'],
$station['url']
),
1
)
);
}
}
// Set title
$this->addTitle(_('Edit Station'));
$this->addTitle($station['title']);
$this->addTitle($quest['title']);
$this->addTitle($groupsgroup['name']);
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('groupsgroup', $groupsgroup);
$this->set('quest', $quest);
$this->set('title', $title);
$this->set('task', $task);
$this->set('longitude', $longitude);
$this->set('latitude', $latitude);
$this->set('righttext', $rightText);
$this->set('wrongtext', $wrongText);
$this->set('mimetypes', $mimetypes);
$this->set('stationtypes', $stationtypes);
$this->set('validation', $validation);
}
/**
* Action: delete.
*
* Delete a Station of a Character groups Quest.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $questUrl URL-Title of a Character groups Quest
* @param string $stationUrl URL of station
*/
public function delete($seminaryUrl, $groupsgroupUrl, $questUrl, $stationUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character groups-group Quests
$quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl);
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete seminary
$this->Charactergroupsqueststations->deleteStation(
$station['id']
);
// Redirect to overview
$this->redirect(
$this->linker->link(
array(
'charactergroupsquests',
'quest',
$seminary['url'],
$groupsgroup['url'],
$quest['url']
),
0, true, null, true, 'stations'
)
);
}
// Redirect to entry
$this->redirect(
$this->linker->link(
array(
'station',
$seminary['url'],
$groupsgroup['url'],
$quest['url'],
$station['url']
),
1
)
);
}
// Set title
$this->addTitle(_('Delete Station'));
$this->addTitle($station['title']);
$this->addTitle($quest['title']);
$this->addTitle($groupsgroup['name']);
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('groupsgroup', $groupsgroup);
$this->set('quest', $quest);
$this->set('station', $station);
}
/**

View file

@ -239,6 +239,135 @@
}
/**
* Check if a Character groups Quest Station title already exists.
*
* @param int $questId ID of Character groups Quest
* @param string $title Station title to check
* @param int $stationId Do not check this ID (for editing)
* @return boolean Whether Station title exists or not
*/
public function stationTitleExists($questId, $title, $stationId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsqueststations '.
'WHERE charactergroupsquest_id = ? AND (title = ? OR url = ?)',
'iss',
$questId,
$title,
\nre\core\Linker::createLinkParam($title)
);
return (!empty($data) && (is_null($stationId) || $stationId != $data[0]['id']));
}
/**
* Set the media for a Character groups Quest Station.
*
* @param int $stationId ID of Station to upload media for
* @param int $mediaId ID of Station media
*/
public function setPictureForStation($station, $mediaId)
{
$this->db->query(
'UPDATE charactergroupsqueststations '.
'SET stationpicture_id = ? '.
'WHERE id = ?',
'ii',
$mediaId,
$station
);
}
/**
* Create a new Character groups Quest Station.
*
* @param int $questId ID of Quest to create the Station for
* @param int $stationtypeId ID of Station type
* @param string $title Title
* @param string $task Task description
* @param int $latitude GPS latitude
* @param int $longitude GPS longitude
* @param string $righttext Text for correctly solved task
* @param string $wrongtext Text for failed task
* @return int ID of newly created station
*/
public function createStation($questId, $stationtypeId, $title, $task, $latitude, $longitude, $righttext, $wrongtext)
{
// Get position
$pos = $this->db->query(
'SELECT COALESCE(MAX(pos),0)+1 AS pos '.
'FROM charactergroupsqueststations '.
'WHERE charactergroupsquest_id = ?',
'i',
$questId
);
$pos = $pos[0]['pos'];
// Create Station
$this->db->query(
'INSERT INTO charactergroupsqueststations '.
'(charactergroupsquest_id, stationtype_id, title, url, pos, task, latitude, longitude, righttext, wrongtext) '.
'VALUES '.
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
'iissisddss',
$questId, $stationtypeId, $title,
\nre\core\Linker::createLinkParam($title), $pos,
$task, $latitude, $longitude, $righttext, $wrongtext
);
// Return ID of newly created Station
return $this->db->getInsertId();
}
/**
* Edit a Character groups Quest Station.
*
* @param int $stationId ID of Station to edit
* @param int $stationtypeId ID of Station type
* @param string $title Title
* @param string $task Task description
* @param int $latitude GPS latitude
* @param int $longitude GPS longitude
* @param string $righttext Text for correctly solved task
* @param string $wrongtext Text for failed task
*/
public function editStation($stationId, $stationtypeId, $title, $task, $latitude, $longitude, $righttext, $wrongtext)
{
$this->db->query(
'UPDATE charactergroupsqueststations '.
'SET stationtype_id = ?, title = ?, url = ?, task = ?, latitude = ?, longitude = ?, righttext = ?, wrongtext = ? '.
'WHERE id = ?',
'isssddssi',
$stationtypeId, $title,
\nre\core\Linker::createLinkParam($title),
$task, $latitude, $longitude, $righttext, $wrongtext,
$stationId
);
}
/**
* Delete a Character-group Quest station.
*
* @param int $stationId ID of Station to delete
*/
public function deleteStation($stationId)
{
$this->db->query(
'DELETE FROM charactergroupsqueststations '.
'WHERE ID = ?',
'i',
$stationId
);
}

View file

@ -67,9 +67,8 @@
</section>
<?php endif ?>
<?php if(!empty($stations)) : ?>
<section>
<h1><i class="fa fa-map-signs fa-fw"></i><?=_('Stations')?></h1>
<h1 id="stations"><i class="fa fa-map-signs fa-fw"></i><?=_('Stations')?></h1>
<div id="map" class="map"></div>
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
@ -79,6 +78,7 @@
</ul>
</nav>
<?php endif ?>
<?php if(!empty($stations)) : ?>
<ol class="grpqlist">
<?php foreach($stations as &$station) : ?>
<li>
@ -96,8 +96,10 @@
</li>
<?php endforeach ?>
</ol>
<?php else : ?>
<p><?=sprintf(_('Your %s-group has not discovered any station yet'), $groupsgroup['name'])?>.</p>
<?php endif ?>
</section>
<?php endif ?>
<section>
<h1><i class="fa fa-users fa-fw"></i><?=$groupsgroup['name']?></h1>

View file

@ -0,0 +1,99 @@
<?=$moodpic?>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','index',$seminary['url']))?>"><?=_('Character Groups')?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','groupsgroup',$seminary['url'],$groupsgroup['url']))?>"><?=$groupsgroup['name']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroupsquests','quest',$seminary['url'],$groupsgroup['url'],$quest['url']))?>"><?=$quest['title']?></a></li>
</ul>
<h1><?=_('New Station')?></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 'icon':
switch($setting) {
case 'error': printf(_('Error during icon upload: %s'), $value);
break;
case 'mimetype': printf(_('Icon has wrong type “%s”'), $value);
break;
case 'size': echo _('Icon exceeds size maximum');
break;
default: echo _('Icon invalid');
}
break;
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;
} ?>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<form method="post" action="" class="logreg" enctype="multipart/form-data">
<fieldset>
<legend><?=_('Icon')?></legend>
<input type="file" name="icon" />
<p><?=_('Allowed file types')?>:</p>
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<li><?=sprintf(_('%s-files'), strtoupper(explode('/',$mimetype['mimetype'])[1]))?> <?php if($mimetype['size'] > 0) : ?>(<?=_('max.')?> <?=round($mimetype['size']/(1024*1024),2)?>MiB)<?php endif ?></li>
<?php endforeach ?>
</ul>
</fieldset>
<fieldset>
<legend><?=_('Location')?></legend>
</fieldset>
<fieldset>
<label for="stationtype"><?=('Stationtype')?>:</label>
<select id="stationtype" name="stationtype">
<?php foreach($stationtypes as &$stationtype) : ?>
<option value="<?=$stationtype['url']?>" <?php if($stationtype['selected']) : ?>selected="selected"<?php endif ?>>
<?php switch($stationtype['classname']) {
case null: echo _('Stationttype Empty');
break;
case 'multiplechoice': echo _('Stationtype multiplechoice');
break;
case 'keyword': echo _('Stationtype keyword');
break;
} ?>
</option>
<?php endforeach ?>
</select>
</fieldset>
<fieldset>
<label for="title"><?=_('Title')?>:</label>
<input type="text" id="title" name="title" placeholder="<?=_('Title')?>" title="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" value="<?=$title?>" <?=($validation !== true && array_key_exists('title', $validation)) ? 'class="invalid"' : null?> />
<label for="task"><?=_('Task')?>:</label><br />
<textarea id="task" name="task" placeholder="<?=_('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
<label for="rightText"><?=('Right text')?>:</label><br />
<textarea id="rightText" name="rightText" placeholder="<?=_('Right text')?>" style="width:100%; height:10em;"><?=$righttext?></textarea><br />
<label for="wrongText"><?=_('Wrong text')?>:</label><br />
<textarea id="wrongText" name="wrongText" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongtext?></textarea><br />
</fieldset>
<input type="submit" name="create" value="<?=_('create')?>" />
</form>
<script>
$(function() {
$("#task").markItUp(mySettings);
$("#rightText").markItUp(mySettings);
$("#wrongText").markItUp(mySettings);
});
</script>

View file

@ -0,0 +1,14 @@
<?=$moodpic?>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','index',$seminary['url']))?>"><?=_('Character Groups')?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','groupsgroup',$seminary['url'],$groupsgroup['url']))?>"><?=$groupsgroup['name']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroupsquests','quest',$seminary['url'],$groupsgroup['url'],$quest['url']))?>"><?=$quest['title']?></a></li>
</ul>
<h1><?=_('Delete Station')?></h1>
<?=sprintf(_('Should the Station “%s” really be deleted?'), $station['title'])?>
<form method="post">
<input type="submit" name="delete" value="<?=_('delete')?>" />
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
</form>

View file

@ -0,0 +1,99 @@
<?=$moodpic?>
<ul class="breadcrumbs">
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','index',$seminary['url']))?>"><?=_('Character Groups')?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','groupsgroup',$seminary['url'],$groupsgroup['url']))?>"><?=$groupsgroup['name']?></a></li>
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroupsquests','quest',$seminary['url'],$groupsgroup['url'],$quest['url']))?>"><?=$quest['title']?></a></li>
</ul>
<h1><?=_('Edit Station')?></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 'icon':
switch($setting) {
case 'error': printf(_('Error during icon upload: %s'), $value);
break;
case 'mimetype': printf(_('Icon has wrong type “%s”'), $value);
break;
case 'size': echo _('Icon exceeds size maximum');
break;
default: echo _('Icon invalid');
}
break;
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;
} ?>
</li>
<?php endforeach ?>
</ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<form method="post" action="" class="logreg" enctype="multipart/form-data">
<fieldset>
<legend><?=_('Icon')?></legend>
<input type="file" name="icon" />
<p><?=_('Allowed file types')?>:</p>
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<li><?=sprintf(_('%s-files'), strtoupper(explode('/',$mimetype['mimetype'])[1]))?> <?php if($mimetype['size'] > 0) : ?>(<?=_('max.')?> <?=round($mimetype['size']/(1024*1024),2)?>MiB)<?php endif ?></li>
<?php endforeach ?>
</ul>
</fieldset>
<fieldset>
<legend><?=_('Location')?></legend>
</fieldset>
<fieldset>
<label for="stationtype"><?=('Stationtype')?>:</label>
<select id="stationtype" name="stationtype">
<?php foreach($stationtypes as &$stationtype) : ?>
<option value="<?=$stationtype['url']?>" <?php if($stationtype['selected']) : ?>selected="selected"<?php endif ?>>
<?php switch($stationtype['classname']) {
case null: echo _('Stationttype Empty');
break;
case 'multiplechoice': echo _('Stationtype multiplechoice');
break;
case 'keyword': echo _('Stationtype keyword');
break;
} ?>
</option>
<?php endforeach ?>
</select>
</fieldset>
<fieldset>
<label for="title"><?=_('Title')?>:</label>
<input type="text" id="title" name="title" placeholder="<?=_('Title')?>" title="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" value="<?=$title?>" <?=($validation !== true && array_key_exists('title', $validation)) ? 'class="invalid"' : null?> />
<label for="task"><?=_('Task')?>:</label><br />
<textarea id="task" name="task" placeholder="<?=_('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
<label for="rightText"><?=('Right text')?>:</label><br />
<textarea id="rightText" name="rightText" placeholder="<?=_('Right text')?>" style="width:100%; height:10em;"><?=$righttext?></textarea><br />
<label for="wrongText"><?=_('Wrong text')?>:</label><br />
<textarea id="wrongText" name="wrongText" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongtext?></textarea><br />
</fieldset>
<input type="submit" name="edit" value="<?=_('edit')?>" />
</form>
<script>
$(function() {
$("#task").markItUp(mySettings);
$("#rightText").markItUp(mySettings);
$("#wrongText").markItUp(mySettings);
});
</script>

View file

@ -8,9 +8,8 @@
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
<nav class="admin">
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),1)?>"><?=_('Edit')?></a></li>
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),1)?>"><?=_('Delete')?></a></li>
<li><a href="<?=$linker->link(array('manage',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),1)?>"><?=_('Manage')?></a></li>
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),1)?>"><?=_('edit')?></a></li>
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$groupsgroup['url'],$quest['url'],$station['url']),1)?>"><?=_('delete')?></a></li>
</nav>
<?php endif ?>