From 2437f331aa052410fb128afbf6084213469059aa Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 13 Apr 2014 15:10:35 +0200 Subject: [PATCH] implement Achievements --- agents/intermediate/AchievementsAgent.inc | 35 ++ app/controllers/SeminaryRoleController.inc | 134 ++++++ controllers/AchievementsController.inc | 162 +++++++ controllers/CharactersController.inc | 4 + controllers/MediaController.inc | 54 ++- controllers/SeminarybarController.inc | 7 +- models/AchievementsModel.inc | 471 +++++++++++++++++++++ models/MediaModel.inc | 17 +- views/html/achievements/index.tpl | 28 ++ views/html/characters/character.tpl | 30 +- views/html/seminarybar/index.tpl | 11 +- 11 files changed, 914 insertions(+), 39 deletions(-) create mode 100644 agents/intermediate/AchievementsAgent.inc create mode 100644 controllers/AchievementsController.inc create mode 100644 views/html/achievements/index.tpl diff --git a/agents/intermediate/AchievementsAgent.inc b/agents/intermediate/AchievementsAgent.inc new file mode 100644 index 00000000..e6b965f9 --- /dev/null +++ b/agents/intermediate/AchievementsAgent.inc @@ -0,0 +1,35 @@ + + * @copyright 2014 Heinrich-Heine-Universität Düsseldorf + * @license http://www.gnu.org/licenses/gpl.html + * @link https://bitbucket.org/coderkun/the-legend-of-z + */ + + namespace hhu\z\agents\intermediate; + + + /** + * Agent to list Achievements. + * + * @author Oliver Hanraths + */ + class AchievementsAgent extends \nre\agents\IntermediateAgent + { + + + + + /** + * Action: index. + */ + public function index(\nre\core\Request $request, \nre\core\Response $response) + { + } + + } + +?> diff --git a/app/controllers/SeminaryRoleController.inc b/app/controllers/SeminaryRoleController.inc index 36a9b439..9c06fdf1 100644 --- a/app/controllers/SeminaryRoleController.inc +++ b/app/controllers/SeminaryRoleController.inc @@ -73,6 +73,9 @@ // Check permissions $this->checkPermission($request, $response); + + // Check achievements + $this->checkAchievements($request, $response); } @@ -131,6 +134,137 @@ } } + + /** + * Check for newly achieved Achievements. + */ + private function checkAchievements(\nre\core\Request $request, \nre\core\Response $response) + { + // Get Seminary + $seminary = self::$seminary; + + // Get Character + $character = self::$character; + + // Get unachieved Achievments + $achievements = array_merge( + $this->Achievements->getUnachhievedAchievementsForCharacter($seminary['id'], $character['id']), + $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary($seminary['id']) + ); + + // Check conditions + foreach($achievements as &$achievement) + { + // Get conditions + $conditions = array(); + $progress = 0; + switch($achievement['condition']) + { + // Date conditions + case 'date': + $conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']); + foreach($conditionsDate as &$condition) + { + $conditions[] = array( + 'func' => 'checkAchievementConditionDate', + 'params' => array( + $condition['select'] + ) + ); + } + break; + // Character conditions + case 'character': + $conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']); + foreach($conditionsCharacter as &$condition) + { + $conditions[] = array( + 'func' => 'checkAchievementConditionCharacter', + 'params' => array( + $condition['field'], + $condition['value'], + $character['id'] + ) + ); + } + break; + // Quest conditions + case 'quest': + $conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']); + foreach($conditionsQuest as &$condition) + { + $conditions[] = array( + 'func' => 'checkAchievementConditionQuest', + 'params' => array( + $condition['field'], + $condition['count'], + $condition['value'], + $condition['status'], + $condition['groupby'], + $condition['quest_id'], + $character['id'] + ) + ); + } + break; + // Achievement conditions + case 'achievement': + $conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']); + foreach($conditionsAchievement as &$condition) + { + $conditions[] = array( + 'func' => 'checkAchievementConditionAchievement', + 'params' => array( + $condition['field'], + $condition['count'], + $condition['value'], + $condition['groupby'], + $condition['meta_achievement_id'], + $character['id'] + ) + ); + } + break; + } + + // Check conditions + $achieved = ($achievement['all_conditions'] == 1); + foreach($conditions as &$condition) + { + // Calculate result of condition + $result = call_user_func_array( + array( + $this->Achievements, + $condition['func'] + ), + $condition['params'] + ); + + // The overall result and abort if possible + if($achievement['all_conditions']) + { + if(!$result) { + $achieved = false; + break; + } + } + else + { + if($result) { + $achieved = true; + break; + } + } + + } + + // Set status + if($achieved) { + $this->Achievements->setAchievementAchieved($achievement['id'], $character['id']); + } + } + } + } ?> diff --git a/controllers/AchievementsController.inc b/controllers/AchievementsController.inc new file mode 100644 index 00000000..b6ef6595 --- /dev/null +++ b/controllers/AchievementsController.inc @@ -0,0 +1,162 @@ + + * @copyright 2014 Heinrich-Heine-Universität Düsseldorf + * @license http://www.gnu.org/licenses/gpl.html + * @link https://bitbucket.org/coderkun/the-legend-of-z + */ + + namespace hhu\z\controllers; + + + /** + * Controller of the Agent to list Achievements. + * + * @author Oliver Hanraths + */ + class AchievementsController extends \hhu\z\controllers\SeminaryRoleController + { + /** + * Required models + * + * @var array + */ + public $models = array('achievements', 'seminaries', 'media'); + /** + * User permissions + * + * @var array + */ + public $permissions = array( + 'index' => array('admin', 'moderator', 'user') + ); + /** + * User seminary permissions + * + * @var array + */ + public $seminaryPermissions = array( + 'index' => array('admin', 'moderator', 'user') + ); + + + + + /** + * Action: index. + * + * List Achievements of a Seminary. + * + * @throws IdNotFoundException + * @param string $seminaryUrl URL-Title of Seminary + */ + public function index($seminaryUrl) + { + // Get Seminary + $seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl); + + // Get Character + $character = IntermediateController::$character; + + // Get Achievements + $achievements = $this->Achievements->getAchievementsForSeminary($seminary['id']); + foreach($achievements as &$achievement) + { + // Get status for Character + $achieved = $this->Achievements->hasCharacterAchievedAchievement($achievement['id'], $character['id']); + + // Get Character progress + if(!$achieved && $achievement['progress']) + { + $conditions = array(); + switch($achievement['condition']) + { + // Character conditions + case 'character': + $conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']); + foreach($conditionsCharacter as &$condition) + { + $conditions[] = array( + 'func' => 'getAchievementConditionCharacterProgress', + 'params' => array( + $condition['field'], + $condition['value'], + $character['id'] + ) + ); + } + break; + // Quest conditions + case 'quest': + $conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']); + foreach($conditionsQuest as &$condition) + { + $conditions[] = array( + 'func' => 'getAchievementConditionQuestProgress', + 'params' => array( + $condition['field'], + $condition['count'], + $condition['value'], + $condition['status'], + $condition['groupby'], + $condition['quest_id'], + $character['id'] + ) + ); + } + break; + // Achievement conditions + case 'achievement': + $conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']); + foreach($conditionsAchievement as &$condition) + { + $conditions[] = array( + 'func' => 'getAchievementConditionAchievementProgress', + 'params' => array( + $condition['field'], + $condition['count'], + $condition['value'], + $condition['groupby'], + $condition['meta_achievement_id'], + $character['id'] + ) + ); + } + break; + } + + $characterProgresses = array(); + foreach($conditions as &$condition) + { + // Calculate progress of condition + $characterProgresses[] = call_user_func_array( + array( + $this->Achievements, + $condition['func'] + ), + $condition['params'] + ); + } + + $achievement['characterProgress'] = array_sum($characterProgresses) / count($characterProgresses); + } + + // Get media + $achievement['media_index'] = 'unachieved_achievementsmedia_id'; + if($achieved) { + $achievement['media_index'] = 'achieved_achievementsmedia_id'; + } + } + + + // Pass data to view + $this->set('seminary', $seminary); + $this->set('achievements', $achievements); + } + + } + +?> diff --git a/controllers/CharactersController.inc b/controllers/CharactersController.inc index e0a14362..fbeb0ead 100644 --- a/controllers/CharactersController.inc +++ b/controllers/CharactersController.inc @@ -120,6 +120,9 @@ // Get Character groups $groups = $this->Charactergroups->getGroupsForCharacter($character['id']); + // Get Achievements + $achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id']); + // Pass data to view $this->set('seminary', $seminary); @@ -127,6 +130,7 @@ $this->set('characterfields', $characterfields); $this->set('user', $user); $this->set('groups', $groups); + $this->set('achievements', $achievements); } diff --git a/controllers/MediaController.inc b/controllers/MediaController.inc index 35105c4a..4036954b 100644 --- a/controllers/MediaController.inc +++ b/controllers/MediaController.inc @@ -28,7 +28,7 @@ 'index' => array('admin', 'moderator', 'user', 'guest'), 'seminaryheader' => array('admin', 'moderator', 'user', 'guest'), 'seminary' => array('admin', 'moderator', 'user', 'guest'), - 'avatar' => array('admin', 'moderator', 'user') + 'achievement' => array('admin', 'moderator', 'user', 'guest') ); /** * User seminary permissions @@ -36,14 +36,15 @@ * @var array */ public $seminaryPermissions = array( - 'seminary' => array('admin', 'moderator', 'user', 'guest') + 'seminary' => array('admin', 'moderator', 'user', 'guest'), + 'achievement' => array('admin', 'moderator', 'user', 'guest') ); /** * Required models * * @var array */ - public $models = array('seminaries', 'media'); + public $models = array('seminaries', 'achievements', 'media'); @@ -153,6 +154,53 @@ } + /** + * Action: achievement + * + * Display the achievement of a Seminary. + * + * @throws IdNotFoundException + * @param string $seminaryUrl URL-title of the Seminary + * @param string $achievementUrl URL-title of the Achievement + * @param string $action Action for processing the media + */ + public function achievement($seminaryUrl, $achievementUrl) + { + // Get Seminary + $seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl); + + // Get Character + $character = IntermediateController::$character; + + // Get Achievement + $achievement = $this->Achievements->getAchievementByUrl($seminary['id'], $achievementUrl); + + // Get media + $index = ''; + if(is_null($character) || !$this->Achievements->hasCharacterAchievedAchievement($achievement['id'], $character['id'])) { + $index = 'unachieved_achievementsmedia_id'; + } + else { + $index = 'achieved_achievementsmedia_id'; + } + if(is_null($achievement[$index])) { + throw new \nre\exceptions\IdNotFoundException($achievementUrl); + } + $media = $this->Media->getSeminaryMediaById($achievement[$index]); + + // Get file + $file = $this->getMediaFile($media, null); + if(is_null($file)) { + return; + } + + + // Pass data to view + $this->set('media', $media); + $this->set('file', $file); + } + + /** diff --git a/controllers/SeminarybarController.inc b/controllers/SeminarybarController.inc index 04963719..d3253096 100644 --- a/controllers/SeminarybarController.inc +++ b/controllers/SeminarybarController.inc @@ -25,7 +25,7 @@ * * @var array */ - public $models = array('characters', 'quests', 'questgroups'); + public $models = array('characters', 'quests', 'questgroups', 'achievements'); @@ -53,11 +53,16 @@ $lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']); } + // Get last achieved Achievement + $achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id']); + $lastAchievement = array_shift($achievements); + // Pass data to view $this->set('seminary', $seminary); $this->set('character', $character); $this->set('lastQuest', $lastQuest); + $this->set('lastAchievement', $lastAchievement); } } diff --git a/models/AchievementsModel.inc b/models/AchievementsModel.inc index 760c9f06..a426efa2 100644 --- a/models/AchievementsModel.inc +++ b/models/AchievementsModel.inc @@ -31,6 +31,477 @@ parent::__construct(); } + + + + /** + * Get an Achievement by its URL. + * + * @param int $seminaryId ID of Seminary + * @param string $achievementUrl URL-title of Achievement + * @return array Achievement data + */ + public function getAchievementByUrl($seminaryId, $achievementUrl) + { + $data = $this->db->query( + 'SELECT achievements.id, achievementconditions.condition, title, url, description, progress, unachieved_achievementsmedia_id, achieved_achievementsmedia_id '. + 'FROM achievements '. + 'LEFT JOIN achievementconditions ON achievementconditions.id = achievements.achievementcondition_id '. + 'WHERE seminary_id = ? AND url = ?', + 'is', + $seminaryId, $achievementUrl + ); + if(empty($data)) { + throw new \nre\exceptions\IdNotFoundException($achievementUrl); + } + + + return $data[0]; + } + + + /** + * Get all Achievements of a Seminary. + * + * @param int $seminaryId ID of Seminary to get Achievements of + * @return array Achievements data + */ + public function getAchievementsForSeminary($seminaryId, $includeHidden=false) + { + return $this->db->query( + 'SELECT achievements.id, achievementconditions.condition, title, url, description, progress, unachieved_achievementsmedia_id, achieved_achievementsmedia_id '. + 'FROM achievements '. + 'LEFT JOIN achievementconditions ON achievementconditions.id = achievements.achievementcondition_id '. + 'WHERE seminary_id = ? AND hidden <= ?', + 'ii', + $seminaryId, $includeHidden + ); + } + + + /** + * Get all not yet achieved Achievements for a Seminary that can + * only be achieved once (only by one Character). + * + * @param int $seminaryId ID of Seminary + * @return array Achievements data + */ + public function getUnachievedOnlyOnceAchievementsForSeminary($seminaryId) + { + return $this->db->query( + 'SELECT achievements.id, achievementconditions.condition, title, url, description, progress, hidden, only_once, all_conditions, unachieved_achievementsmedia_id, achieved_achievementsmedia_id '. + 'FROM achievements '. + 'LEFT JOIN achievementconditions ON achievementconditions.id = achievements.achievementcondition_id '. + 'WHERE achievements.seminary_id = ? AND only_once = 1 AND NOT EXISTS ('. + 'SELECT character_id '. + 'FROM achievements_characters '. + 'WHERE achievements_characters.achievement_id = achievements.id'. + ')', + 'i', + $seminaryId + ); + } + + + /** + * Get all achieved Achievements for a Character. + * + * @param int $characterId ID of Character + * @return array Achievements data + */ + public function getAchievedAchievementsForCharacter($characterId) + { + return $this->db->query( + 'SELECT achievements.id, achievements_characters.created, achievements.title, achievements.url, achievements.description, achievements.progress, unachieved_achievementsmedia_id, achieved_achievementsmedia_id '. + 'FROM achievements '. + 'INNER JOIN achievements_characters ON achievements_characters.achievement_id = achievements.id '. + 'WHERE achievements_characters.character_id = ? '. + 'ORDER BY achievements_characters.created DESC', + 'i', + $characterId + ); + } + + + /** + * Get all not yet achieved Achievements for a Character. + * + * @param int $seminaryId ID of Seminary + * @param int $characterId ID of Character + * @return array Achievements data + */ + public function getUnachhievedAchievementsForCharacter($seminaryId, $characterId) + { + return $this->db->query( + 'SELECT achievements.id, achievementconditions.condition, title, url, description, progress, hidden, only_once, all_conditions, unachieved_achievementsmedia_id, achieved_achievementsmedia_id '. + 'FROM achievements '. + 'LEFT JOIN achievementconditions ON achievementconditions.id = achievements.achievementcondition_id '. + 'WHERE achievements.seminary_id = ? AND only_once = 0 AND NOT EXISTS ('. + 'SELECT character_id '. + 'FROM achievements_characters '. + 'WHERE '. + 'achievements_characters.achievement_id = achievements.id AND '. + 'achievements_characters.character_id = ?'. + ')', + 'ii', + $seminaryId, + $characterId + ); + } + + + /** + * Get all date conditions for an Achievement. + * + * @param int $achievementId ID of Achievement + * @return array Date conditions + */ + public function getAchievementConditionsDate($achievementId) + { + return $this->db->query( + 'SELECT `select` '. + 'FROM achievementconditions_date '. + 'WHERE achievement_id = ?', + 'i', + $achievementId + ); + } + + + /** + * Check a date condition. + * + * @param string $select SELECT-string with date-functions + * @return boolean Result + */ + public function checkAchievementConditionDate($select) + { + $data = $this->db->query( + 'SELECT ('.$select.') AS got ' + ); + if(!empty($data)) { + return ($data[0]['got'] == 1); + } + + + return false; + } + + + /** + * Get all Character conditions for an Achievement. + * + * @param int $achievementId ID of Achievement + * @return array Character conditions + */ + public function getAchievementConditionsCharacter($achievementId) + { + return $this->db->query( + 'SELECT field, value '. + 'FROM achievementconditions_character '. + 'WHERE achievement_id = ?', + 'i', + $achievementId + ); + } + + + /** + * Check a Character condition. + * + * @param string $field Field to check + * @param int $value The value the field has to match + * @param int $characterId ID of Character + * @return boolean Result + */ + public function checkAchievementConditionCharacter($field, $value, $characterId) + { + $data = $this->db->query( + "SELECT ($field >= $value) AS got ". + 'FROM v_characters '. + 'WHERE user_id = ?', + 'i', + $characterId + ); + if(!empty($data)) { + return ($data[0]['got'] == 1); + } + + + return false; + } + + + /** + * Get the progress for a Character condition. + * + * @param string $field Field to check + * @param int $value The value the field has to match + * @param int $characterId ID of Character + * @return float Percentage progress + */ + public function getAchievementConditionCharacterProgress($field, $value, $characterId) + { + $data = $this->db->query( + "SELECT $field AS field ". + 'FROM v_characters '. + 'WHERE user_id = ?', + 'i', + $characterId + ); + if(!empty($data)) { + return $data[0]['field'] / $value; + } + + + return 0; + } + + + /** + * Get all Quest conditions for an Achievement. + * + * @param int $achievementId ID of Achievement + * @return array Quest conditions + */ + public function getAchievementConditionsQuest($achievementId) + { + return $this->db->query( + 'SELECT field, `count`, value, quest_id, status, groupby '. + 'FROM achievementconditions_quest '. + 'WHERE achievement_id = ?', + 'i', + $achievementId + ); + } + + + /** + * Check a Quest condition. + * + * @param string $field Field to check + * @param boolean $count Conut field-value + * @param int $value The value the field has to match + * @param int $status Status of Quest or NULL + * @param string $groupby Field to group or NULL + * @param int $questId ID of related Quest or NULL + * @param int $characterId ID of Character + * @return boolean Result + */ + public function checkAchievementConditionQuest($field, $count, $value, $status, $groupby, $questId, $characterId) + { + $data = $this->db->query( + 'SELECT ('.( + $count + ? "count($field) >= $value" + : "$field = $value" + ). ') AS got '. + 'FROM quests_characters '. + 'WHERE '. + 'character_id = ?'. + (!is_null($questId) ? " AND quest_id = $questId" : ''). + (!is_null($status) ? " AND status = $status" : ''). + (!is_null($groupby) ? " GROUP BY $groupby" : ''), + 'i', + $characterId + ); + if(!empty($data)) { + foreach($data as &$datum) { + if($datum['got'] == 1) { + return true; + } + } + } + + + return false; + } + + + /** + * Get the progress for a Quest condition. + * + * @param string $field Field to check + * @param boolean $count Conut field-value + * @param int $value The value the field has to match + * @param int $status Status of Quest or NULL + * @param string $groupby Field to group or NULL + * @param int $questId ID of related Quest or NULL + * @param int $characterId ID of Character + * @return float Percentage progress + */ + public function getAchievementConditionQuestProgress($field, $count, $value, $status, $groupby, $questId, $characterId) + { + $data = $this->db->query( + 'SELECT '.( + $count + ? "count($field)" + : "$field" + ). ' AS field '. + 'FROM quests_characters '. + 'WHERE '. + 'character_id = ?'. + (!is_null($questId) ? " AND quest_id = $questId" : ''). + (!is_null($status) ? " AND status = $status" : ''). + (!is_null($groupby) ? " GROUP BY $groupby" : ''), + 'i', + $characterId + ); + if(!empty($data)) + { + $maxField = 0; + foreach($data as &$datum) { + $maxField = max($maxField, intval($datum['field'])); + } + + return $maxField / $value; + } + + + return 0; + } + + + /** + * Get all Metaachievement conditions for an Achievement. + * + * @param int $achievementId ID of Achievement + * @return array Metaachievement conditions + */ + public function getAchievementConditionsAchievement($achievementId) + { + return $this->db->query( + 'SELECT field, `count`, value, meta_achievement_id, groupby '. + 'FROM achievementconditions_achievement '. + 'WHERE achievement_id = ?', + 'i', + $achievementId + ); + } + + + /** + * Check a Metaachievement condition. + * + * @param string $field Field to check + * @param boolean $count Conut field-value + * @param int $value The value the field has to match + * @param string $groupby Field to group or NULL + * @param int $metaAchievementId ID of related Achievement or NULL + * @param int $characterId ID of Character + * @return boolean Result + */ + public function checkAchievementConditionAchievement($field, $count, $value, $groupby, $metaAchievementId, $characterId) + { + $data = $this->db->query( + 'SELECT ('.( + $count + ? "count($field) >= $value" + : "$field = $value" + ). ') AS got '. + 'FROM achievements_characters '. + 'WHERE '. + 'character_id = ?'. + (!is_null($metaAchievementId) ? " AND achievement_id = $metaAchievementId" : ''). + (!is_null($groupby) ? " GROUP BY $groupby" : ''), + 'i', + $characterId + ); + if(!empty($data)) { + foreach($data as &$datum) { + if($datum['got'] == 1) { + return true; + } + } + } + + + return false; + } + + + /** + * Get the progress for a Metaachievement condition. + * + * @param string $field Field to check + * @param boolean $count Conut field-value + * @param int $value The value the field has to match + * @param string $groupby Field to group or NULL + * @param int $metaAchievementId ID of related Achievement or NULL + * @param int $characterId ID of Character + * @return float Percentage progress + */ + public function getAchievementConditionAchievementProgress($field, $count, $value, $groupby, $metaAchievementId, $characterId) + { + $data = $this->db->query( + 'SELECT '.( + $count + ? "count($field)" + : "$field" + ). ' AS field '. + 'FROM achievements_characters '. + 'WHERE '. + 'character_id = ?'. + (!is_null($metaAchievementId) ? " AND achievement_id = $metaAchievementId" : ''). + (!is_null($groupby) ? " GROUP BY $groupby" : ''), + 'i', + $characterId + ); + if(!empty($data)) + { + $maxField = 0; + foreach($data as &$datum) { + $maxField = max($maxField, intval($datum['field'])); + } + + return $maxField / $value; + } + + + return 0; + } + + + /** + * Set an Achievement as achieved for a Character. + * + * @param int $achievementId ID of Achievement + * @param int $characterId ID of Character + */ + public function setAchievementAchieved($achievementId, $characterId) + { + $this->db->query( + 'INSERT INTO achievements_characters '. + '(achievement_id, character_id) '. + 'VALUES '. + '(?, ?)', + 'ii', + $achievementId, $characterId + ); + } + + + /** + * Check if a Character has achieved an Achievement. + * + * @param int $achievementId ID of Achievement + * @param int $characterId ID of Character + * @return boolean Whether Character has achieved the Achievement or not + */ + public function hasCharacterAchievedAchievement($achievementId, $characterId) + { + $data = $this->db->query( + 'SELECT character_id '. + 'FROM achievements_characters '. + 'WHERE achievement_id = ? AND character_id = ?', + 'ii', + $achievementId, $characterId + ); + + + return !empty($data); + } + } ?> diff --git a/models/MediaModel.inc b/models/MediaModel.inc index 34e0c0e8..2c2d5eae 100644 --- a/models/MediaModel.inc +++ b/models/MediaModel.inc @@ -88,21 +88,21 @@ * Get a Seminary medium by its URL. * * @throws IdNotFoundException - * @param int $seminaryId ID of the seminary - * @param string $mediaURL URL-name of the Medium - * @return array Medium data + * @param int $seminaryId ID of the seminary + * @param string $seminaryMediaUrl URL-name of the Seminary medium + * @return array Seminary medium data */ - public function getSeminaryMediaByUrl($seminaryId, $mediaUrl) + public function getSeminaryMediaByUrl($seminaryId, $seminaryMediaUrl) { $data = $this->db->query( 'SELECT id, name, url, description, mimetype '. 'FROM seminarymedia '. 'WHERE url = ?', 's', - $mediaUrl + $seminaryMediaUrl ); if(empty($data)) { - throw new \nre\exceptions\IdNotFoundException($mediaUrl); + throw new \nre\exceptions\IdNotFoundException($seminaryMediaUrl); } @@ -114,9 +114,8 @@ * Get a Seminary medium by its ID. * * @throws IdNotFoundException - * @param int $seminaryId ID of the seminary - * @param int $mediaId ID of the Medium - * @return array Medium data + * @param int $seminaryMediaId ID of the Seminary medium + * @return array Seminary medium data */ public function getSeminaryMediaById($mediaId) { diff --git a/views/html/achievements/index.tpl b/views/html/achievements/index.tpl new file mode 100644 index 00000000..62c99c1a --- /dev/null +++ b/views/html/achievements/index.tpl @@ -0,0 +1,28 @@ + +
+ +
+ +

+

+ +
    + +
  • + + + +

    +
    + + +
    +
    + +
    +

     %

    +
    + +
  • + +
diff --git a/views/html/characters/character.tpl b/views/html/characters/character.tpl index d597f182..63054c06 100644 --- a/views/html/characters/character.tpl +++ b/views/html/characters/character.tpl @@ -67,31 +67,15 @@

Neue Achievements

diff --git a/views/html/seminarybar/index.tpl b/views/html/seminarybar/index.tpl index 8b2db16f..0879970c 100644 --- a/views/html/seminarybar/index.tpl +++ b/views/html/seminarybar/index.tpl @@ -16,16 +16,21 @@ +

  • - -

    Des Königs neue Quests

    -

    erreicht am: 14.07.2014

    + + + +

    +

    format(new \DateTime($lastAchievement['created'])))?>

+ +

Wille und die Majas