|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2005 - 2010 Jochen Rieger (j.rieger@connecta.ag) 00006 * (c) 2010 - 2011 Michael Miousse (michael.miousse@infoglobe.ca) 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * 00018 * This script is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * This copyright notice MUST APPEAR in all copies of the script! 00024 ***************************************************************/ 00025 /** 00026 * This class provides Check Link Handler plugin implementation. 00027 * 00028 * @author Dimitri König <dk@cabag.ch> 00029 * @author Michael Miousse <michael.miousse@infoglobe.ca> 00030 * @package TYPO3 00031 * @subpackage linkvalidator 00032 */ 00033 class tx_linkvalidator_linktype_LinkHandler extends tx_linkvalidator_linktype_Abstract { 00034 00035 const DELETED = 'deleted'; 00036 00037 /** 00038 * TSconfig of the module tx_linkhandler. 00039 * 00040 * @var array 00041 */ 00042 protected $tsconfig; 00043 00044 /** 00045 * Get TSconfig when loading the class. 00046 */ 00047 function __construct() { 00048 $this->tsconfig = t3lib_BEfunc::getModTSconfig(1, 'mod.tx_linkhandler'); 00049 } 00050 00051 /** 00052 * Checks a given URL + /path/filename.ext for validity 00053 * 00054 * @param string $url: url to check 00055 * @param array $softRefEntry: the softref entry which builds the context of that url 00056 * @param object $reference: parent instance of tx_linkvalidator_Processor 00057 * @return string TRUE on success or FALSE on error 00058 */ 00059 public function checkLink($url, $softRefEntry, $reference) { 00060 $response = TRUE; 00061 $errorParams = array(); 00062 $parts = explode(":", $url); 00063 if (count($parts) == 3) { 00064 $tableName = htmlspecialchars($parts[1]); 00065 $rowid = intval($parts[2]); 00066 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 00067 '*', 00068 $tableName, 00069 'uid = ' . intval($rowid) 00070 ); 00071 00072 if ($rows[0]) { 00073 if ($rows[0]['deleted'] == '1') { 00074 $errorParams['errorType'] = DELETED; 00075 $errorParams['tablename'] = $tableName; 00076 $errorParams['uid'] = $rowid; 00077 $response = FALSE; 00078 } 00079 } else { 00080 $errorParams['tablename'] = $tableName; 00081 $errorParams['uid'] = $rowid; 00082 $response = FALSE; 00083 } 00084 } 00085 00086 if(!$response) { 00087 $this->setErrorParams(); 00088 } 00089 00090 return $response; 00091 } 00092 00093 /** 00094 * type fetching method, based on the type that softRefParserObj returns. 00095 * 00096 * @param array $value: reference properties 00097 * @param string $type: current type 00098 * @param string $key: validator hook name 00099 * @return string fetched type 00100 */ 00101 public function fetchType($value, $type, $key) { 00102 if ($type == 'string' && strtolower(substr($value['tokenValue'], 0, 7)) == 'record:') { 00103 $type = 'linkhandler'; 00104 } 00105 return $type; 00106 } 00107 00108 /** 00109 * Generate the localized error message from the error params saved from the parsing. 00110 * 00111 * @param array all parameters needed for the rendering of the error message 00112 * @return string validation error message 00113 */ 00114 public function getErrorMessage($errorParams) { 00115 $errorType = $errorParams['errorType']; 00116 $tableName = $errorParams['tablename']; 00117 $title = $GLOBALS['LANG']->getLL('list.report.rowdeleted.default.title'); 00118 00119 if ($this->tsconfig['properties'][$tableName . '.']) { 00120 $title = $this->tsconfig['properties'][$tableName . '.']['label']; 00121 } 00122 00123 switch ($errorType) { 00124 case DELETED: 00125 $response = $GLOBALS['LANG']->getLL('list.report.rowdeleted'); 00126 $response = str_replace('###title###', $title, $response); 00127 $response = str_replace('###uid###', $errorParams['uid'], $response); 00128 break; 00129 00130 default: 00131 $response = $GLOBALS['LANG']->getLL('list.report.rownotexisting'); 00132 $response = str_replace('###uid###', $errorParams['uid'], $response); 00133 break; 00134 } 00135 00136 return $response; 00137 } 00138 } 00139 00140 00141 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/linktypes/class.tx_linkvalidator_linktypes_linkhandler.php'])) { 00142 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/linktypes/class.tx_linkvalidator_linktypes_linkhandler.php']); 00143 } 00144 00145 ?>
1.8.0