From 6c5086a933451969b72890c9b703d6ee141f9d9f Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 17 Jul 2016 11:52:21 -0400 Subject: Added functions to check cloud files path and return path with hashed names --- include/import.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 3dfe9c7c9..ac52cc9cf 100644 --- a/include/import.php +++ b/include/import.php @@ -1218,8 +1218,8 @@ function convert_oldfields(&$arr,$old,$new) { } } -function scan_webpage_elements($path, $type) { - +function scan_webpage_elements($path, $type, $cloud = false) { + $channel = \App::get_channel(); $dirtoscan = $path; switch ($type) { case 'page': @@ -1237,6 +1237,9 @@ function scan_webpage_elements($path, $type) { default : return array(); } + if($cloud) { + $dirtoscan = get_dirpath_by_cloudpath($channel, $dirtoscan); + } $elements = []; if (is_dir($dirtoscan)) { $dirlist = scandir($dirtoscan); @@ -1247,15 +1250,25 @@ function scan_webpage_elements($path, $type) { } $folder = $dirtoscan . '/' . $element; if (is_dir($folder)) { - $jsonfilepath = $folder . '/' . $json_filename; + if($cloud) { + $jsonfilepath = get_filename_by_cloudname($json_filename, $channel, $folder); + } else { + $jsonfilepath = $folder . '/' . $json_filename; + } if (is_file($jsonfilepath)) { $metadata = json_decode(file_get_contents($jsonfilepath), true); - $metadata['path'] = $folder . '/' . $metadata['contentfile']; + if($cloud) { + $contentfilename = get_filename_by_cloudname($metadata['contentfile'], $channel, $folder); + $metadata['path'] = $folder . '/' . $contentfilename; + } else { + $contentfilename = $metadata['contentfile']; + $metadata['path'] = $folder . '/' . $contentfilename; + } if ($metadata['contentfile'] === '') { logger('Invalid ' . $type . ' content file'); return false; } - $content = file_get_contents($folder . '/' . $metadata['contentfile']); + $content = file_get_contents($folder . '/' . $contentfilename); if (!$content) { logger('Failed to get file content for ' . $metadata['contentfile']); return false; -- cgit v1.2.3