[TASK][EM] More readable "time since last update"-strings 17/19617/2
authorJost Baron <jost.baron@gmx.de>
Wed, 20 Mar 2013 18:00:53 +0000 (19:00 +0100)
committerBenjamin Mack <benni@typo3.org>
Fri, 5 Apr 2013 21:23:37 +0000 (23:23 +0200)
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, 6.0
Change-Id: I2d5c6e8099e6973826debfcf2cbb597c35bb499c
Reviewed-on: https://review.typo3.org/19617
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
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 cfdceca..f10649a 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 6e0b8b6..413691b 100644 (file)
                        <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 d765e48..f7ae4f0 100644 (file)
@@ -1,4 +1,3 @@
-
 <div class="splash-receivedata x-mask-loading is-shown">
        <div class="spinner"></div>
        <f:form
@@ -7,8 +6,11 @@
                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 d4757e6..c91179f 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 2911e59..72008ca 100644 (file)
@@ -1794,6 +1794,11 @@ p {
   #terTableWrapper .spinner {
     display: inline-block; }
 
+.time-since-last-update {
+  font-weight: bold;
+  padding-right: 0.4em;
+  cursor: help; }
+
 .is-loading {
   opacity: 0; }
 
index 8140685..cfa770e 100644 (file)
@@ -37,6 +37,7 @@
                $.ajax({
                        url: url,
                        dataType: 'json',
+                       cache: false,
                        success: function(data) {
 
                                // Something went wrong, show message
                                }
 
                                // Message with latest updates
-                               $('.typo3-extensionmanager-headerRowRight .splash-receivedata .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) {
                });
        }
 
-}(jQuery));
+}(jQuery));
\ No newline at end of file