Commit 3fcf2395 authored by speedprogs_de's avatar speedprogs_de

added controller and templates for category and tag, fixed TypoScript setup

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@43021 735d13b6-9817-0410-8766-e36946ffe9aa
parent f3dddc3a
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Controller for the Category object
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_TerFe2_Controller_CategoryController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Service_TypoScriptParserService
*/
protected $typoScriptParser;
/**
* Initializes the current action
*
* @return void
*/
protected function initializeAction() {
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->typoScriptParser = t3lib_div::makeInstance('Tx_TerFe2_Service_TypoScriptParserService');
// Pre-parse TypoScript setup
$this->settings = $this->typoScriptParser->getParsed($this->settings);
}
/**
* Index action, displays all categories
*/
public function indexAction() {
$this->view->assign('categories', $this->categoryRepository->findAll());
}
/**
* Displays a form for creating a new Category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory A fresh Category object taken as a basis for the rendering
* @dontvalidate $newCategory
*/
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL) {
$this->view->assign('newCategory', $newCategory);
}
/**
* Creates a new Category and forwards to the index action
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory A fresh Category object which has not yet been added to the repository
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory) {
$this->categoryRepository->add($newCategory);
$this->flashMessageContainer->add($this->translate('msg_category_created'));
$this->redirect('index');
}
/**
* Displays a form to edit an existing Category
*
* @param Tx_TerFe2_Domain_Model_Category $category The Category to display
* @dontvalidate $category
*/
public function editAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('category', $category);
}
/**
* Updates an existing Category and forwards to the index action afterwards
*
* @param Tx_TerFe2_Domain_Model_Category $category Category to update
*/
public function updateAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->update($category);
$this->flashMessageContainer->add($this->translate('msg_category_updated'));
$this->redirect('index');
}
/**
* Deletes an existing Category
*
* @param Tx_TerFe2_Domain_Model_Category $category The Category to be deleted
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->remove($category);
$this->flashMessageContainer->add($this->translate('msg_category_deleted'));
$this->redirect('index');
}
/**
* Translate a label
*
* @param string $label Label to translate
* @param array $arguments Optional arguments array
* @return string Translated label
*/
protected function translate($label, array $arguments = array()) {
$extKey = $this->request->getControllerExtensionKey();
return Tx_Extbase_Utility_Localization::translate($label, $extKey, $arguments);
}
}
?>
\ No newline at end of file
......@@ -81,7 +81,7 @@
*/
public function indexAction() {
// Can be replaced by another action/view later
$this->forward('listLatest');
//$this->forward('listLatest');
}
......@@ -148,7 +148,7 @@
/**
* Creates a new Extension and forwards to the index action.
* Creates a new Extension and forwards to the index action
*
* @param Tx_TerFe2_Domain_Model_Extension $newExtension A fresh Extension object which has not yet been added to the repository
*/
......@@ -171,7 +171,7 @@
/**
* Updates an existing Extension and forwards to the index action afterwards.
* Updates an existing Extension and forwards to the index action afterwards
*
* @param Tx_TerFe2_Domain_Model_Extension $extension Extension to update
*/
......@@ -189,12 +189,13 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->remove($extension);
$this->flashMessageContainer->add($this->translate('msg_extension_deleted'));
$this->redirect('index');
}
/**
* Creates a new Version of an existing Extension and forwards to the index action afterwards.
* Creates a new Version of an existing Extension and forwards to the index action afterwards
*
* @param Tx_TerFe2_Domain_Model_Extension $extension An existing Extension object
* @param Tx_TerFe2_Domain_Model_Version $newVersion A fresh Version object which has not yet been added to the repository
......
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Controller for the Tag object
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_TerFe2_Controller_TagController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_TerFe2_Domain_Repository_TagRepository
*/
protected $tagRepository;
/**
* @var Tx_TerFe2_Service_TypoScriptParserService
*/
protected $typoScriptParser;
/**
* Initializes the current action
*
* @return void
*/
protected function initializeAction() {
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
$this->typoScriptParser = t3lib_div::makeInstance('Tx_TerFe2_Service_TypoScriptParserService');
// Pre-parse TypoScript setup
$this->settings = $this->typoScriptParser->getParsed($this->settings);
}
/**
* Index action, displays all categories
*/
public function indexAction() {
$this->view->assign('tags', $this->tagRepository->findAll());
}
/**
* Displays a form for creating a new Tag
*
* @param Tx_TerFe2_Domain_Model_Tag $newTag A fresh Tag object taken as a basis for the rendering
* @dontvalidate $newTag
*/
public function newAction(Tx_TerFe2_Domain_Model_Tag $newTag = NULL) {
$this->view->assign('newTag', $newTag);
}
/**
* Creates a new Tag and forwards to the index action
*
* @param Tx_TerFe2_Domain_Model_Tag $newTag A fresh Tag object which has not yet been added to the repository
*/
public function createAction(Tx_TerFe2_Domain_Model_Tag $newTag) {
$this->tagRepository->add($newTag);
$this->flashMessageContainer->add($this->translate('msg_tag_created'));
$this->redirect('index');
}
/**
* Displays a form to edit an existing Tag
*
* @param Tx_TerFe2_Domain_Model_Tag $tag The Tag to display
* @dontvalidate $tag
*/
public function editAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->view->assign('tag', $tag);
}
/**
* Updates an existing Tag and forwards to the index action afterwards
*
* @param Tx_TerFe2_Domain_Model_Tag $tag Tag to update
*/
public function updateAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->tagRepository->update($tag);
$this->flashMessageContainer->add($this->translate('msg_tag_updated'));
$this->redirect('index');
}
/**
* Deletes an existing Tag
*
* @param Tx_TerFe2_Domain_Model_Tag $tag The Tag to be deleted
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->tagRepository->remove($tag);
$this->flashMessageContainer->add($this->translate('msg_tag_deleted'));
$this->redirect('index');
}
/**
* Translate a label
*
* @param string $label Label to translate
* @param array $arguments Optional arguments array
* @return string Translated label
*/
protected function translate($label, array $arguments = array()) {
$extKey = $this->request->getControllerExtensionKey();
return Tx_Extbase_Utility_Localization::translate($label, $extKey, $arguments);
}
}
?>
\ No newline at end of file
plugin.tx_terfe2 {
persistence {
# cat=plugin.tx_terfe2/persistence/100; type=int+; label=Category storage PID
categoryPid =
# cat=plugin.tx_terfe2/persistence/100; type=int+; label=Extension storage PID
extensionPid = 0
# cat=plugin.tx_terfe2/persistence/200; type=int+; label=Expirience storage PID
experiencePid =
# cat=plugin.tx_terfe2/persistence/110; type=int+; label=Version storage PID
versionPid = 0
# cat=plugin.tx_terfe2/persistence/300; type=int+; label=Extension storage PID
extensionPid =
# cat=plugin.tx_terfe2/persistence/120; type=int+; label=Category storage PID
categoryPid = 0
# cat=plugin.tx_terfe2/persistence/400; type=int+; label=Media storage PID
mediaPid =
# cat=plugin.tx_terfe2/persistence/130; type=int+; label=Tag storage PID
tagPid = 0
# cat=plugin.tx_terfe2/persistence/500; type=int+; label=Relation storage PID
relationPid =
# cat=plugin.tx_terfe2/persistence/140; type=int+; label=Expirience storage PID
experiencePid = 0
# cat=plugin.tx_terfe2/persistence/600; type=int+; label=Tag storage PID
tagPid =
# cat=plugin.tx_terfe2/persistence/150; type=int+; label=Media storage PID
mediaPid = 0
# cat=plugin.tx_terfe2/persistence/700; type=int+; label=Version storage PID
versionPid =
# cat=plugin.tx_terfe2/persistence/160; type=int+; label=Relation storage PID
relationPid = 0
}
view {
# cat=plugin.tx_terfe2/view/100; type=string; label=Path to template root
# cat=plugin.tx_terfe2/view/200; type=string; label=Path to template root
templateRootPath = EXT:ter_fe2/Resources/Private/Templates/
# cat=plugin.tx_terfe2/view/200; type=string; label=Path to template partials
# cat=plugin.tx_terfe2/view/210; type=string; label=Path to template partials
partialRootPath = EXT:ter_fe2/Resources/Private/Partials/
# cat=plugin.tx_terfe2/view/300; type=string; label=Path to template layouts
# cat=plugin.tx_terfe2/view/220; type=string; label=Path to template layouts
layoutRootPath = EXT:ter_fe2/Resources/Private/Layouts/
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
# Plugin configuration ot the extension "ter_fe2"
# ======================================================================
plugin.tx_terfe2 {
## General settings
settings {
......@@ -10,15 +9,16 @@ plugin.tx_terfe2 {
## Storage settings
persistence {
storagePid = {$plugin.tx_terfe2.persistence.extensionPid}
storagePid = {$plugin.tx_terfe2.persistence.extensionPid},{$plugin.tx_terfe2.persistence.versionPid},{$plugin.tx_terfe2.persistence.categoryPid},{$plugin.tx_terfe2.persistence.tagPid},{$plugin.tx_terfe2.persistence.experiencePid},{$plugin.tx_terfe2.persistence.mediaPid},{$plugin.tx_terfe2.persistence.relationPid}
classes {
Tx_TerFe2_Domain_Model_Extension.newRecordStoragePid = {$plugin.tx_terfe2.persistence.extensionPid}
Tx_TerFe2_Domain_Model_Version.newRecordStoragePid = {$plugin.tx_terfe2.persistence.versionPid}
Tx_TerFe2_Domain_Model_Category.newRecordStoragePid = {$plugin.tx_terfe2.persistence.categoryPid}
Tx_TerFe2_Domain_Model_Tag.newRecordStoragePid = {$plugin.tx_terfe2.persistence.tagPid}
Tx_TerFe2_Domain_Model_Experience.newRecordStoragePid = {$plugin.tx_terfe2.persistence.experiencePid}
Tx_TerFe2_Domain_Model_Extension.newRecordStoragePid = {$plugin.tx_terfe2.persistence.extensionPid}
Tx_TerFe2_Domain_Model_Media.newRecordStoragePid = {$plugin.tx_terfe2.persistence.mediaPid}
Tx_TerFe2_Domain_Model_Relation.newRecordStoragePid = {$plugin.tx_terfe2.persistence.relationPid}
Tx_TerFe2_Domain_Model_Tag.newRecordStoragePid = {$plugin.tx_terfe2.persistence.tagPid}
Tx_TerFe2_Domain_Model_Version.newRecordStoragePid = {$plugin.tx_terfe2.persistence.versionPid}
}
}
......@@ -38,5 +38,4 @@ plugin.tx_terfe2 {
_CSS_DEFAULT_STYLE (
)
}
\ No newline at end of file
......@@ -57,17 +57,34 @@
<label index="msg_extension_created">Extension created</label>
<label index="msg_extension_updated">Extension updated</label>
<label index="msg_extension_deleted">Extension deleted</label>
<label index="msg_category_created">Category created</label>
<label index="msg_category_updated">Category updated</label>
<label index="msg_category_deleted">Category deleted</label>
<label index="msg_tag_created">Tag created</label>
<label index="msg_tag_updated">Tag updated</label>
<label index="msg_tag_deleted">Tag deleted</label>
<label index="msg_file_not_valid">Given file is not valid</label>
<label index="list_all_extensions">List of all extensions</label>
<label index="list_latest_extensions">List of new and updated extensions</label>
<label index="list_extensions_by_tag">List of extensions by tag</label>
<label index="list_extensions_by_category">List of extensions by category</label>
<label index="edit_extension">Edit Extension</label>
<label index="new_extension">New Extension</label>
<label index="edit_extension">Edit Extension</label>
<label index="single_extension">Show single Extension</label>
<label index="create_extension">Create new Extension</label>
<label index="new_category">Create new Category</label>
<label index="edit_category">Edit Category</label>
<label index="create_category">Create new Category</label>
<label index="new_tag">Create new Tag</label>
<label index="edit_tag">Edit Tag</label>
<label index="create_tag">Create new Tag</label>
<label index="back_to_list">Back to list</label>
<label index="create">Create</label>
<label index="edit">Edit</label>
<label index="delete">Delete</label>
</languageKey>
......
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="edit_category"/></h2>
<f:form method="post" action="update" name="category" object="{category}">
<label for="title"><f:translate key="tx_terfe2_domain_model_category.title" /></label><br />
<f:form.textbox property="title" /><br />
<label for="description"><f:translate key="tx_terfe2_domain_model_category.description" /></label><br />
<f:form.textbox property="description" /><br /><br />
<f:form.submit value="{f:translate(key:'edit')}" />
</f:form>
<f:link.action action="index"><f:translate key="back_to_list"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<table cellpadding="4" style="border:1px solid black;">
<tr>
<th><f:translate key="tx_terfe2_domain_model_category.title" /></th>
<th><f:translate key="tx_terfe2_domain_model_category.description" /></th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
<f:for each="{categories}" as="category">
<tr>
<td>{category.title}</td>
<td>{category.description}</td>
<td><f:link.action action="edit" arguments="{category : category}"><f:translate key="edit"/></f:link.action></td>
<td><f:link.action action="delete" arguments="{category : category}"><f:translate key="delete"/></f:link.action></td>
</tr>
</f:for>
</table>
<br />
<f:link.action action="new"><f:translate key="create_category"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="new_category"/></h2>
<f:form method="post" action="create" name="newCategory" object="{newCategory}">
<label for="title"><f:translate key="tx_terfe2_domain_model_category.title" /></label><br />
<f:form.textbox property="title" /><br />
<label for="description"><f:translate key="tx_terfe2_domain_model_category.description" /></label><br />
<f:form.textbox property="description" /><br /><br />
<f:form.submit value="{f:translate(key:'create')}" />
</f:form>
<f:link.action action="index"><f:translate key="back_to_list"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="edit_extension"/></h2>
<f:form method="post" action="update" name="extension" object="{extension}">
<label for="extKey"><f:translate key="tx_terfe2_domain_model_extension.ext_key" /></label><br />
<f:form.textbox property="extKey" /><br />
<label for="forgeLink"><f:translate key="tx_terfe2_domain_model_extension.forge_link" /></label><br />
<f:form.textbox property="forgeLink" /><br />
<label for="hudsonLink"><f:translate key="tx_terfe2_domain_model_extension.hudson_link" /></label><br />
<f:form.textbox property="hudsonLink" /><br />
<f:form.submit value="Edit" />
<f:form.textbox property="hudsonLink" /><br /><br />
<f:form.submit value="{f:translate(key:'edit')}" />
</f:form>
<f:link.action action="index"><f:translate key="back_to_list"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
Nothring here at the moment...
<f:link.action action="listLatest">&raquo; Extensions</f:link.action><br />
<f:link.action controller="Category" action="index">&raquo; Categories</f:link.action><br />
<f:link.action controller="Tag" action="index">&raquo; Tags</f:link.action><br />
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="list_all_extensions"/></h2>
<f:render partial="extensionList" arguments="{extensions: extensions}"/>
<br />
<f:link.action action="new"><f:translate key="create_extension"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="list_extensions_by_category"/></h2>
<f:render partial="extensionList" arguments="{extensions: extensions}"/>
<br />
<f:link.action action="new"><f:translate key="create_extension"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="list_extensions_by_tag"/></h2>
<f:render partial="extensionList" arguments="{extensions: extensions}"/>
<br />
<f:link.action action="new"><f:translate key="create_extension"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="list_latest_extensions"/></h2>
<f:render partial="extensionList" arguments="{extensions: extensions}"/>
<br />
<f:link.action action="new"><f:translate key="create_extension"/></f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
<f:section name="main">
<h2><f:translate key="new_extension"/></h2>
<f:form method="post" action="create" name="newExtension" object="{newExtension}">
<label for="extKey"><f:translate key="tx_terfe2_domain_model_extension.ext_key" /></label><br />
<f:form.textbox property="extKey" /><br />
<label for="forgeLink"><f:translate key="tx_terfe2_domain_model_extension.forge_link" /></label><br />
<f:form.textbox property="forgeLink" /><br />
<label for="hudsonLink"><f:translate key="tx_terfe2_domain_model_extension.hudson_link" /></label><br />
<f:form.textbox property="hudsonLink" /><br />
<f:form.submit value="Create new" />
<label for="categories"><f:translate key="tx_terfe2_domain_model_extension.categories" /></label><br />
<f:form.select property="categories" options="{categories}" optionValueField="uid" optionLabelField="title"></f:form.select><br />
<label for="tags"><f:translate key="tx_terfe2_domain_model_extension.tags" /></label><br />