/* **************************************************************
* Copyright notice
*
-* (c) 2006 Karsten Dambekalns <karsten@typo3.org>
+* (c) 2006-2009 Karsten Dambekalns <karsten@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* @subpackage EM
*/
class SC_mod_tools_em_xmlhandler {
+
+ /**
+ * Enxtension Manager module
+ *
+ * @var SC_mod_tools_em_index
+ */
+ var $emObj;
+
/**
* Holds the parsed XML from extensions.xml.gz
* @see parseExtensionsXML()
*
* @var array
*/
- var $emObj;
var $extXMLResult = array();
var $extensionsXML = array();
var $reviewStates = null;
/**
* Reduces the entries in $this->extensionsXML to the latest version per extension and removes entries not matching the search parameter
*
- * @param string $search The list of extensions is reduced to entries matching this. If empty, the full list is returned.
- * @param boolean $latest If true, only the latest version is kept in the list
- * @return [type] ...
+ * @param string $search The list of extensions is reduced to entries matching this. If empty, the full list is returned.
+ * @param string $owner If set only extensions of that user are fetched
+ * @param string $order A field to order the result by
+ * @param boolean $allExt If set also unreviewed and obsolete extensions are shown
+ * @param boolean $allVer If set returns all version of an extension, otherwise only the last
+ * @param integer $offset Offset to return result from (goes into LIMIT clause)
+ * @param integer $limit Maximum number of entries to return (goes into LIMIT clause)
+ * @param boolean $exactMatch If set search is done for exact matches of extension keys only
+ * @return void
*/
- function searchExtensionsXML($search, $owner='', $order = '', $allExt = false, $allVer = false, $offset = 0, $limit = 500) {
+ function searchExtensionsXML($search, $owner='', $order='', $allExt=false, $allVer=false, $offset=0, $limit=500, $exactMatch=false) {
$where = '1=1';
- if ($search) {
- $where .= ' AND extkey LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($search, 'cache_extensions'), 'cache_extensions').'%\'';
+ if ($search && $exactMatch) {
+ $where.= ' AND extkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($search, 'cache_extensions');
+ } elseif($search) {
+ $where.= ' AND extkey LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($search, 'cache_extensions'), 'cache_extensions').'%\'';
}
if ($owner) {
- $where .= ' AND ownerusername='.$GLOBALS['TYPO3_DB']->fullQuoteStr($owner, 'cache_extensions');
+ $where.= ' AND ownerusername='.$GLOBALS['TYPO3_DB']->fullQuoteStr($owner, 'cache_extensions');
}
- if(!(strlen($owner) || $this->useUnchecked || $allExt)) {
- $where .= ' AND reviewstate>0';
+ if (strlen($owner) || $this->useUnchecked || $allExt) {
+ // show extensions without review or that have passed review
+ $where.= ' AND reviewstate >= 0';
+ } else {
+ // only display extensions that have passed review
+ $where.= ' AND reviewstate > 0';
}
- if(!($this->useObsolete || $allExt)) {
- $where .= ' AND state!=5'; // 5 == obsolete
+ if (!$this->useObsolete && !$allExt) {
+ $where.= ' AND state!=5'; // 5 == obsolete
}
switch ($order) {
case 'author_company':
$forder = 'category';
break;
}
- $order = $forder.', title';
+ $order = $forder.', title';
if (!$allVer) {
if ($this->useUnchecked) {
$where .= ' AND lastversion>0';
}
// Fetch count
- $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as cnt', 'cache_extensions', $where, '', $order);
- $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
- $this->matchingCount = $row['cnt'];
- $GLOBALS['TYPO3_DB']->sql_free_result($res);
-
- $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as cnt', 'cache_extensions', $where, '', $order);
+ $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_extensions', $where);
+ $this->matchingCount = $count;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'cache_extensions', $where, '', $order, $offset.','.$limit);
$this->extensionsXML = array();
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
+ /**
+ * Reduces the entries in $this->extensionsXML to the latest version per extension and removes entries not matching the search parameter
+ * The extension key has to be a valid one as search is done for exact matches only.
+ *
+ * @param string $search The list of extensions is reduced to entries with exactely this extension key. If empty, the full list is returned.
+ * @param string $owner If set only extensions of that user are fetched
+ * @param string $order A field to order the result by
+ * @param boolean $allExt If set also unreviewed and obsolete extensions are shown
+ * @param boolean $allVer If set returns all version of an extension, otherwise only the last
+ * @param integer $offset Offset to return result from (goes into LIMIT clause)
+ * @param integer $limit Maximum number of entries to return (goes into LIMIT clause)
+ * @return void
+ */
+ function searchExtensionsXMLExact($search, $owner='', $order='', $allExt=false, $allVer=false, $offset=0, $limit=500) {
+ $this->searchExtensionsXML($search, $owner, $order, $allExt, $allVer, $offset, $limit, true);
+ }
+
function countExtensions() {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('extkey', 'cache_extensions', '1=1', 'extkey');
$cnt = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
}
/**
-+ * Returns the reviewstate of a specific extension-key/version
+ * Returns the reviewstate of a specific extension-key/version
*
* @param string $extKey
* @param string $version: ...
gzclose($fp);
if(!$error) {
- $content.= '<p>The extensions list has been updated and now contains '.$extcount.' extension entries.</p>';
+ $flashMessage = t3lib_div::makeInstance(
+ 't3lib_FlashMessage',
+ sprintf($GLOBALS['LANG']->getLL('ext_import_extlist_updated'), $extcount),
+ $GLOBALS['LANG']->getLL('ext_import_extlist_updated_header')
+ );
+ $content .= $flashMessage->render();
}
return $content;
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
- if ((double)phpversion()>=5) {
- $preg_result = array();
- preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$preg_result);
- $theCharset = $preg_result[1] ? $preg_result[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1');
- xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1
- }
+ $preg_result = array();
+ preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$preg_result);
+ $theCharset = $preg_result[1] ? $preg_result[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1');
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1
// Parse content:
xml_parse_into_struct($parser, $string, $vals, $index);
}
}
}
+
?>
\ No newline at end of file