3b7fc8b2390143078683225a5d6e6eeee6f35a5b
[Packages/TYPO3.CMS.git] / typo3 / sysext / linkvalidator / Classes / Linktype / FileLinktype.php
1 <?php
2 namespace TYPO3\CMS\Linkvalidator\Linktype;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * This class provides Check File Links plugin implementation
21 *
22 * @author Dimitri K├Ânig <dk@cabag.ch>
23 * @author Michael Miousse <michael.miousse@infoglobe.ca>
24 */
25 class FileLinktype extends AbstractLinktype {
26
27 /**
28 * Checks a given URL + /path/filename.ext for validity
29 *
30 * @param string $url Url to check
31 * @param array $softRefEntry The soft reference entry which builds the context of the url
32 * @param \TYPO3\CMS\Linkvalidator\LinkAnalyzer $reference Parent instance
33 * @return bool TRUE on success or FALSE on error
34 */
35 public function checkLink($url, $softRefEntry, $reference) {
36 return @file_exists(PATH_site . rawurldecode($url));
37 }
38
39 /**
40 * Generate the localized error message from the error params saved from the parsing
41 *
42 * @param array $errorParams All parameters needed for the rendering of the error message
43 * @return string Validation error message
44 */
45 public function getErrorMessage($errorParams) {
46 return $this->getLanguageService()->getLL('list.report.filenotexisting');
47 }
48
49 /**
50 * Construct a valid Url for browser output
51 *
52 * @param array $row Broken link record
53 * @return string Parsed broken url
54 */
55 public function getBrokenUrl($row) {
56 return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $row['url'];
57 }
58
59 }