/** * Perform a detailed, technical analysis of the available extension on server! * Includes all kinds of verifications * Takes some time to process, therfore use with care, in particular in listings. * * @param string Extension key * @param array Extension information * @param boolean If set, checks for validity of classes etc. * @return array Information in an array. */ function makeDetailedExtensionAnalysis($extKey, $extInfo, $validity = 0) { // Get absolute path of the extension $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']); $extensionDetails = t3lib_div::makeInstance('tx_em_Extensions_Details', $this); $infoArray = array(); $table_class_prefix = substr($extKey, 0, 5) == 'user_' ? 'user_' : 'tx_' . str_replace('_', '', $extKey) . '_'; $module_prefix = substr($extKey, 0, 5) == 'user_' ? 'u' : 'tx' . str_replace('_', '', $extKey); // Database status: $dbInfo = $this->checkDBupdates($extKey, $extInfo, 1); // Database structure required: if (is_array($dbInfo['structure']['tables_fields'])) { $modify_tables = t3lib_div::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1); $infoArray['dump_tf'] = array(); foreach ($dbInfo['structure']['tables_fields'] as $tN => $d) { if (in_array($tN, $modify_tables)) { $infoArray['fields'][] = $tN . ': <i>' . (is_array($d['fields']) ? implode(', ', array_keys($d['fields'])) : '') . (is_array($d['keys']) ? ' + ' . count($d['keys']) . ' ' . $GLOBALS['LANG']->getLL('detailedExtAnalysis_keys') : '') . '</i>'; if (is_array($d['fields'])) { foreach ($d['fields'] as $fN => $value) { $infoArray['dump_tf'][] = $tN . '.' . $fN; if (!t3lib_div::isFirstPartOfStr($fN, $table_class_prefix)) { $infoArray['NSerrors']['fields'][$fN] = $fN; } else { $infoArray['NSok']['fields'][$fN] = $fN; } } } if (is_array($d['keys'])) { foreach ($d['keys'] as $fN => $value) { $infoArray['dump_tf'][] = $tN . '.KEY:' . $fN; } } } else { $infoArray['dump_tf'][] = $tN; $infoArray['tables'][] = $tN; if (!t3lib_div::isFirstPartOfStr($tN, $table_class_prefix)) { $infoArray['NSerrors']['tables'][$tN] = $tN; } else { $infoArray['NSok']['tables'][$tN] = $tN; } } } if (count($dbInfo['structure']['diff']['diff']) || count($dbInfo['structure']['diff']['extra'])) { $msg = array(); if (count($dbInfo['structure']['diff']['diff'])) { $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_missing'); } if (count($dbInfo['structure']['diff']['extra'])) { $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_of_wrong_type'); } $infoArray['tables_error'] = 1; if (t3lib_extMgm::isLoaded($extKey)) { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are'), implode(' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ', $msg)); } } } // Static tables? if (is_array($dbInfo['static'])) { $infoArray['static'] = array_keys($dbInfo['static']); foreach ($dbInfo['static'] as $tN => $d) { if (!$d['exists']) { $infoArray['static_error'] = 1; if (t3lib_extMgm::isLoaded($extKey)) { $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_static_tables_missing'); } if (!t3lib_div::isFirstPartOfStr($tN, $table_class_prefix)) { $infoArray['NSerrors']['tables'][$tN] = $tN; } else { $infoArray['NSok']['tables'][$tN] = $tN; } } } } // Backend Module-check: $knownModuleList = t3lib_div::trimExplode(',', $extInfo['EM_CONF']['module'], 1); foreach ($knownModuleList as $mod) { if (@is_dir($absPath . $mod)) { if (@is_file($absPath . $mod . '/conf.php')) { $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php'); if (is_array($confFileInfo['TYPO3_MOD_PATH'])) { $shouldBePath = tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/' . $mod . '/'; if (strcmp($confFileInfo['TYPO3_MOD_PATH'][1][1], $shouldBePath)) { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_wrong_mod_path'), $confFileInfo['TYPO3_MOD_PATH'][1][1], $shouldBePath); } } else { // It seems like TYPO3_MOD_PATH and therefore also this warning is no longer needed. // $infoArray['errors'][] = 'No definition of TYPO3_MOD_PATH constant found inside!'; } if (is_array($confFileInfo['MCONF_name'])) { $mName = $confFileInfo['MCONF_name'][1][1]; $mNameParts = explode('_', $mName); $infoArray['moduleNames'][] = $mName; if (!t3lib_div::isFirstPartOfStr($mNameParts[0], $module_prefix) && (!$mNameParts[1] || !t3lib_div::isFirstPartOfStr($mNameParts[1], $module_prefix))) { $infoArray['NSerrors']['modname'][] = $mName; } else { $infoArray['NSok']['modname'][] = $mName; } } else { $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_mconf_missing'); } } else { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_be_module_conf_missing'), $mod . '/conf.php'); } } else { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_module_folder_missing'), $mod . '/'); } } $dirs = t3lib_div::get_dirs($absPath); if (is_array($dirs)) { reset($dirs); while (list(, $mod) = each($dirs)) { if (!in_array($mod, $knownModuleList) && @is_file($absPath . $mod . '/conf.php')) { $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php'); if (is_array($confFileInfo)) { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_unconfigured_module'), $mod . '/conf.php'); } } } } // ext_tables.php: if (@is_file($absPath . 'ext_tables.php')) { $content = t3lib_div::getUrl($absPath . 'ext_tables.php'); if (stristr($content, 't3lib_extMgm::addModule')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module'); } if (stristr($content, 't3lib_extMgm::insertModuleFunction')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module_and_more'); } if (stristr($content, 't3lib_div::loadTCA')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_loadTCA'); } if (stristr($content, '$TCA[')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_TCA'); } if (stristr($content, 't3lib_extMgm::addPlugin')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin'); } } // ext_localconf.php: if (@is_file($absPath . 'ext_localconf.php')) { $content = t3lib_div::getUrl($absPath . 'ext_localconf.php'); if (stristr($content, 't3lib_extMgm::addPItoST43')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin_st43'); } if (stristr($content, 't3lib_extMgm::addPageTSConfig')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_page_ts'); } if (stristr($content, 't3lib_extMgm::addUserTSConfig')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_user_ts'); } if (stristr($content, 't3lib_extMgm::addTypoScriptSetup')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_setup'); } if (stristr($content, 't3lib_extMgm::addTypoScriptConstants')) { $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_constants'); } } if (@is_file($absPath . 'ext_typoscript_constants.txt')) { $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_constants'); } if (@is_file($absPath . 'ext_typoscript_setup.txt')) { $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_setup'); } if (@is_file($absPath . 'ext_conf_template.txt')) { $infoArray['conf'] = 1; } // Classes: if ($validity) { $filesInside = tx_em_Tools::getClassIndexLocallangFiles($absPath, $table_class_prefix, $extKey); if (is_array($filesInside['errors'])) { $infoArray['errors'] = array_merge((array) $infoArray['errors'], $filesInside['errors']); } if (is_array($filesInside['NSerrors'])) { $infoArray['NSerrors'] = array_merge((array) $infoArray['NSerrors'], $filesInside['NSerrors']); } if (is_array($filesInside['NSok'])) { $infoArray['NSok'] = array_merge((array) $infoArray['NSok'], $filesInside['NSok']); } $infoArray['locallang'] = $filesInside['locallang']; $infoArray['classes'] = $filesInside['classes']; } // Upload folders if ($extInfo['EM_CONF']['uploadfolder']) { $infoArray['uploadfolder'] = tx_em_Tools::uploadFolder($extKey); if (!@is_dir(PATH_site . $infoArray['uploadfolder'])) { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'), $infoArray['uploadfolder']); $infoArray['uploadfolder'] = ''; } } // Create directories: if ($extInfo['EM_CONF']['createDirs']) { $infoArray['createDirs'] = array_unique(t3lib_div::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1)); foreach ($infoArray['createDirs'] as $crDir) { if (!@is_dir(PATH_site . $crDir)) { $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'), $crDir); } } } // Return result array: return $infoArray; }