Commit c5413a30 authored by speedprogs_de's avatar speedprogs_de

moved fileHash into version object, added a method to create versions, removed...

moved fileHash into version object, added a method to create versions, removed version controller and templates, added repository for tags and categories

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@42878 735d13b6-9817-0410-8766-e36946ffe9aa
parent 52dd4e08
......@@ -38,6 +38,26 @@
*/
protected $extensionRepository;
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Domain_Repository_TagRepository
*/
protected $tagRepository;
/**
* @var Tx_TerFe2_Service_TypoScriptParserService
*/
protected $typoScriptParser;
/**
* @var Tx_TerFe2_Service_FileHandlerService
*/
protected $fileHandler;
/**
* Initializes the current action
......@@ -46,11 +66,13 @@
*/
protected function initializeAction() {
$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->typoScriptParser = t3lib_div::makeInstance('Tx_TerFe2_Service_TypoScriptParserService');
$this->fileHandler = t3lib_div::makeInstance('Tx_TerFe2_Service_FileHandlerService');
// Pre-parse TypoScript
$typoScriptParser = t3lib_div::makeInstance('Tx_TerFe2_Service_TypoScriptParserService');
$this->settings = $typoScriptParser->getParsed($this->settings);
unset($typoScriptParser);
// Pre-parse TypoScript setup
$this->settings = $this->typoScriptParser->getParsed($this->settings);
}
......@@ -64,6 +86,14 @@
}
/**
* List action, displays all extensions
*/
public function listAction() {
$this->view->assign('extensions', $this->extensionRepository->findAll());
}
/**
* Action that displays a single Extension
*
......@@ -80,9 +110,11 @@
* @param Tx_TerFe2_Domain_Model_Extension $newExtension A fresh Extension object taken as a basis for the rendering
* @dontvalidate $newExtension
*/
/*public function newAction(Tx_TerFe2_Domain_Model_Extension $newExtension = NULL) {
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());
}
/**
......@@ -90,11 +122,11 @@
*
* @param Tx_TerFe2_Domain_Model_Extension $newExtension A fresh Extension object which has not yet been added to the repository
*/
/*public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
$this->extensionRepository->add($newExtension);
$this->flashMessageContainer->add('Your new Extension was created.');
$this->flashMessageContainer->add($this->translate('msg_extension_created'));
$this->redirect('index');
}*/
}
/**
......@@ -103,22 +135,20 @@
* @param Tx_TerFe2_Domain_Model_Extension $extension The Extension to display
* @dontvalidate $extension
*/
/*public function editAction(Tx_TerFe2_Domain_Model_Extension $extension) {
public function editAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->view->assign('extension', $extension);
}*/
}
/**
* Creates a new Version of 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 An existing Extension object
* @param Tx_TerFe2_Domain_Model_Version $newVersion A fresh Version object which has not yet been added to the repository
* @param Tx_TerFe2_Domain_Model_Extension $extension Extension to update
*/
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Version $newVersion) {
$extension->addVersion($newVersion);
$extension->setLastUpdate(new DateTime());
$newVersion->setExtension($extension);
$this->redirect('index', 'Extension');
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->update($extension);
$this->flashMessageContainer->add($this->translate('msg_extension_updated'));
$this->redirect('index');
}
......@@ -132,5 +162,38 @@
$this->redirect('index');
}
/**
* 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
*/
public function createVersionAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Version $newVersion) {
// Get file hash
$fileHash = $this->fileHandler->getFileHash($newVersion->getFilename());
if (!empty($fileHash)) {
$newVersion->setFileHash($fileHash);
$newVersion->setExtension($extension);
$extension->addVersion($newVersion);
$extension->setLastUpdate(new DateTime());
$this->redirect('index');
} else {
$this->flashMessages->add($this->translate('msg_file_not_valid'));
}
}
/**
* 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()) {
return Tx_Extbase_Utility_Localization::translate($label, 'ter_fe2', $arguments);
}
}
?>
\ No newline at end of file
......@@ -58,12 +58,6 @@
*/
protected $lastUpdate;
/**
* fileHash
* @var string
*/
protected $fileHash;
/**
* categories
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_TerFe2_Domain_Model_Category>
......@@ -177,27 +171,6 @@
}
/**
* Setter for fileHash
*
* @param string $fileHash MD5 hash of the t3x file
* @return void
*/
public function setFileHash($fileHash) {
$this->fileHash = $fileHash;
}
/**
* Getter for fileHash
*
* @return string MD5 hash of the t3x file
*/
public function getFileHash() {
return $this->fileHash;
}
/**
* Getter for categories
*
......
......@@ -178,6 +178,12 @@
*/
protected $cglComplianceNote;
/**
* Hash of the t3x file
* @var string
*/
protected $fileHash;
/**
* Relation to manual object of ter_doc extension
* @var string
......@@ -702,6 +708,27 @@
}
/**
* Setter for fileHash
*
* @param string $fileHash Hash of the t3x file
* @return void
*/
public function setFileHash($fileHash) {
$this->fileHash = $fileHash;
}
/**
* Getter for fileHash
*
* @return string Hash of the t3x file
*/
public function getFileHash() {
return $this->fileHash;
}
/**
* Setter for manual
*
......
......@@ -2,8 +2,7 @@
/*******************************************************************
* Copyright notice
*
* (c) 2011 Thomas Loeffler <loeffler@spooner-web.de>, Spooner Web
* Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
......@@ -25,76 +24,13 @@
******************************************************************/
/**
* Controller for the Version object
* Repository for Tx_TerFe2_Domain_Model_Category
*
* @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_VersionController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_TerFe2_Domain_Repository_VersionRepository
*/
protected $versionRepository;
/**
* Initializes the current action
*
* @return void
*/
protected function initializeAction() {
$this->versionRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_VersionRepository');
}
/**
* List action for this controller. Displays all Versions.
*
* @param Tx_TerFe2_Domain_Model_Extension $extension An existing Extension object
*/
public function indexAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$versions = $this->versionRepository->findByExtension($extension);
$this->view->assign('versions', $versions);
}
/**
* Action that displays a single Version
*
* @param Tx_TerFe2_Domain_Model_Version $version The Version to display
*/
public function showAction(Tx_TerFe2_Domain_Model_Version $version) {
$this->view->assign('version', $version);
}
/**
* Displays a form for creating a new Version
*
* @param Tx_TerFe2_Domain_Model_Extension $extension An existing Extension object
* @param Tx_TerFe2_Domain_Model_Version $newVersion A fresh Version object taken as a basis for the rendering
* @dontvalidate $newVersion
*/
public function newAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Version $newVersion = NULL) {
$this->view->assign('extension', $extension);
$this->view->assign('newVersion', $newVersion);
}
/**
* Creates a new Version and forwards to the index action.
*
* @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
*/
public function createAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Version $newVersion) {
$extension->addVersion($newVersion);
$extension->setLastUpdate(new DateTime());
$newVersion->setExtension($extension);
$this->redirect('index', 'Extension');
}
class Tx_TerFe2_Domain_Repository_CategoryRepository extends Tx_Extbase_Persistence_Repository {
}
?>
\ 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!
******************************************************************/
/**
* Repository for Tx_TerFe2_Domain_Model_Tag
*
* @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_Domain_Repository_TagRepository extends Tx_Extbase_Persistence_Repository {
}
?>
\ No newline at end of file
......@@ -70,7 +70,8 @@
* @return array Unpacked extension files
*/
public function unpackT3xFile($filename) {
if (!$this->fileExists($filename)) {
$filename = $this->getAbsFilename($filename);
if (empty($filename)) {
return array();
}
......@@ -102,7 +103,8 @@
* @return string Generated hash or an empty string if file not found
*/
public function getFileHash($filename) {
if (!$this->fileExists($filename)) {
$filename = $this->getAbsFilename($filename);
if (empty($filename)) {
return '';
}
......@@ -120,7 +122,8 @@
* @return boolean FALSE if file not exists
*/
public function transferFile($filename, $visibleFilename = '') {
if (!$this->fileExists($filename)) {
$filename = $this->getAbsFilename($filename);
if (empty($filename)) {
return FALSE;
}
......
......@@ -6,10 +6,10 @@
$TCA['tx_terfe2_domain_model_extension'] = array(
'ctrl' => $TCA['tx_terfe2_domain_model_extension']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'ext_key,forge_link,hudson_link,last_update,file_hash,categories,tags,versions',
'showRecordFieldList' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions',
),
'types' => array(
'1' => array('showitem' => 'ext_key,forge_link,hudson_link,last_update,file_hash,categories,tags,versions'),
'1' => array('showitem' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions'),
),
'palettes' => array(
'1' => array('showitem' => ''),
......@@ -99,15 +99,6 @@
'default' => '0',
),
),
'file_hash' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_extension.file_hash',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim',
),
),
'categories' => array(
'exclude' => 0,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_extension.categories',
......
......@@ -363,6 +363,11 @@
'type' => 'passthrough',
),
),
'file_hash' => array(
'config' => array(
'type' => 'passthrough',
),
),
),
);
?>
\ No newline at end of file
......@@ -11,7 +11,6 @@
<label index="forge_link.description">forgeLink</label>
<label index="hudson_link.description">hudsonLink</label>
<label index="last_update.description">lastUpdate</label>
<label index="file_hash.description">fileHash</label>
<label index="categories.description">category</label>
<label index="tags.description">tag</label>
<label index="versions.description">version</label>
......
......@@ -11,7 +11,6 @@
<label index="tx_terfe2_domain_model_extension.forge_link">Forge Link</label>
<label index="tx_terfe2_domain_model_extension.hudson_link">Hudson Link</label>
<label index="tx_terfe2_domain_model_extension.last_update">Last update</label>
<label index="tx_terfe2_domain_model_extension.file_hash">MD5 hash of the t3x file</label>
<label index="tx_terfe2_domain_model_extension.categories">Categories</label>
<label index="tx_terfe2_domain_model_extension.tags">Tags</label>
<label index="tx_terfe2_domain_model_extension.versions">Versions</label>
......
<f:layout name="default" />
This Template is responsible for creating a table of domain objects.
<f:section name="main">
<h1>Listing for Versions</h1>
<f:flashMessages />
<table cellpadding="4" style="border:1px solid black;">
<tr>
<th><f:translate key="tx_terfe2_domain_model_version.title" /></th>
<th><f:translate key="tx_terfe2_domain_model_version.version_number" /></th>
</tr>
<f:for each="{versions}" as="version">
<tr>
<td>{version.title}</td>
<td>{version.versionNumber}</td>
</tr>
</f:for>
</table>
<br />
<f:link.action action="index" controller="Extension">Back to listing</f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
This template displays a NEW form for the current domain object.
<f:section name="main">
<h1>New Version</h1>
<f:flashMessages />
<f:render partial="formErrors" arguments="{for: 'newVersion'}" />
<f:form method="post" controller="Version" action="create" name="newVersion" object="{newVersion}" arguments="{extension : extension}">
<label for="title"><f:translate key="tx_terfe2_domain_model_version.title" /></label><br />
<f:form.textbox property="title" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.filename" /></label><br />
<f:form.textbox property="filename" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.author" /></label><br />
<f:form.textbox property="author" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.version_number" /></label><br />
<f:form.textbox property="versionNumber" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.upload_date" /></label><br />
<f:form.textbox property="uploadDate" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.state" /></label><br />
<f:form.textbox property="state" /><br />
<label for="title"><f:translate key="tx_terfe2_domain_model_version.em_category" /></label><br />
<f:form.textbox property="emCategory" /><br />
<f:form.submit value="Create new" />
</f:form>
<f:link.action action="index" controller="Extension">Back to listing</f:link.action>
</f:section>
\ No newline at end of file
<f:layout name="default" />
This Template is responsible for creating a single view for a domain object
<f:section name="main">
<h1>Single View for Versions</h1>
<f:flashMessages />
<table cellpadding="4" style="border:1px solid black;">
<tr>
<td><f:translate key="tx_terfe2_domain_model_version.ext_key" /></td>
<td>{version.extKey}</td>
</tr>
<tr>
<td><f:translate key="tx_terfe2_domain_model_version.forge_link" /></td>
<td>{version.forgeLink}</td>
</tr>
<tr>
<td><f:translate key="tx_terfe2_domain_model_version.hudson_link" /></td>
<td>{version.hudsonLink}</td>
</tr>
</table>
<br />
<f:link.action action="edit" arguments="{version : version}">Edit</f:link.action>
<f:link.action action="delete" arguments="{version : version}">Delete</f:link.action>
<f:link.action action="index" controller="Extension">Back to listing</f:link.action>
</f:section>
\ No newline at end of file
......@@ -8,12 +8,10 @@
$_EXTKEY,
'Pi1',
array(
'Extension' => 'index, show, new, create, edit, update, delete',
'Version' => 'index, show, new, create',
'Extension' => 'index, list, show, new, create, edit, update, delete, createVersion',
),
array(
'Extension' => 'create, update, delete',
'Version' => 'create',
'Extension' => 'create, update, delete, createVersion',
)
);
?>
\ No newline at end of file
......@@ -9,7 +9,6 @@ CREATE TABLE tx_terfe2_domain_model_extension (
forge_link tinytext,
hudson_link tinytext,
last_update int(11) unsigned DEFAULT '0',
file_hash varchar(50) DEFAULT '' NOT NULL,
categories int(11) unsigned DEFAULT '0',
tags int(11) unsigned DEFAULT '0' NOT NULL,
versions int(11) unsigned DEFAULT '0' NOT NULL,
......@@ -138,6 +137,7 @@ CREATE TABLE tx_terfe2_domain_model_version (
lock_type tinytext,
cgl_compliance tinytext,
cgl_compliance_note text,
file_hash varchar(50) DEFAULT '' NOT NULL,
manual tinytext,
media int(11) unsigned DEFAULT '0' NOT NULL,
experience int(11) unsigned DEFAULT '0' NOT NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment