]> Tony Duckles's Git Repositories (git.nynim.org) - delicious-utils.git/commitdiff
delicious-dump: Handle changed XML output format master
authorTony Duckles <tony@nynim.org>
Wed, 28 Sep 2011 01:36:57 +0000 (20:36 -0500)
committerTony Duckles <tony@nynim.org>
Wed, 28 Sep 2011 01:36:57 +0000 (20:36 -0500)
delicious-dump/delicious-dump-allposts.php
delicious-dump/delicious-dump-alltags.php

index 11be456bbfadcfdb1e7d6800d4d30866a43f1398..49fc846dd46dd5a633ce54d72c51d2b16b3f9343 100644 (file)
   $oPhpDelicious = new PhpDelicious(AUTH_DELICIOUS_USERNAME, AUTH_DELICIOUS_PASSWORD);\r
   if ($sXml = $oPhpDelicious->HttpRequest($sCmd)) {\r
    if (strlen($sXml) > 0) {\r
-     // Strip last two lines off the file, because these contain a timestamp\r
-     $sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
-     $sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+     //// Strip last two lines off the file, because these contain a timestamp\r
+     //$sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+     //$sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+\r
+     // If $sXml contains no line-breaks, pretty-ify the XML\r
+     if (strpos($sXml, "\n") !== true) {\r
+       $sXml = str_replace("?><posts ","?>\n<posts ", $sXml);\r
+       $sXml = str_replace("><post ",">\n  <post ", $sXml);\r
+       $sXml = str_replace("></posts>",">\n</posts>", $sXml);\r
+     }\r
 \r
      fwrite(STDOUT, $sXml);\r
    }\r
index 8cc422ce65e3c1e6f90d0fb30c16170359583d18..80fcac65f2539d8384f7a38ef85ba7689a288c8f 100644 (file)
   $oPhpDelicious = new PhpDelicious(AUTH_DELICIOUS_USERNAME, AUTH_DELICIOUS_PASSWORD);\r
   if ($sXml = $oPhpDelicious->HttpRequest($sCmd)) {\r
    if (strlen($sXml) > 0) {\r
-     // Strip last two lines off the file, because these contain a timestamp\r
-     $sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
-     $sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+     //// Strip last two lines off the file, because these contain a timestamp\r
+     //$sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+     //$sXml = substr($sXml, 0, strrpos($sXml,"\n"));\r
+\r
+     // If $sXml contains no line-breaks, pretty-ify the XML\r
+     if (strpos($sXml, "\n") !== true) {\r
+       $sXml = str_replace("?><tags ","?>\n<tags ", $sXml);\r
+       $sXml = str_replace("><tag ",">\n  <tag ", $sXml);\r
+       $sXml = str_replace("></tags>",">\n</tags>", $sXml);\r
+     }\r
 \r
      fwrite(STDOUT, $sXml);\r
    }\r