Replaced DIRECTORY_SEPARATOR (#63)

Replace DIRECTORY_SEPARATOR with slash
HFP-2862-fix-download-warning
Sjoerd Zonneveld 2019-09-27 11:15:10 +02:00 committed by Frode Petterson
parent e6fa3d7e54
commit 7d7b420b45
2 changed files with 15 additions and 15 deletions

View File

@ -373,7 +373,7 @@ class H5PDefaultStorage implements \H5PFileStorage {
$target = "{$this->path}/content/{$contentId}"; $target = "{$this->path}/content/{$contentId}";
} }
$contentSource = $source . DIRECTORY_SEPARATOR . 'content'; $contentSource = $source . '/' . 'content';
$contentFiles = array_diff(scandir($contentSource), array('.','..', 'content.json')); $contentFiles = array_diff(scandir($contentSource), array('.','..', 'content.json'));
foreach ($contentFiles as $file) { foreach ($contentFiles as $file) {
if (is_dir("{$contentSource}/{$file}")) { if (is_dir("{$contentSource}/{$file}")) {
@ -445,8 +445,8 @@ class H5PDefaultStorage implements \H5PFileStorage {
* @return bool * @return bool
*/ */
public function hasPresave($libraryFolder, $developmentPath = null) { public function hasPresave($libraryFolder, $developmentPath = null) {
$path = is_null($developmentPath) ? 'libraries' . DIRECTORY_SEPARATOR . $libraryFolder : $developmentPath; $path = is_null($developmentPath) ? 'libraries' . '/' . $libraryFolder : $developmentPath;
$filePath = realpath($this->path . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . 'presave.js'); $filePath = realpath($this->path . '/' . $path . '/' . 'presave.js');
return file_exists($filePath); return file_exists($filePath);
} }

View File

@ -933,7 +933,7 @@ class H5PValidator {
// Process and validate libraries using the unpacked library folders // Process and validate libraries using the unpacked library folders
$files = scandir($tmpDir); $files = scandir($tmpDir);
foreach ($files as $file) { foreach ($files as $file) {
$filePath = $tmpDir . DIRECTORY_SEPARATOR . $file; $filePath = $tmpDir . '/' . $file;
if ($file === '.' || $file === '..' || $file === 'content' || !is_dir($filePath)) { if ($file === '.' || $file === '..' || $file === 'content' || !is_dir($filePath)) {
continue; // Skip continue; // Skip
@ -1102,14 +1102,14 @@ class H5PValidator {
$this->h5pF->setErrorMessage($this->h5pF->t('Invalid library name: %name', array('%name' => $file)), 'invalid-library-name'); $this->h5pF->setErrorMessage($this->h5pF->t('Invalid library name: %name', array('%name' => $file)), 'invalid-library-name');
return FALSE; return FALSE;
} }
$h5pData = $this->getJsonData($filePath . DIRECTORY_SEPARATOR . 'library.json'); $h5pData = $this->getJsonData($filePath . '/' . 'library.json');
if ($h5pData === FALSE) { if ($h5pData === FALSE) {
$this->h5pF->setErrorMessage($this->h5pF->t('Could not find library.json file with valid json format for library %name', array('%name' => $file)), 'invalid-library-json-file'); $this->h5pF->setErrorMessage($this->h5pF->t('Could not find library.json file with valid json format for library %name', array('%name' => $file)), 'invalid-library-json-file');
return FALSE; return FALSE;
} }
// validate json if a semantics file is provided // validate json if a semantics file is provided
$semanticsPath = $filePath . DIRECTORY_SEPARATOR . 'semantics.json'; $semanticsPath = $filePath . '/' . 'semantics.json';
if (file_exists($semanticsPath)) { if (file_exists($semanticsPath)) {
$semantics = $this->getJsonData($semanticsPath, TRUE); $semantics = $this->getJsonData($semanticsPath, TRUE);
if ($semantics === FALSE) { if ($semantics === FALSE) {
@ -1122,7 +1122,7 @@ class H5PValidator {
} }
// validate language folder if it exists // validate language folder if it exists
$languagePath = $filePath . DIRECTORY_SEPARATOR . 'language'; $languagePath = $filePath . '/' . 'language';
if (is_dir($languagePath)) { if (is_dir($languagePath)) {
$languageFiles = scandir($languagePath); $languageFiles = scandir($languagePath);
foreach ($languageFiles as $languageFile) { foreach ($languageFiles as $languageFile) {
@ -1133,7 +1133,7 @@ class H5PValidator {
$this->h5pF->setErrorMessage($this->h5pF->t('Invalid language file %file in library %library', array('%file' => $languageFile, '%library' => $file)), 'invalid-language-file'); $this->h5pF->setErrorMessage($this->h5pF->t('Invalid language file %file in library %library', array('%file' => $languageFile, '%library' => $file)), 'invalid-language-file');
return FALSE; return FALSE;
} }
$languageJson = $this->getJsonData($languagePath . DIRECTORY_SEPARATOR . $languageFile, TRUE); $languageJson = $this->getJsonData($languagePath . '/' . $languageFile, TRUE);
if ($languageJson === FALSE) { if ($languageJson === FALSE) {
$this->h5pF->setErrorMessage($this->h5pF->t('Invalid language file %languageFile has been included in the library %name', array('%languageFile' => $languageFile, '%name' => $file)), 'invalid-language-file'); $this->h5pF->setErrorMessage($this->h5pF->t('Invalid language file %languageFile has been included in the library %name', array('%languageFile' => $languageFile, '%name' => $file)), 'invalid-language-file');
return FALSE; return FALSE;
@ -1144,7 +1144,7 @@ class H5PValidator {
} }
// Check for icon: // Check for icon:
$h5pData['hasIcon'] = file_exists($filePath . DIRECTORY_SEPARATOR . 'icon.svg'); $h5pData['hasIcon'] = file_exists($filePath . '/' . 'icon.svg');
$validLibrary = $this->isValidH5pData($h5pData, $file, $this->libraryRequired, $this->libraryOptional); $validLibrary = $this->isValidH5pData($h5pData, $file, $this->libraryRequired, $this->libraryOptional);
@ -1228,8 +1228,8 @@ class H5PValidator {
*/ */
private function isExistingFiles($files, $tmpDir, $library) { private function isExistingFiles($files, $tmpDir, $library) {
foreach ($files as $file) { foreach ($files as $file) {
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $file['path']); $path = str_replace(array('/', '\\'), '/', $file['path']);
if (!file_exists($tmpDir . DIRECTORY_SEPARATOR . $library . DIRECTORY_SEPARATOR . $path)) { if (!file_exists($tmpDir . '/' . $library . '/' . $path)) {
$this->h5pF->setErrorMessage($this->h5pF->t('The file "%file" is missing from library: "%name"', array('%file' => $path, '%name' => $library)), 'library-missing-file'); $this->h5pF->setErrorMessage($this->h5pF->t('The file "%file" is missing from library: "%name"', array('%file' => $path, '%name' => $library)), 'library-missing-file');
return FALSE; return FALSE;
} }
@ -1520,7 +1520,7 @@ class H5PStorage {
if (!$skipContent) { if (!$skipContent) {
$basePath = $this->h5pF->getUploadedH5pFolderPath(); $basePath = $this->h5pF->getUploadedH5pFolderPath();
$current_path = $basePath . DIRECTORY_SEPARATOR . 'content'; $current_path = $basePath . '/' . 'content';
// Save content // Save content
if ($content === NULL) { if ($content === NULL) {
@ -1539,7 +1539,7 @@ class H5PStorage {
} }
} }
$content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json'); $content['params'] = file_get_contents($current_path . '/' . 'content.json');
if (isset($options['disable'])) { if (isset($options['disable'])) {
$content['disable'] = $options['disable']; $content['disable'] = $options['disable'];
@ -1916,7 +1916,7 @@ Class H5PExport {
*/ */
private static function populateFileList($dir, &$files, $relative = '') { private static function populateFileList($dir, &$files, $relative = '') {
$strip = strlen($dir) + 1; $strip = strlen($dir) + 1;
$contents = glob($dir . DIRECTORY_SEPARATOR . '*'); $contents = glob($dir . '/' . '*');
if (!empty($contents)) { if (!empty($contents)) {
foreach ($contents as $file) { foreach ($contents as $file) {
$rel = $relative . substr($file, $strip); $rel = $relative . substr($file, $strip);
@ -3701,7 +3701,7 @@ class H5PContentValidator {
$wl_regex = '/\.(' . preg_replace('/ +/i', '|', preg_quote($whitelist)) . ')$/i'; $wl_regex = '/\.(' . preg_replace('/ +/i', '|', preg_quote($whitelist)) . ')$/i';
foreach ($files as $file) { foreach ($files as $file) {
$filePath = $contentPath . DIRECTORY_SEPARATOR . $file; $filePath = $contentPath . '/' . $file;
if (is_dir($filePath)) { if (is_dir($filePath)) {
$valid = $this->validateContentFiles($filePath, $isLibrary) && $valid; $valid = $this->validateContentFiles($filePath, $isLibrary) && $valid;
} }