Bug #22085 » 13471_01.diff
typo3/class.db_list_extra.inc (working copy) | ||
---|---|---|
var $CBnames=array(); // Tracking names of elements (for clipboard use)
|
||
var $duplicateStack=array(); // Used to track which elements has duplicates and how many
|
||
/**
|
||
* @deprecated since 4.4: Use getReferenceCount instead
|
||
*/
|
||
var $references; // References of the current record
|
||
protected $referenceCount = array(); // [$tablename][$uid] = number of referencing records
|
||
var $translations; // Translations of the current record
|
||
var $selFieldList; // select fields for the query which fetches the translations of the current record
|
||
... | ... | |
if (is_array($row)) {
|
||
$this->setReferences($table, $row['uid']);
|
||
// add special classes for first and last row
|
||
$rowSpecial = '';
|
||
if ($cc == 1 && $indent == 0) {
|
||
... | ... | |
} elseif ($fCol == '_PATH_') {
|
||
$theData[$fCol]=$this->recPath($row['pid']);
|
||
} elseif ($fCol == '_REF_') {
|
||
$theData[$fCol]=$this->makeRef($table,$row['uid']);
|
||
$theData[$fCol]=$this->getReferenceHTML($table, $row['uid']);
|
||
} elseif ($fCol == '_CONTROL_') {
|
||
$theData[$fCol]=$this->makeControl($table,$row);
|
||
} elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
|
||
... | ... | |
* @param string Table name
|
||
* @param integer Uid of current record
|
||
* @return void
|
||
*
|
||
* @deprecated since 4.4: Use getReferenceCount instead
|
||
*/
|
||
function setReferences($table, $uid) {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'*',
|
||
'tablename, recuid, field',
|
||
'sys_refindex',
|
||
'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
|
||
' AND ref_uid='.intval($uid).
|
||
... | ... | |
}
|
||
/**
|
||
* Get number of records referencing current record
|
||
* Fetches number from db if not already calculated
|
||
*
|
||
* @param string Table name
|
||
* @param integer Uid of current record
|
||
* @return integer Number of references to record
|
||
*/
|
||
protected function getReferenceCount($table, $uid) {
|
||
$referenceCount = 0;
|
||
if (isset($this->referenceCount[$table][$uid])) {
|
||
$referenceCount = $this->referenceCount[$table][$uid];
|
||
} else {
|
||
$referenceCountRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'COUNT(*) AS count',
|
||
'sys_refindex',
|
||
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
|
||
' AND ref_uid=' . intval($uid) .
|
||
' AND deleted=0'
|
||
);
|
||
$this->referenceCount[$table][$uid] = $referenceCountRow[0]['count'];
|
||
$referenceCount = $referenceCountRow[0]['count'];
|
||
}
|
||
return $referenceCount;
|
||
}
|
||
/**
|
||
* Rendering the header row for a table
|
||
*
|
||
* @param string Table name
|
||
... | ... | |
$title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
|
||
$params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
|
||
$refCountMsg = t3lib_BEfunc::referenceCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'), count($this->references)) .
|
||
$refCountMsg = t3lib_BEfunc::referenceCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'), $this->getReferenceCount($table, $row['uid'])) .
|
||
t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord')) . ")";
|
||
$cells['delete']='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').' "'. $title.'" '.$refCountMsg).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
|
||
'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
|
||
... | ... | |
* @param string Table name
|
||
* @param integer UID of record
|
||
* @return string HTML-table
|
||
*
|
||
* @deprecated since 4.4: Use getReferenceHTML() instead
|
||
*/
|
||
function makeRef($table,$uid) {
|
||
// Compile information for title tag:
|
||
// Compile information for title tag:
|
||
$infoData=array();
|
||
if (is_array($this->references)) {
|
||
foreach ($this->references as $row) {
|
||
... | ... | |
}
|
||
/**
|
||
* Make reference count HTML
|
||
*
|
||
* @param string Table name
|
||
* @param integer UID of record
|
||
* @return string HTML of reference a link
|
||
*/
|
||
protected function getReferenceHTML($table, $uid) {
|
||
$referenceHTML = '';
|
||
$referenceCount = $this->getReferenceCount($table, $uid);
|
||
if ($referenceCount > 0) {
|
||
$referenceQueryRessource = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'tablename, recuid, field',
|
||
'sys_refindex',
|
||
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
|
||
' AND ref_uid=' . intval($uid) .
|
||
' AND deleted=0',
|
||
'',
|
||
'',
|
||
'0,20'
|
||
);
|
||
$referenceHTMLTitle = array();
|
||
while((strlen(implode(' / ', $referenceHTMLTitle)) < 100) && ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($referenceQueryRessource))) {
|
||
$referenceHTMLTitle[] = $row[0] . ':' . $row[1] . ':' . $row[2];
|
||
}
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($referenceQueryRessource);
|
||
$referenceHTML = '<a href="#" ' .
|
||
'onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . $uid . '\'); return false;') . '" ' .
|
||
'title="' . htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ', $referenceHTMLTitle), 100)) . '">' .
|
||
$referenceCount .
|
||
'</a>';
|
||
}
|
||
return $referenceHTML;
|
||
}
|
||
/**
|
||
* Creates the localization panel
|
||
*
|
||
* @param string The table
|
||
... | ... | |
break;
|
||
case '_REF_':
|
||
$csvRow[] = $this->makeRef($table, $row['uid']);
|
||
$csvRow[] = $this->getReferenceHTML($table, $row['uid']);
|
||
break;
|
||
// remove these columns from the CSV view
|