/**
  * @test
  */
 public function filelinkCreatesCorrectUrlForFileWithUrlEncodedSpecialChars()
 {
     $fileNameAndPath = PATH_site . 'typo3temp/var/tests/phpunitJumpUrlTestFile with spaces & amps.txt';
     file_put_contents($fileNameAndPath, 'Some test data');
     $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site));
     $fileName = substr($fileNameAndPath, strlen(PATH_site . 'typo3temp/var/tests/'));
     $expectedLink = str_replace('%2F', '/', rawurlencode($relativeFileNameAndPath));
     $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/var/tests/'));
     $this->assertEquals('<a href="' . $expectedLink . '">' . $fileName . '</a>', $result);
     \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($fileNameAndPath);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function filelinkDisablesGlobalJumpUrlWithDeprecatedOptionIfConfigured()
 {
     $testData = $this->initializeJumpUrlTestEnvironment($this->never());
     $fileName = 'phpunitJumpUrlTestFile.txt';
     $fileNameAndPath = 'typo3temp/' . $fileName;
     file_put_contents(PATH_site . $fileNameAndPath, 'Some test data');
     $expectedLink = $testData['absRefPrefix'] . $fileNameAndPath;
     $expectedLink = '<a href="' . $expectedLink . '">' . $fileName . '</a>';
     // Test with deprecated configuration
     $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => 0));
     $this->assertEquals($expectedLink, $result);
     GeneralUtility::unlink_tempfile($fileNameAndPath);
 }
Exemplo n.º 3
0
 function getFileLinks(&$markerArray, $row)
 {
     $files_stdWrap = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $this->conf['newsFiles_stdWrap.']['wrap']);
     $markerArray['###TEXT_FILES###'] = $files_stdWrap[0] . $this->local_cObj->stdWrap($this->pi_getLL('textFiles'), $this->conf['newsFilesHeader_stdWrap.']);
     $fileArr = explode(',', $row['news_files']);
     $filelinks = '';
     $rss2Enclousres = '';
     foreach ($fileArr as $val) {
         // fills the marker ###FILE_LINK### with the links to the atached files
         $filelinks .= $this->local_cObj->filelink($val, $this->conf['newsFiles.']);
         // <enclosure> support for RSS 2.0
         if ($this->theCode == 'XML') {
             $path = trim($this->conf['newsFiles.']['path']);
             $theFile = $path . $val;
             if (@is_file($theFile)) {
                 $fileURL = $this->config['siteUrl'] . $theFile;
                 $fileSize = filesize($theFile);
                 $fileMimeType = $this->getMimeTypeByHttpRequest($fileURL);
                 $rss2Enclousres .= '<enclosure url="' . $fileURL . '" ';
                 $rss2Enclousres .= 'length ="' . $fileSize . '" ';
                 $rss2Enclousres .= 'type="' . $fileMimeType . '" />' . "\n\t\t\t";
             }
         }
     }
     $markerArray['###FILE_LINK###'] = $filelinks . $files_stdWrap[1];
     $markerArray['###NEWS_RSS2_ENCLOSURES###'] = trim($rss2Enclousres);
 }