>>>>".wysiwyg_GUID."(.*?)".wysiwyg_GUID."<<<<< \\/>/",$markup,$matches);
return $matches[1];
}
function save_wysiwyg($pickle, $markup) {
// put back the wysiwyg bits
if(isset($pickle)) {
foreach ($pickle as $name) {
foreach ($name as $key => $html) {
$markup = insert_wysiwyg($key, $html, $markup);
}
}
}
// add the >>>> <<<< bits to new markup
$markup = preg_replace("/(?<=)/","$1 >>>>>".wysiwyg_GUID."Edit me!".wysiwyg_GUID."<<<<< ",$markup);
return $markup;
}
function load_wysiwyg($markup) {
// take out the wysiwyg bits
$allPickled = array();
$names = nameList_wysiwyg($markup);
foreach($names as $name) {
$pickle = array();
$pickle[$name] = get_wysiwyg($name, $markup);
$allPickled[] = $pickle;
$markup = hide_wysiwyg($name, $markup);
}
$ret = array();
$ret['markup'] = $markup;
$ret['pickle'] = $allPickled;
return $ret;
}
function hide_wysiwyg($name, $markup) {
$ret = preg_replace("/(?<=>>>>".wysiwyg_GUID.".*?".wysiwyg_GUID."<<<<< (?=\\/>)/", " ", $markup);
return $ret;
}
function insert_wysiwyg($name, $html, $markup) {
return preg_replace("/(?<=)/", " >>>>>".wysiwyg_GUID.$html.wysiwyg_GUID."<<<<< ", $markup);
}
function nameList_wysiwyg($markup) {
$nameList = array();
preg_match_all("//",$markup,$matches);
foreach ($matches[1] as $match) {
$nameList[] = $match;
}
return $nameList;
}
?>