"; select(DB_NEW); $query = sprintf("SELECT id,name,classId FROM bruckmuehle_index WHERE class = 'TicketPage'"); $result = getAll($query); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ importTicketPage($line['id'], $line['name'], $line['classId']); } } # imports the headings for a person page function importPersonPage($id, $name, $classId){ select(DB_OLD); $line = getOne(sprintf("SELECT * FROM flexicon_personpage WHERE name = %s", sqlstring($name))); if(!empty($line)){ echo "import personpage $line[name] » $name
\n"; } else{ echo "!!! personpage not found: $name
\n"; return; } select(DB_NEW); $line2 = getOne(sprintf("SELECT buildingBlocks FROM bruckmuehle_stdpage WHERE id = %d", $classId)); $ids = explode("\t", $line['childElements']); $types = explode("\t", $line['childTypes']); $blocks = explode("\t", $line2['buildingBlocks']); foreach($ids as $i=>$id){ if(strtolower($types[$i]) == "headerelement"){ $blocks = array_insert($blocks, $i, importHeadingBlock($id)); } } select(DB_NEW); $query = sprintf("UPDATE bruckmuehle_stdpage SET buildingBlocks = %s WHERE id = %d", sqlstring(implode("\t", $blocks)), $classId); update($query); } # imports the headings for a ticket page function importTicketPage($id, $name, $classId){ select(DB_OLD); $line = getOne(sprintf("SELECT * FROM flexicon_stdpage WHERE name = %s", sqlstring($name))); if(!empty($line)){ echo "import ticketpage $line[name] » $name
\n"; } else{ echo "!!! ticketpage not found: $name
\n"; return; } select(DB_NEW); $line2 = getOne(sprintf("SELECT buildingBlocks FROM bruckmuehle_stdpage WHERE id = %d", $classId)); $ids = explode("\t", $line['childElements']); $types = explode("\t", $line['childTypes']); $blocks = explode("\t", $line2['buildingBlocks']); foreach($ids as $i=>$id){ if(strtolower($types[$i]) == "headerelement"){ $blocks = array_insert($blocks, $i, importHeadingBlock($id)); } } select(DB_NEW); $query = sprintf("UPDATE bruckmuehle_stdpage SET buildingBlocks = %s WHERE id = %d", sqlstring(implode("\t", $blocks)), $classId); update($query); } # imports a heading block # returns id function importHeadingBlock($id){ select(DB_OLD); $line = getOne(sprintf("SELECT * FROM flexicon_headerelement WHERE id = %d", $id)); select(DB_NEW); $query = sprintf("INSERT INTO bruckmuehle_headingblock (content, level) VALUES (%s, %d)", sqlstring($line['content']), $line['level']); $blockId = insert($query); return "headingblock,$blockId"; } // === MAIN ===================================================================================== // mysql_connect(DBHOST, DBUSER, DBPWD); mysql_select_db(DB_OLD); importHeadings(); mysql_close(); echo "import complete"; ?>