99b04cfd02fd594ba541717675233933ee21843a
[Packages/TYPO3.CMS.git] / typo3 / sysext / linkvalidator / Classes / Linktype / FileLinktype.php
1 <?php
2 namespace TYPO3\CMS\Linkvalidator\Linktype;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2005 - 2013 Jochen Rieger (j.rieger@connecta.ag)
8 * (c) 2010 - 2013 Michael Miousse (michael.miousse@infoglobe.ca)
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * This class provides Check File Links plugin implementation
29 *
30 * @author Dimitri K├Ânig <dk@cabag.ch>
31 * @author Michael Miousse <michael.miousse@infoglobe.ca>
32 */
33 class FileLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
34
35 /**
36 * Checks a given URL + /path/filename.ext for validity
37 *
38 * @param string $url Url to check
39 * @param array $softRefEntry The soft reference entry which builds the context of the url
40 * @param \TYPO3\CMS\Linkvalidator\LinkAnalyzer $reference Parent instance
41 * @return boolean TRUE on success or FALSE on error
42 */
43 public function checkLink($url, $softRefEntry, $reference) {
44 if (!@file_exists((PATH_site . rawurldecode($url)))) {
45 return FALSE;
46 }
47 return TRUE;
48 }
49
50 /**
51 * Generate the localized error message from the error params saved from the parsing
52 *
53 * @param array $errorParams All parameters needed for the rendering of the error message
54 * @return string Validation error message
55 */
56 public function getErrorMessage($errorParams) {
57 $response = $GLOBALS['LANG']->getLL('list.report.filenotexisting');
58 return $response;
59 }
60
61 /**
62 * Construct a valid Url for browser output
63 *
64 * @param array $row Broken link record
65 * @return string Parsed broken url
66 */
67 public function getBrokenUrl($row) {
68 $brokenUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $row['url'];
69 return $brokenUrl;
70 }
71 }
72 ?>