implement basic CRUD for Quests
This commit is contained in:
parent
396d716684
commit
97a827890d
10 changed files with 840 additions and 156 deletions
|
|
@ -1,44 +1,111 @@
|
|||
<?php if(!is_null($seminary['seminarymedia_id'])) : ?>
|
||||
<?php if(!is_null($questgroup['picture'])) : ?>
|
||||
<div class="moodpic">
|
||||
<img src="<?=$linker->link(array('media','seminaryheader',$seminary['url']))?>" />
|
||||
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questgroup['picture']['url']))?>" />
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?=$questgroupshierarchypath?>
|
||||
|
||||
<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('index',$seminary['url']),1)?>"><?=_('Quests')?></a></li>
|
||||
</ul>
|
||||
<h1><?=_('Create Quest')?></h1>
|
||||
|
||||
<?php if($validation !== true) : ?>
|
||||
<ul>
|
||||
<?php foreach($validation as $field => &$settings) : ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?php foreach($settings as $setting => $value) : ?>
|
||||
<li>
|
||||
<?php switch($field) {
|
||||
case 'media':
|
||||
switch($setting) {
|
||||
case 'error': printf(_('Error during picture upload: %s'), $value);
|
||||
break;
|
||||
case 'mimetype': printf(_('Picture has wrong type “%s”'), $value);
|
||||
break;
|
||||
case 'size': echo _('Picture exceeds size maximum');
|
||||
break;
|
||||
default: echo _('Picture 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;
|
||||
case 'xps':
|
||||
switch($setting) {
|
||||
case 'minlength': printf(_('XPs not set'), $value);
|
||||
break;
|
||||
case 'regex': echo _('XPs contain illegal characters');
|
||||
break;
|
||||
default: echo _('XPs invalid');
|
||||
}
|
||||
break;
|
||||
} ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<label for="name"><?=_('Name')?>:</label>
|
||||
<input type="text" name="name" value="" placeholder="<?=_('Name')?>" /><br />
|
||||
<label for="questgroup"><?=_('Questgroup')?>:</label>
|
||||
<select name="questgroup">
|
||||
<?php foreach($questgroups as &$questgroup) : ?>
|
||||
<option value="<?=$questgroup['url']?>"><?=$questgroup['title']?></option>
|
||||
<legend><?=_('Picture')?></legend>
|
||||
<input type="file" name="media" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
|
||||
<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 ?>
|
||||
</select><br />
|
||||
<label for="questtype"><?=('Questtype')?>:</label>
|
||||
<select name="questtype">
|
||||
<?php foreach($questtypes as &$questtype) : ?>
|
||||
<option value="<?=$questtype['url']?>"><?=$questtype['title']?></option>
|
||||
<?php endforeach ?>
|
||||
</select><br />
|
||||
<label for="name"><?=_('XPs')?>:</label>
|
||||
<input type="number" name="xps" value="" placeholder="<?=_('XPs')?>" /><br />
|
||||
<input type="file" name="questmedia" /><br />
|
||||
</ul>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="prolog">Prolog:</label><br />
|
||||
<textarea name="prolog" placeholder="Prolog" style="width:100%; height:10em;"></textarea><br />
|
||||
<label for="title"><?=_('Title')?>:</label>
|
||||
<input id="title" type="text" name="title" value="<?=$title?>" placeholder="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="xps"><?=_('XPs')?>:</label>
|
||||
<input id="xps" type="number" name="xps" placeholder="<?=_('XPs')?>" title="<?=_('XPs')?>" pattern="<?=substr($validationSettings['xps']['regex'],1,strrpos($validationSettings['xps']['regex'],$validationSettings['xps']['regex'][0])-1)?>" value="<?=$xps?>" <?=(array_key_exists('xps', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="questtype"><?=('Questtype')?>:</label>
|
||||
<select id="questtype" name="questtype">
|
||||
<?php foreach($questtypes as &$questtype) : ?>
|
||||
<option value="<?=$questtype['url']?>" <?php if($questtype['selected']) : ?>selected="selected"<?php endif ?>>
|
||||
<?php switch($questtype['classname']) {
|
||||
case null: echo _('Questtype Empty');
|
||||
break;
|
||||
case 'bossfight': echo _('Questtype bossfight');
|
||||
break;
|
||||
case 'choiceinput': echo _('Questtype choiceinput');
|
||||
break;
|
||||
case 'crossword': echo _('Questtype crossword');
|
||||
break;
|
||||
case 'dragndrop': echo _('Questtype dragndrop');
|
||||
break;
|
||||
case 'multiplechoice': echo _('Questtype multiplechoice');
|
||||
break;
|
||||
case 'submit': echo _('Questtype submit');
|
||||
break;
|
||||
case 'textinput': echo _('Questtype textinput');
|
||||
break;
|
||||
} ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<?php if(is_null($questgroup['hierarchy'])) : ?>
|
||||
<label for="entrytext"><?=('Entry text')?>:</label><br />
|
||||
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"></textarea><br />
|
||||
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
||||
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"></textarea><br />
|
||||
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"><?=$entryText?></textarea><br />
|
||||
<?php endif ?>
|
||||
<label for="task"><?=_('Task')?>:</label><br />
|
||||
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"></textarea><br />
|
||||
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
|
||||
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
||||
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongText?></textarea><br />
|
||||
</fieldset>
|
||||
<input type="submit" name="create" value="<?=_('create')?>" />
|
||||
</form>
|
||||
|
|
|
|||
13
views/html/quests/delete.tpl
Normal file
13
views/html/quests/delete.tpl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php if(!is_null($seminary['seminarymedia_id'])) : ?>
|
||||
<div class="moodpic">
|
||||
<img src="<?=$linker->link(array('media','seminarymoodpic',$seminary['url']))?>">
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?=$questgroupshierarchypath?>
|
||||
|
||||
<h1><?=_('Delete Quest')?></h1>
|
||||
<?=sprintf(_('Should the Quest “%s” really be deleted?'), $quest['title'])?>
|
||||
<form method="post">
|
||||
<input type="submit" name="delete" value="<?=_('delete')?>" />
|
||||
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
|
||||
</form>
|
||||
114
views/html/quests/edit.tpl
Normal file
114
views/html/quests/edit.tpl
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php if(!is_null($questgroup['picture'])) : ?>
|
||||
<div class="moodpic">
|
||||
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questgroup['picture']['url']))?>" />
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?=$questgroupshierarchypath?>
|
||||
|
||||
<h1><?=_('Edit Quest')?></h1>
|
||||
<?php if($validation !== true) : ?>
|
||||
<ul>
|
||||
<?php foreach($validation as $field => &$settings) : ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?php foreach($settings as $setting => $value) : ?>
|
||||
<li>
|
||||
<?php switch($field) {
|
||||
case 'media':
|
||||
switch($setting) {
|
||||
case 'error': printf(_('Error during picture upload: %s'), $value);
|
||||
break;
|
||||
case 'mimetype': printf(_('Picture has wrong type “%s”'), $value);
|
||||
break;
|
||||
case 'size': echo _('Picture exceeds size maximum');
|
||||
break;
|
||||
default: echo _('Picture 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;
|
||||
case 'xps':
|
||||
switch($setting) {
|
||||
case 'minlength': printf(_('XPs not set'), $value);
|
||||
break;
|
||||
case 'regex': echo _('XPs contain illegal characters');
|
||||
break;
|
||||
default: echo _('XPs invalid');
|
||||
}
|
||||
break;
|
||||
} ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<?php if(!is_null($media)) : ?>
|
||||
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>"><img style="width:10em; display:block;" src="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>" /></a>
|
||||
<?php endif ?>
|
||||
<legend><?=_('Picture')?></legend>
|
||||
<input type="file" name="media" accept="<?=implode(',', array_map(function($m) { return $m['mimetype']; }, $mimetypes))?>" />
|
||||
<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>
|
||||
<label for="title"><?=_('Title')?>:</label>
|
||||
<input id="title" type="text" name="title" value="<?=$title?>" placeholder="<?=_('Title')?>" maxlength="<?=$validationSettings['title']['maxlength']?>" <?=(array_key_exists('title', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="xps"><?=_('XPs')?>:</label>
|
||||
<input id="xps" type="number" name="xps" placeholder="<?=_('XPs')?>" title="<?=_('XPs')?>" pattern="<?=substr($validationSettings['xps']['regex'],1,strrpos($validationSettings['xps']['regex'],$validationSettings['xps']['regex'][0])-1)?>" value="<?=$xps?>" <?=(array_key_exists('xps', $validation)) ? 'class="invalid"' : null?> /><br />
|
||||
<label for="questtype"><?=('Questtype')?>:</label>
|
||||
<select id="questtype" name="questtype">
|
||||
<?php foreach($questtypes as &$questtype) : ?>
|
||||
<option value="<?=$questtype['url']?>" <?php if($questtype['selected']) : ?>selected="selected"<?php endif ?>>
|
||||
<?php switch($questtype['classname']) {
|
||||
case null: echo _('Questtype Empty');
|
||||
break;
|
||||
case 'bossfight': echo _('Questtype bossfight');
|
||||
break;
|
||||
case 'choiceinput': echo _('Questtype choiceinput');
|
||||
break;
|
||||
case 'crossword': echo _('Questtype crossword');
|
||||
break;
|
||||
case 'dragndrop': echo _('Questtype dragndrop');
|
||||
break;
|
||||
case 'multiplechoice': echo _('Questtype multiplechoice');
|
||||
break;
|
||||
case 'submit': echo _('Questtype submit');
|
||||
break;
|
||||
case 'textinput': echo _('Questtype textinput');
|
||||
break;
|
||||
} ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<?php if(is_null($questgroup['hierarchy'])) : ?>
|
||||
<label for="entrytext"><?=('Entry text')?>:</label><br />
|
||||
<textarea name="entrytext" placeholder="<?=_('Entry text')?>" style="width:100%; height:10em;"><?=$entryText?></textarea><br />
|
||||
<?php endif ?>
|
||||
<label for="task"><?=_('Task')?>:</label><br />
|
||||
<textarea name="task" placeholder="<?=('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
|
||||
<label for="wrongtext"><?=('Wrong text')?>:</label><br />
|
||||
<textarea name="wrongtext" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongText?></textarea><br />
|
||||
</fieldset>
|
||||
<input type="submit" name="edit" value="<?=_('edit')?>" />
|
||||
</form>
|
||||
|
|
@ -6,6 +6,14 @@
|
|||
<?=$questgroupshierarchypath?>
|
||||
<h1><?=$quest['title']?></h1>
|
||||
|
||||
<?php if(count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\SeminaryController::$character['characterroles'])) > 0) : ?>
|
||||
<nav class="admin">
|
||||
<li><a href="<?=$linker->link('edit', 5)?>"><?=_('Edit Quest')?></a></li>
|
||||
<?php if(in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles'])) : ?>
|
||||
<li><a href="<?=$linker->link('delete', 5)?>"><?=_('Delete Quest')?></a></li>
|
||||
<?php endif ?>
|
||||
</nav>
|
||||
<?php endif ?>
|
||||
<?php if(array_key_exists('Prolog', $questtexts) && count($questtexts['Prolog']) > 0) : ?>
|
||||
<section>
|
||||
<h1 id="questtext"><?=_('Prolog')?></h1>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue