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)
* @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;
}
$list = tx_em_Database::getExtensionListFromRepository(
- $repoUtility->getRepositoryUID(),
+ $repositoryId,
$where,
$orderBy,
$orderDir,
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',
$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.
*
}
//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>' .
/**
* Keeps instance of a XML parser.
*
- * @var em_xml_abstract_parser
+ * @var tx_em_Parser_ExtensionXmlAbstractParser
*/
protected $parser;
*
* @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.
* @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.
*
$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',
self::$fieldIndicesNoQuote
);
}
+ tx_em_Database::insertLastVersion($this->repositoryUID);
return $this->sumRecords;
}
* @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
+?>
/**
* Keeps instance of a XML parser.
*
- * @var tx_em_XmlAbstractParser
+ * @var tx_em_Parser_MirrorXmlAbstractParser
*/
protected $parser;
*
* @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);
}
}
-?>
\ No newline at end of file
+?>
// 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')) {
$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']])) {
$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
$isAvailable = FALSE;
}
}
+
return $isAvailable;
}
* @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);
abstract protected function throwException($message = "", $code = 0);
}
-?>
\ No newline at end of file
+?>
*
* @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',
+ ),
+ );
/**
}
}
-?>
\ No newline at end of file
+?>
* @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);
}
* @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;
}
$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) {
$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()));
* @return boolean True on success
*/
public function execute() {
- // Throws exceptions if something goes wrong
+ // Throws exceptions if something goes wrong
$this->updateExtensionlist();
return (TRUE);
// 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);
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
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