/** * Displays a list of extensions where a newer version is available * in the TER than the one that is installed right now * integrated from the extension "ter_update_check" for TYPO3 4.2 by Christian Welzel * * @return string */ function showExtensionsToUpdate() { global $LANG; $extList = $this->getInstalledExtensions(); $content = '<table cellspacing="1" class="t3-em-extension-list t3-em-extension-list-to-update">' . '<tr class="t3-row-header">' . '<td></td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_name') . '</td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_key') . '</td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_loc_ver') . '</td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_rem_ver') . '</td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_location') . '</td>' . '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_comment') . '</td>' . '</tr>'; foreach ($extList[0] as $name => $data) { $this->xmlHandler->searchExtensionsXMLExact($name, '', '', TRUE, TRUE); if (!is_array($this->xmlHandler->extensionsXML[$name])) { continue; } $v = $this->xmlHandler->extensionsXML[$name]['versions']; $versions = array_keys($v); natsort($versions); $lastversion = end($versions); if ((t3lib_extMgm::isLoaded($name) || $this->parentObject->MOD_SETTINGS['display_installed']) && ($data['EM_CONF']['shy'] == 0 || $this->parentObject->MOD_SETTINGS['display_shy']) && tx_em_Tools::versionDifference($lastversion, $data['EM_CONF']['version'], 1)) { $imgInfo = @getImageSize(tx_em_Tools::getExtPath($name, $data['type']) . '/ext_icon.gif'); if (is_array($imgInfo)) { $icon = '<img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($data['type']) . $name . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" />'; } elseif ($data['_ICON']) { //TODO: see if this can be removed, seems to be wrong in this context $icon = $data['_ICON']; } else { $icon = '<img src="clear.gif" width="1" height="1" alt="" />'; } $comment = '<table cellpadding="0" cellspacing="0" width="100%">'; foreach ($versions as $vk) { $va =& $v[$vk]; if (t3lib_div::int_from_ver($vk) <= t3lib_div::int_from_ver($data['EM_CONF']['version'])) { continue; } $comment .= '<tr><td valign="top" style="padding-right:2px;border-bottom:1px dotted gray">' . $vk . '</td>' . '<td valign="top" style="border-bottom:1px dotted gray">' . nl2br($va[uploadcomment]) . '</td></tr>'; } $comment .= '</table>'; $serverMD5Array = $this->parentObject->extensionDetails->serverExtensionMD5array($name, $data); if (is_array($serverMD5Array)) { ksort($serverMD5Array); } $currentMD5Array = unserialize($data['EM_CONF']['_md5_values_when_last_written']); if (is_array($currentMD5Array)) { @ksort($currentMD5Array); } $warn = ''; if (strcmp(serialize($currentMD5Array), serialize($serverMD5Array))) { $warn = '<tr class="bgColor4" style="color:red"><td colspan="7">' . tx_em_Tools::rfw('<br /><strong>' . $name . ': ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_warn_diff') . '</strong>') . '</td></tr>' . LF; if ($this->parentObject->MOD_SETTINGS['display_files'] == 1) { $affectedFiles = tx_em_Tools::findMD5ArrayDiff($serverMD5Array, $currentMD5Array); if (count($affectedFiles)) { $warn .= '<tr class="bgColor4"><td colspan="7"><strong>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_modified') . '</strong><br />' . tx_em_Tools::rfw(implode('<br />', $affectedFiles)) . '</td></tr>' . LF; } } } $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="' . 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>' . '<td valign="top" nowrap="nowrap">' . $this->api->typeLabels[$data['type']] . (strlen($data['doubleInstall']) > 1 ? '<strong> ' . tx_em_Tools::rfw($data['doubleInstall']) . '</strong>' : '') . '</td>' . '<td valign="top">' . $comment . '</td></tr>' . LF . $warn . '<tr class="bgColor4"><td colspan="7"><hr style="margin:0px" /></td></tr>' . LF; } } return $content . '</table><br />'; }
/** * Imports an extensions from the online repository * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)" * * @param string Extension key * @param string Version * @param string Install scope: "L" or "G" or "S" * @param boolean If true, extension is uploaded as file * @param boolean If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept. * @param array Direct input array (like from kickstarter) * @return string Return false on success, returns error message if error. */ function importExtFromRep($extKey, $version, $loc, $uploadFlag = 0, $dontDelete = 0, $directInput = '') { $uploadSucceed = false; $uploadedTempFile = ''; if (is_array($directInput)) { $fetchData = array($directInput, ''); $loc = $loc === 'G' || $loc === 'S' ? $loc : 'L'; } elseif ($uploadFlag) { if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) { // Read uploaded file: if (!$uploadedTempFile) { if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) { t3lib_div::sysLog('Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3); $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']); } $fileContent = t3lib_div::getUrl($uploadedTempFile); if (!$fileContent) { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_empty'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } // Decode file data: $fetchData = $this->terConnection->decodeExchangeData($fileContent); if (is_array($fetchData)) { $extKey = $fetchData[0]['extKey']; if ($extKey) { if (!$this->CMD['uploadOverwrite']) { $loc = $loc === 'G' || $loc === 'S' ? $loc : 'L'; $comingExtPath = tx_em_Tools::typePath($loc) . $extKey . '/'; if (@is_dir($comingExtPath)) { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) . '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } // ... else go on, install... } // ... else go on, install... } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_key'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_file'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true, true); // Fetch extension from TER: if (!strlen($version)) { $versions = array_keys($this->xmlHandler->extensionsXML[$extKey]['versions']); $version = end($versions); } $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlHandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL()); } // At this point the extension data should be present; so we want to write it to disc: $content = $this->install->installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1); if ($uploadSucceed && $uploadedTempFile) { t3lib_div::unlink_tempfile($uploadedTempFile); } return false; }