add correct abstract to seminary page
This commit is contained in:
parent
3c8458b98e
commit
e10d1d0650
4 changed files with 78 additions and 6 deletions
|
|
@ -46,6 +46,38 @@
|
||||||
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
|
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cut a string to the given length but only word boundaries.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param string $string String to cut
|
||||||
|
* @param int $length Length to cut string
|
||||||
|
* @param int $scope Maximum length to cut string regardless word boundaries
|
||||||
|
* @return string Cutted string
|
||||||
|
*/
|
||||||
|
public static function shortenString($string, $length, $scope)
|
||||||
|
{
|
||||||
|
// Determine length
|
||||||
|
$length = min($length, strlen($string));
|
||||||
|
|
||||||
|
// Look for word boundary
|
||||||
|
if(($pos = strpos($string, ' ', $length)) !== false)
|
||||||
|
{
|
||||||
|
// Check if boundary is outside of scope
|
||||||
|
if($pos > $length + $scope) {
|
||||||
|
$pos = strrpos(substr($string, 0, $pos), ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$pos = strlen($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Cut string and return it
|
||||||
|
return substr($string, 0, $pos);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -100,9 +100,21 @@
|
||||||
// Get Questgroups
|
// Get Questgroups
|
||||||
$hierarchy['questgroups'] = $this->Questgroups->getQuestgroupsForHierarchy($hierarchy['id']);
|
$hierarchy['questgroups'] = $this->Questgroups->getQuestgroupsForHierarchy($hierarchy['id']);
|
||||||
|
|
||||||
// Check permission of Questgroups
|
// Get additional data
|
||||||
for($i=1; $i<count($hierarchy['questgroups']); $i++) {
|
for($i=0; $i<count($hierarchy['questgroups']); $i++)
|
||||||
$hierarchy['questgroups'][$i]['access'] = $this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id']);
|
{
|
||||||
|
// Get first Questgroup text
|
||||||
|
$text = $this->Questgroups->getFirstQuestgroupText($hierarchy['questgroups'][$i]['id']);
|
||||||
|
if(!empty($text))
|
||||||
|
{
|
||||||
|
$text = \hhu\z\Utils::shortenString($text['text'], 100, 120).' …';
|
||||||
|
$hierarchy['questgroups'][$i]['text'] = $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check permission of Questgroups
|
||||||
|
if($i >= 1) {
|
||||||
|
$hierarchy['questgroups'][$i]['access'] = $this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get first texts of a Questgroup.
|
||||||
|
*
|
||||||
|
* @param int $questgroupId ID of a Questgroup
|
||||||
|
* @return array First Text of this Questgroup
|
||||||
|
*/
|
||||||
|
public function getFirstQuestgroupText($questgroupId)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT id, pos, text '.
|
||||||
|
'FROM questgrouptexts '.
|
||||||
|
'WHERE questgroup_id = ? '.
|
||||||
|
'ORDER BY pos ASC '.
|
||||||
|
'LIMIT 1',
|
||||||
|
'i',
|
||||||
|
$questgroupId
|
||||||
|
);
|
||||||
|
if(!empty($data)) {
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next Questgroup.
|
* Get the next Questgroup.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<h1><?=_('Seminaries')?></h1>
|
<h1><?=_('Seminaries')?></h1>
|
||||||
<h2><?=$seminary['title']?></h2>
|
<h2><?=$seminary['title']?></h2>
|
||||||
<h3>Beschreibung</h3>
|
<h3><?=_('Description')?></h3>
|
||||||
<p><?=\hhu\z\Utils::t($seminary['description'])?></p>
|
<p><?=\hhu\z\Utils::t($seminary['description'])?></p>
|
||||||
|
|
||||||
<?php foreach($questgroupshierarchy as &$hierarchy) : ?>
|
<?php foreach($questgroupshierarchy as &$hierarchy) : ?>
|
||||||
|
|
@ -18,7 +18,9 @@
|
||||||
</div>
|
</div>
|
||||||
<p class="xpnumeric">350 / 450 XP</p>
|
<p class="xpnumeric">350 / 450 XP</p>
|
||||||
</div>
|
</div>
|
||||||
<p>Einleitungstext: Mit völlig verseuchtem Tagewerk machst du dich an die Arbeit und stellst schnell fest...</p>
|
<?php if(array_key_exists('text', $group)) : ?>
|
||||||
|
<p><?=$group['text']?></p>
|
||||||
|
<?php endif ?>
|
||||||
<a href="<?=$linker->link(array('questgroups','questgroup',$seminary['url'],$group['url']))?>" class="cta orange">Auf ins Abenteuer!</a>
|
<a href="<?=$linker->link(array('questgroups','questgroup',$seminary['url'],$group['url']))?>" class="cta orange">Auf ins Abenteuer!</a>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<?=_('locked')?></p>
|
<?=_('locked')?></p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue