Commit 18de0394 authored by Steffen Ritter's avatar Steffen Ritter Committed by Christian Kuhn
Browse files

[TASK] CleanUp the Reference-List in title-tooltip

file list and record list module show the references to the
record in a reference column using the title-tag of a link.
This code is duplicated in both classes.

This patch moves the logic, which is used in both classes
to the shared base-class.

Change-Id: Ifd39913671527a435888175c3b556da011e8d7da
Resolves: #39362
Releases: 6.0
Reviewed-on: http://review.typo3.org/13327
Reviewed-by: Oliver Klee
Reviewed-by: Wouter Wolters
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
parent 89f9649c
......@@ -383,6 +383,42 @@ class t3lib_recordList {
}
return $this->translateTools;
}
/**
* Generates HTML code for a Reference tooltip out of
* sys_refindex records you hand over
*
* @param array $references array of records from sys_refindex table
* @param string $launchViewParameter JavaScript String, which will be passed as parameters to top.launchView
* @return string
*/
protected function generateReferenceToolTip(array $references, $launchViewParameter = '') {
$result = array();
foreach ($references as $reference) {
$result[] =
$reference['tablename'] . ':' .
$reference['recuid'] . ':' .
$reference['field'];
if (strlen(implode(' / ', $result)) >= 100) {
break;
}
}
if (empty($result)) {
$htmlCode = '-';
} else {
$htmlCode = '<a href="#"';
if ($launchViewParameter !== '') {
$htmlCode .= ' onclick="' . htmlspecialchars('top.launchView(' . $launchViewParameter . '); return false;') . '"';
}
$htmlCode .= ' title="' . htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ', $result), 100)) . '">';
$htmlCode .= count($result);
$htmlCode .= '</a>';
}
return $htmlCode;
}
}
?>
\ No newline at end of file
......@@ -1486,12 +1486,7 @@ class localRecordList extends recordList {
* references to the corresponding record
*/
protected function createReferenceHtml($tableName, $uid) {
$referenceCount = $this->getReferenceCount($tableName, $uid);
if ($referenceCount == 0) {
return '';
}
$queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'tablename, recuid, field',
'sys_refindex',
'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
......@@ -1504,25 +1499,7 @@ class localRecordList extends recordList {
'0,20'
);
$referenceTitles = array();
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
$referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
':' . $row['field'];
if (strlen(implode(' / ', $referenceTitles)) >= 100) {
break;
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
return '<a href="#" ' .
'onclick="' . htmlspecialchars(
'top.launchView(\'' . $tableName . '\', \'' . $uid .
'\'); return false;'
) . '" ' .
'title="' . htmlspecialchars(
t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
) . '">' . $referenceCount . '</a>';
return $this->generateReferenceToolTip($rows, '\'' . $tableName . '\', \'' . $uid . '\'');
}
/**
......
......@@ -746,15 +746,7 @@ class fileList extends t3lib_recordList {
' AND ref_uid = ' . $fileOrFolderObject->getUid() . ' AND deleted=0'
);
// Compile information for title tag:
$infoData = array();
if (is_array($rows)) {
foreach ($rows as $row) {
$infoData[] = $row['tablename'] . ':' . $row['recuid'] . ':' . $row['field'];
}
}
return count($infoData) ? '<a href="#" onclick="' . htmlspecialchars('top.launchView( \'_FILE\', \'' . $fileOrFolderObject->getCombinedIdentifier() . '\'); return false;') . '" title="' . htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ', $infoData), 100)) . '">' . count($infoData) . '</a>' : '-';
return $this->generateReferenceToolTip($rows, '\'_FILE\', \'' . $fileOrFolderObject->getCombinedIdentifier() . '\'');
}
}
?>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment