summaryrefslogtreecommitdiff
path: root/update.php
diff options
context:
space:
mode:
authorBenjamin Franzke <bfr@qbus.de>2015-02-19 09:23:12 +0100
committerBenjamin Franzke <bfr@qbus.de>2015-02-19 09:26:19 +0100
commitc0c2ebe662db2a54b2bf4e80073d254100f9b310 (patch)
tree84986e9ff23c76a72bd738d8309c013ea3299f08 /update.php
parentb57490031b95c017c58bd17d1c9ebcf7ac73807f (diff)
downloadendnote-import-c0c2ebe662db2a54b2bf4e80073d254100f9b310.tar.gz
endnote-import-c0c2ebe662db2a54b2bf4e80073d254100f9b310.tar.bz2
endnote-import-c0c2ebe662db2a54b2bf4e80073d254100f9b310.zip
Add php script that builds the xslt pipeline
On servers we often dont have make and xsltproc available so we should issue stuff directly from php.
Diffstat (limited to 'update.php')
-rwxr-xr-xupdate.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/update.php b/update.php
new file mode 100755
index 0000000..1a5233b
--- /dev/null
+++ b/update.php
@@ -0,0 +1,37 @@
+#!/usr/bin/env php
+<?php
+
+$input = 'LIKAT Publications.xml';
+$output = 'dbxml_new.xml';
+
+/* Check filetime and do import only if the input xml was updated */
+if (filemtime($input) <= filemtime($output))
+ exit;
+
+$xml = new DOMDocument();
+$xml->load($input);
+
+/* TODO Check whether the input xml is valid – if not it is probably changed currently.
+ * Add 5min timeout and try again */
+
+$preprocess = new DOMDocument();
+$preprocess->load('convert-style-to-html.xsl');
+
+$process = new DOMDocument();
+$process->load('endnote-to-dbxml.xsl');
+
+$proc1 = new XSLTProcessor();
+$proc1->importStyleSheet($preprocess);
+
+$proc2 = new XSLTProcessor();
+$proc2->importStyleSheet($process);
+
+$step1 = $proc1->transformToDoc($xml);
+$step2 = $proc2->transformToXML($step1);
+$step3 = preg_replace('#<([^>]*)/>#', '<\1></\1>', $step2);
+
+file_put_contents($output, $step3);
+
+/* TODO: Issue the mysql command directly from php */
+
+/* TODO: Write mail, add exception handler and write mail on error as well */