Commit 4688b926 authored by speedprogs_de's avatar speedprogs_de

added author object

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@45017 735d13b6-9817-0410-8766-e36946ffe9aa
parent f28e6dda
<?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
*
* @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_AuthorController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* Initializes the current action
*
* @return void
*/
protected function initializeAction() {
$this->authorRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_AuthorRepository');
// Pre-parse TypoScript setup
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
}
/**
* Index action, displays all authors
*
* @return void
*/
public function indexAction() {
$this->view->assign('authors', $this->authorRepository->findAll());
}
/**
* Displays a form for creating a new Author
*
* @param Tx_TerFe2_Domain_Model_Author $newAuthor A fresh Author object taken as a basis for the rendering
* @return void
* @dontvalidate $newAuthor
*/
public function newAction(Tx_TerFe2_Domain_Model_Author $newAuthor = NULL) {
$this->view->assign('newAuthor', $newAuthor);
}
/**
* Creates a new Author and forwards to the index action
*
* @param Tx_TerFe2_Domain_Model_Author $newAuthor A fresh Author object which has not yet been added to the repository
* @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 and forwards to the index action afterwards
*
* @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 be deleted
* @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');
}
/**
* 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
......@@ -44,7 +44,7 @@
* @return void
*/
protected function initializeAction() {
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
// Pre-parse TypoScript setup
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
......
......@@ -45,7 +45,7 @@
* @return void
*/
protected function initializeAction() {
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
// Pre-parse TypoScript setup
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
......
<?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!
******************************************************************/
/**
* Author of an extension
*
* @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_Model_Author extends Tx_Extbase_DomainObject_AbstractEntity {
/**
* Name of the author
* @var string
* @validate NotEmpty
*/
protected $name;
/**
* Email address
* @var string
* @validate EmailAddress
*/
protected $email;
/**
* Company name
* @var string
*/
protected $company;
/**
* Link to forge profile
* @var string
*/
protected $forgeLink;
/**
* versions
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_TerFe2_Domain_Model_Version>
* @lazy
*/
protected $versions;
/**
* Constructor. Initializes all Tx_Extbase_Persistence_ObjectStorage instances.
*/
public function __construct() {
$this->versions = new Tx_Extbase_Persistence_ObjectStorage();
}
/**
* Setter for name
*
* @param string $name Name of the author
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Getter for name
*
* @return string Name of the author
*/
public function getName() {
return $this->name;
}
/**
* Setter for email
*
* @param string $email Email address
* @return void
*/
public function setEmail($email) {
$this->email = $email;
}
/**
* Getter for email
*
* @return string Email address
*/
public function getEmail() {
return $this->email;
}
/**
* Setter for company
*
* @param string $company Company name
* @return void
*/
public function setCompany($company) {
$this->company = $company;
}
/**
* Getter for company
*
* @return string Company name
*/
public function getCompany() {
return $this->company;
}
/**
* Setter for forgeLink
*
* @param string $name Link to forge profile
* @return void
*/
public function setForgeLink($forgeLink) {
$this->forgeLink = $forgeLink;
}
/**
* Getter for forgeLink
*
* @return string Link to forge profile
*/
public function getForgeLink() {
return $this->forgeLink;
}
/**
* Getter for versions
*
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_TerFe2_Domain_Model_Version> versions
*/
public function getVersions() {
return $this->versions;
}
/**
* Adds a version
*
* @param Tx_TerFe2_Domain_Model_Version The Version to be added
* @return void
*/
public function addVersion(Tx_TerFe2_Domain_Model_Version $version) {
$this->versions->attach($version);
}
/**
* Removes a version
*
* @param Tx_TerFe2_Domain_Model_Version The Version to be removed
* @return void
*/
public function removeVersion(Tx_TerFe2_Domain_Model_Version $version) {
$this->versions->detach($version);
}
}
?>
\ No newline at end of file
......@@ -53,9 +53,9 @@
protected $fileHash;
/**
* author
* @var string
* @validate NotEmpty
* Author
* @var Tx_TerFe2_Domain_Model_Author
* @lazy
*/
protected $author;
......@@ -295,20 +295,20 @@
}
/**
* Setter for author
* Setter for Author
*
* @param string $author author
* @param Tx_TerFe2_Domain_Model_Author $author Author
* @return void
*/
public function setAuthor($author) {
public function setAuthor(Tx_TerFe2_Domain_Model_Author $author) {
$this->author = $author;
}
/**
* Getter for author
* Getter for Author
*
* @return string author
* @return Tx_TerFe2_Domain_Model_Author Author
*/
public function getAuthor() {
return $this->author;
......
<?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_Author
*
* @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_AuthorRepository extends Tx_Extbase_Persistence_Repository {
}
?>
\ No newline at end of file
......@@ -152,7 +152,11 @@
}
// Get class structure and property options
$classNames = array('Tx_TerFe2_Domain_Model_Extension', 'Tx_TerFe2_Domain_Model_Version');
$classNames = array(
'Tx_TerFe2_Domain_Model_Extension',
'Tx_TerFe2_Domain_Model_Version',
'Tx_TerFe2_Domain_Model_Author',
);
foreach ($classNames as $className) {
$classSchema = $this->reflectionService->getClassSchema($className);
$dataMap = $this->dataMapFactory->buildDataMap($className);
......@@ -175,6 +179,11 @@
$tagValues = $this->reflectionService->getPropertyTagValues($className, $propertyName, 'validate');
$required = (stripos(implode(',', $tagValues), 'NotEmpty') !== FALSE);
// Check for Author fields
if ($className == 'Tx_TerFe2_Domain_Model_Author') {
$propertyName = 'author' . ucfirst($propertyName);
}
// Build field
$this->extInfoSchema[$propertyName] = array(
'type' => $propertyData['type'],
......
......@@ -87,6 +87,7 @@
$extData['uploadComment'] = '';
$extData['fileName'] = $fileName;
$extData['versionString'] = $extData['version'];
$extData['authorName'] = $extData['author'];
$extData['authorEmail'] = $extData['author_email'];
$extData['authorCompany'] = $extData['author_company'];
$extData['emCategory'] = $extData['category'];
......
......@@ -43,6 +43,11 @@
*/
protected $extensionRepository;
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
......@@ -68,15 +73,14 @@
* Public method, usually called by scheduler.
*
* TODO:
* - Check how to handle author information
* - Add upload comment to version object (requires a connection to ter extension?)
* - Create ViewHelper to get image file from extensionProvider using getUrlToFile()
* - Add upload comment to version object (get via SOAP connection from ter)
* - Create new Versions only if Extension was already registered via Frontend,
* do not create new Extensions if not
* - Finalize SOAP Extension Provider
* - Additonal Version Info:
* - Codelines
* - Codebytes
* - Add "authorForgeLink" to extInfo
* - Maybe make author name not required
*
* @return boolean TRUE on success
*/
......@@ -98,12 +102,20 @@
continue;
}
// Load Author if already exists, else create new one
$author = $this->getAuthor($extInfo);
$version->setAuthor($author);
// Load Extension if already exists, else create new one
$extension = $this->getExtension($extInfo);
$version->setExtension($extension);
// Add Version to Object Storages
$author->addVersion($version);
$extension->addVersion($version);
// Persist Extension object now to prevent duplicates
$this->session->registerReconstitutedObject($author);
$this->session->registerReconstitutedObject($extension);
$this->persistenceManager->persistAll();
}
......@@ -136,6 +148,7 @@
// Load required objects
$this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$this->extensionRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->authorRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->registry = t3lib_div::makeInstance('t3lib_Registry');
$this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_Manager');
$this->session = $this->persistenceManager->getSession();
......@@ -196,7 +209,6 @@
$version->setTitle($extInfo['title']);
$version->setDescription($extInfo['description']);
$version->setFileHash($extInfo['fileHash']);
$version->setAuthor($extInfo['author']);
$version->setVersionNumber($extInfo['versionNumber']);
$version->setVersionString($extInfo['versionString']);
$version->setUploadDate(new DateTime());
......@@ -275,6 +287,27 @@
}
/**
* Load Author object if already exists, else create new one
*
* @param array $extInfo Extension information
* @return Tx_TerFe2_Domain_Model_Author New or existing Author object
*/
public function getAuthor(array $extInfo) {
$author = $this->authorRepository->findOneByEmail($extInfo['authorEmail']);
if ($author === NULL) {
// Create new Author
$author = t3lib_div::makeInstance('Tx_TerFe2_Domain_Model_Author');
$author->setName($extInfo['authorName']);
$author->setEmail($extInfo['authorEmail']);
$author->setCompany($extInfo['authorCompany']);
//$author->setForgeLink($extInfo['authorForgeLink']);
}
return $author;
}
/**
* Add Extension Provider to Extension information
*
......
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
$TCA['tx_terfe2_domain_model_author'] = array(
'ctrl' => $TCA['tx_terfe2_domain_model_author']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'name,email,company,forge_link,versions',
),
'types' => array(
'1' => array('showitem' => 'name,email,company,forge_link,versions'),
),
'palettes' => array(
'1' => array('showitem' => ''),
),
'columns' => array(
'sys_language_uid' => array(
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.language',
'config' => array(
'type' => 'select',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => array(
array('LLL:EXT:lang/locallang_general.php:LGL.allLanguages', -1),
array('LLL:EXT:lang/locallang_general.php:LGL.default_value', 0),
),
),
),
'l18n_parent' => array(
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.l18n_parent',
'config' => array(
'type' => 'select',
'foreign_table' => 'tx_terfe2_domain_model_author',
'foreign_table_where' => 'AND tx_terfe2_domain_model_author.uid=###REC_FIELD_l18n_parent### AND tx_terfe2_domain_model_author.sys_language_uid IN (-1,0)',
'items' => array(
array('', 0),
),
),
),
'l18n_diffsource' => array(
'config' => array(
'type' => 'passthrough',
),
),
't3ver_label' => array(
'displayCond' => 'FIELD:t3ver_label:REQ:true',
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.versionLabel',
'config' => array(
'type' => 'none',
'cols' => 27,
),
),
'hidden' => array(
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
'config' => array(
'type' => 'check',
),
),
'name' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_author.name',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim,required',
),
),
'email' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_author.email',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim',
),
),
'company' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_author.company',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim',
),
),
'forge_link' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_author.forge_link',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim',
),
),
'versions' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_author.versions',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_terfe2_domain_model_version',
'foreign_field' => 'author',
'maxitems' => 9999,
'appearance' => array(
'collapse' => 0,
'newRecordLinkPosition' => 'bottom',
),
),
),
),
);
?>
\ No newline at end of file
......@@ -6,10 +6,10 @@
$TCA['tx_terfe2_domain_model_version'] = array(
'ctrl' => $TCA['tx_terfe2_domain_model_version']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'title,description,author,version_number,version_string,upload_date,upload_comment,download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,manual,media,experience,software_relation',
'showRecordFieldList' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,manual,media,experience,software_relation',
),
'types' => array(
'1' => array('showitem' => 'title,description,author,version_number,version_string,upload_date,upload_comment,download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,manual,media,experience,software_relation'),
'1' => array('showitem' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,manual,media,experience,software_relation'),
),
'palettes' => array(
'1' => array('showitem' => ''),
......@@ -79,15 +79,6 @@
'rows' => 5,
),
),
'author' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_version.author',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim,required',
),
),
'version_number' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_version.version_number',
......@@ -344,6 +335,11 @@
),
),
),
'author' => array(
'config' => array(
'type' => 'passthrough',
),
),
'extension' => array(
'config' => array(
'type' => 'passthrough',
......
......@@ -51,6 +51,11 @@
<label index="tx_terfe2_domain_model_relation.software_type">Core, extension or system</label>
<label index="tx_terfe2_domain_model_relation.tx_terfe2_key">extension key, php, mysql or something else</label>
<label index="tx_terfe2_domain_model_relation.version">Version of the field "key", e.g. key "php" and version "5.2"</label>
<label index="tx_terfe2_domain_model_author">Author of the extension</label>
<label index="tx_terfe2_domain_model_author.name">Name of the author</label>
<label index="tx_terfe2_domain_model_author.email">Email address</label>
<label index="tx_terfe2_domain_model_author.company">Company name</label>
<label index="tx_terfe2_domain_model_author.forge_link">Link to forge profile</label>
<label index="tx_terfe2_task_updateextensionlisttask.name">Get new extensions</label>
<label index="tx_terfe2_task_updateextensionlisttask.description">Get new extensions in ter directory</label>
......@@ -64,6 +69,9 @@
<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_author_created">Author created</label>
<label index="msg_author_updated">Author updated</label>
<label index="msg_author_deleted">Author deleted</label>
<label index="msg_file_not_valid">Given file is not valid</label>