Commit 78dd1dc0 authored by speedprogs_de's avatar speedprogs_de

added controllers

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51656 735d13b6-9817-0410-8766-e36946ffe9aa
parent e8f72808
<?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!
******************************************************************/
/**
* Abstract controller
*/
abstract class Tx_TerFe2_Controller_AbstractController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* Pre-parse TypoScript setup
*
* @return void
*/
public function initializeAction() {
// Pre-parse settings
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
// Initialize the controller
$this->initializeController();
}
/**
* Override in concrete controller to initialize it
*
* @return void
*/
protected function initializeController() {
}
/**
* 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()) {
$extensionKey = $this->request->getControllerExtensionKey();
return Tx_Extbase_Utility_Localization::translate($label, $extensionKey, $arguments);
}
}
?>
\ No newline at end of file
<?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 author object
*/
class Tx_TerFe2_Controller_AuthorController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->authorRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_AuthorRepository');
}
/**
* Index action, displays all authors
*
* @return void
*/
public function indexAction() {
$this->view->assign('authors', $this->authorRepository->findAll());
}
/**
* Action that displays a single author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
}
/**
* Displays a form for creating a new author
*
* @param Tx_TerFe2_Domain_Model_Author $newAuthor New author object
* @return void
* @dontvalidate $newAuthor
*/
public function newAction(Tx_TerFe2_Domain_Model_Author $newAuthor = NULL) {
$this->view->assign('newAuthor', $newAuthor);
}
/**
* Creates a new author
*
* @param Tx_TerFe2_Domain_Model_Author $newAuthor New author object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Author $newAuthor) {
$this->authorRepository->add($newAuthor);
$this->flashMessageContainer->add($this->translate('msg.author_created'));
$this->redirect('index');
}
/**
* Displays a form to edit an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
* @dontvalidate $author
*/
public function editAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
}
/**
* Updates an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author Author to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->update($author);
$this->flashMessageContainer->add($this->translate('msg.author_updated'));
$this->redirect('index');
}
/**
* Deletes an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to delete
* @return void
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->remove($author);
$this->flashMessageContainer->add($this->translate('msg.author_deleted'));
$this->redirect('index');
}
}
?>
\ No newline at end of file
<?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
*/
class Tx_TerFe2_Controller_CategoryController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
}
/**
* Index action, displays all categories
*
* @return void
*/
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 New category object
* @return void
* @dontvalidate $newCategory
*/
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL) {
$this->view->assign('newCategory', $newCategory);
}
/**
* Creates a new category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
*/
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
* @return void
* @dontvalidate $category
*/
public function editAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('category', $category);
}
/**
* Updates an existing category
*
* @param Tx_TerFe2_Domain_Model_Category $category Category to update
* @return void
*/
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 delete
* @return void
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->remove($category);
$this->flashMessageContainer->add($this->translate('msg.category_deleted'));
$this->redirect('index');
}
}
?>
\ No newline at end of file
<?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 extension object
*/
class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Domain_Repository_TagRepository
*/
protected $tagRepository;
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->extensionRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
$this->authorRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_AuthorRepository');
}
/**
* Index action, shows an overview
*
* @return void
*/
public function indexAction() {
// TODO: Implement functionality
}
/**
* List action, displays all extensions
*
* @return void
*/
public function listAction() {
$this->view->assign('extensions', $this->extensionRepository->findAll());
}
/**
* List latest action, displays new and updated extensions
*
* @return void
*/
public function listLatestAction() {
$latestCount = (!empty($this->settings['latestCount']) ? $this->settings['latestCount'] : 20);
$extensions = $this->extensionRepository->findNewAndUpdated($latestCount);
$this->view->assign('extensions', $extensions);
}
/**
* List by category action, displays all extensions in a category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to search in
* @return void
*/
public function listByCategoryAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('extensions', $this->extensionRepository->findByCategory($category));
}
/**
* List by tag action, displays all extensions with a tag
*
* @param Tx_TerFe2_Domain_Model_Tag $tag The tag to search for
* @return void
*/
public function listByTagAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->view->assign('extensions', $this->extensionRepository->findByTag($tag));
}
/**
* Action that displays a single extension
*
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->view->assign('extension', $extension);
}
/**
* Displays a form for creating a new extension
*
* @param Tx_TerFe2_Domain_Model_Extension $newExtension New extension object
* @return void
* @dontvalidate $newExtension
*/
public function newAction(Tx_TerFe2_Domain_Model_Extension $newExtension = NULL) {
$this->view->assign('newExtension', $newExtension);
$this->view->assign('categories', $this->categoryRepository->findAll());
$this->view->assign('tags', $this->tagRepository->findAll());
}
/**
* Creates a new extension
*
* @param Tx_TerFe2_Domain_Model_Extension $newExtension New extension object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
$this->extensionRepository->add($newExtension);
$this->flashMessageContainer->add($this->translate('msg.extension_created'));
$this->redirect('index');
}
/**
* Displays a form to edit an existing extension
*
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to display
* @return void
* @dontvalidate $extension
*/
public function editAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->view->assign('extension', $extension);
}
/**
* Updates an existing extension
*
* @param Tx_TerFe2_Domain_Model_Extension $extension extension to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->update($extension);
$this->flashMessageContainer->add($this->translate('msg.extension_updated'));
$this->redirect('show', NULL, NULL, array('extension' => $extension->getUid()));
}
/**
* Deletes an existing extension and all versions
*
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to delete
* @return void
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->remove($extension);
$this->flashMessageContainer->add($this->translate('msg.extension_deleted'));
$this->redirect('index');
}
/**
* Check file hash and increment counter while downloading
*
* @param Tx_TerFe2_Domain_Model_Version $newVersion An existing version object
* @param string $format Format of the file output
* @return void
*/
public function downloadAction(Tx_TerFe2_Domain_Model_Version $version, $format = 't3x') {
// TODO: Implement functionality
}
}
?>
\ No newline at end of file
<?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
*/
class Tx_TerFe2_Controller_TagController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var Tx_TerFe2_Domain_Repository_TagRepository
*/
protected $tagRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
}
/**
* Index action, displays all tags
*
* @return void
*/
public function indexAction() {
$this->view->assign('tags', $this->tagRepository->findAll());
}
/**
* Displays a form for creating a new tag
*
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to add the new tag
* @param Tx_TerFe2_Domain_Model_Tag $newTag New tag object
* @return void
* @dontvalidate $newTag
*/
public function newAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Tag $newTag = NULL) {
$this->view->assign('newTag', $newTag);
$this->view->assign('extension', $extension);
}
/**
* Creates a new tag
*
* @param Tx_TerFe2_Domain_Model_Tag $newTag New tag object
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to add the new tag
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Tag $newTag, Tx_TerFe2_Domain_Model_Extension $extension) {
if ($tag = $this->tagRepository->findByTitle($newTag->getTitle())->getFirst()) {
$extension->addTag($tag);
} else {
$this->tagRepository->add($newTag);
$extension->addTag($newTag);
}
$this->flashMessageContainer->add($this->translate