Project

General

Profile

Feature #23396 ยป 15489-1.diff

Administrator Admin, 2010-08-19 14:22

View differences:

typo3/sysext/em/mod1/class.em_index.php (copie de travail)
*
* SECTION: Extension analyzing (detailed information)
* 2710: function makeDetailedExtensionAnalysis($extKey,$extInfo,$validity=0)
* 2892: function getClassIndexLocallangFiles($absPath,$table_class_prefix,$extKey)
* 2962: function modConfFileAnalysis($confFilePath)
* 2990: function serverExtensionMD5Array($extKey,$conf)
* 3015: function findMD5ArrayDiff($current,$past)
......
2 => $GLOBALS['LANG']->getLL('show_more_details'),
3 => $GLOBALS['LANG']->getLL('show_technical'),
4 => $GLOBALS['LANG']->getLL('show_validating'),
5 => $GLOBALS['LANG']->getLL('show_changed'),
),
'display_shy' => '',
......
// page/be_user TSconfig settings and blinding of menu-items
if (!$BE_USER->getTSConfigVal('mod.'.$this->MCONF['name'].'.allowTVlisting')) {
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
}
......
unset($this->MOD_MENU['listOrder']['type']);
unset($this->MOD_MENU['display_details'][2]);
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
}
......
<td>' . (is_array($techInfo['TSfiles']) ?
implode('<br />', $techInfo['TSfiles']) : '') . '</td>' .
$this->helpCol('TSfiles') . '</tr>';
$lines[] = '<tr class="bgColor4"><td>' . $GLOBALS['LANG']->getLL('extInfoArray_language_files') . '</td>
<td>' . (is_array($techInfo['locallang']) ?
implode('<br />', $techInfo['locallang']) : '') . '</td>' .
$this->helpCol('locallang') . '</tr>';
$lines[] = '<tr class="bgColor4"><td>' . $GLOBALS['LANG']->getLL('extInfoArray_upload_folder') . '</td>
<td>' . ($techInfo['uploadfolder'] ?
$techInfo['uploadfolder'] : '') . '</td>' .
......
<td>' . (is_array($techInfo['moduleNames']) ?
implode('<br />', $techInfo['moduleNames']) : '') . '</td>' .
$this->helpCol('moduleNames') . '</tr>';
$lines[] = '<tr class="bgColor4"><td>' . $GLOBALS['LANG']->getLL('extInfoArray_class_names') . '</td>
<td>' . (is_array($techInfo['classes']) ?
implode('<br />', $techInfo['classes']) : '') . '</td>' .
$this->helpCol('classNames') . '</tr>';
$lines[] = '<tr class="bgColor4"><td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '<br />' .
$GLOBALS['LANG']->getLL('extInfoArray_dev_relevant') . '</td>
<td>' . (is_array($techInfo['errors']) ?
$GLOBALS['TBE_TEMPLATE']->rfw(implode('<br />', $techInfo['errors'])) : '') . '</td>' .
$this->helpCol('errors') . '</tr>';
$lines[] = '<tr class="bgColor4"><td>' . $GLOBALS['LANG']->getLL('extInfoArray_annoyances') . '<br />' .
$GLOBALS['LANG']->getLL('extInfoArray_dev_relevant') . '</td>
<td>' . (is_array($techInfo['NSerrors']) ?
(!t3lib_div::inList($this->nameSpaceExceptions, $extKey) ?
t3lib_div::view_array($techInfo['NSerrors']) :
$GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('extInfoArray_exception'))) : '') . '</td>' .
$this->helpCol('NSerrors') . '</tr>';
$currentMd5Array = $this->serverExtensionMD5Array($extKey,$extInfo);
$affectedFiles='';
......
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_affects') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modules') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_config') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
} elseif ($this->MOD_SETTINGS['display_details']==4) {
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_locallang') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_classes') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_annoyances') . '</td>';
} elseif ($this->MOD_SETTINGS['display_details']==5) {
$cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_changed_files') . '</td>';
} else {
......
'<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' .
$GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : '')) .
'</td>';
} elseif ($this->MOD_SETTINGS['display_details']==4) {
$techInfo=$this->makeDetailedExtensionAnalysis($extKey,$extInfo,1);
$cells[] = '<td>'.(is_array($techInfo['locallang']) ? implode('<br />',$techInfo['locallang']) : '').'</td>';
$cells[] = '<td>'.(is_array($techInfo['classes']) ? implode('<br />',$techInfo['classes']) : '').'</td>';
$cells[] = '<td>'.(is_array($techInfo['errors']) ? $GLOBALS['TBE_TEMPLATE']->rfw(implode('<hr />',$techInfo['errors'])) : '').'</td>';
$cells[] = '<td>'.(is_array($techInfo['NSerrors']) ?
(!t3lib_div::inList($this->nameSpaceExceptions, $extKey) ?
t3lib_div::view_array($techInfo['NSerrors']) :
$GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('extInfoArray_exception'))) : '') . '</td>';
} elseif ($this->MOD_SETTINGS['display_details']==5) {
$currentMd5Array = $this->serverExtensionMD5Array($extKey,$extInfo);
$affectedFiles = '';
......
$infoArray['conf'] = 1;
}
// Classes:
if ($validity) {
$filesInside = $this->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'] = $this->ulFolder($extKey);
......
}
/**
* Analyses the php-scripts of an available extension on server
*
* @param string Absolute path to extension
* @param string Prefix for tables/classes.
* @param string Extension key
* @return array Information array.
* @see makeDetailedExtensionAnalysis()
*/
function getClassIndexLocallangFiles($absPath,$table_class_prefix,$extKey) {
$filesInside = t3lib_div::removePrefixPathFromList(t3lib_div::getAllFilesAndFoldersInPath(array(),$absPath,'php,inc',0,99,$this->excludeForPackaging),$absPath);
$out = array();
$reg = array();
foreach($filesInside as $fileName) {
if (substr($fileName,0,4)!='ext_' && substr($fileName,0,6)!='tests/') { // ignore supposed-to-be unit tests as well
$baseName = basename($fileName);
if (substr($baseName,0,9)=='locallang' && substr($baseName,-4)=='.php') {
$out['locallang'][] = $fileName;
} elseif ($baseName!='conf.php') {
if (filesize($absPath.$fileName)<500*1024) {
$fContent = t3lib_div::getUrl($absPath.$fileName);
unset($reg);
if (preg_match('/\n[[:space:]]*class[[:space:]]*([[:alnum:]_]+)([[:alnum:][:space:]_]*)/',$fContent,$reg)) {
// Find classes:
$lines = explode(LF,$fContent);
foreach($lines as $l) {
$line = trim($l);
unset($reg);
if (preg_match('/^class[[:space:]]*([[:alnum:]_]+)([[:alnum:][:space:]_]*)/',$line,$reg)) {
$out['classes'][] = $reg[1];
$out['files'][$fileName]['classes'][] = $reg[1];
if ($reg[1]!=='ext_update' && substr($reg[1],0,3)!='ux_' && !t3lib_div::isFirstPartOfStr($reg[1],$table_class_prefix) && strcmp(substr($table_class_prefix,0,-1),$reg[1])) {
$out['NSerrors']['classname'][] = $reg[1];
} else $out['NSok']['classname'][] = $reg[1];
}
}
// If class file prefixed 'class.'....
if (substr($baseName,0,6)=='class.') {
$fI = pathinfo($baseName);
$testName=substr($baseName,6,-(1+strlen($fI['extension'])));
if ($testName!=='ext_update' && substr($testName,0,3)!='ux_' && !t3lib_div::isFirstPartOfStr($testName,$table_class_prefix) && strcmp(substr($table_class_prefix,0,-1),$testName)) {
$out['NSerrors']['classfilename'][] = $baseName;
} else {
$out['NSok']['classfilename'][] = $baseName;
if (is_array($out['files'][$fileName]['classes']) && $this->first_in_array($testName,$out['files'][$fileName]['classes'],1)) {
$out['msg'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_class_ok'),
$fileName, $testName
);
} else $out['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_class_not_ok'),
$fileName, $testName
);
}
}
// Check for proper XCLASS definition
// Match $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS'] with single or doublequotes
$XclassSearch = '\$TYPO3_CONF_VARS\[TYPO3_MODE\]\[[\'"]XCLASS[\'"]\]';
$XclassParts = preg_split('/if \(defined\([\'"]TYPO3_MODE[\'"]\) && ' . $XclassSearch . '/', $fContent, 2);
if (count($XclassParts) !== 2) {
// Match $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS'] with single or doublequotes
$XclassSearch = '\$GLOBALS\[[\'"]TYPO3_CONF_VARS[\'"]\]\[TYPO3_MODE\]\[[\'"]XCLASS[\'"]\]';
$XclassParts = preg_split('/if \(defined\([\'"]TYPO3_MODE[\'"]\) && ' . $XclassSearch . '/', $fContent, 2);
}
if (count($XclassParts)==2) {
unset($reg);
preg_match('/^\[[\'"]([[:alnum:]_\/\.]*)[\'"]\]/',$XclassParts[1],$reg);
if ($reg[1]) {
$cmpF = 'ext/'.$extKey.'/'.$fileName;
if (!strcmp($reg[1],$cmpF)) {
if (preg_match('/_once[[:space:]]*\(' . $XclassSearch . '\[[\'"]' . preg_quote($cmpF, '/') . '[\'"]\]\);/', $XclassParts[1])) {
$out['msg'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_xclass_ok'), $fileName);
} else $out['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_xclass_no_include');
} else $out['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_xclass_incorrect'),
$reg[1], $cmpF
);
} else $out['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_xclass_filename'), $fileName);
} elseif (!$this->first_in_array('ux_', $out['files'][$fileName]['classes'])) {
// No Xclass definition required if classname starts with 'ux_'
$out['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_xclass_found'), $fileName);
}
}
}
}
}
}
return $out;
}
/**
* Reads $confFilePath (a module $conf-file) and returns information on the existence of TYPO3_MOD_PATH definition and MCONF_name
*
* @param string Absolute path to a "conf.php" file of a module which we are analysing.
    (1-1/1)