implement CRUD for Character titles
This commit is contained in:
parent
ac0e5a32cb
commit
14b09065a2
9 changed files with 551 additions and 17 deletions
79
agents/intermediate/CharactertitlesAgent.inc
Normal file
79
agents/intermediate/CharactertitlesAgent.inc
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @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 handle Character titles of a Seminary.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactertitlesAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
// Add Moodpic
|
||||||
|
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: create.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function create(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
// Add Moodpic
|
||||||
|
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
// Add Moodpic
|
||||||
|
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
// Add Moodpic
|
||||||
|
$this->addSubAgent('Moodpic', 'seminary', $request->getParam(3), $request->getParam(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -295,6 +295,14 @@
|
||||||
'answer' => array(
|
'answer' => array(
|
||||||
'minlength' => 1,
|
'minlength' => 1,
|
||||||
'maxlength' => 255
|
'maxlength' => 255
|
||||||
|
),
|
||||||
|
'title_male' => array(
|
||||||
|
'minlength' => 3,
|
||||||
|
'maxlength' => 24
|
||||||
|
),
|
||||||
|
'title_female' => array(
|
||||||
|
'minlength' => 3,
|
||||||
|
'maxlength' => 24
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
261
controllers/CharactertitlesController.inc
Normal file
261
controllers/CharactertitlesController.inc
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @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 CharactertitlesAgent to handle Character titles of a
|
||||||
|
* Seminary.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactertitlesController extends \hhu\z\controllers\SeminaryController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Required components
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $components = array('validation');
|
||||||
|
/**
|
||||||
|
* Required models
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $models = array('charactertitles');
|
||||||
|
/**
|
||||||
|
* User permissions
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $permissions = array(
|
||||||
|
'index' => array('admin', 'moderator', 'user'),
|
||||||
|
'create' => array('admin', 'moderator', 'user'),
|
||||||
|
'edit' => array('admin', 'moderator', 'user'),
|
||||||
|
'delete' => array('admin', 'moderator', 'user')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*
|
||||||
|
* List Character titles.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
|
*/
|
||||||
|
public function index($seminaryUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Character titles
|
||||||
|
$titles = $this->Charactertitles->getTitlesForSeminary($seminary['id']);
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Charactertitles');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('titles', $titles);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: create.
|
||||||
|
*
|
||||||
|
* Create a new Character title for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
|
*/
|
||||||
|
public function create($seminaryUrl)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$titleMale = '';
|
||||||
|
$titleFemale = '';
|
||||||
|
$fields = array('title_male', 'title_female');
|
||||||
|
$validation = array();
|
||||||
|
|
||||||
|
// Create new Charactertype
|
||||||
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||||
|
{
|
||||||
|
// Get params and validate them
|
||||||
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
|
$titleMale = $this->request->getPostParam('title_male');
|
||||||
|
if($this->Charactertitles->titleExists($seminary['id'], $titleMale)) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title_male', 'exist', true);
|
||||||
|
}
|
||||||
|
$titleFemale = $this->request->getPostParam('title_female');
|
||||||
|
if($this->Charactertitles->titleExists($seminary['id'], $titleFemale)) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title_female', 'exist', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new Character title
|
||||||
|
if($validation === true)
|
||||||
|
{
|
||||||
|
$titleId = $this->Charactertitles->createTitle(
|
||||||
|
$this->Auth->getUserId(),
|
||||||
|
$seminary['id'],
|
||||||
|
$titleMale,
|
||||||
|
$titleFemale
|
||||||
|
);
|
||||||
|
$title = $this->Charactertitles->getTitleById($titleId);
|
||||||
|
|
||||||
|
// Redirect to editing
|
||||||
|
$this->redirect($this->linker->link(array('edit', $seminary['url'], $title['hash']), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Create new Charactertitle');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('titleMale', $titleMale);
|
||||||
|
$this->set('titleFemale', $titleFemale);
|
||||||
|
$this->set('validation', $validation);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* Edit a Character title for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-title of a Seminary
|
||||||
|
* @param string $titleHash Hash of Character title
|
||||||
|
*/
|
||||||
|
public function edit($seminaryUrl, $titleHash)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Character title
|
||||||
|
$title = $this->Charactertitles->getTitleByHash($titleHash);
|
||||||
|
|
||||||
|
// Values
|
||||||
|
$titleMale = $title['title_male'];
|
||||||
|
$titleFemale = $title['title_female'];
|
||||||
|
$fields = array('title_male', 'title_female');
|
||||||
|
$validation = array();
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||||
|
{
|
||||||
|
// Get params and validate them
|
||||||
|
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||||
|
$titleMale = $this->request->getPostParam('title_male');
|
||||||
|
if($this->Charactertitles->titleExists($seminary['id'], $titleMale, $title['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title_male', 'exist', true);
|
||||||
|
}
|
||||||
|
$titleFemale = $this->request->getPostParam('title_female');
|
||||||
|
if($this->Charactertitles->titleExists($seminary['id'], $titleFemale, $title['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'title_female', 'exist', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit Character title
|
||||||
|
if($validation === true)
|
||||||
|
{
|
||||||
|
$this->Charactertitles->editTitle(
|
||||||
|
$title['id'],
|
||||||
|
$titleMale,
|
||||||
|
$titleFemale
|
||||||
|
);
|
||||||
|
$title = $this->Charactertitles->getTitleById($title['id']);
|
||||||
|
|
||||||
|
// Redirect to overview
|
||||||
|
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get validation settings
|
||||||
|
$validationSettings = array();
|
||||||
|
foreach($fields as &$field) {
|
||||||
|
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Edit Charactertitle');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('titleMale', $titleMale);
|
||||||
|
$this->set('titleFemale', $titleFemale);
|
||||||
|
$this->set('validation', $validation);
|
||||||
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* Delete a Character title for a Seminary.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
|
* @param string $seminaryUrl URL-title of a Seminary
|
||||||
|
* @param string $titleHash Hash of Character title
|
||||||
|
*/
|
||||||
|
public function delete($seminaryUrl, $titleHash)
|
||||||
|
{
|
||||||
|
// Get seminary
|
||||||
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
|
// Get Character title
|
||||||
|
$title = $this->Charactertitles->getTitleByHash($titleHash);
|
||||||
|
|
||||||
|
// Check request method
|
||||||
|
if($this->request->getRequestMethod() == 'POST')
|
||||||
|
{
|
||||||
|
// Check confirmation
|
||||||
|
if(!is_null($this->request->getPostParam('delete')))
|
||||||
|
{
|
||||||
|
// Delete Character title
|
||||||
|
$this->Charactertitles->deleteTitle($title['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to overview
|
||||||
|
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set titile
|
||||||
|
$this->addTitleLocalized('Delete Charactertitle');
|
||||||
|
$this->addTitle($seminary['title']);
|
||||||
|
|
||||||
|
// Pass data to view
|
||||||
|
$this->set('seminary', $seminary);
|
||||||
|
$this->set('title', $title);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
public function getTitleById($titleId)
|
public function getTitleById($titleId)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, title_male, title_female '.
|
'SELECT id, hash, title_male, title_female '.
|
||||||
'FROM charactertitles '.
|
'FROM charactertitles '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'i',
|
'i',
|
||||||
|
|
@ -59,6 +59,50 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Character title by its hash.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
|
* @param int $titleHash Hash of title
|
||||||
|
* @return array Title data
|
||||||
|
*/
|
||||||
|
public function getTitleByHash($titleHash)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT id, hash, title_male, title_female '.
|
||||||
|
'FROM charactertitles '.
|
||||||
|
'WHERE hash = ?',
|
||||||
|
's',
|
||||||
|
$titleHash
|
||||||
|
);
|
||||||
|
if(empty($data)) {
|
||||||
|
throw new \nre\exceptions\IdNotFoundException($titleHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Character titles of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to get titles for
|
||||||
|
* @return array List of title data
|
||||||
|
*/
|
||||||
|
public function getTitlesForSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
return $this->db->query(
|
||||||
|
'SELECT id, hash, title_male, title_female '.
|
||||||
|
'FROM charactertitles '.
|
||||||
|
'WHERE seminary_id = ? '.
|
||||||
|
'ORDER BY title_male, title_female ',
|
||||||
|
'i',
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all titles a Character owns.
|
* Get all titles a Character owns.
|
||||||
*
|
*
|
||||||
|
|
@ -79,17 +123,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO addTitleToCharacter
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Check if a Character title already exists.
|
* Check if a title for a Characters already exists.
|
||||||
*
|
*
|
||||||
* @param string $title Character title to check
|
|
||||||
* @param int $seminaryId ID of Seminary
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $questId Do not check this ID (for editing)
|
* @param string $title Character title to check
|
||||||
|
* @param int $titleId Do not check this ID (for editing)
|
||||||
* @return boolean Whether Character title exists or not
|
* @return boolean Whether Character title exists or not
|
||||||
*/
|
*/
|
||||||
public function characterTitleExists($titleMale, $titleFemale, $seminaryId, $titleId=null)
|
public function titleExists($seminaryId, $title, $titleId=null)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id '.
|
'SELECT id '.
|
||||||
|
|
@ -97,9 +139,8 @@
|
||||||
'WHERE seminary_id = ? AND (title_male = ? OR title_female = ?)',
|
'WHERE seminary_id = ? AND (title_male = ? OR title_female = ?)',
|
||||||
'iss',
|
'iss',
|
||||||
$seminaryId,
|
$seminaryId,
|
||||||
$titleMale,
|
$title,
|
||||||
$titleFemale
|
$title
|
||||||
//\nre\core\Linker::createLinkParam($title)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (!empty($data) && (is_null($titleId) || $titleId != $data[0]['id']));
|
return (!empty($data) && (is_null($titleId) || $titleId != $data[0]['id']));
|
||||||
|
|
@ -107,7 +148,7 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Create a new Character title.
|
* Create a new Character title.
|
||||||
*
|
*
|
||||||
* @param int $userId User-ID that creates the new title
|
* @param int $userId User-ID that creates the new title
|
||||||
* @param int $seminaryId ID of Questgroup
|
* @param int $seminaryId ID of Questgroup
|
||||||
|
|
@ -119,11 +160,12 @@
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'INSERT INTO charactertitles '.
|
'INSERT INTO charactertitles '.
|
||||||
'(created_user_id, seminary_id, title_male, title_female) '.
|
'(created_user_id, seminary_id, hash, title_male, title_female) '.
|
||||||
'VALUES '.
|
'VALUES '.
|
||||||
'(?, ?, ?, ?)',
|
'(?, ?, ?, ?, ?)',
|
||||||
'iiss',
|
'iisss',
|
||||||
$userId, $seminaryId,
|
$userId, $seminaryId,
|
||||||
|
\hhu\z\Utils::createRandomHash(),
|
||||||
$titleMale, $titleFemale
|
$titleMale, $titleFemale
|
||||||
//\nre\core\Linker::createLinkParam($title),
|
//\nre\core\Linker::createLinkParam($title),
|
||||||
);
|
);
|
||||||
|
|
@ -134,7 +176,7 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Edit a Character title.
|
* Edit a Character title.
|
||||||
*
|
*
|
||||||
* @param int $titleId ID of Character title to edit
|
* @param int $titleId ID of Character title to edit
|
||||||
* @param string $titleMale Title for male Characters
|
* @param string $titleMale Title for male Characters
|
||||||
|
|
@ -149,14 +191,13 @@
|
||||||
'ssi',
|
'ssi',
|
||||||
$titleMale,
|
$titleMale,
|
||||||
$titleFemale,
|
$titleFemale,
|
||||||
//\nre\core\Linker::createLinkParam($title),
|
|
||||||
$titleId
|
$titleId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Delete a Character title.
|
* Delete a Character title.
|
||||||
*
|
*
|
||||||
* @param int $titleId ID of Character title to delete
|
* @param int $titleId ID of Character title to delete
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<nav class="admin">
|
<nav class="admin">
|
||||||
<li><a href="<?=$linker->link(array('xplevels','manage',$seminary['url']))?>"><?=_('Manage XP-levels')?></a></li>
|
<li><a href="<?=$linker->link(array('xplevels','manage',$seminary['url']))?>"><?=_('Manage XP-levels')?></a></li>
|
||||||
<li><a href="<?=$linker->link(array('charactertypes','index',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a></li>
|
<li><a href="<?=$linker->link(array('charactertypes','index',$seminary['url']))?>"><?=_('Manage Charactertypes')?></a></li>
|
||||||
|
<li><a href="<?=$linker->link(array('charactertitles','index',$seminary['url']))?>"><?=_('Manage Charactertitles')?></a></li>
|
||||||
</nav>
|
</nav>
|
||||||
<nav class="admin">
|
<nav class="admin">
|
||||||
<li><a href="<?=$linker->link(array('manage',$seminary['url']),1)?>"><?=_('Manage Characters')?></a></li>
|
<li><a href="<?=$linker->link(array('manage',$seminary['url']),1)?>"><?=_('Manage Characters')?></a></li>
|
||||||
|
|
|
||||||
55
views/html/charactertitles/create.tpl
Normal file
55
views/html/charactertitles/create.tpl
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?=$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('index',$seminary['url']),1)?>"><?=_('Charactertitles')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Create new Charactertitle')?></h1>
|
||||||
|
<?php if($validation !== true && !empty($validation)) : ?>
|
||||||
|
<ul class="validation">
|
||||||
|
<?php foreach($validation as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'title_male':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Male title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Male title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Male title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Male title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'title_female':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Female title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Female title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Female title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Female title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<form method="post">
|
||||||
|
<fieldset>
|
||||||
|
<label for="title_male"><?=_('Male title')?>:</label>
|
||||||
|
<input id="title_male" type="text" name="title_male" placeholder="<?=_('Male title')?>" title="<?=_('Male title')?>" required="required" maxlength="<?=$validationSettings['title_male']['maxlength']?>" value="<?=$titleMale?>" <?=($validation !== true && array_key_exists('title_male', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
<br />
|
||||||
|
<label for="title_female"><?=_('Female title')?>:</label>
|
||||||
|
<input id="title_female" type="text" name="title_female" placeholder="<?=_('Female title')?>" title="<?=_('Female title')?>" required="required" maxlength="<?=$validationSettings['title_female']['maxlength']?>" value="<?=$titleFemale?>" <?=($validation !== true && array_key_exists('title_female', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" name="create" value="<?=_('create')?>" />
|
||||||
|
</form>
|
||||||
12
views/html/charactertitles/delete.tpl
Normal file
12
views/html/charactertitles/delete.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('index',$seminary['url']),1)?>"><?=_('Charactertitles')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Delete Charactertitles')?></h1>
|
||||||
|
<?=sprintf(_('Should the Charactertitle “%s/%s” really be deleted?'), $title['title_male'], $title['title_female'])?>
|
||||||
|
<form method="post">
|
||||||
|
<input type="submit" name="delete" value="<?=_('delete')?>" />
|
||||||
|
<input type="submit" name="not-delete" value="<?=_('cancel')?>" />
|
||||||
|
</form>
|
||||||
55
views/html/charactertitles/edit.tpl
Normal file
55
views/html/charactertitles/edit.tpl
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?=$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('index',$seminary['url']),1)?>"><?=_('Charactertypes')?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Edit Charactertype')?></h1>
|
||||||
|
<?php if($validation !== true && !empty($validation)) : ?>
|
||||||
|
<ul class="validation">
|
||||||
|
<?php foreach($validation as $field => &$settings) : ?>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($settings as $setting => $value) : ?>
|
||||||
|
<li>
|
||||||
|
<?php switch($field) {
|
||||||
|
case 'title_male':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Male title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Male title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Male title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Male title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'title_female':
|
||||||
|
switch($setting) {
|
||||||
|
case 'minlength': printf(_('Female title is too short (min. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'maxlength': printf(_('Female title is too long (max. %d chars)'), $value);
|
||||||
|
break;
|
||||||
|
case 'exist': echo _('Female title already exists');
|
||||||
|
break;
|
||||||
|
default: echo _('Female title invalid');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
<form method="post">
|
||||||
|
<fieldset>
|
||||||
|
<label for="title_male"><?=_('Male title')?>:</label>
|
||||||
|
<input id="title_male" type="text" name="title_male" placeholder="<?=_('Male title')?>" title="<?=_('Male title')?>" required="required" maxlength="<?=$validationSettings['title_male']['maxlength']?>" value="<?=$titleMale?>" <?=($validation !== true && array_key_exists('title_male', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
<br />
|
||||||
|
<label for="title_female"><?=_('Female title')?>:</label>
|
||||||
|
<input id="title_female" type="text" name="title_female" placeholder="<?=_('Female title')?>" title="<?=_('Female title')?>" required="required" maxlength="<?=$validationSettings['title_female']['maxlength']?>" value="<?=$titleFemale?>" <?=($validation !== true && array_key_exists('title_female', $validation)) ? 'class="invalid"' : null?> />
|
||||||
|
</fieldset>
|
||||||
|
<input type="submit" name="edit" value="<?=_('save')?>" />
|
||||||
|
</form>
|
||||||
22
views/html/charactertitles/index.tpl
Normal file
22
views/html/charactertitles/index.tpl
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?=$moodpic?>
|
||||||
|
<ul class="breadcrumbs">
|
||||||
|
<li><a href="<?=$linker->link(array('seminaries',$seminary['url']))?>"><?=$seminary['title']?></a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1><?=_('Charactertitles')?></h1>
|
||||||
|
<?php if($seminary['created_user_id'] == \hhu\z\controllers\IntermediateController::$user['id'] || (!is_null(\hhu\z\controllers\SeminaryController::$character) && in_array('admin', \hhu\z\controllers\SeminaryController::$character['characterroles']))) : ?>
|
||||||
|
<nav class="admin">
|
||||||
|
<li><a href="<?=$linker->link(array('create',$seminary['url']),1)?>"><?=_('Create new Character titles')?></a></li>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach($titles as &$title) : ?>
|
||||||
|
<li>
|
||||||
|
<p><?=$title['title_male']?>/<?=$title['title_female']?></p>
|
||||||
|
<ul class="admin">
|
||||||
|
<li><a href="<?=$linker->link(array('edit',$seminary['url'],$title['hash']),1)?>"><?=_('edit')?></a></li>
|
||||||
|
<li><a href="<?=$linker->link(array('delete',$seminary['url'],$title['hash']),1)?>"><?=_('delete')?></a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue