add media to right/wrong text of Character group Quest Stations

This commit is contained in:
oliver 2016-01-24 19:36:05 +01:00
parent 2d65b2e4b0
commit efd304833c
8 changed files with 547 additions and 22 deletions

View file

@ -164,6 +164,38 @@
'mimetype' => 'image/png',
'size' => 10485760
)
),
'stationimages' => array(
array(
'mimetype' => 'image/jpeg',
'size' => 1048576
),
array(
'mimetype' => 'image/png',
'size' => 2097152
)
),
'stationavs' => array(
array(
'mimetype' => 'audio/mpeg',
'size' => 2097152
),
array(
'mimetype' => 'audio/ogg',
'size' => 2097152
),
array(
'mimetype' => 'audio/opus',
'size' => 2097152
),
array(
'mimetype' => 'video/mp4',
'size' => 2097152
),
array(
'mimetype' => 'video/webm',
'size' => 2097152
)
)
);

View file

@ -133,6 +133,20 @@
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
// Get media
if(!is_null($station['rightimage_id'])) {
$station['rightimage'] = $this->Media->getSeminaryMediaById($station['rightimage_id']);
}
if(!is_null($station['rightav_id'])) {
$station['rightav'] = $this->Media->getSeminaryMediaById($station['rightav_id']);
}
if(!is_null($station['wrongimage_id'])) {
$station['wrongimage'] = $this->Media->getSeminaryMediaById($station['wrongimage_id']);
}
if(!is_null($station['wrongav_id'])) {
$station['wrongav'] = $this->Media->getSeminaryMediaById($station['wrongav_id']);
}
// Get Character group
$charactergroup = null;
$character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
@ -233,7 +247,9 @@
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
$iconMimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
$imageMimetypes = \nre\configs\AppConfig::$mimetypes['stationimages'];
$avMimetypes = \nre\configs\AppConfig::$mimetypes['stationavs'];
// Values
$title = '';
@ -243,6 +259,12 @@
$latitude = null;
$rightText = '';
$wrongText = '';
$textMedia = array(
'rightimage' => null,
'rightav' => null,
'wrongimage' => null,
'wrongav' => null
);
$fields = array('title');
$validation = array();
@ -289,7 +311,7 @@
// Check mimetype
$mediaMimetype = null;
$icon['mimetype'] = \hhu\z\Utils::getMimetype($icon['tmp_name'], $icon['type']);
foreach($mimetypes as &$mimetype) {
foreach($iconMimetypes as &$mimetype) {
if($mimetype['mimetype'] == $icon['mimetype']) {
$mediaMimetype = $mimetype;
break;
@ -303,6 +325,51 @@
}
}
// Validate media
if(!empty($_FILES))
{
foreach(array_keys($textMedia) as $mediumKey)
{
if(array_key_exists($mediumKey, $_FILES) && $_FILES[$mediumKey]['error'] != UPLOAD_ERR_NO_FILE)
{
$mediumValidation = true;
$medium = $_FILES[$mediumKey];
// Check error
if($medium['error'] !== UPLOAD_ERR_OK) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'error', $medium['error']);
}
else
{
// Check mimetype
$mediaMimetype = null;
$medium['mimetype'] = \hhu\z\Utils::getMimetype($medium['tmp_name'], $medium['type']);
$mediaMimetypes = (strpos($mediumKey, 'image') !== false) ? $imageMimetypes : $avMimetypes;
foreach($mediaMimetypes as &$mimetype) {
if($mimetype['mimetype'] == $medium['mimetype']) {
$mediaMimetype = $mimetype;
break;
}
}
if(is_null($mediaMimetype)) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'mimetype', $medium['mimetype']);
}
elseif($medium['size'] > $mediaMimetype['size']) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'size', $mediaMimetype['size']);
}
if($validation == true) {
$textMedia[$mediumKey] = $medium;
}
}
if($mediumValidation !== true) {
$validation = $this->Validation->addValidationResults($validation, $mediumKey, $mediumValidation);
}
}
}
}
// Create new Station
if($validation === true)
{
@ -335,6 +402,50 @@
}
}
// Upload media
$textMediaIds = array();
foreach($textMedia as $mediumKey => $medium)
{
if(!is_null($medium))
{
$mediaId = $this->Media->createStationMedia(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('station-%d-%s', $station['id'], $mediumKey),
$medium['name'],
$medium['type'],
$medium['tmp_name']
);
$textMediaIds[$mediumKey] = $mediaId;
}
}
// Set media
if(array_key_exists('rightimage', $textMediaIds)) {
$this->Charactergroupsqueststations->setRightImageForStation(
$station['id'],
$textMediaIds['rightimage']
);
}
if(array_key_exists('rightav', $textMediaIds)) {
$this->Charactergroupsqueststations->setRightAvForStation(
$station['id'],
$textMediaIds['rightav']
);
}
if(array_key_exists('wrongimage', $textMediaIds)) {
$this->Charactergroupsqueststations->setWrongImageForStation(
$station['id'],
$textMediaIds['wrongimage']
);
}
if(array_key_exists('wrongav', $textMediaIds)) {
$this->Charactergroupsqueststations->setWrongAvForStation(
$station['id'],
$textMediaIds['wrongav']
);
}
// Redirect to Station page
$this->redirect(
$this->linker->link(
@ -369,7 +480,9 @@
$this->set('latitude', $latitude);
$this->set('righttext', $rightText);
$this->set('wrongtext', $wrongText);
$this->set('mimetypes', $mimetypes);
$this->set('iconMimetypes', $iconMimetypes);
$this->set('imageMimetypes', $imageMimetypes);
$this->set('avMimetypes', $avMimetypes);
$this->set('stationtypes', $stationtypes);
$this->set('validation', $validation);
}
@ -400,6 +513,20 @@
// Get Station
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
// Get media
if(!is_null($station['rightimage_id'])) {
$station['rightimage'] = $this->Media->getSeminaryMediaById($station['rightimage_id']);
}
if(!is_null($station['rightav_id'])) {
$station['rightav'] = $this->Media->getSeminaryMediaById($station['rightav_id']);
}
if(!is_null($station['wrongimage_id'])) {
$station['wrongimage'] = $this->Media->getSeminaryMediaById($station['wrongimage_id']);
}
if(!is_null($station['wrongav_id'])) {
$station['wrongav'] = $this->Media->getSeminaryMediaById($station['wrongav_id']);
}
// Get Quest types
$stationtypes = $this->Stationtypes->getStationtypes();
foreach($stationtypes as &$stationtype) {
@ -407,7 +534,9 @@
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
$iconMimetypes = \nre\configs\AppConfig::$mimetypes['icons'];
$imageMimetypes = \nre\configs\AppConfig::$mimetypes['stationimages'];
$avMimetypes = \nre\configs\AppConfig::$mimetypes['stationavs'];
// Values
$title = $station['title'];
@ -417,6 +546,12 @@
$latitude = $station['latitude'];
$rightText = $station['righttext'];
$wrongText = $station['wrongtext'];
$textMedia = array(
'rightimage' => null,
'rightav' => null,
'wrongimage' => null,
'wrongav' => null
);
$fields = array('title');
$validation = array();
@ -463,7 +598,7 @@
// Check mimetype
$mediaMimetype = null;
$icon['mimetype'] = \hhu\z\Utils::getMimetype($icon['tmp_name'], $icon['type']);
foreach($mimetypes as &$mimetype) {
foreach($iconMimetypes as &$mimetype) {
if($mimetype['mimetype'] == $icon['mimetype']) {
$mediaMimetype = $mimetype;
break;
@ -477,6 +612,51 @@
}
}
// Validate media
if(!empty($_FILES))
{
foreach(array_keys($textMedia) as $mediumKey)
{
if(array_key_exists($mediumKey, $_FILES) && $_FILES[$mediumKey]['error'] != UPLOAD_ERR_NO_FILE)
{
$mediumValidation = true;
$medium = $_FILES[$mediumKey];
// Check error
if($medium['error'] !== UPLOAD_ERR_OK) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'error', $medium['error']);
}
else
{
// Check mimetype
$mediaMimetype = null;
$medium['mimetype'] = \hhu\z\Utils::getMimetype($medium['tmp_name'], $medium['type']);
$mediaMimetypes = (strpos($mediumKey, 'image') !== false) ? $imageMimetypes : $avMimetypes;
foreach($mediaMimetypes as &$mimetype) {
if($mimetype['mimetype'] == $medium['mimetype']) {
$mediaMimetype = $mimetype;
break;
}
}
if(is_null($mediaMimetype)) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'mimetype', $medium['mimetype']);
}
elseif($medium['size'] > $mediaMimetype['size']) {
$mediumValidation = $this->Validation->addValidationResults($mediumValidation, 'size', $mediaMimetype['size']);
}
if($validation == true) {
$textMedia[$mediumKey] = $medium;
}
}
if($mediumValidation !== true) {
$validation = $this->Validation->addValidationResults($validation, $mediumKey, $mediumValidation);
}
}
}
}
// Edit Station
if($validation === true)
{
@ -509,6 +689,50 @@
}
}
// Upload media
$textMediaIds = array();
foreach($textMedia as $mediumKey => $medium)
{
if(!is_null($medium))
{
$mediaId = $this->Media->createStationMedia(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('station-%d-%s', $station['id'], $mediumKey),
$medium['name'],
$medium['type'],
$medium['tmp_name']
);
$textMediaIds[$mediumKey] = $mediaId;
}
}
// Set media
if(array_key_exists('rightimage', $textMediaIds)) {
$this->Charactergroupsqueststations->setRightImageForStation(
$station['id'],
$textMediaIds['rightimage']
);
}
if(array_key_exists('rightav', $textMediaIds)) {
$this->Charactergroupsqueststations->setRightAvForStation(
$station['id'],
$textMediaIds['rightav']
);
}
if(array_key_exists('wrongimage', $textMediaIds)) {
$this->Charactergroupsqueststations->setWrongImageForStation(
$station['id'],
$textMediaIds['wrongimage']
);
}
if(array_key_exists('wrongav', $textMediaIds)) {
$this->Charactergroupsqueststations->setWrongAvForStation(
$station['id'],
$textMediaIds['wrongav']
);
}
// Redirect
if(!is_null($this->request->getPostParam('edit-task'))) {
// To task editing
@ -555,6 +779,7 @@
$this->set('seminary', $seminary);
$this->set('groupsgroup', $groupsgroup);
$this->set('quest', $quest);
$this->set('station', $station);
$this->set('title', $title);
$this->set('prolog', $prolog);
$this->set('task', $task);
@ -562,14 +787,16 @@
$this->set('latitude', $latitude);
$this->set('righttext', $rightText);
$this->set('wrongtext', $wrongText);
$this->set('mimetypes', $mimetypes);
$this->set('iconMimetypes', $iconMimetypes);
$this->set('imageMimetypes', $imageMimetypes);
$this->set('avMimetypes', $avMimetypes);
$this->set('stationtypes', $stationtypes);
$this->set('validation', $validation);
}
/**
* TODO Action: edittask.
* Action: edittask.
*
* Edit the task of a Character groups Quest Station.
*

View file

@ -590,15 +590,27 @@ CREATE TABLE `charactergroupsqueststations` (
`longitude` decimal(10,6) DEFAULT NULL,
`righttext` text COLLATE utf8mb4_unicode_ci NOT NULL,
`wrongtext` text COLLATE utf8mb4_unicode_ci NOT NULL,
`rightimage_id` int(11) DEFAULT NULL,
`rightav_id` int(11) DEFAULT NULL,
`wrongimage_id` int(11) DEFAULT NULL,
`wrongav_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `charactergroupsquest_id_2` (`charactergroupsquest_id`,`url`),
UNIQUE KEY `charactergroupsquest_id_3` (`charactergroupsquest_id`,`pos`),
KEY `charactergroupsquest_id` (`charactergroupsquest_id`),
KEY `charactergroupsqueststationtype_id` (`stationtype_id`),
KEY `stationpicture_id` (`stationpicture_id`) USING BTREE,
KEY `rightimage_id` (`rightimage_id`),
KEY `rightav_id` (`rightav_id`),
KEY `wrongimage_id` (`wrongimage_id`),
KEY `wrongav_id` (`wrongav_id`),
CONSTRAINT `charactergroupsqueststations_ibfk_1` FOREIGN KEY (`charactergroupsquest_id`) REFERENCES `charactergroupsquests` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `charactergroupsqueststations_ibfk_2` FOREIGN KEY (`stationpicture_id`) REFERENCES `seminarymedia` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `charactergroupsqueststations_ibfk_3` FOREIGN KEY (`stationtype_id`) REFERENCES `stationtypes` (`id`)
CONSTRAINT `charactergroupsqueststations_ibfk_3` FOREIGN KEY (`stationtype_id`) REFERENCES `stationtypes` (`id`),
CONSTRAINT `charactergroupsqueststations_ibfk_4` FOREIGN KEY (`rightimage_id`) REFERENCES `seminarymedia` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `charactergroupsqueststations_ibfk_5` FOREIGN KEY (`rightav_id`) REFERENCES `seminarymedia` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `charactergroupsqueststations_ibfk_6` FOREIGN KEY (`wrongimage_id`) REFERENCES `seminarymedia` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `charactergroupsqueststations_ibfk_7` FOREIGN KEY (`wrongav_id`) REFERENCES `seminarymedia` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

View file

@ -63,7 +63,7 @@
public function getStationById($stationId)
{
$data = $this->db->query(
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext '.
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext, rightimage_id, rightav_id, wrongimage_id, wrongav_id '.
'FROM charactergroupsqueststations '.
'WHERE id = ?',
'i',
@ -88,7 +88,7 @@
public function getStationByUrl($groupsquestId, $stationUrl)
{
$data = $this->db->query(
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext '.
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext, rightimage_id, rightav_id, wrongimage_id, wrongav_id '.
'FROM charactergroupsqueststations '.
'WHERE charactergroupsquest_id = ? AND url = ?',
'is',
@ -296,7 +296,7 @@
* @param int $stationId ID of Station to upload media for
* @param int $mediaId ID of Station media
*/
public function setPictureForStation($station, $mediaId)
public function setPictureForStation($stationId, $mediaId)
{
$this->db->query(
'UPDATE charactergroupsqueststations '.
@ -304,11 +304,59 @@
'WHERE id = ?',
'ii',
$mediaId,
$station
$stationId
);
}
/**
* Set the image for the right-text.
*
* @param int $stationId ID of Station to set image for
* @param int $mediaId ID of Seminary media to set
*/
public function setRightImageForStation($stationId, $mediaId)
{
$this->setMediaForStation($stationId, $mediaId, 'rightimage_id');
}
/**
* Set the audio/video for the right-text.
*
* @param int $stationId ID of Station to set audio/video for
* @param int $mediaId ID of Seminary media to set
*/
public function setRightAVForStation($stationId, $mediaId)
{
$this->setMediaForStation($stationId, $mediaId, 'rightav_id');
}
/**
* Set the image for the wrong-text.
*
* @param int $stationId ID of Station to set image for
* @param int $mediaId ID of Seminary media to set
*/
public function setWrongImageForStation($stationId, $mediaId)
{
$this->setMediaForStation($stationId, $mediaId, 'wrongimage_id');
}
/**
* Set the audio/video for the wrong-text.
*
* @param int $stationId ID of Station to set audio/video for
* @param int $mediaId ID of Seminary media to set
*/
public function setWrongAvForStation($stationId, $mediaId)
{
$this->setMediaForStation($stationId, $mediaId, 'wrongav_id');
}
/**
* Create a new Character groups Quest Station.
*
@ -437,6 +485,29 @@
);
}
/**
* Add a medium for a Character groups Quest Station.
*
* @param int $stationId ID of Station to upload media for
* @param int $mediaId ID of Seminary media
* @param string $field Field name to set media to
*/
private function setMediaForStation($stationId, $mediaId, $field)
{
$this->db->query(
sprintf(
'UPDATE charactergroupsqueststations '.
'SET %s = ? '.
'WHERE id = ?',
$field
),
'ii',
$mediaId,
$stationId
);
}
}
?>

View file

@ -557,6 +557,46 @@
}
/**
* Create a new Character groups Quest Station media by creating a new
* Seminarymedia .
*
* @param int $userId ID of user that does the upload
* @param int $seminaryId ID of Seminary
* @param string $filename Filename of uploading media
* @param string $description Description for media
* @param string $mimetype Mimetype of media
* @param string $tmpFilename Name of temporary uploaded file
* @return mixed ID of media record or false if upload failed
*/
public function createStationMedia($userId, $seminaryId, $filename, $description, $mimetype, $tmpFilename)
{
$mediaId = false;
$this->db->setAutocommit(false);
try {
// Create Seminary media record
$mediaId = $this->createSeminaryMedia($userId, $seminaryId, $filename, $description, $mimetype);
// Create filename
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminarymedia'].DS.$mediaId;
if(!move_uploaded_file($tmpFilename, $filename))
{
$this->db->rollback();
$mediaId = false;
}
}
catch(\nre\exceptions\DatamodelException $e) {
$this->db->rollback();
$this->db->setAutocommit(true);
}
$this->db->setAutocommit(true);
return $mediaId;
}
/**
* Create a new Achievement media by creating a new Seminarymedia and
* adding it to the list of media for Achievements.

View file

@ -39,6 +39,20 @@
default: echo _('Title invalid');
}
break;
case 'rightimage':
case 'rightav':
case 'wrongimage':
case 'wrongav':
switch($setting) {
case 'error': printf(_('Error during file upload: %s'), $value);
break;
case 'mimetype': printf(_('File has wrong type “%s”'), $value);
break;
case 'size': echo _('File exceeds size maximum');
break;
default: echo _('File invalid');
}
break;
} ?>
</li>
<?php endforeach ?>
@ -53,7 +67,7 @@
<input type="file" name="icon" />
<p><?=_('Allowed file types')?>:</p>
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<?php foreach($iconMimetypes 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>
@ -65,6 +79,9 @@
<input id="latitude" name="latitude" type="hidden" value="<?=$latitude?>" />
</fieldset>
<fieldset>
<legend><?=_('Basic data')?></legend>
<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="stationtype"><?=('Stationtype')?>:</label>
<select id="stationtype" name="stationtype">
<?php foreach($stationtypes as &$stationtype) : ?>
@ -80,16 +97,42 @@
</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="prolog"><?=_('Prolog')?>:</label><br />
<textarea id="prolog" name="prolog" placeholder="<?=_('Prolog')?>" style="width:100%; height:10em;"><?=$prolog?></textarea><br />
<label for="task"><?=_('Task')?>:</label><br />
<textarea id="task" name="task" placeholder="<?=_('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
</fieldset>
<fieldset>
<legend><?=_('Correctly solved')?></legend>
<input type="file" name="rightimage" />
<ul>
<?php foreach($imageMimetypes 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>
<input type="file" name="rightav" />
<ul>
<?php foreach($avMimetypes 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>
<label for="rightText"><?=('Right text')?>:</label><br />
<textarea id="rightText" name="rightText" placeholder="<?=_('Right text')?>" style="width:100%; height:10em;"><?=$righttext?></textarea><br />
</fieldset>
<fieldset>
<legend><?=_('Incorreclty solved')?></legend>
<input type="file" name="wrongimage" />
<ul>
<?php foreach($imageMimetypes 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>
<input type="file" name="wrongav" />
<ul>
<?php foreach($avMimetypes 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>
<label for="wrongText"><?=_('Wrong text')?>:</label><br />
<textarea id="wrongText" name="wrongText" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongtext?></textarea><br />
</fieldset>

View file

@ -39,6 +39,20 @@
default: echo _('Title invalid');
}
break;
case 'rightimage':
case 'rightav':
case 'wrongimage':
case 'wrongav':
switch($setting) {
case 'error': printf(_('Error during file upload: %s'), $value);
break;
case 'mimetype': printf(_('File has wrong type “%s”'), $value);
break;
case 'size': echo _('File exceeds size maximum');
break;
default: echo _('File invalid');
}
break;
} ?>
</li>
<?php endforeach ?>
@ -53,7 +67,7 @@
<input type="file" name="icon" />
<p><?=_('Allowed file types')?>:</p>
<ul>
<?php foreach($mimetypes as &$mimetype) : ?>
<?php foreach($iconMimetypes 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>
@ -65,6 +79,9 @@
<input id="latitude" name="latitude" type="hidden" value="<?=$latitude?>" />
</fieldset>
<fieldset>
<legend><?=_('Basic data')?></legend>
<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="stationtype"><?=('Stationtype')?>:</label>
<select id="stationtype" name="stationtype">
<?php foreach($stationtypes as &$stationtype) : ?>
@ -80,16 +97,75 @@
</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="prolog"><?=_('Prolog')?>:</label><br />
<textarea id="prolog" name="prolog" placeholder="<?=_('Prolog')?>" style="width:100%; height:10em;"><?=$prolog?></textarea><br />
<label for="task"><?=_('Task')?>:</label><br />
<textarea id="task" name="task" placeholder="<?=_('Task')?>" style="width:100%; height:10em;"><?=$task?></textarea><br />
<fieldset>
<legend><?=_('Correctly solved')?></legend>
<?php if(array_key_exists('rightimage', $station)) : ?>
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightimage']['url']))?>">
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightimage']['url'],'charactergroupsqueststation'))?>" />
</a>
<?php else : ?>
<i class="placeholder fa fa-picture-o fa-4x"></i><br />
<?php endif ?>
<br />
<input type="file" name="rightimage" />
<ul>
<?php foreach($imageMimetypes 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>
<?php if(array_key_exists('rightav', $station)) : ?>
<?php if(strpos($station['rightav']['mimetype'], 'audio') !== false) : ?>
<audio controls="controls" autoplay="false" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightav']['url'],'charactergroupsqueststation'))?>"></audio>
<?php else : ?>
<video controls="controls" autoplay="false" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightav']['url'],'charactergroupsqueststation'))?>"></video>
<?php endif ?>
<?php else : ?>
<i class="placeholder fa fa-film fa-4x"></i><br />
<?php endif ?>
<input type="file" name="rightav" />
<ul>
<?php foreach($avMimetypes 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>
<label for="rightText"><?=('Right text')?>:</label><br />
<textarea id="rightText" name="rightText" placeholder="<?=_('Right text')?>" style="width:100%; height:10em;"><?=$righttext?></textarea><br />
</fieldset>
<fieldset>
<legend><?=_('Incorreclty solved')?></legend>
<?php if(array_key_exists('wrongimage', $station)) : ?>
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongimage']['url']))?>">
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongimage']['url'],'charactergroupsqueststation'))?>" />
</a>
<?php else : ?>
<i class="placeholder fa fa-picture-o fa-4x"></i><br />
<?php endif ?>
<br />
<input type="file" name="wrongimage" />
<ul>
<?php foreach($imageMimetypes 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>
<?php if(array_key_exists('wrongav', $station)) : ?>
<?php if(strpos($station['wrongav']['mimetype'], 'audio') !== false) : ?>
<audio controls="controls" autoplay="false" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongav']['url'],'charactergroupsqueststation'))?>"></audio>
<?php else : ?>
<video controls="controls" autoplay="false" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongav']['url'],'charactergroupsqueststation'))?>"></video>
<?php endif ?>
<?php else : ?>
<i class="placeholder fa fa-film fa-4x"></i><br />
<?php endif ?>
<input type="file" name="wrongav" />
<ul>
<?php foreach($avMimetypes 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>
<label for="wrongText"><?=_('Wrong text')?>:</label><br />
<textarea id="wrongText" name="wrongText" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongtext?></textarea><br />
</fieldset>

View file

@ -122,10 +122,34 @@
<?php if($solved): ?>
<div class="text">
<?php if(array_key_exists('rightimage', $station)) : ?>
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightimage']['url']))?>">
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightimage']['url'],'charactergroupsqueststation'))?>" />
</a><br />
<?php endif ?>
<?php if(array_key_exists('rightav', $station)) : ?>
<?php if(strpos($station['rightav']['mimetype'], 'audio') !== false) : ?>
<audio controls="controls" autoplay="autoplay" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightav']['url'],'charactergroupsqueststation'))?>"></audio>
<?php else : ?>
<video controls="controls" autoplay="autoplay" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['rightav']['url'],'charactergroupsqueststation'))?>"></video>
<?php endif ?>
<?php endif ?>
<?=$t->t($station['righttext'])?>
</div>
<?php elseif($tried) : ?>
<div class="text">
<?php if(array_key_exists('wrongimage', $station)) : ?>
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongimage']['url']))?>">
<img src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongimage']['url'],'charactergroupsqueststation'))?>" />
</a><br />
<?php endif ?>
<?php if(array_key_exists('wrongav', $station)) : ?>
<?php if(strpos($station['wrongav']['mimetype'], 'audio') !== false) : ?>
<audio controls="controls" autoplay="autoplay" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongav']['url'],'charactergroupsqueststation'))?>"></audio>
<?php else : ?>
<video controls="controls" autoplay="autoplay" preload="metadata" src="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongav']['url'],'charactergroupsqueststation'))?>" poster="<?=$linker->link(array('media','seminary',$seminary['url'],$station['wrongimage']['url']))?>"></video>
<?php endif ?>
<?php endif ?>
<?=$t->t($station['wrongtext'])?>
</div>
<?php else : ?>