[TASK] EM: show updatable extensions in Local Extension List
authorXavier Perseguers <xavier@typo3.org>
Sat, 10 Sep 2011 06:35:14 +0000 (08:35 +0200)
committerXavier Perseguers <xavier@typo3.org>
Sat, 10 Sep 2011 18:17:49 +0000 (20:17 +0200)
Move the "Show updatable extensions" filter from tab "Remote Repository"
to "Local Extension List".

Change-Id: I8a8dd78549a7b07cae5f7f843f34c691e76fd850
Resolves: #29586
Releases: 4.6
Reviewed-on: http://review.typo3.org/4892
Reviewed-by: Francois Suter
Tested-by: Francois Suter
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/em/classes/connection/class.tx_em_connection_extdirectserver.php
typo3/sysext/em/classes/database/class.tx_em_database.php
typo3/sysext/em/classes/settings/class.tx_em_settings.php
typo3/sysext/em/res/css/t3_em.css
typo3/sysext/em/res/js/em_components.js
typo3/sysext/em/res/js/em_languages.js
typo3/sysext/em/res/js/em_locallist.js
typo3/sysext/em/res/js/em_repositorylist.js
typo3/sysext/em/res/js/em_tools.js

index 463f05d..2c3a8d2 100644 (file)
@@ -102,25 +102,55 @@ class tx_em_Connection_ExtDirectServer {
        /**
         * Render local extension list
         *
-        * @return string $content
+        * @param object $parameters
+        * @return array
         */
-       public function getExtensionList() {
+       public function getExtensionList($parameters) {
+               $repositoryId = $parameters->repository;
+
                /** @var $list tx_em_Extensions_List */
                $list = t3lib_div::makeInstance('tx_em_Extensions_List');
                $extList = $list->getInstalledExtensions(TRUE);
 
+               $temp = array();
+               $localList = array();
+               foreach ($extList as $entry) {
+                       $temp[] = '"' . $entry['extkey'] . '"';
+                       $entry['intversion'] = t3lib_utility_VersionNumber::convertVersionNumberToInteger($entry['version']);
+                       $localList[$entry['extkey']] = $entry;
+               }
 
-               return array(
-                       'length' => count($extList),
-                       'data' => $extList
+               $where = ' AND cache_extensions.extkey IN (' . implode(',', $temp) . ')';
+               $additionalData = tx_em_Database::getExtensionListFromRepository(
+                       $repositoryId,
+                       '',
+                       $where
                );
 
+               foreach ($additionalData['results'] as $key => $value) {
+                       $isUpdatable = ($localList[$value['extkey']]['intversion'] < $value['maxintversion']);
+                       $localList[$value['extkey']]['versionislower'] = $isUpdatable;
+                       $localList[$value['extkey']]['maxversion'] = tx_em_Tools::versionFromInt($value['maxintversion']);
+               }
+
+               return array(
+                       'length' => count($localList),
+                       'data' => array_values($localList)
+               );
        }
 
+       /**
+        * Returns the list of extensions with additional data
+        *
+        * @return array
+        */
        public function getFlatExtensionList() {
-               $list = $this->getExtensionList();
+               /** @var $list tx_em_Extensions_List */
+               $list = t3lib_div::makeInstance('tx_em_Extensions_List');
+               $extList = $list->getInstalledExtensions(TRUE);
+
                $flatList = array();
-               foreach ($list['data'] as $entry) {
+               foreach ($extList as $entry) {
                        $flatList[$entry['extkey']] = array(
                                'version' => $entry['version'],
                                'intversion' => t3lib_utility_VersionNumber::convertVersionNumberToInteger($entry['version']),
@@ -137,10 +167,11 @@ class tx_em_Connection_ExtDirectServer {
        /**
         * Render extensionlist for languages
         *
-        * @return unknown
+        * @param object $parameters
+        * @return array
         */
-       public function getInstalledExtkeys() {
-               $list = $this->getExtensionList();
+       public function getInstalledExtkeys($parameters) {
+               $list = $this->getExtensionList($parameters);
                $extList = $list['data'];
 
                $selectedLanguages = t3lib_div::trimExplode(',', $this->globalSettings['selectedLanguages']);
@@ -678,7 +709,7 @@ class tx_em_Connection_ExtDirectServer {
        }
 
 
-/**
+       /**
         * Prints backupdelete
         *
         * @param string $parameter
@@ -1634,4 +1665,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/connection/class.tx_em_connection_extdirectserver.php']);
 }
 
-?>
\ No newline at end of file
+?>
index c1c50a8..f586637 100644 (file)
@@ -214,7 +214,7 @@ final class tx_em_Database {
         * Update the lastversion field after update
         *
         * @param int $repositoryUid
-        * @return void
+        * @return integer
         */
        public function insertLastVersion($repositoryUid = 1) {
                $groupedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
@@ -252,6 +252,7 @@ final class tx_em_Database {
         *
         * @access  public
         * @param   int  $uid  repository UID
+        * @return array
         */
        public function getRepositoryByUID($uid) {
                $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', self::TABLE_REPOSITORY, 'uid=' . intval($uid));
@@ -263,7 +264,7 @@ final class tx_em_Database {
         * Method finds and returns repository identified by its title
         *
         * @param  $title
-        * @return
+        * @return array
         */
        public function getRepositoryByTitle($title) {
                return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
index 34ccf86..808166d 100644 (file)
@@ -133,6 +133,7 @@ class tx_em_Settings implements t3lib_Singleton {
                        'display_own' => '',
                        'display_obsolete' => '',
                        'display_installed' => '',
+                       'display_updatable' => '',
                        'display_files' => '',
                        'hide_shy' => 0,
                        'hide_obsolete' => 0,
index fff9b36..6a2c046 100644 (file)
@@ -218,6 +218,10 @@ a.email {
        margin-right: 5px;
 }
 
+.paddingNoActionIcon img {
+    margin-right: 20px;
+}
+
 .filteringList-highlight {
        background-color: #f48e0c;
     color: #fff;
index 939c41d..4302bf7 100644 (file)
@@ -152,7 +152,7 @@ TYPO3.EM.GridColumns.DummyColumn = {
 
 TYPO3.EM.GridColumns.InstallExtension = {
        header: '',
-       width: 29,
+       width: 45,
        sortable: false,
        hideable: false,
        fixed: true,
@@ -162,6 +162,44 @@ TYPO3.EM.GridColumns.InstallExtension = {
        items: [
                {
                        getClass: function(value, meta, record) {
+                               if (record.data.versionislower) {
+                                       this.items[0].tooltip = String.format(TYPO3.l10n.localize('menu_update_extension'), record.data.version, record.data.maxversion);
+                                       return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-update';
+                               }
+                meta.css += ' paddingNoActionIcon';
+                               return '';
+                       },
+                       handler: function(grid, rowIndex, colIndex) {
+                               var record = grid.store.getAt(rowIndex).data;
+                if (!record.versionislower) {
+                                       return;
+                               }
+                               var action = TYPO3.l10n.localize('menu_update_extensions');
+                               var link = TYPO3.settings.EM.scriptLink
+                                               + '&nodoc=1&view=info&CMD[silentMode]=1&CMD[standAlone]=1&ter_connect=1&CMD[importExt]='
+                                               + record.extkey  + '&CMD[extVersion]=' + record.maxversion + '&CMD[loc]=L';
+
+                               TYPO3.EM.ImportWindow = new TYPO3.EM.InstallWindow({
+                                       title: action + ': ' + record.title + ' (' + record.extkey + ') version ' + record.maxversion,
+                                       record: record,
+                                       installAction: 'import',
+                                       listeners: {
+                                               close: function() {
+                            grid.store.reload({
+                                params: {
+                                    repository: TYPO3.settings.EM.selectedRepository
+                                }
+                            });
+                                               }
+                                       }
+                               }).show(true, function(){
+                                       Ext.getCmp('emInstallIframeWindow').setUrl(link);
+                               });
+                       }
+               },
+               {
+                       getClass: function(value, meta, record) {
+                               meta.css += ' paddingActionIcon';
                                if (record.get('installed') == 0) {
                                        this.items[0].tooltip = TYPO3.l10n.localize('menu_install_extensions');
                                        return 't3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-extension-install';
@@ -190,7 +228,11 @@ TYPO3.EM.GridColumns.InstallExtension = {
                                                url: link,
                                                listeners: {
                                                        close: function() {
-                                                               grid.store.reload();
+                                                               grid.store.reload({
+                                                                       params: {
+                                                                               repository: TYPO3.settings.EM.selectedRepository
+                                                                       }
+                                                               });
                                                                TYPO3.EM.Tools.refreshMenu(record, 'install');
                                                        }
                                                }
@@ -479,7 +521,11 @@ TYPO3.EM.LocalListTab = {
        listeners: {
                activate: function(panel) {
                        if (TYPO3.EM.App.refreshLocalList) {
-                               Ext.StoreMgr.get('localstore').load();
+                               Ext.StoreMgr.get('localstore').load({
+                                       params: {
+                                               repository: TYPO3.settings.EM.selectedRepository
+                                       }
+                               });
                        }
                },
                scope: this
index b6e5c75..f2d0536 100644 (file)
@@ -130,6 +130,9 @@ TYPO3.EM.Languages = Ext.extend(Ext.FormPanel, {
                        root            : 'data',
                        idProperty  : 'extkey',
                        fields : [{name : 'extkey'},{name : 'icon'},{name: 'stype'}],
+                       baseParams: {
+                               repository: TYPO3.settings.EM.selectedRepository
+                       },
                        listeners : {
                                'load': function(store, records, options){
                                        if(records.length) {
index 3392a36..0156f24 100644 (file)
@@ -305,8 +305,8 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
                this.localstore = new Ext.data.GroupingStore({
                        storeId: 'localstore',
                        proxy: new Ext.data.DirectProxy({
-                                               directFn: TYPO3.EM.ExtDirect.getExtensionList
-                                       }),
+                               directFn: TYPO3.EM.ExtDirect.getExtensionList
+                       }),
                        autoLoad: false,
                        reader: new Ext.data.JsonReader({
                                                idProperty: 'extkey',
@@ -340,7 +340,9 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
                                                        {name:'doNotLoadInFE'},
                                                        {name:'depends'},
                                                        {name:'conflicts'},
-                                                       {name:'suggests'}
+                                                       {name:'suggests'},
+                                                       {name:'versionislower'},
+                                                       {name:'maxversion'}
                                                ]
                                        }),
 
@@ -370,7 +372,7 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
                                                this.doClearFilters.hide();
                                                this.doClearFiltersSeperator.hide();
                                        }
-                                       if (!TYPO3.settings.EM.hide_obsolete && !TYPO3.settings.EM.hide_shy && !TYPO3.settings.EM.display_installed) {
+                                       if (!TYPO3.settings.EM.hide_obsolete && !TYPO3.settings.EM.hide_shy && !TYPO3.settings.EM.display_installed && !TYPO3.settings.EM.display_updatable) {
                                                this.filterMenuButton.removeClass('bold');
                                        } else {
                                                this.filterMenuButton.addClass('bold');
@@ -407,20 +409,24 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
                                if (TYPO3.settings.EM.display_installed == 1 && record.data.installed == 0) {
                                        return false;
                                }
+                               if (TYPO3.settings.EM.display_updatable == 1 && record.data.versionislower == 0) {
+                                       return false;
+                               }
 
                                return true;
                        },
 
                        hasStoreFilter: function() {
-                               return (TYPO3.settings.EM.hide_obsolete || TYPO3.settings.EM.hide_shy || TYPO3.settings.EM.display_installed);
+                               return (TYPO3.settings.EM.hide_obsolete || TYPO3.settings.EM.hide_shy || TYPO3.settings.EM.display_installed || TYPO3.settings.EM.display_updatable);
                        },
 
                        clearStoreFilters: function(scope) {
                                Ext.each(scope.filterMenuButton.menu.items.items, function(item) {
                                        item.setChecked(false, true);
                                });
-                               TYPO3.settings.EM.hide_obsolete = TYPO3.settings.EM.hide_shy = TYPO3.settings.EM.display_installed = 0;
+                               TYPO3.settings.EM.hide_obsolete = TYPO3.settings.EM.hide_shy = TYPO3.settings.EM.display_installed = TYPO3.settings.EM.display_updatable = 0;
                                TYPO3.EM.ExtDirect.saveSetting('display_installed', 0);
+                               TYPO3.EM.ExtDirect.saveSetting('display_updatable', 0);
                                TYPO3.EM.ExtDirect.saveSetting('hide_shy', 0);
                                TYPO3.EM.ExtDirect.saveSetting('hide_obsolete', 0);
                                scope.filterRecords();
@@ -515,6 +521,16 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
                                                                scope: this
                                                        },
                                                        {
+                                                               checked: TYPO3.settings.EM.display_updatable ? true : false,
+                                                               text: TYPO3.l10n.localize('display_updatesOnly'),
+                                                               handler: function(item, event) {
+                                                                       TYPO3.settings.EM.display_updatable = item.checked ? 0 : 1;
+                                                                       TYPO3.EM.ExtDirect.saveSetting('display_updatable', TYPO3.settings.EM.display_updatable);
+                                                                       this.filterRecords();
+                                                               },
+                                                               scope: this
+                                                       },
+                                                       {
                                                                checked: TYPO3.settings.EM.hide_shy ? true : false,
                                                                text: TYPO3.l10n.localize('hide_shy'),
                                                                handler: function(item, event) {
@@ -594,7 +610,11 @@ TYPO3.EM.LocalList = Ext.extend(Ext.grid.GridPanel, {
        onRender: function() {
                TYPO3.EM.LocalList.superclass.onRender.apply(this, arguments);
                if (this.localstore.getCount() == 0) {
-                       this.localstore.load();
+                       this.localstore.load({
+                               params: {
+                                       repository: TYPO3.settings.EM.selectedRepository
+                               }
+                       });
                }
 
                this.on('rowdblclick', function(grid, rowIndex, event) {
index 6f35e4d..88ab1f1 100644 (file)
@@ -250,15 +250,6 @@ TYPO3.EM.RepositoryList = Ext.extend(Ext.grid.GridPanel, {
                                                                        this.store.reload();
                                                                },
                                                                scope: this
-                                                       }, {
-                                                               checked: false,
-                                                               group: 'installFilter',
-                                                               text: TYPO3.l10n.localize('display_updatesOnly'),
-                                                               handler: function(item, event) {
-                                                                       this.showInstalledOnly = 2;
-                                                                       this.store.reload();
-                                                               },
-                                                               scope: this
                                                        }
                                                ]
                                        }
index 835c97a..18beac2 100644 (file)
@@ -43,7 +43,11 @@ TYPO3.EM.Tools = function() {
                                var search = Ext.getCmp('localSearchField');
                                search.setValue(extKey);
                                search.refreshTrigger();
-                               localStore.load();
+                               localStore.load({
+                                       params: {
+                                               repository: TYPO3.settings.EM.selectedRepository
+                                       }
+                               });
                        }
                },