diff --git a/HumanFormat.php b/HumanFormat.php index aaaf634..535b1fd 100644 --- a/HumanFormat.php +++ b/HumanFormat.php @@ -21,9 +21,13 @@ class HumanFormat { public static function toHumanReadableString($item) { $itemFile = '--- ' . $item->title . ' ---' . "\n"; $itemFile .= 'Item ID: ' . $item->item_id . "\n"; + $itemImages = array(); if ($item instanceof PodioItem) { foreach ($item->fields as $field) { - if ($field instanceof PodioItemField) { + if($field instanceof PodioImageItemField) { + $itemImages = $field->values; + $itemFile .= $field->label . ': ' . HumanFormat::getFieldValue($field) . "\n"; + } elseif ($field instanceof PodioItemField) { $itemFile .= $field->label . ': ' . HumanFormat::getFieldValue($field) . "\n"; } else { echo "WARN non PodioItemField:"; @@ -38,7 +42,7 @@ public static function toHumanReadableString($item) { } } $itemFile .= "\n"; - return $itemFile; + return array($itemFile, $itemImages); } /** diff --git a/podio_backup_full_cli.php b/podio_backup_full_cli.php index ff574b0..e9086a4 100644 --- a/podio_backup_full_cli.php +++ b/podio_backup_full_cli.php @@ -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){ + 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 .= "