Browse Source

[add] Include folder name in the <folder> tag of the export xml data

master
Solomon Peachy 2 months ago
parent
commit
d79dc9b49f
  1. 1
      CHANGES
  2. 18
      src/export.php
  3. 24
      src/include/export.php
  4. 10
      src/po.dtd
  5. 4
      tools/backup/002_generate-backup.pl

1
CHANGES

@ -74,6 +74,7 @@ v2.37.1 (December 3, 2012)
[fix] Abort import if a DB insert fails [#466]
[misc] Replace '@' with '{at}' in copyright blurb to deter spammers.
[fix] Fix a couple of undefined variables.
[add] Include folder name in the export xml data.
2.37 (September 27, 2010)

18
src/export.php

@ -1,7 +1,7 @@
<?php
// Copyright (C) 2002-2006 Balint Kis (balint@k-i-s.net)
// Copyright (C) 2005-2013 Solomon Peachy (pizza@shaftnet.org)
// Copyright (C) 2005-2022 Solomon Peachy (pizza@shaftnet.org)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -74,19 +74,20 @@ for ($photos = 0; $photos < $num_photos; $photos++) {
case "photo_iptc":
case "photo_xml":
$photo_data = pg_fetch_assoc(pg_query($database, "
select folder, author, title, caption, caption_writer, copyright_statement, web_statement, date_of_exposure, category, supplemental_category,
select folder, author, title, photo.caption, caption_writer, copyright_statement, web_statement, date_of_exposure, category, supplemental_category,
location, credit, source,
access_rights, hide_original, headline, instructions,
photo.access_rights, hide_original, headline, instructions,
camera, film, focal_length, aperture, shutter, transmission_reference,
exposure_comp, ev_difference, camera_metering, camera_program, flash_mode, flash_comp,
scan_resolution, scan_bitdepth, scan_multiscan, iso_override,
latitude, longitude, altitude, img_direction, users, can_access_photo(photo.identifier, $po_user[id], '{".$passwords."}') as ok,
store_url, photo.comments as remark
from photo, photo_version, photo_tech
latitude, longitude, altitude, img_direction, photo.users, can_access_photo(photo.identifier, $po_user[id], '{".$passwords."}') as ok,
store_url, photo.comments as remark, folder.caption as folder_name
from photo, photo_version, photo_tech, folder
where photo.identifier = photo_version.photo
and photo.identifier = photo_tech.photo
and folder.identifier = photo.folder
and photo.identifier = $photo_identifier[identifier]"));
/* Get any keywords for the photo... */
$keywords = get_photo_keywords($database, $photo_identifier['identifier']);
@ -155,6 +156,7 @@ for ($photos = 0; $photos < $num_photos; $photos++) {
case "photo_xml":
$image_data = array ("file" => array(0 => array("name" => "", "remark" => "", "master" => "")),
"folder" => $photo_data['folder'],
"folder_name" => $photo_data['folder_name'],
"author" => $photo_data['author'],
"title" => $photo_data['title'],
"keywords" => $keywords,
@ -203,7 +205,7 @@ for ($photos = 0; $photos < $num_photos; $photos++) {
$image_data['file'][$versions]['master'] = $photo_version_single['master'];
}
fwrite($xml_file_desciptor, create_xml_folder_header($image_data['folder']));
fwrite($xml_file_desciptor, create_xml_folder_header($image_data['folder'], $image_data['folder_name']));
fwrite($xml_file_desciptor, create_xml_photo($image_data));
fwrite($xml_file_desciptor, create_xml_folder_footer());
break;

24
src/include/export.php

@ -1,7 +1,7 @@
<?php
// Copyright (C) 2002-2006 Balint Kis (balint@k-i-s.net)
// Copyright (C) 2005-2013 Solomon Peachy (pizza@shaftnet.org)
// Copyright (C) 2005-2022 Solomon Peachy (pizza@shaftnet.org)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -36,8 +36,9 @@ function create_xml_bulkupload_header() {
return "<bulkupload>\n";
}
function create_xml_folder_header($folder_id) {
return "<folder id=\"$folder_id\">\n";
function create_xml_folder_header($folder_id, $folder_name) {
$folder_name = htmlspecialchars($folder_name, ENT_XML1, 'UTF-8');
return "<folder id=\"$folder_id\" name=\"$folder_name\">\n";
}
function create_xml_folder_footer() {
@ -141,19 +142,6 @@ function create_xml_photo($image_data) {
$xml_string .= "/>\n";
}
if (($image_data['storage_location_type'] && $image_data['storage_location_type'] != "null") ||
($image_data['storage_location_id'] && $image_data['storage_location_id'] != "null") ||
($image_data['storage_index'] && $image_data['storage_index'] != "null")) {
$xml_string .= "<storage";
if ($image_data['storage_location_type'] && $image_data['storage_location_type'] != "null")
$xml_string .= " type=\"".$image_data['storage_location_type']."\"";
if ($image_data['storage_location_id'] && $image_data['storage_location_id'] != "null")
$xml_string .= " id=\"".$image_data['storage_location_id']."\"";
if ($image_data['storage_index'] && $image_data['storage_index'] != "null")
$xml_string .= " idx=\"".$image_data['storage_index']."\"";
$xml_string .= " />\n";
}
if (($image_data['access_rights'] && $image_data['access_rights'] != "null") ||
($image_data['hide_original'] && $image_data['hide_original'] != "null")) {
$xml_string .= "<access";
@ -207,7 +195,7 @@ function create_xml_photo($image_data) {
if ($parts[1] == PO_EQUIPMENT_SUPPORT) {
$xml_string .= "<support id=\"$parts[0]\" />\n";
}
if ($parts[1] == PO_EQUIPMENT_LENS) {
$xml_string .= "<lens id=\"$parts[0]\" ";
@ -245,4 +233,4 @@ function create_xml_photo($image_data) {
return $xml_string;
}
?>
?>

10
src/po.dtd

@ -61,11 +61,6 @@
altitude CDATA #IMPLIED
direction CDATA #IMPLIED >
<!ELEMENT storage EMPTY >
<!ATTLIST storage type CDATA #IMPLIED
id CDATA #IMPLIED
idx CDATA #IMPLIED >
<!ELEMENT access EMPTY >
<!ATTLIST access type CDATA #REQUIRED
original CDATA #REQUIRED >
@ -106,11 +101,12 @@
<!ELEMENT photo (file | file | author | keyword | caption | copyright | web_statement |
caption_writer | category | supplemental_category | credit | source | headline |
instructions | transmission_reference | expdate | location | geolocation | storage |
instructions | transmission_reference | expdate | location | geolocation |
access | camera | lens | filter | film | flash | scanner | support | title | purchase_url )* >
<!ELEMENT folder (photo)*>
<!ATTLIST folder id CDATA #REQUIRED >
<!ATTLIST folder id CDATA #REQUIRED
name CDATA #IMPLIED >
<!ELEMENT bulkupload (folder)* >

4
tools/backup/002_generate-backup.pl

@ -16,8 +16,8 @@ my ($size, $max, $count, $block);
# configuration
my $root = "/mnt/bulk2/peachyphotos_repo"; # points to PO repository
my $db_backup = "db.backup.bz2"; # Lives in PO repo
my $root = "/mnt/bulk/peachyphotos_repo"; # points to PO repository
my $db_backup = "db.backup.xz"; # Lives in PO repo
my $db_dsn = "dbname=photo"; # db dsn
my $db_pass = "apache"; # db pass
my $db_user = "apache"; # db user

Loading…
Cancel
Save