TYPO3 API  SVNRelease
class.tx_em_extensions_details.php
Go to the documentation of this file.
00001 <?php
00002 /* **************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) webservices.nl
00006 *  (c) 2006-2010 Karsten Dambekalns <karsten@typo3.org>
00007 *  (c) 2010 Steffen Kamper <steffen@typo3.org>
00008 *  All rights reserved
00009 *
00010 *  This script is part of the TYPO3 project. The TYPO3 project is
00011 *  free software; you can redistribute it and/or modify
00012 *  it under the terms of the GNU General Public License as published by
00013 *  the Free Software Foundation; either version 2 of the License, or
00014 *  (at your option) any later version.
00015 *
00016 *  The GNU General Public License can be found at
00017 *  http://www.gnu.org/copyleft/gpl.html.
00018 *  A copy is found in the textfile GPL.txt and important notices to the license
00019 *  from the author is found in LICENSE.txt distributed with these scripts.
00020 *
00021 *
00022 *  This script is distributed in the hope that it will be useful,
00023 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 *  GNU General Public License for more details.
00026 *
00027 *  This copyright notice MUST APPEAR in all copies of the script!
00028 ***************************************************************/
00029 /* $Id: class.tx_em_extensions_details.php 2058 2010-03-17 09:39:15Z steffenk $ */
00030 
00031 /**
00032  * This class handles extension details
00033  *
00034  */
00035 
00036 class tx_em_Extensions_Details {
00037 
00038     protected $maxUploadSize = 31457280;
00039     protected $descrTable = '_MOD_tools_em';
00040     protected $parentObject;
00041 
00042     protected $categories;
00043     protected $states;
00044 
00045     /**
00046      * Instance of EM API
00047      *
00048      * @var tx_em_API
00049      */
00050     protected $api;
00051 
00052     /**
00053      * Class for install extensions
00054      *
00055      * @var em_install
00056      */
00057     public $install;
00058 
00059     /**
00060      * Constructor
00061      *
00062      * @param object $parentObject
00063      */
00064     public function __construct($parentObject = NULL) {
00065         $this->parentObject = $parentObject;
00066         $this->api = t3lib_div::makeInstance('tx_em_API');
00067         $this->install = t3lib_div::makeInstance('tx_em_Install', $this);
00068         $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('em') . 'language/locallang.xml');
00069         $this->categories = array(
00070             'be' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE'),
00071             'module' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE_modules'),
00072             'fe' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE'),
00073             'plugin' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE_plugins'),
00074             'misc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_miscellanous'),
00075             'services' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_services'),
00076             'templates' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_templates'),
00077             'example' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_examples'),
00078             'doc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_documentation')
00079         );
00080         $this->states = tx_em_Tools::getStates();
00081     }
00082 
00083 
00084     /**
00085      * Reads $confFilePath (a module $conf-file) and returns information on the existence of TYPO3_MOD_PATH definition and MCONF_name
00086      *
00087      * @param   string      Absolute path to a "conf.php" file of a module which we are analysing.
00088      * @return  array       Information found.
00089      * @see writeTYPO3_MOD_PATH()
00090      */
00091     function modConfFileAnalysis($confFilePath) {
00092         $lines = explode(LF, t3lib_div::getUrl($confFilePath));
00093         $confFileInfo = array();
00094         $confFileInfo['lines'] = $lines;
00095         $reg = array();
00096 
00097         foreach ($lines as $k => $l) {
00098             $line = trim($l);
00099 
00100             unset($reg);
00101             if (preg_match('/^define[[:space:]]*\([[:space:]]*["\']TYPO3_MOD_PATH["\'][[:space:]]*,[[:space:]]*["\']([[:alnum:]_\/\.]+)["\'][[:space:]]*\)[[:space:]]*;/', $line, $reg)) {
00102                 $confFileInfo['TYPO3_MOD_PATH'] = array($k, $reg);
00103             }
00104 
00105             unset($reg);
00106             if (preg_match('/^\$MCONF\[["\']?name["\']?\][[:space:]]*=[[:space:]]*["\']([[:alnum:]_]+)["\'];/', $line, $reg)) {
00107                 $confFileInfo['MCONF_name'] = array($k, $reg);
00108             }
00109         }
00110         return $confFileInfo;
00111     }
00112 
00113     /**
00114      * Check if upload folder / "createDir" directories should be created.
00115      *
00116      * @param   string      Extension key
00117      * @param   array       Extension information array
00118      * @return  string      HTML content.
00119      */
00120     function checkUploadFolder($extKey, $extInfo) {
00121 
00122         // Checking for upload folder:
00123         $uploadFolder = PATH_site . tx_em_Tools::uploadFolder($extKey);
00124         if ($extInfo['EM_CONF']['uploadfolder'] && !@is_dir($uploadFolder)) {
00125             if (t3lib_div::_POST('_uploadfolder')) { // CREATE dir:
00126                 t3lib_div::mkdir($uploadFolder);
00127                 $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
00128 <HTML>
00129 <HEAD>
00130     <TITLE></TITLE>
00131 <META http-equiv=Refresh Content="0; Url=../../">
00132 </HEAD>
00133 </HTML>';
00134                 t3lib_div::writeFile($uploadFolder . 'index.html', $indexContent);
00135             } else { // Show checkbox / HTML for creation:
00136                 $content .= '
00137                     <br /><h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_upload_folder') . '</h3>
00138                     <p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_upload_folder_needed'),
00139                     tx_em_Tools::uploadFolder($extKey)
00140                 ) . '<br />
00141                         <label for="check_uploadfolder">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'),
00142                     tx_em_Tools::uploadFolder($extKey)
00143                 ) . '</label>
00144                         <input type="checkbox" name="_uploadfolder" id="check_uploadfolder" checked="checked" value="1" /><br />
00145                     </p>
00146                 ';
00147             }
00148         }
00149 
00150         // Additional directories that should be created:
00151         if ($extInfo['EM_CONF']['createDirs']) {
00152             $createDirs = array_unique(t3lib_div::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1));
00153 
00154             foreach ($createDirs as $crDir) {
00155                 if (!@is_dir(PATH_site . $crDir)) {
00156                     if (t3lib_div::_POST('_createDir_' . md5($crDir))) { // CREATE dir:
00157 
00158                         // Initialize:
00159                         $crDirStart = '';
00160                         $dirs_in_path = explode('/', preg_replace('/\/$/', '', $crDir));
00161 
00162                         // Traverse each part of the dir path and create it one-by-one:
00163                         foreach ($dirs_in_path as $dirP) {
00164                             if (strcmp($dirP, '')) {
00165                                 $crDirStart .= $dirP . '/';
00166                                 if (!@is_dir(PATH_site . $crDirStart)) {
00167                                     t3lib_div::mkdir(PATH_site . $crDirStart);
00168                                     $finalDir = PATH_site . $crDirStart;
00169                                 }
00170                             } else {
00171                                 throw new RuntimeException(
00172                                     'TYPO3 Fatal Error: ' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'), PATH_site . $crDir),
00173                                     1270853982
00174                                 );
00175                             }
00176                         }
00177                         if ($finalDir) {
00178                             $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
00179 <HTML>
00180 <HEAD>
00181     <TITLE></TITLE>
00182 <META http-equiv=Refresh Content="0; Url=/">
00183 </HEAD>
00184 </HTML>';
00185                             t3lib_div::writeFile($finalDir . 'index.html', $indexContent);
00186                         }
00187                     } else { // Show checkbox / HTML for creation:
00188                         $md5CrDir = md5($crDir);
00189                         $content .= '
00190                             <br />
00191                             <h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_folder') . '</h3>
00192                             <p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_folder_needed'),
00193                             $crDir
00194                         ) . '<br />
00195                                 <label for="check_createDir_' . $md5CrDir . '">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'),
00196                             $crDir
00197                         ) . '</label>
00198                                 <input type="checkbox" name="_createDir_' . $md5CrDir . '" id="check_createDir_' . $md5CrDir . '" checked="checked" value="1" /><br />
00199                             </p>
00200                         ';
00201                     }
00202                 }
00203             }
00204         }
00205 
00206         return $content;
00207     }
00208 
00209 
00210     /**
00211      * Processes return-data from online repository.
00212      * Currently only the returned emconf array is written to extension.
00213      *
00214      * @param   array       Command array returned from TER
00215      * @return  string      Message
00216      */
00217     function uploadExtensionToTER($em) {
00218         $msg = '';
00219         $response = $this->parentObject->terConnection->uploadToTER($em);
00220 
00221         if (!is_array($response)) {
00222             return $response;
00223         }
00224 
00225         if ($response['resultCode'] == TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED) {
00226             $em['extInfo']['EM_CONF']['version'] = $response['version'];
00227             $response['resultMessages'][] = sprintf($GLOBALS['LANG']->getLL('terCommunication_ext_version'),
00228                 $response['version']
00229             );
00230             $response['resultMessages'][] = $this->updateLocalEM_CONF($em['extKey'], $em['extInfo']);
00231         }
00232 
00233         $msg = '<ul><li>' . implode('</li><li>', $response['resultMessages']) . '</li></ul>';
00234         return $msg;
00235     }
00236 
00237     /**
00238      * Forces update of local EM_CONF. This will renew the information of changed files.
00239      *
00240      * @param   string      Extension key
00241      * @param   array       Extension information array
00242      * @return  string      Status message
00243      */
00244     function updateLocalEM_CONF($extKey, $extInfo) {
00245         $extInfo['EM_CONF']['_md5_values_when_last_written'] = serialize($this->serverExtensionMD5array($extKey, $extInfo));
00246         $emConfFileContent = $this->construct_ext_emconf_file($extKey, $extInfo['EM_CONF']);
00247 
00248         $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
00249         $emConfFileName = $absPath . 'ext_emconf.php';
00250         if ($emConfFileContent) {
00251 
00252             if (@is_file($emConfFileName)) {
00253                 if (t3lib_div::writeFile($emConfFileName, $emConfFileContent) === true) {
00254                     return sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_ok'),
00255                         substr($emConfFileName, strlen($absPath)));
00256                 } else {
00257                     return '<strong>' . sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_not_writable'),
00258                         $emConfFileName) . '</strong>';
00259                 }
00260             } else {
00261                 return ('<strong>' . sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_not_found'),
00262                     $emConfFileName) . '</strong>');
00263             }
00264         } else {
00265             return sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_no_content'),
00266                 substr($emConfFileName, strlen($absPath)));
00267         }
00268     }
00269 
00270     /**
00271      * Creates a MD5-hash array over the current files in the extension
00272      *
00273      * @param   string      Extension key
00274      * @param   array       Extension information array
00275      * @return  array       MD5-keys
00276      */
00277     function serverExtensionMD5array($extKey, $conf) {
00278 
00279         // Creates upload-array - including filelist.
00280         $mUA = $this->makeUploadarray($extKey, $conf);
00281 
00282         $md5Array = array();
00283         if (is_array($mUA['FILES'])) {
00284 
00285             // Traverse files.
00286             foreach ($mUA['FILES'] as $fN => $d) {
00287                 if ($fN != 'ext_emconf.php') {
00288                     $md5Array[$fN] = substr($d['content_md5'], 0, 4);
00289                 }
00290             }
00291         } else {
00292             debug(array($mUA, $conf), 'serverExtensionMD5Array:' . $extKey);
00293         }
00294         return $md5Array;
00295     }
00296 
00297     /*******************************************
00298      *
00299      * Compiling upload information, emconf-file etc.
00300      *
00301      *******************************************/
00302 
00303     /**
00304      * Compiles the ext_emconf.php file
00305      *
00306      * @param   string      Extension key
00307      * @param   array       EM_CONF array
00308      * @return  string      PHP file content, ready to write to ext_emconf.php file
00309      */
00310     function construct_ext_emconf_file($extKey, $EM_CONF) {
00311 
00312         // clean version number:
00313         $vDat = tx_em_Tools::renderVersion($EM_CONF['version']);
00314         $EM_CONF['version'] = $vDat['version'];
00315 
00316         $code = '<?php
00317 
00318 ########################################################################
00319 # Extension Manager/Repository config file for ext "' . $extKey . '".
00320 #
00321 # Auto generated ' . date('d-m-Y H:i') . '
00322 #
00323 # Manual updates:
00324 # Only the data in the array - everything else is removed by next
00325 # writing. "version" and "dependencies" must not be touched!
00326 ########################################################################
00327 
00328 $EM_CONF[$_EXTKEY] = ' . tx_em_Tools::arrayToCode($EM_CONF, 0) . ';
00329 
00330 ?>';
00331         return str_replace(CR, '', $code);
00332     }
00333 
00334     /**
00335      * Make upload array out of extension
00336      *
00337      * @param   string      Extension key
00338      * @param   array       Extension information array
00339      * @return  mixed       Returns array with extension upload array on success, otherwise an error string.
00340      */
00341     function makeUploadarray($extKey, $conf) {
00342         $extPath = tx_em_Tools::getExtPath($extKey, $conf['type']);
00343 
00344         if ($extPath) {
00345 
00346             // Get files for extension:
00347             $fileArr = array();
00348             $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $extPath, '', 0, 99, $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging']);
00349 
00350             // Calculate the total size of those files:
00351             $totalSize = 0;
00352             foreach ($fileArr as $file) {
00353                 $totalSize += filesize($file);
00354             }
00355 
00356             // If the total size is less than the upper limit, proceed:
00357             if ($totalSize < $this->maxUploadSize) {
00358 
00359                 // Initialize output array:
00360                 $uploadArray = array();
00361                 $uploadArray['extKey'] = $extKey;
00362                 $uploadArray['EM_CONF'] = $conf['EM_CONF'];
00363                 $uploadArray['misc']['codelines'] = 0;
00364                 $uploadArray['misc']['codebytes'] = 0;
00365 
00366                 $uploadArray['techInfo'] = $this->install->makeDetailedExtensionAnalysis($extKey, $conf, 1);
00367 
00368                 // Read all files:
00369                 foreach ($fileArr as $file) {
00370                     $relFileName = substr($file, strlen($extPath));
00371                     $fI = pathinfo($relFileName);
00372                     if ($relFileName != 'ext_emconf.php') { // This file should be dynamically written...
00373                         $uploadArray['FILES'][$relFileName] = array(
00374                             'name' => $relFileName,
00375                             'size' => filesize($file),
00376                             'mtime' => filemtime($file),
00377                             'is_executable' => (TYPO3_OS == 'WIN' ? 0 : is_executable($file)),
00378                             'content' => t3lib_div::getUrl($file)
00379                         );
00380                         if (t3lib_div::inList('php,inc', strtolower($fI['extension']))) {
00381                             $uploadArray['FILES'][$relFileName]['codelines'] = count(explode(LF, $uploadArray['FILES'][$relFileName]['content']));
00382                             $uploadArray['misc']['codelines'] += $uploadArray['FILES'][$relFileName]['codelines'];
00383                             $uploadArray['misc']['codebytes'] += $uploadArray['FILES'][$relFileName]['size'];
00384 
00385                             // locallang*.php files:
00386                             if (substr($fI['basename'], 0, 9) == 'locallang' && strstr($uploadArray['FILES'][$relFileName]['content'], '$LOCAL_LANG')) {
00387                                 $uploadArray['FILES'][$relFileName]['LOCAL_LANG'] = tx_em_Tools::getSerializedLocalLang($file, $uploadArray['FILES'][$relFileName]['content']);
00388                             }
00389                         }
00390                         $uploadArray['FILES'][$relFileName]['content_md5'] = md5($uploadArray['FILES'][$relFileName]['content']);
00391                     }
00392                 }
00393 
00394                 // Return upload-array:
00395                 return $uploadArray;
00396             } else {
00397                 return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_size'),
00398                     $totalSize, t3lib_div::formatSize($this->maxUploadSize));
00399             }
00400         } else {
00401             return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_path'),
00402                 $extKey);
00403         }
00404     }
00405 
00406 
00407     /**
00408      * Prints a table with extension information in it.
00409      *
00410      * @param   string      Extension key
00411      * @param   array       Extension information array
00412      * @param   boolean     If set, the information array shows information for a remote extension in TER, not a local one.
00413      * @return  string      HTML content.
00414      */
00415     function extInformationarray($extKey, $extInfo, $remote = 0) {
00416         $emConf = $extInfo['EM_CONF'];
00417 
00418         $lines = array();
00419         $lines[] = '
00420             <tr class="t3-row-header"><td colspan="2"><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_general_info') . '</strong></td></tr>';
00421 
00422         // row for the extension title
00423         $key = 'title';
00424         $dataCol = $emConf['_icon'] . $emConf[$key];
00425         $lines[] = array(
00426             $this->headerCol($key),
00427             $dataCol
00428         );
00429 
00430         // row for the extension description
00431         $key = 'description';
00432         $dataCol = nl2br(htmlspecialchars($emConf[$key]));
00433         $lines[] = array(
00434             $this->headerCol($key),
00435             $dataCol
00436         );
00437 
00438         // row for the extension author
00439         $key = 'author';
00440         $dataCol = tx_em_Tools::wrapEmail($emConf['author'] . ($emConf['author_email'] ? ' <' . $emConf['author_email'] . '>' : ''), $emConf['author_email']);
00441         if ($emConf['author_company']) {
00442             $dataCol .= ', ' . $emConf['author_company'];
00443         }
00444         $lines[] = array(
00445             $this->headerCol($key),
00446             $dataCol
00447         );
00448 
00449         // row for the version
00450         $key = 'version';
00451         $dataCol = $emConf[$key];
00452         $lines[] = array(
00453             $this->headerCol($key),
00454             $dataCol
00455         );
00456 
00457         // row for the category
00458         $key = 'category';
00459         $dataCol = $this->categories[$emConf[$key]];
00460         $lines[] = array(
00461             $this->headerCol($key),
00462             $dataCol
00463         );
00464 
00465         // row for the state
00466         $key = 'state';
00467         $dataCol = $this->states[$emConf[$key]];
00468         $lines[] = array(
00469             $this->headerCol($key),
00470             $dataCol
00471         );
00472 
00473         // row for the shy state
00474         $key = 'shy';
00475         if ($emConf[$key]) {
00476             $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
00477         } else {
00478             $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
00479         }
00480         $lines[] = array(
00481             $this->headerCol($key),
00482             $dataCol
00483         );
00484 
00485         // row for the internal state
00486         $key = 'internal';
00487         if ($emConf[$key]) {
00488             $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
00489         } else {
00490             $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
00491         }
00492         $lines[] = array(
00493             $this->headerCol($key),
00494             $dataCol
00495         );
00496 
00497         // row for the dependencies
00498         $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_depends_on');
00499         $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dependencies', $headerCol);
00500         $dataCol = tx_em_Tools::depToString($emConf['constraints']);
00501         $lines[] = array(
00502             $headerCol,
00503             $dataCol
00504         );
00505 
00506         // row for the conflicts
00507         $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_conflicts_with');
00508         $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conflicts', $headerCol);
00509         $dataCol = tx_em_Tools::depToString($emConf['constraints'], 'conflicts');
00510         $lines[] = array(
00511             $headerCol,
00512             $dataCol
00513         );
00514 
00515         // row for the suggestions
00516         $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_suggests');
00517         $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conflicts', $headerCol);
00518         $dataCol = tx_em_Tools::depToString($emConf['constraints'], 'suggests');
00519         $lines[] = array(
00520             $this->headerCol('suggests'),
00521             $dataCol
00522         );
00523 
00524         if (!$remote) {
00525 
00526             $key = 'priority';
00527             $lines[] = array(
00528                 $this->headerCol($key),
00529                 $emConf[$key]
00530             );
00531 
00532 
00533             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_clear_cache');
00534             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_clearCacheOnLoad', $headerCol);
00535             if ($emConf['clearCacheOnLoad']) {
00536                 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
00537             } else {
00538                 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
00539             }
00540             $lines[] = array(
00541                 $headerCol,
00542                 $dataCol
00543             );
00544 
00545             $key = 'module';
00546             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_incl_modules');
00547             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_module', $headerCol);
00548             $lines[] = array(
00549                 $headerCol,
00550                 $emConf[$key]
00551             );
00552 
00553             $key = 'lockType';
00554             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_lock_type');
00555             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_lockType', $headerCol);
00556             $lines[] = array(
00557                 $headerCol,
00558                 ($emConf[$key] ? $emConf[$key] : '')
00559             );
00560 
00561             $key = 'doNotLoadInFE';
00562             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_load_in_frontend');
00563             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_doNotLoadInFE', $headerCol);
00564             if (!$emConf['doNotLoadInFE']) {
00565                 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
00566             } else {
00567                 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
00568             }
00569             $lines[] = array(
00570                 $headerCol,
00571                 $dataCol
00572             );
00573 
00574             $key = 'modify_tables';
00575             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_modifies_tables');
00576             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_modify_tables', $headerCol);
00577             $lines[] = array(
00578                 $headerCol,
00579                 $emConf[$key]
00580             );
00581 
00582 
00583             // Installation status:
00584             $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo, 1);
00585             $lines[] = array('<tr><td colspan="2">&nbsp;</td></tr>');
00586             $lines[] = array('<tr class="t3-row-header"><td colspan="2"><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_inst_status') . '</strong></td></tr>');
00587 
00588 
00589             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_inst_type');
00590             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_type', $headerCol);
00591             $dataCol = $this->api->typeLabels[$extInfo['type']] . ' - <em>' . $this->api->typeDescr[$extInfo['type']] . '</em>';
00592             $lines[] = array($headerCol, $dataCol);
00593 
00594 
00595             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_inst_twice');
00596             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_doubleInstall', $headerCol);
00597             $dataCol = $this->extInformationArray_dbInst($extInfo['doubleInstall'], $extInfo['type']);
00598             $lines[] = array($headerCol, $dataCol);
00599 
00600 
00601             if (is_array($extInfo['files'])) {
00602                 sort($extInfo['files']);
00603                 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_root_files');
00604                 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_rootfiles', $headerCol);
00605                 $dataCol = implode('<br />', $extInfo['files']);
00606                 $lines[] = array($headerCol, $dataCol);
00607             }
00608 
00609             if ($techInfo['tables'] || $techInfo['static'] || $techInfo['fields']) {
00610                 if (!$remote && t3lib_extMgm::isLoaded($extKey)) {
00611                     $tableStatus = tx_em_Tools::rfw(($techInfo['tables_error'] ?
00612                             '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_table_error') . '</strong><br />' .
00613                                     $GLOBALS['LANG']->getLL('extInfoArray_missing_fields') : '') .
00614                             ($techInfo['static_error'] ?
00615                                     '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' .
00616                                             $GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : ''));
00617                 } else {
00618                     $tableStatus = $techInfo['tables_error'] || $techInfo['static_error'] ?
00619                             $GLOBALS['LANG']->getLL('extInfoArray_db_update_needed') : $GLOBALS['LANG']->getLL('extInfoArray_tables_ok');
00620                 }
00621             }
00622 
00623             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_db_requirements');
00624             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dbReq', $headerCol);
00625             $dataCol = $this->extInformationArray_dbReq($techInfo, 1);
00626             $lines[] = array($headerCol, $dataCol);
00627 
00628             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_db_status');
00629             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dbStatus', $headerCol);
00630             $lines[] = array($headerCol, $tableStatus);
00631 
00632             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_flags');
00633             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_flags', $headerCol);
00634             $dataCol = (is_array($techInfo['flags']) ? implode('<br />', $techInfo['flags']) : '');
00635             $lines[] = array($headerCol, $dataCol);
00636 
00637             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_config_template');
00638             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conf', $headerCol);
00639             $dataCol = ($techInfo['conf'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '');
00640             $lines[] = array($headerCol, $dataCol);
00641 
00642             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_typoscript_files');
00643             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_TSfiles', $headerCol);
00644             $dataCol = (is_array($techInfo['TSfiles']) ? implode('<br />', $techInfo['TSfiles']) : '');
00645             $lines[] = array($headerCol, $dataCol);
00646 
00647             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_language_files');
00648             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_locallang', $headerCol);
00649             $dataCol = (is_array($techInfo['locallang']) ? implode('<br />', $techInfo['locallang']) : '');
00650             $lines[] = array($headerCol, $dataCol);
00651 
00652             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_upload_folder');
00653             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_uploadfolder', $headerCol);
00654             $dataCol = ($techInfo['uploadfolder'] ? $techInfo['uploadfolder'] : '');
00655             $lines[] = array($headerCol, $dataCol);
00656 
00657             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_create_directories');
00658             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_createDirs', $headerCol);
00659             $dataCol = (is_array($techInfo['createDirs']) ? implode('<br />', $techInfo['createDirs']) : '');
00660             $lines[] = array($headerCol, $dataCol);
00661 
00662             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_module_names');
00663             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_moduleNames', $headerCol);
00664             $dataCol = (is_array($techInfo['moduleNames']) ? implode('<br />', $techInfo['moduleNames']) : '');
00665             $lines[] = array($headerCol, $dataCol);
00666 
00667             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_class_names');
00668             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_classNames', $headerCol);
00669             $dataCol = (is_array($techInfo['classes']) ? implode('<br />', $techInfo['classes']) : '');
00670             $lines[] = array($headerCol, $dataCol);
00671 
00672             $currentMd5Array = $this->serverExtensionMD5array($extKey, $extInfo);
00673 
00674             $msgLines = array();
00675             if (strcmp($extInfo['EM_CONF']['_md5_values_when_last_written'], serialize($currentMd5Array))) {
00676                 $msgLines[] = tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_difference_detected') . '</strong>');
00677                 $affectedFiles = tx_em_Tools::findMD5ArrayDiff($currentMd5Array, unserialize($extInfo['EM_CONF']['_md5_values_when_last_written']));
00678                 if (count($affectedFiles)) {
00679                     $msgLines[] = '<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_modified_files') . '</strong><br />' .
00680                             tx_em_Tools::rfw(implode('<br />', $affectedFiles));
00681                 }
00682             }
00683 
00684             $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_files_changed');
00685             $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_filesChanged', $headerCol);
00686             $dataCol = implode('<br />', $msgLines);
00687             $lines[] = array($headerCol, $dataCol);
00688         }
00689 
00690         $output = '';
00691         foreach ($lines as $cols) {
00692             // if it's just one line, we assume it's a headline,
00693             // thus no need to wrap it in HTML table tags
00694             if (count($cols) == 1) {
00695                 $output .= $cols[0];
00696             } else {
00697                 $output .= '
00698                     <tr class="bgColor4">
00699                         <td>' . $cols[0] . '</td>
00700                         <td>' . $cols[1] . '</td>
00701                     </tr>';
00702             }
00703         }
00704 
00705 
00706         return '<table border="0" cellpadding="1" cellspacing="2">
00707                     ' . $output . '
00708                 </table>';
00709     }
00710 
00711     /**
00712      * Returns HTML with information about database requirements
00713      *
00714      * @param   array       Technical information array
00715      * @param   boolean     Table header displayed
00716      * @return  string      HTML content.
00717      */
00718     function extInformationArray_dbReq($techInfo, $tableHeader = 0) {
00719         return nl2br(trim((is_array($techInfo['tables']) ?
00720                 ($tableHeader ?
00721                         "\n\n<strong>" . $GLOBALS['LANG']->getLL('extDumpTables_tables') . "</strong>\n" : '') .
00722                         implode(LF, $techInfo['tables']) : '') .
00723                 (is_array($techInfo['static']) ?
00724                         "\n\n<strong>" . $GLOBALS['LANG']->getLL('extBackup_static_tables') . "</strong>\n" .
00725                                 implode(LF, $techInfo['static']) : '') .
00726                 (is_array($techInfo['fields']) ?
00727                         "\n\n<strong>" . $GLOBALS['LANG']->getLL('extInfoArray_additional_fields') . "</strong>\n" .
00728                                 implode('<hr />', $techInfo['fields']) : '')));
00729     }
00730 
00731     /**
00732      * Double install warning.
00733      *
00734      * @param   string      Double-install string, eg. "LG" etc.
00735      * @param   string      Current scope, eg. "L" or "G" or "S"
00736      * @return  string      Message
00737      */
00738     function extInformationArray_dbInst($dbInst, $current) {
00739         if (strlen($dbInst) > 1) {
00740             $others = array();
00741             for ($a = 0; $a < strlen($dbInst); $a++) {
00742                 if (substr($dbInst, $a, 1) != $current) {
00743                     $others[] = '"' . $this->api->typeLabels[substr($dbInst, $a, 1)] . '"';
00744                 }
00745             }
00746             return tx_em_Tools::rfw(
00747                 sprintf($GLOBALS['LANG']->getLL('extInfoArray_double_installation_infotext'),
00748                     implode(' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ', $others),
00749                     $this->api->typeLabels[$current]
00750                 )
00751             );
00752         } else {
00753             return '';
00754         }
00755     }
00756 
00757 
00758     /**
00759      * Returns help text if applicable.
00760      *
00761      * @param   string      Help text key
00762      * @return  string      HTML table cell
00763      * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7
00764      */
00765     function helpCol($key) {
00766         global $BE_USER;
00767         if ($BE_USER->uc['edit_showFieldHelp']) {
00768             if (empty($key)) {
00769                 return '<td>&nbsp;</td>';
00770             }
00771             else {
00772                 return t3lib_BEfunc::cshItem($this->descrTable, 'emconf_' . $key, $GLOBALS['BACK_PATH'], '<td>|</td>');
00773             }
00774         }
00775         else {
00776             return '';
00777         }
00778     }
00779 
00780     /**
00781      * Returns the header column (for the extension details item), and applies help text if available
00782      *
00783      * @param   string  field key
00784      * @return  string  HTML ready to go
00785      */
00786     function headerCol($key) {
00787         $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_' . $key);
00788         return t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_' . $key, $headerCol);
00789     }
00790 }
00791 
00792 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_details.php'])) {
00793     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_details.php']);
00794 }
00795 
00796 ?>