Follow-up to #16315: New extension manager part 1: splitting classes: fixed many...
authorSteffen Kamper <info@sk-typo3.de>
Tue, 16 Nov 2010 16:05:12 +0000 (16:05 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Tue, 16 Nov 2010 16:05:12 +0000 (16:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9402 709f56b5-9817-0410-a4d7-c38de5d9e867

12 files changed:
ChangeLog
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/extensions/class.tx_em_extensions_list.php
typo3/sysext/em/classes/import/class.tx_em_import_extensionlistimporter.php
typo3/sysext/em/classes/import/class.tx_em_import_mirrorlistimporter.php
typo3/sysext/em/classes/index.php
typo3/sysext/em/classes/parser/class.tx_em_parser_xmlabstractparser.php
typo3/sysext/em/classes/parser/class.tx_em_parser_xmlparserfactory.php
typo3/sysext/em/classes/repository/class.tx_em_repository_utility.php
typo3/sysext/em/classes/tasks/class.tx_em_tasks_updateextensionlist.php
typo3/sysext/em/ext_tables.sql

index 3080a0d..fb7cabe 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
 
 2010-11-16  Steffen Kamper  <steffen@typo3.org>
 
+       * Follow-up to #16315: New extension manager part 1: splitting classes: fixed many small issues
        * Added feature #16408: Support for Custom Navigation Components (Thanks to Stefan Galinski)
        * Added feature #16396: Implement a Grid View + wizard to enable the backend layout to be adapted to the frontend look and feel (Thanks to Joey Hasenau, Martin Ficzel and Thomas Hempel)
 
index f3f37c2..dfb6a2a 100644 (file)
@@ -356,9 +356,7 @@ class tx_em_Connection_ExtDirectServer {
         * @return string $content
         */
        public function getRemoteExtensionList($parameters) {
-               /* @var $repoUtility em_repository_utility */
-               $repoUtility = t3lib_div::makeInstance('tx_em_Repository_Utility');
-               $repoUtility->setRepository($this->getSettingsObject()->getSelectedRepository());
+               $repositoryId = $this->getSettingsObject()->getSelectedRepository();
 
                $search = $parameters->query;
                $limit = $parameters->start . ', ' . $parameters->limit;
@@ -376,7 +374,7 @@ class tx_em_Connection_ExtDirectServer {
                }
 
                $list = tx_em_Database::getExtensionListFromRepository(
-                       $repoUtility->getRepositoryUID(),
+                       $repositoryId,
                        $where,
                        $orderBy,
                        $orderDir,
index bb4ea6d..6f13721 100644 (file)
@@ -92,7 +92,6 @@ final class tx_em_Database {
        public function getExtensionListFromRepository($repository, $andWhere = '', $orderBy = '', $orderDir = 'ASC', $limit = '') {
                $order = $orderBy ? $orderBy . ' ' . $orderDir : '';
                $ret = array();
-
                $temp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
                        'count(*) count',
                        'cache_extensions',
@@ -175,6 +174,40 @@ final class tx_em_Database {
                $GLOBALS['TYPO3_DB']->exec_INSERTquery(self::TABLE_EXTENSION, $arrFields);
        }
 
+       /**
+        * Update the lastversion field after update
+        *
+        * @param int $repositoryUid
+        * @return void
+        */
+       public function insertLastVersion($repositoryUid = 1) {
+               $groupedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       'extkey, version, max(intversion)',
+                       'cache_extensions',
+                       'repository=' . intval($repositoryUid),
+                       'extkey'
+               );
+
+               if (count($groupedRows)) {
+                       // set all to 0
+                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
+                               'cache_extensions',
+                               'lastversion=1 AND repository=' . intval($repositoryUid),
+                               array('lastversion' => 0)
+                       );
+
+                               // Find latest version of extensions and set lastversion to 1 for these
+                       foreach ($groupedRows as $row) {
+                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
+                                       'cache_extensions',
+                                       'extkey="' . $row['extkey'] . '" AND version="' . $row['version'] . '" AND repository=' . intval($repositoryUid),
+                                       array('lastversion' => 1)
+                               );
+                       }
+               }
+       }
+
+
        /**
         * Method finds and returns repository fields identified by its UID.
         *
index a694d81..0d0aeed 100644 (file)
@@ -688,7 +688,11 @@ EXTENSION KEYS:
                                }
                                //TODO: $extInfo is unknown in this context
                                $content .= '<tr class="bgColor4"><td valign="top">' . $icon . '</td>' .
-                                               '<td valign="top">' . ($data['EM_CONF']['state'] == 'excludeFromUpdates' ? '<span style="color:#cf7307">' . $data['EM_CONF']['title'] . ' ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:write_protected') . '</span>' : '<a href="?CMD[importExtInfo]=' . $name . '">' . $data[EM_CONF][title] . '</a>') . '</td>' .
+                                               '<td valign="top">' . ($data['EM_CONF']['state'] == 'excludeFromUpdates'
+                                                       ? '<span style="color:#cf7307">' . $data['EM_CONF']['title'] . ' ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:write_protected') . '</span>'
+                                                       : '<a href="' . t3lib_div::linkThisScript(array(
+                                                               'CMD[importExtInfo]' => $name
+                                                               )) . '">' . $data[EM_CONF][title] . '</a>') . '</td>' .
                                                '<td valign="top">' . $name . '</td>' .
                                                '<td valign="top" align="right">' . $data[EM_CONF][version] . '</td>' .
                                                '<td valign="top" align="right">' . $lastversion . '</td>' .
index d5e292b..eccdde2 100644 (file)
@@ -48,7 +48,7 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
        /**
         * Keeps instance of a XML parser.
         *
-        * @var em_xml_abstract_parser
+        * @var tx_em_Parser_ExtensionXmlAbstractParser
         */
        protected $parser;
 
@@ -71,7 +71,29 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
         *
         * @var  array
         */
-       static protected $fieldNames = array('extkey', 'version', 'intversion', 'alldownloadcounter', 'downloadcounter', 'title', 'ownerusername', 'authorname', 'authoremail', 'authorcompany', 'lastuploaddate', 't3xfilemd5', 'repository', 'state', 'reviewstate', 'category', 'description', 'dependencies', 'uploadcomment' /*, 'lastversion', 'lastreviewedversion'*/);
+       static protected $fieldNames = array(
+               'extkey',
+               'version',
+               'intversion',
+               'alldownloadcounter',
+               'downloadcounter',
+               'title',
+               'ownerusername',
+               'authorname',
+               'authoremail',
+               'authorcompany',
+               'lastuploaddate',
+               't3xfilemd5',
+               'repository',
+               'state',
+               'reviewstate',
+               'category',
+               'description',
+               'dependencies',
+               'uploadcomment',
+               //'lastversion',
+               //'lastreviewedversion'
+       );
 
        /**
         * Keeps indexes of fields that should not be quoted.
@@ -101,24 +123,15 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
         * @throws  tx_em_XmlException in case no valid parser instance is available
         */
        function __construct() {
-               // TODO catch parser exception
-               $this->parser = em_xml_parser_factory::getParserInstance('extension');
-               if (!is_object(tx_em_Parser_XmlParserFactory::getParserInstance('extension'))) {
+                       // TODO catch parser exception
+               $this->parser = tx_em_Parser_XmlParserFactory::getParserInstance('extension');
+               if (is_object($this->parser)) {
+                       $this->parser->attach($this);
+               } else {
                        throw new tx_em_XmlException(get_class($this) . ': ' . 'No XML parser available.');
                }
        }
 
-       /**
-        * Gets parser object
-        *
-        * @return tx_em_XmlParserFactory
-        */
-       protected function getParser() {
-               $parser = tx_em_Parser_XmlParserFactory::getParserInstance('extension');
-               $parser->attach($this);
-               return $parser;
-       }
-
        /**
         * Method initializes parsing of extension.xml.gz file.
         *
@@ -134,9 +147,9 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
                $zlibStream = 'compress.zlib://';
                $this->sumRecords = 0;
 
-               $this->getParser()->parseXML($zlibStream . $localExtListFile);
+               $this->parser->parseXML($zlibStream . $localExtListFile);
 
-               // flush last rows to database if existing
+                       // flush last rows to database if existing
                if (count($this->arrRows)) {
                        $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows(
                                'cache_extensions',
@@ -145,6 +158,7 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
                                self::$fieldIndicesNoQuote
                        );
                }
+               tx_em_Database::insertLastVersion($this->repositoryUID);
                return $this->sumRecords;
        }
 
@@ -199,10 +213,10 @@ class tx_em_Import_ExtensionListImporter implements SplObserver {
         * @return  void
         */
        public function update(SplSubject $subject) {
-               if (is_subclass_of($subject, 'tx_em_ExtensionXmlAbstractParser')) {
+               if (is_subclass_of($subject, 'tx_em_Parser_ExtensionXmlAbstractParser')) {
                        $this->loadIntoDB($subject);
                }
        }
 }
 
-?>
\ No newline at end of file
+?>
index 201ed21..d9d51ab 100644 (file)
@@ -49,7 +49,7 @@ class tx_em_Import_MirrorListImporter implements SplObserver {
        /**
         * Keeps instance of a XML parser.
         *
-        * @var  tx_em_XmlAbstractParser
+        * @var  tx_em_Parser_MirrorXmlAbstractParser
         */
        protected $parser;
 
@@ -68,10 +68,10 @@ class tx_em_Import_MirrorListImporter implements SplObserver {
         *
         * @access  public
         * @return  void
-        * @throws  em_xml_Exception in case no valid parser instance is available
+        * @throws  tx_em_XmlException in case no valid parser instance is available
         */
        function __construct() {
-               // TODO catch parser exception
+                       // TODO catch parser exception
                $this->parser = tx_em_Parser_XmlParserFactory::getParserInstance('mirror');
                if (is_object($this->parser)) {
                        $this->parser->attach($this);
@@ -113,4 +113,4 @@ class tx_em_Import_MirrorListImporter implements SplObserver {
        }
 }
 
-?>
\ No newline at end of file
+?>
index 4ef0035..b6116c3 100644 (file)
@@ -426,15 +426,12 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
                        // MENU-ITEMS:
                $this->MOD_MENU = $this->settings->MOD_MENU;
 
-               // temporary unset new modules
+                       // temporary unset new modules
                unset ($this->MOD_MENU['function']['extensionmanager'], $this->MOD_MENU['function']['develop']);
 
 
                $this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'], 'singleDetails', $this->MOD_MENU['singleDetails']);
 
-                       // temporary set main repository
-               //$changed = array_merge((array) t3lib_div::_GP('SET'), array('selectedRepository' => '1'));
-
 
                        // page/be_user TSconfig settings and blinding of menu-items
                if (!$GLOBALS['BE_USER']->getTSConfigVal('mod.' . $this->MCONF['name'] . '.allowTVlisting')) {
@@ -681,7 +678,7 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
                                $this->xmlhandler->searchExtensionsXML($this->listRemote_search, '', $this->MOD_SETTINGS['listOrder'], TRUE, FALSE, $offset, $this->listingLimit);
                        }
                        if (count($this->xmlhandler->extensionsXML)) {
-                               list($list, $cat) = $this->extensionList->prepareImportExtList(true);
+                               list($list, $cat) = $this->extensionList->prepareImportExtList(TRUE);
 
                                // Available extensions
                                if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
@@ -828,7 +825,7 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
 
                                $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
                                                '</strong><br /> ' . $this->privacyNotice;
-                               $this->content .= $this->doc->section($headline, $content, FALSE, TRUE);
+                               $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, 0, TRUE);
                        }
                } else {
                        // section headline and CSH
index 2ba32a4..3c2879f 100644 (file)
@@ -78,6 +78,7 @@ abstract class tx_em_Parser_XmlAbstractParser {
                                $isAvailable = FALSE;
                        }
                }
+
                return $isAvailable;
        }
 
@@ -87,7 +88,7 @@ abstract class tx_em_Parser_XmlAbstractParser {
         * @access  public
         * @param   string  $file: GZIP stream resource
         * @return  void
-        * @throws  em_xml_Exception  in case of XML parser errors
+        * @throws  tx_em_XmlException  in case of XML parser errors
         */
        abstract public function parseXML($file);
 
@@ -102,4 +103,4 @@ abstract class tx_em_Parser_XmlAbstractParser {
        abstract protected function throwException($message = "", $code = 0);
 }
 
-?>
\ No newline at end of file
+?>
index 2d814ae..d862f51 100644 (file)
@@ -63,12 +63,16 @@ class tx_em_Parser_XmlParserFactory {
         *
         * @var array
         */
-       static protected $parsers = array('extension' => array(
-               'tx_em_parser_extensionxmlpullparser' => 'class.tx_em_parser_extensionxmlpullparser.php',
-               'tx_em_parser_extensionxmlpushparser' => 'class.tx_em_parser_extensionxmlpushparser.php',),
+       static protected $parsers = array(
+               'extension' => array(
+                       'tx_em_parser_extensionxmlpullparser' => 'class.tx_em_parser_extensionxmlpullparser.php',
+                       'tx_em_parser_extensionxmlpushparser' => 'class.tx_em_parser_extensionxmlpushparser.php',
+               ),
                'mirror' => array(
                        'tx_em_parser_mirrorxmlpullparser' => 'class.tx_em_parser_mirrorxmlpullparser.php',
-                       'tx_em_parser_mirrorxmlpushparser' => 'class.tx_em_parser_mirrorxmlpushparser.php',));
+                       //'tx_em_parser_mirrorxmlpushparser' => 'class.tx_em_parser_mirrorxmlpushparser.php',
+               ),
+       );
 
 
        /**
@@ -104,4 +108,4 @@ class tx_em_Parser_XmlParserFactory {
        }
 }
 
-?>
\ No newline at end of file
+?>
index bcbd2b0..523fb6f 100644 (file)
@@ -90,7 +90,7 @@ class tx_em_Repository_Utility implements t3lib_Singleton {
         * @return  void
         */
        function __construct(&$repository = NULL) {
-               if ($repository != NULL && is_object($repository)
+               if ($repository !== NULL && is_object($repository)
                                && $repository instanceof tx_em_Repository) {
                        $this->setRepository($repository);
                }
@@ -306,13 +306,14 @@ class tx_em_Repository_Utility implements t3lib_Singleton {
         * @return  integer
         */
        public function getRepositoryUID($insertIfMissing = FALSE) {
-               $uid = NULL;
-               $repository = tx_em_Database::getRepositoryByUID($this->repository->getId());
+               $uid = $this->repository->getId();
+               $repository = tx_em_Database::getRepositoryByUID($uid);
                if (empty($repository) && $insertIfMissing) {
                        $uid = tx_em_Database::insertRepository($this->repository);
                } else {
-                       $uid = intval($repository[0]['uid']);
+                       $uid = intval($repository['uid']);
                }
+
                return $uid;
        }
 
@@ -339,7 +340,7 @@ class tx_em_Repository_Utility implements t3lib_Singleton {
 
                $updateNecessity = $this->isExtListUpdateNecessary();
 
-               if ($updateNecessity != 0) {
+               if ($updateNecessity !== 0) {
                        // retrieval of file necessary
                        $tmpBitmask = (self::PROBLEM_EXTENSION_FILE_NOT_EXISTING | self::PROBLEM_EXTENSION_HASH_CHANGED);
                        if (($tmpBitmask & $updateNecessity) > 0) {
@@ -347,17 +348,20 @@ class tx_em_Repository_Utility implements t3lib_Singleton {
                                $updateNecessity &= ~$tmpBitmask;
                        }
 
-                       // database table cleanup
+                               // database table cleanup
                        if (($updateNecessity & self::PROBLEM_NO_VERSIONS_IN_DATABASE)) {
                                $updateNecessity &= ~self::PROBLEM_NO_VERSIONS_IN_DATABASE;
                        } else {
                                $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_extensions', 'repository=' . $this->getRepositoryUID());
                        }
-                       // no further problems - start of import process
+
+                               // no further problems - start of import process
                        if ($updateNecessity === 0) {
+                               $uid = $this->getRepositoryUID(TRUE);
+                               /* @var $objExtListImporter tx_em_Import_ExtensionListImporter */
                                $objExtListImporter = t3lib_div::makeInstance('tx_em_Import_ExtensionListImporter');
-                               $objExtListImporter->import($this->getLocalExtListFile(), $this->getRepositoryUID(TRUE));
-                               $sumRecords = tx_em_Database::getExtensionCountFromRepository($this->getRepositoryUID());
+                               $objExtListImporter->import($this->getLocalExtListFile(), $uid);
+                               $sumRecords = tx_em_Database::getExtensionCountFromRepository($uid);
                                if ($renderFlashMessage) {
                                        $flashMessage->setTitle($GLOBALS['LANG']->getLL('ext_import_extlist_updated_header'));
                                        $flashMessage->setMessage(sprintf($GLOBALS['LANG']->getLL('ext_import_extlist_updated'), tx_em_Database::getExtensionCountFromRepository()));
index ec6ff7c..1280465 100644 (file)
@@ -36,7 +36,7 @@ class tx_em_Tasks_UpdateExtensionList extends tx_scheduler_Task {
         * @return boolean True on success
         */
        public function execute() {
-               // Throws exceptions if something goes wrong
+                       // Throws exceptions if something goes wrong
                $this->updateExtensionlist();
 
                return (TRUE);
@@ -58,7 +58,9 @@ class tx_em_Tasks_UpdateExtensionList extends tx_scheduler_Task {
 
                        // update all repositories
                foreach ($repositories as $repository) {
+                       /* @var $objRepository tx_em_Repository */
                        $objRepository = t3lib_div::makeInstance('tx_em_Repository', $repository['uid']);
+                       /* @var $objRepositoryUtility tx_em_Repository_Utility */
                        $objRepositoryUtility = t3lib_div::makeInstance('tx_em_Repository_Utility', $objRepository);
                        $count = $objRepositoryUtility->updateExtList(FALSE);
                        unset($objRepository, $objRepositoryUtility);
@@ -70,4 +72,4 @@ if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/em/classes/tasks/class.tx_em_tasks_updateextensionlist.php']);
 }
 
-?>
+?>
\ No newline at end of file
index d1045af..5088a3f 100644 (file)
@@ -37,5 +37,5 @@ CREATE TABLE cache_extensions (
   intversion int(11) NOT NULL default '0',
   lastversion int(3) NOT NULL default '0',
   lastreviewedversion int(3) NOT NULL default '0',
-  KEY extkey (extkey,version)
+  PRIMARY KEY (extkey,version,repository)
 );
\ No newline at end of file