TYPO3 CMS  TYPO3_6-2
LinkHandler.php
Go to the documentation of this file.
1 <?php
3 
18 
26 
30  const DELETED = 'deleted';
31 
40  public function checkLink($url, $softRefEntry, $reference) {
41  $response = TRUE;
42  $errorParams = array();
43  $parts = explode(':', $url);
44  if (count($parts) == 3) {
45  $tableName = htmlspecialchars($parts[1]);
46  $rowid = (int)$parts[2];
47  $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $tableName, 'uid = ' . (int)$rowid);
48  if ($row) {
49  if ($row['deleted'] == '1') {
50  $errorParams['errorType'] = self::DELETED;
51  $errorParams['tablename'] = $tableName;
52  $errorParams['uid'] = $rowid;
53  $response = FALSE;
54  }
55  } else {
56  $errorParams['tablename'] = $tableName;
57  $errorParams['uid'] = $rowid;
58  $response = FALSE;
59  }
60  }
61 
62  if (!$response) {
64  }
65  return $response;
66  }
67 
76  public function fetchType($value, $type, $key) {
77  if ($value['type'] === 'string' && GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'record:')) {
78  $type = 'linkhandler';
79  }
80  return $type;
81  }
82 
89  public function getErrorMessage($errorParams) {
90  $errorType = $errorParams['errorType'];
91  $tableName = $errorParams['tablename'];
92  if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['title'])) {
93  $title = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'], TRUE);
94  } else {
95  $title = $tableName;
96  }
97  switch ($errorType) {
98  case self::DELETED:
99  $response = str_replace(
100  array(
101  '###title###',
102  '###uid###'
103  ),
104  array(
105  $title,
106  $errorParams['uid']
107  ),
108  $GLOBALS['LANG']->getLL('list.report.rowdeleted')
109  );
110  break;
111  default:
112  $response = str_replace('###uid###', $errorParams['uid'], $GLOBALS['LANG']->getLL('list.report.rownotexisting'));
113  }
114  return $response;
115  }
116 }
static isFirstPartOfStr($str, $partStr)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]