Added script for importing DDS to kyberia
authorHarvie <tomas@mudrunka.cz>
Mon, 20 Dec 2010 01:10:32 +0000 (02:10 +0100)
committerHarvie <tomas@mudrunka.cz>
Mon, 20 Dec 2010 01:10:32 +0000 (02:10 +0100)
bash/dewey_decimal_system/kybca-import.php [new file with mode: 0755]

diff --git a/bash/dewey_decimal_system/kybca-import.php b/bash/dewey_decimal_system/kybca-import.php
new file mode 100755 (executable)
index 0000000..f9243ba
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/php
+<?php
+//You will need JSON PHP extension for this script...
+/* This script have to be included to nodes.php
+ * somewhere after all othere needed includes and initializations
+ * like that:
+ * require('kybca-import.php'); die('hotovo!');
+ */
+
+$dds=json_decode(file_get_contents('dds.json'),true);
+//die(print_r($dds));
+
+function aaddnode($params) {
+       //$_POST['code']=true;
+       $params['node_creator']=UBIK_ID;
+       return nodes::addNode($params);
+       //return(rand(3,100000));
+}
+
+function apostrof($txt) {
+       return str_replace("'",'',$txt); //kyberia is broken... screw you!!!
+}
+
+function recursive_add($tree,$id,$depth) {
+       foreach($tree as $key => $value) {
+               $new=$key;
+               while((!is_numeric($new)) || $new < 2) $new=aaddNode(array(
+                       'node_parent' => $id, 'node_name' => apostrof($key), 'node_content' => apostrof($key),
+                       'template_id' => 2, 'node_system_access' => $depth>1?'public':'moderated', 'node_external_access' => 'yes'
+               ));
+               $tree[$new]=$tree[$key]; unset($tree[$key]); //rename key to new
+               $tree[$new] = recursive_add($tree[$new],$new,$depth+1);
+       }
+       //foreach($tree as $key => $value) $tree[$key] = recursive_add($tree[$key],$key);
+       return $tree;
+}
+
+$dds = recursive_add($dds['dds'],4738157,0);
+echo '<pre>'; print_r($dds); echo '</pre>';
This page took 0.17461 seconds and 4 git commands to generate.