\\[\\[#([A-Za-z]+\\-\\d+[-.:\\w]*))\\]\\]/e', "FoxEditAnchor(\$pagename, '$1')"); function FoxEditAnchor($pagename, $x) { global $HTMLStylesFmt; if (TrackAnchors($x)) return ''; $out = ''; if (CondAuth($pagename, 'edit')) { $HTMLStylesFmt['foxsectionedit'] = " .foxsectionedit { font-size:12px; font-style:normal; font-weight:400;} "; $out .= "".FoxEditLinkMarkup($pagename, 'section=#'.$x.' label=(edit) tooltip=\'edit '.$x.'\'').""; } $out .= ""; return Keep($out); } # ROS Pattern for preserving one empty line before each line with foxedit anchor $ROSPatterns['/(?.*?\\[\\[#([A-Za-z]+\\-\\d+[-.:\\w]*))\\]\\])/'] = "\n\n$1"; } # make it possible to treat [[#section]] .... [[#sectionend]] as a PTV of name 'section' $PageTextVarPatterns['[[#anchor]]'] = "/(\\[\\[#(\\w[-\\w]*)\\]\\](?: *\n)?)(.*?)(\\[\\[#\\2end\\]\\])/s"; //Handle section edit by setting page vars and loading edit form $HandleActions['foxedit'] = 'FoxHandleEdit'; function FoxHandleEdit($pagename) { global $FoxAuth, $EditSource, $EditTarget, $EditSection, $InputValues, $FmtV, $FmtPV, $FoxMsgFmt, $FoxEditPTVSectionForm, $FoxEditPageSectionForm, $PageStartFmt, $PageEndFmt, $FoxPageEditFmt, $EnableFoxEditFormCheck, $QualifyPatterns, $FoxCheckError, $FoxEditForm; //check if function is called by Fox preview if ($_POST['preview'] || $FoxCheckError==1) $args = $_SESSION['foxedit'][$pagename]; //fetch arguments from url of first foxedit call else { $args = RequestArgs(); //fetch GET or POST arguments FoxURLArgs($pagename); //set url arguments for use with preview } #echo "
\$args "; print_r($args); echo ""; //DEBUG $EditSource = (isset($args['source'])) ? $args['source'] : $pagename; $target = (isset($args['target'])) ? $args['target'] : $EditSource; $prefix = (isset($args['prefix']) ? $args['prefix'] : ''); $section = (isset($args['section']) ? urldecode($args['section']) : ''); //open targetpage, get section, set InputValues for 'text' control $fulltarget = $target.$section; $EditTarget = MakePagename($pagename, $target); $page = RetrieveAuthPage($EditTarget, $FoxAuth, true); if (!$page) Abort( "?cannot read $page"); $text = $page['text']; //check if we got fullpage edit if ($section=='') { $mode = 'section'; $formpage = $FoxEditPageSectionForm; //default can open whole page for editing } //check if we got anchored section, else section is ptv else { if (strstr($section,'#')) { $mode = 'section'; $text = TextSection($page['text'], $fulltarget, array('anchors' => 1)); if (empty($text)) FoxAbort($pagename,"$[Error: cannot find section] '$EditSection'"); $formpage = $FoxEditPageSectionForm; } else { $mode = 'ptv'; $QualifyPatterns = NULL; //prevent substitutions by Qualify function $text = PageTextVar($EditSource, $section); $formpage = $FoxEditPTVSectionForm; } } //check if we should use a specified form if (isset($args['form'])) { $formpage = $args['form']; if ($section=='') $mode = ''; //no $mode since it could be whole page edit or ptv edit } //get text for insertion in editform textarea if ($InputValues['text']) $EditText = $InputValues['text']; else $EditText = $InputValues['text'] = str_replace('$','$',htmlspecialchars($text,ENT_NOQUOTES)); //set global $EditSection $EditSection = $prefix.$section; //retrieve edit form from page or page section $formpage = FmtPageName($formpage, $pagename); if ($formpage) { $formname = MakePageName($pagename, $formpage); if (PageExists($formname)) { $eform = RetrieveAuthSection($formname, $formpage); if ($eform=='') $FoxMsgFmt[] = "$[Warning: cannot find edit form] '''$formpage'''. Using basic edit form instead."; if (IsEnabled($EnableFoxEditFormCheck, 1)) { //check if edit form is the right type if (preg_match("/\\(:input\\s+([^\\)]+)\\s*name\\=\\$:/",$eform)) { if ($mode=='section') Abort( "Error: wrong PTV name in foxedit link or edit form not suitable for PTV editing!"); } else if ($mode=='ptv') Abort("Error: wrong section name in foxedit link or edit form not suitable for section editing!"); } } } //if no form, use hardcoded basic form, either for ptv or section edit if (!$formpage || empty($eform)) { $eform = "%red%(:foxmessages:)\n"; if ($mode=='ptv') $eform .= "(:fox eform ptvtarget=$target template=0 redirect=1:)"; else $eform .= "(:fox eform foxaction=replace put=overwrite target=$fulltarget :)" ."\n(:foxtemplate \"{\$\$text}\":)"; $eform .= "\n(:input hidden csum 'Section edited':)" ."\n'''Editing $target section $section'''" ."(:input defaults source={$EditSource}:)"; if ($mode=='ptv') $eform .= Keep("