-
Notifications
You must be signed in to change notification settings - Fork 9
Added support for image download; Removed the file name trimming #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,6 +214,8 @@ function backup_app($app, $path, $downloadFiles) { | |
|
||
foreach ($allitems as $item) { | ||
|
||
// print_r($item); | ||
|
||
if ($verbose) | ||
echo " - " . $item->title . "\n"; | ||
|
||
|
@@ -223,7 +225,7 @@ function backup_app($app, $path, $downloadFiles) { | |
|
||
unset($itemFile); | ||
|
||
$itemFile = HumanFormat::toHumanReadableString($item); | ||
list($itemFile, $itemImages) = HumanFormat::toHumanReadableString($item); | ||
|
||
if ($downloadFiles) { | ||
foreach ($appFiles as $file) { | ||
|
@@ -240,6 +242,19 @@ function backup_app($app, $path, $downloadFiles) { | |
} | ||
} | ||
|
||
/* */ | ||
if (sizeof($itemImages) > 0){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be inside the above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe so, since you could have image field(s) without files to download. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
foreach ($itemImages as $file){ | ||
$link = downloadFileIfHostedAtPodio($path_item, $file); | ||
if (!preg_match("/^http/i", $link)) { | ||
$link = RelativePaths::getRelativePath($path_app, $path_item . '/' . $link); | ||
} | ||
$itemFile .= "Image: $link\n"; | ||
$files_in_app_html .= "<tr><td>" . $file->name . "</td><td><a href=\"" . $link . "\">" . $link . "</a></td><td>" . $file->context['title'] . "</td></tr>"; | ||
} | ||
} | ||
/* */ | ||
|
||
//TODO refactor to use less api calls: (not possible??!) | ||
if ($item->comment_count > 0) { | ||
#echo "comments.. (".$item->comment_count.")\n"; | ||
|
@@ -422,7 +437,7 @@ function contacts2text($contacts) { | |
function fixDirName($name) { | ||
$name = preg_replace("/[^.a-zA-Z0-9_-]/", '', $name); | ||
|
||
$name = substr($name, 0, 25); | ||
// $name = substr($name, 0, 25); | ||
return $name; | ||
} | ||
|
||
|
@@ -462,6 +477,7 @@ function downloadFileIfHostedAtPodio($folder, $file) { | |
$filename = fixDirName($file->name); | ||
while (file_exists($folder . '/' . $filename)) | ||
$filename = 'Z' . $filename; | ||
|
||
if (array_key_exists($file->file_id, $filestore)) { | ||
|
||
echo "DEBUG: Detected duplicate download for file: $file->file_id\n"; | ||
|
@@ -493,4 +509,4 @@ function downloadFileIfHostedAtPodio($folder, $file) { | |
return $link; | ||
} | ||
|
||
?> | ||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should be something like
array_merge
to account for multiple image fields in one item.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably correct, I will have to spin up an organization to test that out, since I only have one image field.