Bug #20903 » 11747_optimize_makeRef.diff
t3lib/class.t3lib_befunc.php (Arbeitskopie) | ||
---|---|---|
* @param string Table name (or "_FILE" if its a file)
|
||
* @param string Reference: If table, then integer-uid, if _FILE, then file reference (relative to PATH_site)
|
||
* @param string Message with %s, eg. "There were %s records pointing to this file!"
|
||
* @param string reference count
|
||
* @return string Output string (or integer count value if no msg string specified)
|
||
*/
|
||
public static function referenceCount($table, $ref, $msg = '') {
|
||
// Look up the path:
|
||
if ($table=='_FILE') {
|
||
if (t3lib_div::isFirstPartOfStr($ref, PATH_site)) {
|
||
$ref = substr($ref, strlen(PATH_site));
|
||
$condition = 'ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($ref, 'sys_refindex');
|
||
public static function referenceCount($table, $ref, $msg = '', $count = NULL) {
|
||
if ($count === NULL) {
|
||
// Look up the path:
|
||
if ($table=='_FILE') {
|
||
if (t3lib_div::isFirstPartOfStr($ref, PATH_site)) {
|
||
$ref = substr($ref, strlen(PATH_site));
|
||
$condition = 'ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($ref, 'sys_refindex');
|
||
} else {
|
||
return '';
|
||
}
|
||
} else {
|
||
return '';
|
||
$condition = 'ref_uid=' . intval($ref);
|
||
}
|
||
} else {
|
||
$condition = 'ref_uid=' . intval($ref);
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
|
||
'*',
|
||
'sys_refindex',
|
||
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
|
||
' AND ' . $condition .
|
||
' AND deleted=0'
|
||
);
|
||
}
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
|
||
'*',
|
||
'sys_refindex',
|
||
'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
|
||
' AND ' . $condition .
|
||
' AND deleted=0'
|
||
);
|
||
return ($count ? ($msg ? sprintf($msg, $count) : $count) : '');
|
||
}
|
typo3/class.db_list_extra.inc (Arbeitskopie) | ||
---|---|---|
if (is_array($row)) {
|
||
$this->setReferences($table, $row['uid']);
|
||
// add special classes for first and last row
|
||
$rowSpecial = '';
|
||
if ($cc == 1 && $indent == 0) {
|
||
... | ... | |
}
|
||
/**
|
||
* Write sys_refindex entries for current record to $this->references
|
||
*
|
||
* @param string Table name
|
||
* @param integer Uid of current record
|
||
* @return void
|
||
*/
|
||
function setReferences($table, $uid) {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'*',
|
||
'sys_refindex',
|
||
'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
|
||
' AND ref_uid='.intval($uid).
|
||
' AND deleted=0'
|
||
);
|
||
$this->references = $rows;
|
||
}
|
||
/**
|
||
* Rendering the header row for a table
|
||
*
|
||
* @param string Table name
|
||
... | ... | |
$titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
|
||
$title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
|
||
$params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
|
||
$cells['delete']='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').' "'. $title.'" '.t3lib_BEfunc::referenceCount($table,$row['uid'],' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'))).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
|
||
$refCountMsg = t3lib_BEfunc::referenceCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'), count($this->references));
|
||
$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="" />'.
|
||
'</a>';
|
||
} elseif(!$this->table) {
|
||
... | ... | |
*/
|
||
function makeRef($table,$uid) {
|
||
// Look up the path:
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'*',
|
||
'sys_refindex',
|
||
'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
|
||
' AND ref_uid='.intval($uid).
|
||
' AND deleted=0'
|
||
);
|
||
// Compile information for title tag:
|
||
$infoData=array();
|
||
if (is_array($rows)) {
|
||
foreach($rows as $row) {
|
||
if (is_array($this->references)) {
|
||
foreach ($this->references as $row) {
|
||
$infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
|
||
}
|
||
}
|