add editing of Character groups Quest Station tasks
This commit is contained in:
parent
b7ce9f09cd
commit
112c7d0b4f
6 changed files with 184 additions and 22 deletions
|
@ -73,6 +73,19 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: edittask.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
// Add Moodpic
|
||||
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), 'charactergroups');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
|
|
|
@ -71,6 +71,19 @@
|
|||
public abstract function quest($seminary, $groupsgroup, $quest, $station, $charactergroup);
|
||||
|
||||
|
||||
/**
|
||||
* Action: edittask.
|
||||
*
|
||||
* Edit the task of a Station.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $groupsgroup Current Groups group data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $station Current Station data
|
||||
*/
|
||||
public abstract function edittask($seminary, $groupsgroup, $quest, $station);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -305,10 +305,10 @@
|
|||
array('^charactergroupsquests/([^/]+)/([^/]+)/create/?$', 'charactergroupsquests/create/$1/$2', true),
|
||||
array('^charactergroupsquests/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsquests/quest/$1/$2/$3', true),
|
||||
array('^charactergroupsquests/([^/]+)/([^/]+)/([^/]+)/(edit|delete|manage)/?$', 'charactergroupsquests/$4/$1/$2/$3', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/index/$1/$2/$3?layout=ajax', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/create/?$', 'charactergroupsqueststations/create/$1/$2/$3', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(edit|delete)/?$', 'charactergroupsqueststations/$5/$1/$2/$3/$4', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/station/$1/$2/$3/$4', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/index/$1/$2/$3?layout=ajax', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/create/?$', 'charactergroupsqueststations/create/$1/$2/$3', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(edit|edittask|delete)/?$', 'charactergroupsqueststations/$5/$1/$2/$3/$4', true),
|
||||
array('^charactergroupsqueststations/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$', 'charactergroupsqueststations/station/$1/$2/$3/$4', true),
|
||||
array('^achievements/([^/]+)/(create|manage)/?$', 'achievements/$2/$1', true),
|
||||
array('^achievements/([^/]+)/([^/]+)/(edit|conditions|moveup|movedown|delete)/?$', 'achievements/$3/$1/$2', true),
|
||||
array('^achievements/([^/]+)/?$', 'achievements/index/$1', true),
|
||||
|
@ -364,9 +364,9 @@
|
|||
array('^charactergroupsquests/create/([^/]+)/([^/]+)/?$', 'charactergroupsquests/$1/$2/create', true),
|
||||
array('^charactergroupsquests/quest/(.*)$', 'charactergroupsquests/$1', true),
|
||||
array('^charactergroupsquests/(edit|delete|manage)/([^/]+)/([^/]+)/([^/]+)$', 'charactergroupsquests/$2/$3/$4/$1', true),
|
||||
array('^charactergroupsqueststations/index/(.*)$', 'charactergroupsqueststations/$1', true),
|
||||
array('^charactergroupsqueststations/station/(.*)$', 'charactergroupsqueststations/$1', true),
|
||||
array('^charactergroupsqueststations/(create|edit|delete)/(.*)$', 'charactergroupsqueststations/$2/$1', true),
|
||||
array('^charactergroupsqueststations/index/(.*)$', 'charactergroupsqueststations/$1', true),
|
||||
array('^charactergroupsqueststations/station/(.*)$', 'charactergroupsqueststations/$1', true),
|
||||
array('^charactergroupsqueststations/(create|edit|edittask|delete)/(.*)$', 'charactergroupsqueststations/$2/$1', true),
|
||||
array('^achievements/index/(.*)$', 'achievements/$1', true),
|
||||
array('^achievements/(create|manage)/(.*)$', 'achievements/$2/$1', true),
|
||||
array('^achievements/(edit|conditions|moveup|movedown|delete)/(.*)$', 'achievements/$2/$1', true),
|
||||
|
|
|
@ -394,7 +394,7 @@
|
|||
// Get Quest types
|
||||
$stationtypes = $this->Stationtypes->getStationtypes();
|
||||
foreach($stationtypes as &$stationtype) {
|
||||
$stationtype['selected'] = false;
|
||||
$stationtype['selected'] = ($stationtype['id'] == $station['stationtype_id']);
|
||||
}
|
||||
|
||||
// Get allowed mimetypes
|
||||
|
@ -497,19 +497,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Redirect to Station page
|
||||
$this->redirect(
|
||||
$this->linker->link(
|
||||
array(
|
||||
'station',
|
||||
$seminary['url'],
|
||||
$groupsgroup['url'],
|
||||
$quest['url'],
|
||||
$station['url']
|
||||
),
|
||||
1
|
||||
)
|
||||
);
|
||||
// Redirect
|
||||
if(!is_null($this->request->getPostParam('edit-task'))) {
|
||||
// To task editing
|
||||
$this->redirect(
|
||||
$this->linker->link(
|
||||
array(
|
||||
'edittask',
|
||||
$seminary['url'],
|
||||
$groupsgroup['url'],
|
||||
$quest['url'],
|
||||
$station['url']
|
||||
),
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
// To Station page
|
||||
$this->redirect(
|
||||
$this->linker->link(
|
||||
array(
|
||||
'station',
|
||||
$seminary['url'],
|
||||
$groupsgroup['url'],
|
||||
$quest['url'],
|
||||
$station['url']
|
||||
),
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,6 +555,54 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO Action: edittask.
|
||||
*
|
||||
* Edit the task of a Character groups Quest Station.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $groupsgroupUrl URL-Title of a Character groups-group
|
||||
* @param string $questUrl URL-Title of a Character groups Quest
|
||||
* @param string $stationUrl URL of station
|
||||
*/
|
||||
public function edittask($seminaryUrl, $groupsgroupUrl, $questUrl, $stationUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character groups-group
|
||||
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
|
||||
|
||||
// Get Character groups-group Quests
|
||||
$quest = $this->Charactergroupsquests->getQuestByUrl($groupsgroup['id'], $questUrl);
|
||||
|
||||
// Get Station
|
||||
$station = $this->Charactergroupsqueststations->getStationByUrl($quest['id'], $stationUrl);
|
||||
|
||||
// Render editing task
|
||||
$task = null;
|
||||
$stationtype = $this->Stationtypes->getStationtypeById($station['stationtype_id']);
|
||||
if(!is_null($stationtype['classname'])) {
|
||||
$task = $this->renderTaskEditing($stationtype['classname'], $seminary, $groupsgroup, $quest, $station);
|
||||
}
|
||||
|
||||
|
||||
// Set title
|
||||
$this->addTitleLocalized('Edit Station task');
|
||||
$this->addTitle($station['title']);
|
||||
$this->addTitle($quest['title']);
|
||||
$this->addTitle($groupsgroup['name']);
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('groupsgroup', $groupsgroup);
|
||||
$this->set('quest', $quest);
|
||||
$this->set('task', $task);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
|
@ -735,6 +801,61 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render editing of a Station task.
|
||||
*
|
||||
* @param string $stationtypeClassname Name of the class for the Stationtype of a Station
|
||||
* @param array $seminary Seminary data
|
||||
* @param array $groupsgroup Groupsgroup data
|
||||
* @param array $quest Quest data
|
||||
* @param array $station Station data
|
||||
* @return string Rendered output
|
||||
*/
|
||||
private function renderTaskEditing($stationtypeClassname, $seminary, $groupsgroup, $quest, $station)
|
||||
{
|
||||
$task = null;
|
||||
try {
|
||||
// Generate request and response
|
||||
$request = clone $this->request;
|
||||
$response = $this->createStationtypeResponse('edittask', $seminary, $groupsgroup, $quest, $station);
|
||||
|
||||
// Load Stationtype Agent
|
||||
$stationtypeAgent = $this->loadStationtypeAgent($stationtypeClassname, $request, $response);
|
||||
|
||||
// Render Task
|
||||
$task = $this->runStationtypeAgent($stationtypeAgent, $request, $response);
|
||||
}
|
||||
catch(\nre\exceptions\ViewNotFoundException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\nre\exceptions\ActionNotFoundException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\StationtypeModelNotValidException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\StationtypeModelNotFoundException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\StationtypeControllerNotValidException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\StationtypeControllerNotFoundException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\StationtypeAgentNotValidException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
catch(\hhu\z\exceptions\stationtypeAgentNotFoundException $e) {
|
||||
$task = $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
// Return rendered output
|
||||
return $task;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a response for the Stationtype rendering.
|
||||
*
|
||||
|
|
|
@ -91,7 +91,10 @@
|
|||
<label for="wrongText"><?=_('Wrong text')?>:</label><br />
|
||||
<textarea id="wrongText" name="wrongText" placeholder="<?=_('Wrong text')?>" style="width:100%; height:10em;"><?=$wrongtext?></textarea><br />
|
||||
</fieldset>
|
||||
<input type="submit" name="edit" value="<?=_('edit')?>" />
|
||||
<?php if(!is_null($stationtype['classname'])) : ?>
|
||||
<input type="submit" name="edit-task" value="<?=_('edit task')?>" />
|
||||
<?php endif ?>
|
||||
<input type="submit" name="edit" value="<?=_('save')?>" />
|
||||
</form>
|
||||
<script>
|
||||
$(function() {
|
||||
|
|
12
views/html/charactergroupsqueststations/edittask.tpl
Normal file
12
views/html/charactergroupsqueststations/edittask.tpl
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?=$moodpic?>
|
||||
<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('charactergroups','index',$seminary['url']))?>"><?=_('Character Groups')?></a></li>
|
||||
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroups','groupsgroup',$seminary['url'],$groupsgroup['url']))?>"><?=$groupsgroup['name']?></a></li>
|
||||
<li><i class="fa fa-chevron-right fa-fw"></i><a href="<?=$linker->link(array('charactergroupsquests','quest',$seminary['url'],$groupsgroup['url'],$quest['url']))?>"><?=$quest['title']?></a></li>
|
||||
</ul>
|
||||
|
||||
<h1><?=_('Edit Station task')?></h1>
|
||||
<?php if(!is_null($task)) : ?>
|
||||
<?=$task?>
|
||||
<?php endif ?>
|
Loading…
Add table
Reference in a new issue