Commit b54d8792 authored by speedprogs_de's avatar speedprogs_de
Browse files

working version review process

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@53283 735d13b6-9817-0410-8766-e36946ffe9aa
parent 33347b97
......@@ -68,13 +68,48 @@
/**
* Send flash message and redirect to given action
*
* @param string $message Identifier of the message to send
* @param string $action Name of the action
* @param string $messageIdentifier Identifier of the message to send
* @param string $controller Unqualified object name of the controller
* @param string $extension Name of the extension containing the controller
* @param array $arguments Arguments to pass to the target action
* @return void
*/
protected function redirectWithMessage($action, $messageIdentifier) {
$this->flashMessageContainer->add($this->translate('msg.' . $messageIdentifier));
$this->redirect($action);
protected function redirectWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) {
$this->flashMessageContainer->add($message);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->redirect($action, $controller, $extension, $arguments);
}
/**
* Send flash message and forward to given action
*
* @param string $message Identifier of the message to send
* @param string $action Name of the action
* @param string $controller Unqualified object name of the controller
* @param string $extension Name of the extension containing the controller
* @param array $arguments Arguments to pass to the target action
* @return void
*/
protected function forwardWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) {
$this->flashMessageContainer->add($message);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->forward($action, $controller, $extension, $arguments);
}
/**
* Clear cache of given pages
*
* @param string $pages List of page ids
* @return void
*/
protected function clearPageCache($pages) {
if (!empty($pages)) {
$pages = t3lib_div::intExplode(',', $pages, TRUE);
Tx_Extbase_Utility_Cache::clearPageCache($pages);
}
}
}
......
......@@ -43,6 +43,11 @@
*/
protected $terSettings = array();
/**
* @var array
*/
protected $terAccount = array();
/**
* Initialize action
......@@ -53,6 +58,7 @@
parent::initializeAction();
$this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : array());
$this->terSettings = (!empty($this->settings['terConnection']) ? $this->settings['terConnection'] : array());
$this->terAccount = $this->getTerAccount();
$this->terConnection = $this->getTerConnection();
}
......@@ -73,27 +79,40 @@
/**
* Create a connection to the TER server
* Returns the account data from current frontend user
*
* @return Tx_TerFe2_Service_Ter The TER connection
* @return array Frontend user account data
*/
protected function getTerConnection() {
// Get username and password
protected function getTerAccount() {
$username = $this->frontendUser['username'];
$password = $this->frontendUser['password'];
if (!empty($this->terSettings['username']) && !empty($this->terSettings['password'])) {
$username = $settings['username'];
$password = $settings['password'];
}
return array(
'username' => $username,
'password' => $password,
);
}
/**
* Create a connection to the TER server
*
* @return Tx_TerFe2_Service_Ter The TER connection
*/
protected function getTerConnection() {
// Check the wsdl uri
if (empty($this->terSettings['wsdl'])) {
throw new Exception($this->translate('registerkey.noWsdl'));
throw new Exception('No wsdl set to connect to TER server');
}
// Create connection
$wsdl = $this->terSettings['wsdl'];
return $this->objectManager->create('Tx_TerFe2_Service_Ter', $wsdl, $username, $password);
return $this->objectManager->create('Tx_TerFe2_Service_Ter', $wsdl, $this->terAccount['username'], $this->terAccount['password']);
}
}
......
......@@ -93,7 +93,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->update($author);
$this->redirectWithMessage('list', 'author_updated');
$this->redirectWithMessage($this->translate('msg.author_updated'), 'list');
}
}
......
......@@ -93,7 +93,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory) {
$this->categoryRepository->add($newCategory);
$this->redirectWithMessage('list', 'category_created');
$this->redirectWithMessage($this->translate('msg.category_created'), 'list');
}
......@@ -117,7 +117,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->update($category);
$this->redirectWithMessage('list', 'category_updated');
$this->redirectWithMessage($this->translate('msg.category_updated'), 'list');
}
......@@ -129,7 +129,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->remove($category);
$this->redirectWithMessage('list', 'category_deleted');
$this->redirectWithMessage($this->translate('msg.category_deleted'), 'list');
}
}
......
......@@ -198,7 +198,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
$this->extensionRepository->add($newExtension);
$this->redirectWithMessage('index', 'extension_created');
$this->redirectWithMessage($this->translate('msg.extension_created'), 'index');
}
......@@ -222,8 +222,8 @@
*/
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()));
$actionParameters = array('extension' => $extension);
$this->redirectWithMessage($this->translate('msg.extension_updated'), 'show', NULL, NULL, $actionParameters);
}
......@@ -235,7 +235,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->remove($extension);
$this->redirectWithMessage('index', 'extension_deleted');
$this->redirectWithMessage($this->translate('msg.extension_deleted'), 'index');
}
......@@ -276,16 +276,15 @@
if (Tx_TerFe2_Utility_File::isAbsolutePath($fileUrl)) {
$fileUrl = Tx_TerFe2_Utility_File::getUrlFromAbsolutePath($fileUrl);
}
$this->flashMessageContainer->add($this->translate('msg.file_not_found') . ': ' . $fileUrl);
$this->redirect('index');
//$this->redirectWithMessage('index', 'file_not_found');
$this->redirectWithMessage($this->translate('msg.file_not_found') . ': ' . $fileUrl, 'index');
// $this->redirectWithMessage($this->translate('msg.file_not_found'), 'index');
}
// Check file hash of t3x packages
if ($format === 't3x') {
$fileHash = Tx_TerFe2_Utility_File::getFileHash($fileUrl);
if ($fileHash != $version->getFileHash()) {
$this->redirectWithMessage('index', 'file_hash_not_equal');
$this->redirectWithMessage($this->translate('msg.file_hash_not_equal'), 'index');
}
}
......@@ -306,7 +305,7 @@
// Send file to browser
if (!Tx_TerFe2_Utility_File::transferFile($fileUrl)) {
$this->redirectWithMessage('index', 'could_not_transfer_file');
$this->redirectWithMessage($this->translate('msg.could_not_transfer_file'), 'index');
}
// Fallback
......
......@@ -99,8 +99,8 @@
$this->mediaRepository->add($newMedia);
$extension->addMedia($newMedia);
}
$this->flashMessageContainer->add($this->translate('msg.media_created'));
$this->redirect('show', 'Extension', NULL, array('extension' => $extension));
$actionParameters = array('extension' => $extension);
$this->redirectWithMessage($this->translate('msg.media_created'), 'show', 'Extension', NULL, $actionParameters);
}
......@@ -125,7 +125,7 @@
public function updateAction(Tx_TerFe2_Domain_Model_Media $media) {
$this->mediaRepository->update($media);
// TODO: Update extension too
$this->redirectWithMessage('list', 'media_updated');
$this->redirectWithMessage($this->translate('msg.media_updated'), 'list');
}
......@@ -138,7 +138,7 @@
public function deleteAction(Tx_TerFe2_Domain_Model_Media $media) {
$this->mediaRepository->remove($media);
// TODO: Remove from extension too
$this->redirectWithMessage('list', 'media_deleted');
$this->redirectWithMessage($this->translate('msg.media_deleted'), 'list');
}
}
......
......@@ -28,21 +28,6 @@
*/
class Tx_TerFe2_Controller_ReviewController extends Tx_TerFe2_Controller_AbstractTerBasedController {
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* @var Tx_TerFe2_Domain_Repository_VersionRepository
*/
protected $versionRepository;
/**
* @var Tx_TerFe2_Provider_ProviderManager
*/
protected $providerManager;
/**
* @var Tx_Extbase_Persistence_Manager
*/
......@@ -55,77 +40,52 @@
* @return void
*/
protected function initializeController() {
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository');
$this->providerManager = $this->objectManager->get('Tx_TerFe2_Provider_ProviderManager');
$this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_Manager');
$this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_Manager');
}
/**
* Display the version overview
* Set unsecure flag of all given versions
*
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to display
* @param string $extensionKey Extension key
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to update
* @param array $unsecureVersions Version UIDs
* @return void
* @dontvalidate $extension
* @dontvalidate $extensionKey
*/
public function indexAction(Tx_TerFe2_Domain_Model_Extension $extension = NULL, $extensionKey = NULL) {
if (!empty($extensionKey)) {
if (!is_string($extensionKey)) {
throw new Exception('No valid extension key given');
}
$extension = $this->extensionRepository->findOneByExtKey($extensionKey);
}
if ($extension !== NULL && $extension instanceof Tx_TerFe2_Domain_Model_Extension) {
$this->view->assign('extension', $extension);
}
}
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension, array $unsecureVersions) {
$extensionKey = $extension->getExtKey();
$versions = $extension->getVersions();
$persist = FALSE;
/**
* Displays a form to edit an existing extension
*
* @param Tx_TerFe2_Domain_Model_Version $version Version to modify
* @param integer $reviewState Review state
* @param boolean $inherit Inherit changes to all versions before current
* @return void
* @dontvalidate $version
* @dontvalidate $reviewState
* @dontvalidate $inherit
*/
public function editAction(Tx_TerFe2_Domain_Model_Version $version = NULL, $reviewState = NULL, $inherit = FALSE) {
$this->view->assign('version', $version);
$this->view->assign('reviewState', $reviewState);
}
foreach ($versions as $version) {
$versionString = $version->getVersionString();
$actionParameters = array('extension' => $extension);
$reviewState = 0;
if (in_array($version->getUid(), $unsecureVersions)) {
$reviewState = -1;
}
/**
* Updates an existing extension
*
* @param Tx_TerFe2_Domain_Model_Version $version Version to modify
* @param integer $reviewState Review state
* @param boolean $inherit Inherit changes to all versions before current
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Version $version, $reviewState, $inherit = FALSE) {
$reviewStateDataArr = array (
'extensionKey' => (string) $version->getExtension()->getExtKey(),
'version' => (string) $version->getVersionString(),
'reviewState' => (int) $reviewState,
);
if ($reviewState === $version->getReviewState()) {
continue;
}
if ($soapClientObj->setReviewState($accountDataArr, $reviewStateDataArr)) {
if (empty($inherit)) {
$version->setReviewState((int) $reviewState);
$error = '';
if ($this->terConnection->setReviewState($extensionKey, $versionString, $reviewState, $error)) {
$version->setReviewState($reviewState);
$persist = TRUE;
} else {
$versions = $this->versionRepository->findAllBelowVersion($version->getExtension(), $version->getVersionNumber());
$message = $this->translate('msg.reviewstate_not_enabled', array($versionString, $error));
$this->redirectWithMessage($message, 'show', 'Extension', NULL, $actionParameters);
return;
}
}
if ($persist) {
$this->persistenceManager->persistAll();
} else {
$this->flashMessageContainer->add('msg.reviewstate_not_enabled');
$this->redirectWithMessage($this->translate('msg.reviewstate_enabled'), 'show', 'Extension', NULL, $actionParameters);
}
$this->redirectWithMessage($this->translate('msg.reviewstate_not_changed'), 'show', 'Extension', NULL, $actionParameters);
}
}
......
......@@ -161,5 +161,32 @@
return (!empty($result['resultCode']) && $result['resultCode'] === '10000');
}
/**
* Set review state of an extension version
*
* @param string $extensionKey The extension key
* @param string $versionString Version as string
* @param integer $reviewState New review state
* @param string $error Contains the error
* @return boolean TRUE if success
*/
public function setReviewState($extensionKey, $versionString, $reviewState, &$error = '') {
$parameters = array(
'extensionKey' => $extensionKey,
'version' => $versionString,
'reviewState' => $reviewState,
);
try {
$this->getSoapService()->setReviewState($this->userData, $parameters);
} catch (SoapFault $exception) {
$error = $exception->faultstring;
return FALSE;
}
return TRUE;
}
}
?>
\ No newline at end of file
......@@ -46,7 +46,7 @@
/**
* @var string
*/
protected $languageFile = 'EXT:ter_fe2/Resources/Private/Language/locallang.xml';
protected $languageFile = 'EXT:ter_fe2/Resources/Private/Language/locallang_db.xml';
/**
* @var string
......
......@@ -99,6 +99,9 @@ plugin.tx_terfe2 {
# cat=TER Frontend/settings/5060; type=boolean; label=Show tag overview: Show all tags in index list
tagOverview = 0
# cat=TER Frontend/settings/5070; type=boolean; label=Show review form: Show review form in detail view
reviewForm = 1
}
}
......
......@@ -45,6 +45,7 @@ plugin.tx_terfe2 {
categoryOverview = {$plugin.tx_terfe2.settings.show.categoryOverview}
tagExtensions = {$plugin.tx_terfe2.settings.show.tagExtensions}
tagOverview = {$plugin.tx_terfe2.settings.show.tagOverview}
reviewForm = {$plugin.tx_terfe2.settings.show.reviewForm}
}
}
......
......@@ -68,28 +68,6 @@
<label index="tx_terfe2_domain_model_author.company">Company name</label>
<label index="tx_terfe2_domain_model_author.forge_link">Forge profile</label>
<label index="tx_terfe2_task_elementsPerRun">Element count to process at once</label>
<label index="tx_terfe2_task_clearCachePages">Clear cache of these pages after run</label>
<label index="tx_terfe2_task_forceLastRun">Force last run time</label>
<label index="tx_terfe2_task_forceOffset">Force offset</label>
<label index="tx_terfe2_task_ignoreEmptyUntil">Proceed with empty result up to an offset of</label>
<label index="tx_terfe2_task_providerName">Fetch extensions from this source</label>
<label index="tx_terfe2_task_createExtensions">Create extensions if not exist</label>
<label index="tx_terfe2_task_extensionFilePath">Relative path to extension files directory</label>
<label index="tx_terfe2_task_forceRecalculation">Force recalculation of extension downloads</label>
<label index="tx_terfe2_task_validityTime">Entries are valid for this time (seconds)</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>
<label index="tx_terfe2_task_updatedownloadstask.name">Update download count</label>
<label index="tx_terfe2_task_updatedownloadstask.description">Update the number of downloads for the latest versions</label>
<label index="tx_terfe2_task_createextensionfilestask.name">Create extension related files</label>
<label index="tx_terfe2_task_createextensionfilestask.description">Create extension related files like zip file or images</label>
<label index="tx_terfe2_task_searchindextask.name">Update search index</label>
<label index="tx_terfe2_task_searchindextask.description">Update search index with new versions</label>
<label index="tx_terfe2_provider_mirrorprovider.name">Mirror Servers</label>
<label index="tx_terfe2_provider_fileprovider.name">Local Filesystem</label>
<label index="tx_terfe2_provider_soapprovider.name">SOAP Server</label>
<label index="msg.extension_created">Extension created</label>
<label index="msg.extension_updated">Extension updated</label>
<label index="msg.extension_deleted">Extension deleted</label>
......@@ -112,7 +90,9 @@
<label index="msg.could_not_transfer_file">File download is broken</label>
<label index="msg.sorting_manipulated">Sorting form was manipulated</label>
<label index="msg.extension_not_found">Extension not found</label>
<label index="msg.reviewstate_not_enabled">The review state could not be set on TER server</label>
<label index="msg.reviewstate_enabled">The review state has been set</label>
<label index="msg.reviewstate_not_enabled">The review state could not be set for version "%s". Message: "%s"</label>
<label index="msg.reviewstate_not_changed">The review state has not changed</label>
<label index="header.latest_extensions">Latest Extensions</label>
<label index="header.top_rated_extensions">Top rated Extensions</label>
......@@ -122,6 +102,7 @@
<label index="header.quicklinks">Quicklinks</label>
<label index="header.json_output">JSON Output</label>
<label index="header.rss_output">RSS Output</label>
<label index="header.review_form">Extension review</label>
<label index="link.latest_extensions">Latest Extensions</label>
<label index="link.latest_extensions.rss">Latest Extensions (RSS)</label>
......@@ -165,6 +146,7 @@
<label index="create_category">Create new Category</label>
<label index="single_category">Show single Category</label>
<label index="category_extensions">Extensions in this category</label>
<label index="update_review">Update</label>
<label index="new_tag">Create new Tag for extension</label>
<label index="edit_tag">Edit Tag</label>
......@@ -218,7 +200,9 @@
<label index="filesize">Size</label>
<label index="last_uploaded">Last uploaded</label>
<label index="last_updated">Last updated</label>
<label index="version_history">Versions history</label>
<label index="version_history">Version history</label>
<label index="versions">Versions</label>
<label index="review_versions">Unsecure versions</label>
<label index="registerkey.notloggedin">Please log in to manage your extension or to register a new extension key.</label>
<label index="registerkey.key_registered">Extension key registered</label>
......
......@@ -111,6 +111,29 @@
<label index="tx_terfe2_domain_model_author.username">Username</label>
<label index="tx_terfe2_domain_model_author.versions">Versions</label>
<label index="tx_terfe2_task_elementsPerRun">Element count to process at once</label>
<label index="tx_terfe2_task_clearCachePages">Clear cache of these pages after run</label>
<label index="tx_terfe2_task_forceLastRun">Force last run time</label>
<label index="tx_terfe2_task_forceOffset">Force offset</label>
<label index="tx_terfe2_task_ignoreEmptyUntil">Proceed with empty result up to an offset of</label>
<label index="tx_terfe2_task_providerName">Fetch extensions from this source</label>
<label index="tx_terfe2_task_createExtensions">Create extensions if not exist</label>
<label index="tx_terfe2_task_extensionFilePath">Relative path to extension files directory</label>
<label index="tx_terfe2_task_forceRecalculation">Force recalculation of extension downloads</label>
<label index="tx_terfe2_task_validityTime">Entries are valid for this time (seconds)</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>
<label index="tx_terfe2_task_updatedownloadstask.name">Update download count</label>
<label index="tx_terfe2_task_updatedownloadstask.description">Update the number of downloads for the latest versions</label>
<label index="tx_terfe2_task_createextensionfilestask.name">Create extension related files</label>
<label index="tx_terfe2_task_createextensionfilestask.description">Create extension related files like zip file or images</label>
<label index="tx_terfe2_task_searchindextask.name">Update search index</label>
<label index="tx_terfe2_task_searchindextask.description">Update search index with new versions</label>
<label index="tx_terfe2_provider_mirrorprovider.name">Mirror Servers</label>
<label index="tx_terfe2_provider_fileprovider.name">Local Filesystem</label>
<label index="tx_terfe2_provider_soapprovider.name">SOAP Server</label>
<label index="tt_content.flexform_pi1.s_def">General</label>
<label index="tt_content.flexform_pi1.s_def.type">Type</label>
<label index="tt_content.flexform_pi1.s_def.type.list">List</label>
......@@ -127,6 +150,9 @@
<label index="tt_content.flexform_pi1.s_list">List</label>
<label index="tt_content.flexform_pi1.s_detail">Detail</label>
<label index="tt_content.flexform_pi1.s_search">Search</label>
<label index="newContentElement.wizardItem.title">TER Frontend Index</label>
<label index="newContentElement.wizardItem.description">Adds the TER Frontend Index to current page.</label>
</languageKey>
</data>
</T3locallang>
\ No newline at end of file
<h3><f:translate key="header.review_form"/></h3>
<div class="ter-ext-single-review">
<f:form method="post" action="update" controller="Review" name="extension" object="{extension}">
<label for="versionReview"><f:translate key="review_versions" />:</label>
<div class="ter-ext-single-versions" id="versionReview">
<table cellpadding="0" cellspacing="0" border="0">
<f:for each="{extension.reverseVersionsByDate}" as="version" iteration="versionIterator">
<tr class="{f:if(condition:'{versionIterator.isOdd}', then: 'odd', else: 'even')}">
<td class="ter-ext-single-versions-input">
<f:form.checkbox name="unsecureVersions[]" id="version-{version.uid}" value="{version.uid}" checked="{version.reviewState} < 0" />
</td>
<td class="ter-ext-single-versions-label">
<label for="version-{version.uid}">{version.versionString}</label>
</td>
</tr>
</f:for>
</table>
</div>
<f:form.submit value="{f:translate(key:'update_review')}" class="bu" />
</f:form>
</div>
\ No newline at end of file
......@@ -124,6 +124,10 @@
<f:link.action controller="Extension" action="index" class="bu bu-mini dark-grey"><f:translate key="back_to_extension_list" /></f:link.action>
<f:if condition="{settings.show.reviewForm}">
<f:render partial="ReviewForm" arguments="{extension: extension}"/>
</f:if>
</div>
</f:then>
<f:else>
......
......@@ -282,6 +282,75 @@ div.ter-ext-info table tr.ter-ext-single-info-key td {
}
/**
* Review form
*/
div.ter-ext-single-versions {
overflow-y: scroll;
overflow-x: hidden;
border: 1px solid #D1D1D1;
height: 94px;