Index: /documentation/trunk/php/gs-manual-export.php =================================================================== --- /documentation/trunk/php/gs-manual-export.php (revision 27506) +++ /documentation/trunk/php/gs-manual-export.php (revision 27507) @@ -19,5 +19,5 @@ // 0. Initialization -$xml_source_path = '/research/jmt12/gsdl-docs/temp'; + // - we have a counter to assign identifiers to text blocks etc without ids $text_id_counter = 1; @@ -44,4 +44,16 @@ { $_REQUEST['a'] = 'store'; // Try to store the file to disk +} + +$var_path = filecat(array($base_path, 'var')); +$timestamp = time(); +//$xml_source_path = '**PATH TO GSDL MANUALS**' +$xml_source_path = '/tmp'; +if ($_REQUEST['a'] == 'download') +{ + // Clear out previous exports + recursiveRemove($var_path, '/greenstone/greenstone-documentation/php/var'); + // New export + $xml_source_path = fileCat(array($var_path, $timestamp)); } @@ -66,25 +78,18 @@ echo '
Manual: ' . $_REQUEST['m'] . ' Language: ' . $_REQUEST['l'] . "
\nClick here to download XML file
' . "\n"; + // Zip up the manual files + $zip_file = ucfirst($_REQUEST['m']) . '_' . $_REQUEST['l'] . '.zip'; + $zip_path = fileCat(array($xml_source_path, $zip_file)); + $zip_command = 'zip -r "' . $zip_path . '" . > /dev/null 2>&1'; + //cho '[DEBUG] zip_command:' . $zip_command . '
'; + $tgz_file = ucfirst($_REQUEST['m']) . '_' . $_REQUEST['l'] . '.tgz'; + $tgz_path = fileCat(array($xml_source_path, $tgz_file)); + $tgz_command = 'tar -czf "' . $tgz_path . '" * > /dev/null 2>&1'; + //cho '[DEBUG] tgz_command:' . $tgz_command . '
'; + // We need to move to the document folder so that archives have sensible paths + $original_cwd = getcwd(); + chdir($xml_file_dir); + system($zip_command); + system($tgz_command); + // Go back + chdir($original_cwd); + // Links are ready + echo 'Download XML file plus images as: ZIP or TGZ
' . "\n"; } echo 'Click here to return to dokuwiki
' . "\n"; @@ -1205,9 +1228,10 @@ $image_source_path = $dokuwiki_path . '/data/media/' . $_REQUEST['l'] . '/manuals/images/' . strtolower($filename); $image_destination_dir = $xml_source_path . '/' . $_REQUEST['l'] . '/images'; - mkAllDir($image_destination_dir, 0755); + mkAllDir($image_destination_dir); $image_destination_path = $image_destination_dir . '/' . $filename; if (copy($image_source_path, $image_destination_path)) { echo '[copying file: ' . $filename . "] \n"; + chmod($image_destination_path, 0664); } else