Code:
<?
$bestand = "../".$_GET['bestand'];
$best = $_GET['bestand'];
$innerHTML = '';
$doc = new DOMDocument();
$doc->loadHTMLFile($bestand);
$elem = $doc->getElementById("inhoud");
// loop through all childNodes, getting html
$children = $elem->childNodes;
foreach ($children as $child) {
$tmp_doc = new DOMDocument();
$tmp_doc->appendChild($tmp_doc->importNode($child,true));
$innerHTML .= $tmp_doc->saveHTML();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>Lets Zottegem beheer</title>
<link rel="stylesheet" type="text/css" href="../css/master.css">
<script type="text/javascript" src="../ajax.js"></script>
<script type="text/javascript" src="../menu.js"></script>
<script type="text/javascript" src="../tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
skin : "o2k7",
plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<style type="text/css">
table td {
vertical-align: top;vertical-align: top;
}
</style>
</head>
<body onLoad="laad('menu.htm')">
<div id="page-container">
<div id="kop">
<h1>LETS Regio Zottegem beheer</h1>
</div>
<div id="menu">
</div>
<div id="pagina">
<div id="titel">
<h2>Kalender</h2>
</div>
<div id="inhoud">
<form method="post" action="<? echo $_SERVER['PHP_SELF']."?bestand=".$best; ?>">
<p>
<textarea name="content" cols="50" rows="15">
<? echo htmlentities($innerHTML); ?>
</textarea>
<input type="submit" value="Opslaan op computer" />
</p>
</form>
<?php
// oorspronkelijk
if(isset($_POST['content'])){
//$bestand = "../kalender.html";
$doc = new DOMDocument();
$doc->loadHTMLFile($bestand);
$elemOud = $doc->getElementById("inhoud");
//nieuw deel
$nieuw = new DOMDocument();
echo "<pre>".$nieuw->saveHTML()."</pre>";
$nieuw ->loadHTML("<div id='inhoud'>".$_POST['content']."</div>");
echo "Nieuw: ".$nieuw->saveHTML();
$elemNieuw = $nieuw->getElementById("inhoud");
//foreach ($src->childNodes as $el) $dst->appendChild($destdoc->importNode($el, TRUE));
//foreach ($elemNieuw->childNodes as $el) $elemOud->appendChild($ddoc->importNode($el, TRUE));
$elemNieuw = $doc->importNode($nieuw->documentElement,true);
$elemOud->parentNode->replaceChild($elemNieuw, $elemOud);
echo "<br><br>".$doc->saveHTML();
$doc->saveHTMLFile ("test.html");
//echo $bestand." werd opgeslaan op jouw PC";
} //end-if lokaal opslaan
?>
</div>
</div>
</div>
</body></html>