Merge
This commit is contained in:
commit
df1a70fe3c
10 changed files with 139 additions and 44 deletions
|
|
@ -1,2 +1,3 @@
|
|||
syntax: glob
|
||||
media/*
|
||||
tmp/*
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@
|
|||
public static $dirs = array(
|
||||
'locale' => 'locale',
|
||||
'media' => 'media',
|
||||
'questtypes' => 'questtypes'
|
||||
'questtypes' => 'questtypes',
|
||||
'temporary' => 'tmp'
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -86,8 +87,7 @@
|
|||
array('characters/(?!(index|character))', 'characters/index/$1', true),
|
||||
array('charactergroups/(?!(index|groupsgroup|group))', 'charactergroups/index/$1', true),
|
||||
array('charactergroupsquests/(?!(quest))', 'charactergroupsquests/quest/$1', true),
|
||||
array('media/(.*)', 'media/$1?layout=binary', false),
|
||||
array('media/(.*)', 'media/index/$1', true)
|
||||
array('media/(.*)', 'media/$1?layout=binary', false)
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -104,8 +104,7 @@
|
|||
//array('seminaries/seminary/(.*)', '$1', false)
|
||||
array('characters/index/(.*)', 'characters/$1', true),
|
||||
array('charactergroup/index/(.*)', 'charactergroup/$1', true),
|
||||
array('charactergroupsquests/quest/(.*)', 'charactergroupsquests/$1', true),
|
||||
array('media/index/(.*)', 'media/$1', true)
|
||||
array('charactergroupsquests/quest/(.*)', 'charactergroupsquests/$1', true)
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
* @param string $seminaryUrl URL-title of the Seminary
|
||||
* @param string $mediaUrl URL-name of the medium
|
||||
*/
|
||||
public function index($seminaryUrl, $mediaUrl)
|
||||
public function index($seminaryUrl, $mediaUrl, $action=null)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
|
@ -80,6 +80,10 @@
|
|||
// Get Media
|
||||
$media = $this->Media->getMediaByUrl($seminary['id'], $mediaUrl);
|
||||
|
||||
// Get format
|
||||
$format = explode('/', $media['mimetype']);
|
||||
$format = $format[1];
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: ".$media['mimetype']."");
|
||||
|
||||
|
|
@ -94,9 +98,38 @@
|
|||
return;
|
||||
}
|
||||
|
||||
// Load and process file
|
||||
$file = null;
|
||||
switch($action)
|
||||
{
|
||||
// No action
|
||||
case null:
|
||||
// Do not process the file
|
||||
$file = file_get_contents($media['filename']);
|
||||
break;
|
||||
case 'questgroup':
|
||||
if(!in_array(strtoupper($format), static::getImageTypes())) {
|
||||
$file = file_get_contents($media['filename']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = static::resizeImage(
|
||||
$media['filename'],
|
||||
$format,
|
||||
480
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ParamsNotValidException($action);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('media', $media);
|
||||
$this->set('file', $file);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -138,6 +171,70 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get supported image types.
|
||||
*
|
||||
* @return array List of supported image types
|
||||
*/
|
||||
private static function getImageTypes()
|
||||
{
|
||||
$im = new \Imagick();
|
||||
|
||||
|
||||
return $im->queryFormats();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize an image.
|
||||
*
|
||||
* @param string $fileName Absolute pathname of image to resize
|
||||
* @param string $mimeType Mimetype of target image
|
||||
* @param int $size New size to resize to
|
||||
*/
|
||||
private static function resizeImage($fileName, $mimeType, $size)
|
||||
{
|
||||
// Read image from cache
|
||||
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.'media-'.basename($fileName).'-'.$size;
|
||||
if(file_exists($tempFileName))
|
||||
{
|
||||
// Check age of file
|
||||
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
|
||||
// Too old, delete
|
||||
unlink($tempFileName);
|
||||
}
|
||||
else {
|
||||
// Valid, read and return
|
||||
return file_get_contents($tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ImageMagick
|
||||
$im = new \Imagick($fileName);
|
||||
|
||||
// Calculate new size
|
||||
$geometry = $im->getImageGeometry();
|
||||
if($geometry['width'] < $size) {
|
||||
$size = $geometry['width'];
|
||||
}
|
||||
|
||||
// Process
|
||||
$im->thumbnailImage($size, 5000, true);
|
||||
$im->contrastImage(1);
|
||||
$im->setImageFormat($mimeType);
|
||||
|
||||
// Save temporary file
|
||||
$im->writeImage($tempFileName);
|
||||
|
||||
|
||||
// Return resized image
|
||||
return $im;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -108,15 +108,18 @@
|
|||
if(count($childQuestgroupshierarchy) == 0)
|
||||
{
|
||||
$quests = $this->Quests->getMainquestsForQuestgroup($questgroup['id']);
|
||||
for($i=0; $i<count($quests); $i++)
|
||||
foreach($quests as $i => &$quest)
|
||||
{
|
||||
// Set status
|
||||
$quest['solved'] = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||
|
||||
// Check permission
|
||||
if($i > 0) {
|
||||
$quests[$i]['access'] = $this->Quests->hasCharacterSolvedQuest($quests[$i-1]['id'], $character['id']);
|
||||
$quest['access'] = $this->Quests->hasCharacterSolvedQuest($quests[$i-1]['id'], $character['id']);
|
||||
}
|
||||
|
||||
// Attach sidequests
|
||||
$quests[$i]['sidequests'] = $this->Quests->getSidequestsForQuest($quests[$i]['id']);
|
||||
$quests[$i]['sidequests'] = $this->Quests->getSidequestsForQuest($quest['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'users', 'questgroupshierarchy', 'questgroups');
|
||||
public $models = array('seminaries', 'users', 'questgroupshierarchy', 'questgroups', 'media');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
|
|
@ -101,22 +101,31 @@
|
|||
$hierarchy['questgroups'] = $this->Questgroups->getQuestgroupsForHierarchy($hierarchy['id']);
|
||||
|
||||
// Get additional data
|
||||
for($i=0; $i<count($hierarchy['questgroups']); $i++)
|
||||
//for($i=0; $i<count($hierarchy['questgroups']); $i++)
|
||||
foreach($hierarchy['questgroups'] as $i => &$questgroup)
|
||||
{
|
||||
// Get first Questgroup text
|
||||
$text = $this->Questgroups->getFirstQuestgroupText($hierarchy['questgroups'][$i]['id']);
|
||||
$text = $this->Questgroups->getFirstQuestgroupText($questgroup['id']);
|
||||
if(!empty($text))
|
||||
{
|
||||
$text = \hhu\z\Utils::shortenString($text['text'], 100, 120).' …';
|
||||
$hierarchy['questgroups'][$i]['text'] = $text;
|
||||
$questgroup['text'] = $text;
|
||||
}
|
||||
|
||||
// Get Character XPs
|
||||
$hierarchy['questgroups'][$i]['character_xps'] = $this->Questgroups->getAchievedXPsForQuestgroup($hierarchy['questgroups'][$i]['id'], $character['id']);
|
||||
$hierarchy['questgroups'][$i]['character_xps'] = $this->Questgroups->getAchievedXPsForQuestgroup($questgroup['id'], $character['id']);
|
||||
|
||||
// Check permission of Questgroups
|
||||
if($i >= 1) {
|
||||
$hierarchy['questgroups'][$i]['access'] = $this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id']);
|
||||
$questgroup['access'] = $this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id']);
|
||||
}
|
||||
|
||||
// Get Media
|
||||
$questgroup['picture'] = null;
|
||||
try {
|
||||
$questgroup['picture'] = $this->Media->getMediaById($questgroup['questgroupspicture_id']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
if(is_null($parentQuestgroupId))
|
||||
{
|
||||
$questgroups = $this->db->query(
|
||||
'SELECT id, questgroupshierarchy_id, pos, title, url '.
|
||||
'SELECT id, questgroupshierarchy_id, pos, title, url, questgroupspicture_id '.
|
||||
'FROM questgroups '.
|
||||
'WHERE questgroups.questgroupshierarchy_id = ? AND parent_questgroup_id IS NULL '.
|
||||
'ORDER BY questgroups.pos ASC',
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
else
|
||||
{
|
||||
$questgroups = $this->db->query(
|
||||
'SELECT id, questgroupshierarchy_id, pos, title, url '.
|
||||
'SELECT id, questgroupshierarchy_id, pos, title, url, questgroupspicture_id '.
|
||||
'FROM questgroups '.
|
||||
'WHERE questgroups.questgroupshierarchy_id = ? AND parent_questgroup_id = ? '.
|
||||
'ORDER BY questgroups.pos ASC',
|
||||
|
|
|
|||
0
tmp/empty
Normal file
0
tmp/empty
Normal file
|
|
@ -1 +1 @@
|
|||
<?=file_get_contents($media['filename'])?>
|
||||
<?=$file?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<h1><?=_('Seminaries')?></h1>
|
||||
<h2><?=$seminary['title']?></h2>
|
||||
<h2><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></h2>
|
||||
|
||||
<?=$questgroupshierarchypath?>
|
||||
<?=$questgroupspicture?>
|
||||
|
|
@ -19,12 +18,12 @@
|
|||
<div class="qgtitle"><a href="<?=$linker->link(array('questgroups','questgroup',$seminary['url'],$group['url']))?>"><i class="fa fa-square-o fa-fw"></i><?=$group['title']?></a></div>
|
||||
<div class="qgprogress cf">
|
||||
<div class="xpbar">
|
||||
<span style="width:25%"></span>
|
||||
<span style="width:<?=round($group['character_xps']/$group['xps']*100)?>%"></span>
|
||||
</div>
|
||||
<p class="xpnumeric"><?=$group['character_xps']?> / <?=$group['xps']?> XP</p>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?=$hierarchy['title_singular']?> <?=_('locked')?>
|
||||
<div class="qgtitle"><i class="fa fa-square-o fa-fw"></i><?=$hierarchy['title_singular']?> <?=_('locked')?></div>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endforeach?>
|
||||
|
|
@ -35,33 +34,21 @@
|
|||
<?php if(isset($quests) && !is_null($quests)) : ?>
|
||||
<h3><?=_('Quests')?></h3>
|
||||
<ul class="qglist">
|
||||
<li>
|
||||
<div class="qgtitle">
|
||||
<a href="#" class="solved"><i class="fa fa-check-square-o fa-fw"></i>Beispiel für eine gelöste Quest</a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="qgtitle">
|
||||
<a href="#" class="bonus"><i class="fa fa-share-square-o fa-fw"></i>Beispiel für eine gefunde Side-Questline</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php foreach($quests as &$quest) : ?>
|
||||
<li>
|
||||
<li class="qgtitle">
|
||||
<?php if(!array_key_exists('access', $quest) || $quest['access']) : ?>
|
||||
<div class="qgtitle">
|
||||
<a href="<?=$linker->link(array('quests','quest',$seminary['url'],$questgroup['url'],$quest['url']))?>"><i class="fa fa-square-o fa-fw"></i><?=$quest['title']?></a>
|
||||
</div>
|
||||
<a href="<?=$linker->link(array('quests','quest',$seminary['url'],$questgroup['url'],$quest['url']))?>" <?php if($quest['solved']) : ?>class="solved"<?php endif ?>><i class="fa <?=($quest['solved']) ? 'fa-check-square-o' : 'fa-share-square-o'?> fa-fw"></i><?=$quest['title']?></a>
|
||||
<?php if(count($quest['sidequests']) > 0) : ?>
|
||||
<br />
|
||||
<?=_('containing optional Quests')?>:
|
||||
<ul>
|
||||
<ul class="gplist">
|
||||
<?php foreach($quest['sidequests'] as &$sidequest) : ?>
|
||||
<li><?=$sidequest['title']?></li>
|
||||
<li class="qgtitle">
|
||||
<a href="<?=$linker->link(array('quests','quest',$seminary['url'],$questgroup['url'],$sidequest['url']))?>" class="bonus"><i class="fa fa-share-square-o fa-fw"><?=$sidequest['title']?></i></a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<?php else : ?>
|
||||
<?=_('locked')?>
|
||||
<i class="fa fa-share-square-o fa-fw"><?=_('locked')?></i>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<h1><?=_('Seminaries')?></h1>
|
||||
<h2><?=$seminary['title']?></h2>
|
||||
<h2><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></h2>
|
||||
<h3><?=_('Description')?></h3>
|
||||
<p><?=\hhu\z\Utils::t($seminary['description'])?></p>
|
||||
|
||||
|
|
@ -15,7 +14,7 @@
|
|||
<a href="<?=$linker->link(array('questgroups','questgroup',$seminary['url'],$group['url']))?>"><?=$group['title']?></a></p>
|
||||
<div class="cf">
|
||||
<div class="xpbar">
|
||||
<span style="width:25%"></span>
|
||||
<span style="width:<?=round($group['character_xps']*100/$group['xps'])?>%"></span>
|
||||
</div>
|
||||
<p class="xpnumeric"><?=$group['character_xps']?> / <?=$group['xps']?> XP</p>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue