[TASK][EM] More readable "time since last update"-strings 16/19116/8
authorJost Baron <jost.baron@gmx.de>
Wed, 20 Mar 2013 18:00:53 +0000 (19:00 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 22 Mar 2013 19:48:36 +0000 (20:48 +0100)
The extensionmanager now shows the time elapsed since the last update,
not the time of the last update. The time of the last update is still
shown in a tooltip. Some english localizations have changed.

Resolves: #46524
Related: #39921
Releases: 6.1
Change-Id: I2d5c6e8099e6973826debfcf2cbb597c35bb499c
Reviewed-on: https://review.typo3.org/19116
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extensionmanager/Classes/Controller/UpdateFromTerController.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/TimeSinceLastUpdateViewHelper.php [new file with mode: 0644]
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Partials/List/UpdateFromTer.html
typo3/sysext/extensionmanager/Resources/Private/Scss/page/_get.scss
typo3/sysext/extensionmanager/Resources/Private/Templates/UpdateFromTer/UpdateExtensionListFromTer.json
typo3/sysext/extensionmanager/Resources/Public/Css/main.css
typo3/sysext/extensionmanager/Resources/Public/JavaScript/update.js

index 6e57487..5005822 100644 (file)
@@ -100,8 +100,7 @@ class UpdateFromTerController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
        public function updateExtensionListFromTerAction($forceUpdateCheck = FALSE) {
                $updated = FALSE;
                $errorMessage = '';
-               /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
-               $repository = $this->repositoryRepository->findOneByUid((int)$this->settings['repositoryUid']);
+
                if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
                        try {
                                $updated = $this->repositoryHelper->updateExtList();
@@ -109,6 +108,8 @@ class UpdateFromTerController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
                                $errorMessage = $e->getMessage();
                        }
                }
+               /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
+               $repository = $this->repositoryRepository->findOneByUid((int)$this->settings['repositoryUid']);
                $this->view->assign('updated', $updated)
                                ->assign('repository', $repository)
                                ->assign('errorMessage', $errorMessage);
diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/TimeSinceLastUpdateViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/TimeSinceLastUpdateViewHelper.php
new file mode 100644 (file)
index 0000000..9efe621
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
+use \TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+
+/*****************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Jost Baron <j.baron@netzkoenig.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!
+ *****************************************************************/
+
+/**
+ * Shows the elapsed time since the last update of the extension repository
+ * from TER in a readable manner.
+ */
+class TimeSinceLastUpdateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+
+       /**
+        * Render method
+        *
+        * @param \DateTime $lastUpdateTime The date of the last update.
+        * @return string
+        */
+       public function render($lastUpdateTime) {
+
+               $now = new \DateTime();
+               $timeSinceLastUpdate = $lastUpdateTime->diff($now, TRUE);
+
+               $result = '';
+
+               if ($timeSinceLastUpdate->days > 1) {
+                       $label = LocalizationUtility::translate('extensionList.updateFromTer.lastUpdate.days.plural', 'extensionmanager');
+                       $result = $timeSinceLastUpdate->format('%a') . $label;
+
+               } elseif ($timeSinceLastUpdate->days === 1) {
+                       $label = LocalizationUtility::translate('extensionList.updateFromTer.lastUpdate.days.singular', 'extensionmanager');
+                       $result = '1' . $label;
+
+               } elseif ($timeSinceLastUpdate->h > 1) {
+                       $label = LocalizationUtility::translate('extensionList.updateFromTer.lastUpdate.hours.plural', 'extensionmanager');
+                       $result = $timeSinceLastUpdate->format('%h') . $label;
+
+               } elseif ($timeSinceLastUpdate->h === 1) {
+                       $label = LocalizationUtility::translate('extensionList.updateFromTer.lastUpdate.hours.singular', 'extensionmanager');
+                       $result = '1' . $label;
+
+               } else {
+                       $label = LocalizationUtility::translate('extensionList.updateFromTer.lastUpdate.lessThanOneHour', 'extensionmanager');
+                       $result = $label;
+               }
+
+               return $result;
+       }
+}
+
+?>
\ No newline at end of file
index d5a67a2..dc672cd 100644 (file)
                        <trans-unit id="extensionList.showAllVersions.label" xml:space="preserve">
                                <source>Show all versions</source>
                        </trans-unit>
+
                        <trans-unit id="extensionList.updateFromTer.label" xml:space="preserve">
                                <source>Retrieving Extension-List from TYPO3 Extension Repository (TER)</source>
                        </trans-unit>
                        <trans-unit id="extensionList.updateFromTer.lastUpdate.label" xml:space="preserve">
                                <source>Last update:</source>
                        </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.timeSinceLastUpdateLabel" xml:space="preserve">
+                               <source>Time since last update:</source>
+                       </trans-unit>
                        <trans-unit id="extensionList.updateFromTer.lastUpdate.noInfo" xml:space="preserve">
-                               <source>No information available about last update.</source>
+                               <source>unknown</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.fullTimeFormat" xml:space="preserve">
+                               <source>Y-m-d H:i:s</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.timeOfLastUpdate" xml:space="preserve">
+                               <source>Time of last update: </source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.noTimeOfLastUpdate" xml:space="preserve">
+                               <source>No last update time known.</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.days.plural" xml:space="preserve">
+                               <source> days</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.days.singular" xml:space="preserve">
+                               <source> day</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.hours.plural" xml:space="preserve">
+                               <source> hours</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.hours.singular" xml:space="preserve">
+                               <source> hour</source>
+                       </trans-unit>
+                       <trans-unit id="extensionList.updateFromTer.lastUpdate.lessThanOneHour" xml:space="preserve">
+                               <source>Less than one hour</source>
                        </trans-unit>
 
                        <trans-unit id="task.updateExtensionListTask.name" xml:space="preserve">
index ddde192..3cd6e03 100644 (file)
@@ -4,8 +4,10 @@
        format="json"
        class="update-from-ter"
        >
-       {f:translate(key: 'extensionList.updateFromTer.lastUpdate.label')}
-       <span class="text">{f:translate(key: 'extensionList.updateFromTer.lastUpdate.noInfo')}</span>
+       {f:translate(key: 'extensionList.updateFromTer.lastUpdate.timeSinceLastUpdateLabel')}
+       <span class="time-since-last-update" title="{f:translate(key: 'extensionList.updateFromTer.lastUpdate.noTimeOfLastUpdate')}">
+               {f:translate(key: 'extensionList.updateFromTer.lastUpdate.noInfo')}
+       </span>
        <input
                type="submit"
                value="{f:translate(key: 'extensionList.updateFromTer.buttonLabel')}" />
index f8293e8..78d3f53 100644 (file)
@@ -1,6 +1,4 @@
 
-
-
 // Loader
 #terTableWrapper {
        position: relative;
        }
 }
 
+.time-since-last-update {
+       font-weight: bold;
+       padding-right: 0.4em;
+       cursor: help;
+}
 
 .is-loading {
        opacity: 0;
index 1186d71..819d9df 100644 (file)
@@ -2,7 +2,8 @@
 <em:format.jsonEncode
        additionalAttributes="{
                updated: updated,
-               message: '{repository.lastUpdate -> f:format.date()} ({repository.extensionCount} extensions)',
+               lastUpdateTime: '{repository.lastUpdate -> f:format.date(format: \'{f:translate(key: \\\'extensionList.updateFromTer.lastUpdate.fullTimeFormat\\\')}\')}',
+               timeSinceLastUpdate: '{em:timeSinceLastUpdate(lastUpdateTime: repository.lastUpdate)}',
                errorMessage: errorMessage
        }"
 />
index 6f4180e..d4242e1 100644 (file)
@@ -1759,6 +1759,11 @@ button.ui-button::-moz-focus-inner {
   #terTableWrapper .spinner {
     display: inline-block; }
 
+.time-since-last-update {
+  font-weight: bold;
+  padding-right: 0.4em;
+  cursor: help; }
+
 .is-loading {
   opacity: 0; }
 
index fbb3fab..20e40ac 100644 (file)
@@ -40,6 +40,7 @@
                $.ajax({
                        url: url,
                        dataType: 'json',
+                       cache: false,
                        success: function(data) {
 
                                // Something went wrong, show message
                                }
 
                                // Message with latest updates
-                               $('.update-from-ter .text').html(
-                                       data.message
+                               var $lastUpdate = $('.update-from-ter .time-since-last-update');
+                               $lastUpdate.text(data.timeSinceLastUpdate);
+                               $lastUpdate.attr(
+                                       'title',
+                                       TYPO3.l10n.localize('extensionList.updateFromTer.lastUpdate.timeOfLastUpdate') + data.lastUpdateTime
                                );
 
                                if (data.updated) {