require_once $_SERVER['DOCUMENT_ROOT'] . '/weblication/grid.php';
$path = '/de/index.php';
$dom = new DOMDocument();
$dom->load( $_SERVER['DOCUMENT_ROOT'] . $path );
$xpath = new DOMXPath( $dom );
$existingNodes = [];
$newNodes = [ '/de/start.php', '/de/neu.php' ];
$classesQuery = '/wd:document/wd:extension/wd:object/wd:data[@id="classes"]';
$classesNodeList = $xpath->query( $classesQuery );
if( $classesNodeList->length === 1 ) {
$classesNode = $classesNodeList->item( 0 );
$entryNodeList = $xpath->query( 'wd:entry', $classesNode );
if( $entryNodeList->length > 0 ) {
foreach( $entryNodeList as $entryNode ) {
$existingNodes[] = $entryNode->getAttribute( 'url' );
}
}
$classesNode->nodeValue = '';
$setNodes = !empty( $newNodes ) ? array_unique( array_merge( $existingNodes, $newNodes ) ) : [];
if( !empty( $setNodes ) ) {
foreach( $setNodes as $setNode ) {
$node = $dom->createElement( 'wd:entry' );
$node->setAttribute( 'url', $setNode );
$classesNode->appendChild( $node );
}
}
$content = $dom->saveXML();
$content = wStringconverter::removePrologXml( $content );
file_put_contents( $_SERVER['DOCUMENT_ROOT'] . $path, $content );
}