docs
[mirrors/Programs.git] / bash / dewey_decimal_system / kybca-import.php
1 #!/usr/bin/php
2 <?php
3 //You will need JSON PHP extension for this script...
4 /* This script have to be included to nodes.php
5 * somewhere after all othere needed includes and initializations
6 * like that:
7 * require('kybca-import.php'); die('hotovo!');
8 */
9
10 $dds=json_decode(file_get_contents('dds.json'),true);
11 //die(print_r($dds));
12
13 function aaddnode($params) {
14 //$_POST['code']=true;
15 $params['node_creator']=UBIK_ID;
16 return nodes::addNode($params);
17 //return(rand(3,100000));
18 }
19
20 function apostrof($txt) {
21 return str_replace("'",'',$txt); //kyberia is broken... screw you!!!
22 }
23
24 function recursive_add($tree,$id,$depth) {
25 foreach($tree as $key => $value) {
26 $new=$key;
27 while((!is_numeric($new)) || $new < 2) $new=aaddNode(array(
28 'node_parent' => $id, 'node_name' => apostrof($key), 'node_content' => apostrof($key),
29 'template_id' => 2, 'node_system_access' => $depth>1?'public':'moderated', 'node_external_access' => 'yes'
30 ));
31 $tree[$new]=$tree[$key]; unset($tree[$key]); //rename key to new
32 $tree[$new] = recursive_add($tree[$new],$new,$depth+1);
33 }
34 //foreach($tree as $key => $value) $tree[$key] = recursive_add($tree[$key],$key);
35 return $tree;
36 }
37
38 $dds = recursive_add($dds['dds'],4738157,0);
39 echo '<pre>'; print_r($dds); echo '</pre>';
This page took 0.394087 seconds and 4 git commands to generate.