From ef91390f7691489de4b469f59b50672641c67ebe Mon Sep 17 00:00:00 2001 From: disappearer Date: Mon, 13 Mar 2006 18:40:53 +0000 Subject: [PATCH] Many changes in output, some refactoring, see changelog git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/trunk@2455 735d13b6-9817-0410-8766-e36946ffe9aa --- ChangeLog | 7 ++ class.tx_terfe_common.php | 50 ++++---- locallang_common.xml | 6 + pi1/class.tx_terfe_pi1.php | 228 +++++++++++++++++++++++-------------- 4 files changed, 176 insertions(+), 115 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4461054e..7850efa6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +13.03.2006 Michael Scharkow + * more refactoring + * complete overhaul of all output (thanks to Ingo Renner and Joey Hasenau) + * info and detail view merged + * stdSelection for all queries (no obsolete, testing and documentation) + * added simple upload comment changelog in single view + 12.03.2006 Michael Scharkow * refactoring of pi1, compact lists use a common function now * added state and last update in compact lists diff --git a/class.tx_terfe_common.php b/class.tx_terfe_common.php index 7bdbccfc..4be69ca4 100755 --- a/class.tx_terfe_common.php +++ b/class.tx_terfe_common.php @@ -185,6 +185,7 @@ class tx_terfe_common { $extensionRecord[$key] = unserialize ($value); break; case 'lastuploaddate': + $extensionRecord['lastuploaddate_raw'] = $value; $extensionRecord[$key] = strftime($this->getLL('general_dateandtimeformat'), $value); break; case 'versiondownloadcounter': @@ -498,28 +499,23 @@ class tx_terfe_common { // Render the depencies information: $colorStyle = $extensionIsAvailable ? '' : 'color:red;'; if (!$extensionIsAvailable) $someExtensionsAreNotAvailable = TRUE; - $tableRows[] = ' - - '.$this->getLL('extension_dependencies_kind_'.$dependencyArr['kind'],'',1).' - '.$this->csConvHSC ($dependencyArr['extensionKey']).' - '.$dependencyArr['versionRange'].' - + $tableRows[] = ' +
  • '.$this->getLL('extension_dependencies_kind_'.$dependencyArr['kind'],'',1).' '.$this->csConvHSC ($dependencyArr['extensionKey']).' ' + .$dependencyArr['versionRange'].'
  • '; } } if ($someExtensionsAreNotAvailable) { $tableRows[] = ' - - '.$this->getLL('extension_dependencies_someextensionsarenotavailable','',1).' - +
  • '.$this->getLL('extension_dependencies_someextensionsarenotavailable','',1).'
  • '; } $output = ' - +
      '.implode ('', $tableRows).' -
    + '; } return $output; @@ -559,15 +555,15 @@ class tx_terfe_common { } foreach ($dependingExtensionKeysArr as $key => $versionsArr) { - $tableRows[] = ''.$this->csConvHSC($key).''.implode (', ', $versionsArr).''; + $tableRows[] = '
  • '.$this->csConvHSC($key).' '.implode (', ', $versionsArr).'
  • '; } if (count ($tableRows)) { - $output = ' - '.$this->getLL('extension_reversedependencies_intro','',1).' - + $output = + '

    '.$this->getLL('extension_reversedependencies_intro','',1).'

    +
      '.implode ('', $tableRows).' -
    + '; } } @@ -602,11 +598,11 @@ class tx_terfe_common { } $tableRows[] = ' - '.$this->csConvHSC ($fileName).' - '.t3lib_div::formatSize($fileArr['size']).' - '.$viewLink.' - '.strftime($this->getLL('general_dateandtimeformat'), $fileArr['mtime']).' - '.$downloadLink.' + '.$this->csConvHSC ($fileName).' + '.t3lib_div::formatSize($fileArr['size']).' + '.$viewLink.' + '.strftime($this->getLL('general_dateandtimeformat'), $fileArr['mtime']).' + '.$downloadLink.' '; } @@ -626,13 +622,13 @@ class tx_terfe_common { } $output =' - +
    + '.implode ('', $tableRows).'
    FilenameSizeViewDateDownload
    -

    -

    '.$this->getLL('extensionfiles_downloadcompressedt3x','',1).'

    -
    - '.$filePreview.' + +
  • + '.$filePreview.'
  • '; } @@ -924,4 +920,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ter_fe/ include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ter_fe/class.tx_terfe_common.php']); } -?> \ No newline at end of file +?> diff --git a/locallang_common.xml b/locallang_common.xml index bd9d2441..92a51aad 100755 --- a/locallang_common.xml +++ b/locallang_common.xml @@ -21,6 +21,7 @@ + @@ -49,6 +50,8 @@ + + @@ -73,6 +76,7 @@ + @@ -101,6 +105,8 @@ + + diff --git a/pi1/class.tx_terfe_pi1.php b/pi1/class.tx_terfe_pi1.php index d911ee6e..a17dddf3 100755 --- a/pi1/class.tx_terfe_pi1.php +++ b/pi1/class.tx_terfe_pi1.php @@ -33,24 +33,25 @@ * * * - * 72: class tx_terfe_pi1 extends tslib_pibase - * 92: protected function init($conf) - * 114: public function main($content,$conf) - * 149: protected function renderListView_new() - * 204: protected function renderListView_categories() - * 243: protected function renderListView_popular() - * 297: protected function renderListView_search() - * 325: protected function renderListView_searchResult() - * 369: protected function renderListView_compactList($mode) - * 443: protected function renderSingleView_extension ($extensionKey, $version) - * 514: protected function renderSingleView_extensionInfo($extensionRecord) - * 575: protected function renderSingleView_extensionDetails ($extensionRecord) - * 627: protected function renderSingleView_feedbackForm ($extensionRecord) - * 695: protected function renderListView_detailledExtensionRecord($extensionRecord) - * 744: protected function renderListView_shortExtensionRecord($extensionRecord) - * 775: protected function renderTopMenu() + * 73: class tx_terfe_pi1 extends tslib_pibase + * 93: protected function init($conf) + * 115: public function main($content,$conf) + * 150: protected function renderListView_new() + * 205: protected function renderListView_categories() + * 244: protected function renderListView_popular() + * 298: protected function renderListView_search() + * 326: protected function renderListView_searchResult() + * 370: protected function renderListView_compactList($mode) + * 445: protected function renderSingleView_extension ($extensionKey, $version) + * 521: protected function renderSingleView_extensionInfo($extensionRecord) + * 581: protected function renderSingleView_extensionDetails ($extensionRecord) + * 644: protected function renderSingleView_feedbackForm ($extensionRecord) + * 712: protected function renderListView_detailledExtensionRecord($extensionRecord) + * 771: protected function renderListView_shortExtensionRecord($extensionRecord) + * 805: protected function getUploadHistory($extensionKey, $lastuploaddate) + * 833: protected function renderTopMenu() * - * TOTAL FUNCTIONS: 15 + * TOTAL FUNCTIONS: 16 * (This index is automatically created/updated by the extension "extdeveval") * */ @@ -80,6 +81,7 @@ class tx_terfe_pi1 extends tslib_pibase { protected $viewMode = ''; // View mode, one of the following: LATEST, CATEGORIES, FULLLIST protected $feedbackMailsCCAddress = 'robert@typo3.org'; // Email address(es) which also receive the feedback emails + protected $stdSelection = 'state in ("experimental","alpha","beta","stable") AND category <> "doc" AND '; // Standard selection criteria protected $tooFewReviewsMode = TRUE; // If set, by default unreviewed extensions appear in all modes but "unsupported". This is for the time when we yet don't have enough reviews /** @@ -161,7 +163,7 @@ class tx_terfe_pi1 extends tslib_pibase { $res = $TYPO3_DB->exec_SELECTquery ( '*', 'tx_terfe_extensions', - 'lastuploaddate > '.(time()-($numberOfDays*24*3600)).' '.($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), + $this->stdSelection.'lastuploaddate > '.(time()-($numberOfDays*24*3600)).' '.($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), '', 'lastuploaddate DESC', '30' @@ -188,9 +190,9 @@ class tx_terfe_pi1 extends tslib_pibase { $content.= ' '.$searchForm.'

    '.htmlspecialchars(sprintf($this->pi_getLL('listview_new_introduction',''), $numberOfDays)).'

    - +
      '.implode('', $tableRows).' -
    + '; return $content; } @@ -210,7 +212,7 @@ class tx_terfe_pi1 extends tslib_pibase { $res = $TYPO3_DB->exec_SELECTquery ( '*', 'tx_terfe_extensions', - 'lastuploaddate > '.(time()-($numberOfDays*24*3600)). ' '.($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), + $this->stdSelection.'lastuploaddate > '.(time()-($numberOfDays*24*3600)). ' '.($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), '', 'lastuploaddate DESC', '' @@ -227,9 +229,9 @@ class tx_terfe_pi1 extends tslib_pibase { $content.= '

    '.htmlspecialchars(sprintf($this->pi_getLL('renderview_new_introduction',''), $numberOfDays)).'

    - +
      '.implode('', $tableRows).' -
    + '; return $content; } @@ -254,6 +256,7 @@ class tx_terfe_pi1 extends tslib_pibase { $res = $TYPO3_DB->exec_SELECTquery ( 'DISTINCT extensionkey', 'tx_terfe_extensions', + $this->stdSelection. ($this->tooFewReviewsMode ? 'reviewstate >= 0' : 'reviewstate > 0'), '', 'extensiondownloadcounter DESC', @@ -261,7 +264,7 @@ class tx_terfe_pi1 extends tslib_pibase { ); if ($res) { $counter = 0; - while ($counter < 10 AND $extensionKeyRow = $TYPO3_DB->sql_fetch_assoc ($res)) { + while ($counter < 20 AND $extensionKeyRow = $TYPO3_DB->sql_fetch_assoc ($res)) { $version = $this->commonObj->db_getLatestVersionNumberOfExtension ($extensionKeyRow['extensionkey'], $this->tooFewReviewsMode); $res2 = $TYPO3_DB->exec_SELECTquery ( @@ -281,9 +284,9 @@ class tx_terfe_pi1 extends tslib_pibase { $content.= '

    '.$this->pi_getLL('listview_popular_introduction','',1).'

    - +
      '.implode('', $tableRows).' -
    + '; return $content; } @@ -330,6 +333,7 @@ class tx_terfe_pi1 extends tslib_pibase { $res = $TYPO3_DB->exec_SELECTquery ( '*', 'tx_terfe_extensions', + $this->stdSelection. $TYPO3_DB->searchQuery (explode (' ', $this->piVars['sword']), array('extensionkey','title','description'), 'tx_terfe_extensions').' '.($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), '', 'lastuploaddate DESC', @@ -346,9 +350,9 @@ class tx_terfe_pi1 extends tslib_pibase { } } $output = ' - +
      '.implode('', $tableRows).' -
    + '; } else { $output = $this->pi_getLL('listview_search_noresult','',1); @@ -369,13 +373,13 @@ class tx_terfe_pi1 extends tslib_pibase { protected function renderListView_compactList($mode) { global $TYPO3_DB, $TSFE; $selectConditions = array ( - 'full' => ($this->tooFewReviewsMode ? 'AND reviewstate >= 0' : 'AND reviewstate > 0'), - 'reviewed' => 'AND reviewstate > 0', - 'unreviewed' => ' AND reviewstate = 0' + 'full' => ($this->tooFewReviewsMode ? 'reviewstate >= 0' : 'reviewstate > 0'), + 'reviewed' => 'reviewstate > 0', + 'unreviewed' => 'reviewstate = 0' ); $sorting = $this->piVars['sorting']; - + $sortingConditions = array ( 'by_title' => '', 'by_extkey' => 'extensionkey ASC,', @@ -388,9 +392,9 @@ class tx_terfe_pi1 extends tslib_pibase { $res = $TYPO3_DB->exec_SELECTquery ( 'extensionkey,title,version,state,lastuploaddate', 'tx_terfe_extensions', - 'state in ("experimental","alpha","beta","stable") '. $selectConditions[$mode], + $this->stdSelection.$selectConditions[$mode], '', - $sortingConditions[$sorting].'title ASC', + $sortingConditions[$sorting].'title ASC, lastuploaddate DESC', '' ); $alreadyRenderedExtensionKeys = array(); @@ -421,10 +425,9 @@ class tx_terfe_pi1 extends tslib_pibase { $content = $introArr[$mode]; $content .= ' - +
    - @@ -458,7 +461,7 @@ class tx_terfe_pi1 extends tslib_pibase { 'extensionkey='.$TYPO3_DB->fullQuoteStr($extensionKey, 'tx_terfe_extensions').' AND '. 'version='.$TYPO3_DB->fullQuoteStr($version, 'tx_terfe_extensions') ); - $extensionRecord = $this->commonObj->db_prepareExtensionRecordForOutput ($TYPO3_DB->sql_fetch_assoc ($res)); + $extensionRecord = $TYPO3_DB->sql_fetch_assoc ($res); if (!$extensionRecord || $extensionRecord['reviewstate']== -1) return 'Extension '.htmlspecialchars($extensionKey).' not found!'; // Set the magic "reg1" so we can clear the cache for this manual if a new one is uploaded: @@ -469,7 +472,7 @@ class tx_terfe_pi1 extends tslib_pibase { // Prepare the top menu items: if (!$this->piVars['extView']) $this->piVars['extView'] = 'info'; - $menuItems = array ('info', 'details', 'feedback'); // 'rating' disabled + $menuItems = array ('info','feedback'); // 'rating' disabled // Render the top menu $topMenu = ''; @@ -481,9 +484,6 @@ class tx_terfe_pi1 extends tslib_pibase { // Render content of the currently selected view: switch ($this->piVars['extView']) { - case 'details' : - $subContent = $this->renderSingleView_extensionDetails ($extensionRecord); - break; case 'feedback' : $subContent = $this->renderSingleView_feedbackForm ($extensionRecord); break; @@ -498,7 +498,9 @@ class tx_terfe_pi1 extends tslib_pibase { */ case 'info': default: - $subContent = $this->renderSingleView_extensionInfo ($extensionRecord); + $subContent = '
      '. + $this->renderListView_detailledExtensionRecord ($extensionRecord); + $subContent .= $this->renderSingleView_extensionDetails ($extensionRecord).'
    '; } // Put everything together: @@ -513,6 +515,7 @@ class tx_terfe_pi1 extends tslib_pibase { } /** + * DEPRECATED AND UNUSED * Renders the sub view "Info" of an extension single view * * @param string $extensionKey: The extension key of the extension to render @@ -566,7 +569,6 @@ class tx_terfe_pi1 extends tslib_pibase { -
    '.$this->pi_linkTP_keepPIvars($this->commonObj->getLL('extension_title','',1),array('sorting'=>'by_title'),1).' '.$this->pi_linkTP_keepPIvars($this->commonObj->getLL('extension_extensionkey','',1),array('sorting'=>'by_extkey'),1).''.$this->commonObj->getLL('extension_version','',1).' '.$this->commonObj->getLL('extension_documentation','',1).' '.$this->pi_linkTP_keepPIvars($this->commonObj->getLL('extension_state','',1),array('sorting'=>'by_state'),1).' '.$this->pi_linkTP_keepPIvars($this->commonObj->getLL('extension_lastuploaddate','',1),array('sorting'=>'by_update'),1).''.$this->commonObj->getLL('extension_uploadcomment').': '.$extensionRecord['uploadcomment'].'
    '; return $content; @@ -582,6 +584,7 @@ class tx_terfe_pi1 extends tslib_pibase { protected function renderSingleView_extensionDetails ($extensionRecord) { global $TSFE; + $extensionRecord = $this->commonObj->db_prepareExtensionRecordForOutput ($extensionRecord); $extDetailsRow = $this->commonObj->db_getExtensionDetails ($extensionRecord['extensionkey'], $extensionRecord['version']); // Set the magic "reg1" so we can clear the cache for this manual if a new one is uploaded: @@ -592,34 +595,44 @@ class tx_terfe_pi1 extends tslib_pibase { // Compile detail rows information: $detailRows = ''; + $t3xDownloadURL = substr ($this->commonObj->getExtensionVersionPathAndBaseName($extensionRecord['extensionkey'], $extensionRecord['version']).'.t3x', strlen(PATH_site)); + $detailsArr = array ( - 'extension_extensionkey' => $extensionRecord['extensionkey'], - 'extension_version' => $extensionRecord['version'], - 'extension_category' => $extensionRecord['category'], - 'extension_state' => $extensionRecord['state'], - 'extension_reviewstate' => $extensionRecord['reviewstate'], 'extension_dependencies' => $this->commonObj->getRenderedDependencies ($extensionRecord['dependencies']), 'extension_reversedependencies' => $this->commonObj->getRenderedReverseDependencies ($extensionRecord['extensionkey'], $extensionRecord['version']), - 'extension_lastuploaddate' => $extensionRecord['lastuploaddate'], - 'extension_uploadcomment' => $extensionRecord['uploadcomment'], 'extension_files' => $this->commonObj->getRenderedListOfFiles ($extDetailsRow), + 'extension_history' => $this->getUploadHistory ($extensionRecord['extensionkey'], $extensionRecord['lastuploaddate_raw']), + 'extension_download_extension' => ''.$this->commonObj->getLL('extensionfiles_downloadcompressedt3x','',1).'

    ' + ); foreach ($detailsArr as $llKey => $value) { - $detailRows .= ' - - '.$this->commonObj->getLL($llKey,'',1).': - '.$value.' - + $detailRows[] = ' +
    '.$this->commonObj->getLL($llKey,'',1).'
    +
    '.$value.'
    '; } // Put everything together $content = ' - - '.$detailRows.' -
    - '; +
  • + +
    +
    '.$detailRows[0].'
    +
    '.$detailRows[1].'
    +
    +
    +
    '.$detailRows[3].'
    +
    +
    +
    '.$detailRows[4].' +
  • + + +
  • + '.$detailsArr['extension_files'].' +
  • + '; return $content; } @@ -709,35 +722,45 @@ class tx_terfe_pi1 extends tslib_pibase { $documentationLink = ''.$this->commonObj->getLL('general_terdocnotinstalled','',1).''; } $extensionRecord = $this->commonObj->db_prepareExtensionRecordForOutput ($extensionRecord); + $extensionRecord['reviewstate_label'] = $extensionRecord['reviewstate_raw'] ? 'reviewed' : 'unreviewed'; + + //dummy content + $extensionRecord['rating'] = 'none yet'; + $extensionRecord['versiondownloadcounter'] = '12333/32111'; + + $documentationLink = 'not available'; $tableRows = ' - - - '.$this->commonObj->getIcon_extension ($extensionRecord['extensionkey'], $extensionRecord['version']). -$this->pi_linkTP_keepPIvars(t3lib_div::fixed_lgd_cs($extensionRecord['title'],45), array('view'=>'view','showExt' => $extensionRecord['extensionkey'], 'version' => $extensionRecord['version']),1,1) - // '.$this->pi_linkTP(t3lib_div::fixed_lgd_cs($extensionRecord['title'],45), array('tx_terfe_pi1[view]' => 'search', 'tx_terfe_pi1[showExt]' => $extensionRecord['extensionkey'], 'tx_terfe_pi1[version]' => $extensionRecord['version']),1).' - .' - '.$this->commonObj->getIcon_state($extensionRecord['state_raw']).' - - - - - - - - - - - -
    '.$this->commonObj->getLL('extension_authorname','',1).':'.$extensionRecord['authorname'].'
    '.$this->commonObj->getLL('extension_category','',1).':'.$extensionRecord['category'].'
    '.$this->commonObj->getLL('extension_version','',1).':'.$extensionRecord['version'].'
    '.$this->commonObj->getLL('extension_downloads','',1).':'.$extensionRecord['versiondownloadcounter'].'
    '.$this->commonObj->getLL('extension_lastuploaddate','',1).':'.$extensionRecord['lastuploaddate'].'
    '.$this->commonObj->getLL('extension_uploadcomment','',1).':'.$extensionRecord['uploadcomment'].'
    '.$this->commonObj->getLL('extension_documentation','',1).':'.$documentationLink.'
    - - -

    '.$extensionRecord['description'].'

    - - - -   -   - +
  • +
    +
    Icon
    +
    '.$this->commonObj->getIcon_extension ($extensionRecord['extensionkey'], $extensionRecord['version']).'
    +
    '.$this->commonObj->getLL('extension_title','',1).'
    +
    '.$this->pi_linkTP_keepPIvars($extensionRecord['title'], array('view'=>'view','showExt' => $extensionRecord['extensionkey'], 'version' => $extensionRecord['version']),1,1).'
    +
    '.$this->commonObj->getLL('extension_extensionkey','',1).'
    +
    ( '.$extensionRecord['extensionkey'].' )
    +
    '.$this->commonObj->getLL('extension_state','',1).'
    +
    +
    '.$extensionRecord['state_raw'].', '.$extensionRecord['reviewstate'].' +
    +
    + +
    +
    '.$this->commonObj->getLL('extension_authorname','',1).'
    '.$extensionRecord['authorname'].'
    +
    '.$this->commonObj->getLL('extension_category','',1).'
    '.$extensionRecord['category'].'
    +
    '.$this->commonObj->getLL('extension_version','',1).'
    '.$extensionRecord['version'].'
    +
    '.$this->commonObj->getLL('extension_documentation','',1).'
    '.$documentationLink.'
    +
    '.$this->commonObj->getLL('extension_downloads','',1).'
    '.$extensionRecord['versiondownloadcounter'].'
    +
    '.$this->commonObj->getLL('extension_rating','',1).'
    '.$extensionRecord['rating'].'
    +
    +
    +
    '.$this->commonObj->getLL('extension_lastuploaddate','',1).'
    '.$extensionRecord['lastuploaddate'].'
    +
    '.$this->commonObj->getLL('extension_uploadcomment','',1).'
    '.$extensionRecord['uploadcomment'].'
    +
    +
    +
    '.$this->commonObj->getLL('extension_description','',1).'
    '.$extensionRecord['description'].'
    +
    +
    +
  • '; return $tableRows; @@ -766,7 +789,6 @@ $this->pi_linkTP_keepPIvars(t3lib_div::fixed_lgd_cs($extensionRecord['title'],45 '.$this->pi_linkTP_keepPIvars($extensionRecord['title'], array('view'=>'view','showExt' => $extensionRecord['extensionkey'], 'version' => $extensionRecord['version']),1,1).' '.$extensionRecord['extensionkey'].' - '.$extensionRecord['version'].' '.$documentationLink.' '.$extensionRecord['state'].' '.$extensionRecord['lastuploaddate'].' @@ -776,6 +798,36 @@ $this->pi_linkTP_keepPIvars(t3lib_div::fixed_lgd_cs($extensionRecord['title'],45 return $tableRows; } + /** + * [Describe function...] + * + * @param string $extensionKey: Extension Key + * @param int $lastuploaddate: Timestamp of last upload date + * @return string List of upload comments in reverse order + * @access protected + */ + protected function getUploadHistory($extensionKey, $lastuploaddate){ + global $TYPO3_DB; + $res = $TYPO3_DB->exec_SELECTquery ( + 'version,uploadcomment', + 'tx_terfe_extensions', + 'extensionkey='.$TYPO3_DB->fullQuoteStr($extensionKey, 'tx_terfe_extensions').' AND lastuploaddate < "'.intval($lastuploaddate).'"', + '', + 'lastuploaddate DESC', + '5' + ); + + if ($res) { + $output = '
      '; + while ($result = $TYPO3_DB->sql_fetch_assoc($res)){ + if ($result['uploadcomment']){ + $output .= '
    • '.$result['version'].': '.nl2br(htmlspecialchars($result['uploadcomment'])).'
    • '; + } + } + return $output.'
    '; + } else return FALSE; + } + /** * Renders the top tab menu which allows for selection of the different views. * -- GitLab