$[Rename] \$FullName
\$RenameGroup
$[Add:] $[nothing] \$Group $[new group] $[to any Unqualified Links]

$[Unqualified Links]:

\$UnqualifiedLinks"); SDV($HandleActions['rename'],'HandleRename'); SDV($HandleActions['postrename'],'HandlePostRename'); $FPLFunctions['pickgroup'] = 'FPLPickGroup'; $FPLFunctions['pglist'] = 'FPLPageLinks'; $FPLFunctions['pgbygroup'] = 'FPLLinksByGroup'; Markup_e('linkslist', 'directives','/\\(:linkslist\\s+(?:(publish)=)?(.*?)\\s*:\\)/i', "'<:block>'.Keep(FmtLinksList(MakePageName(\$pagename,\$m[2]), array('o' => 'fmt=pgbygroup','list'=>'all','action'=>\$m[1])))"); Markup_e('includeg','>if', "/\\(:includeg\\s+($GroupPattern(?:[\\/.])$NamePattern)(.*?):\\)/", "PRR().IncludeGText(\$pagename,\$m[1],\$m[2])"); function IncludeGText($pagename,$page,$opts) { global $GroupPattern,$WikiWordPattern; $ogroup = FmtPageName('$Group',$page); $ngroup = FmtPageName('$Group',$pagename); return preg_replace_callback( "/(\\[[=@].*?[=@]\\])|(\\[\\[.*?\\]\\])|([`:\/\$])?\\b(($GroupPattern([\\/.]))?$WikiWordPattern)/", function ($m) use ($ogroup,$ngroup) { return QualifyUnqualifiedLinks($ngroup,$ogroup,$m[0]); }, IncludeText($pagename,"include $page$opts")); } function HandlePageLinks($pagename) { global $HandlePageLinksFmt,$PageStartFmt,$PageLinksFmt,$PageEndFmt,$FmtV; SDV($PageLinksFmt,array( "

$[Links on] \$Group: \$Title

", 'markup:(:linkslist publish=$FullName:)')); SDV($HandlePageLinksFmt,array(&$PageStartFmt,&$PageLinksFmt,&$PageEndFmt)); $FmtV['$Typeset'] = 'Typeset links'; PrintFmt($pagename,$HandlePageLinksFmt); } function HandleRename($pagename) { global $HandleRenameFmt,$PageStartFmt,$PageRenameFmt,$PageEndFmt; SDV($HandleRenameFmt,array(&$PageStartFmt,&$PageRenameFmt,&$PageEndFmt)); $PageRenameFmt = str_replace('$UnqualifiedLinks', FmtLinksList($pagename,array('o'=>'fmt=pglist','list'=>'unqualified')), str_replace('$RenameGroup', FmtGroupList($pagename,array('o'=>'fmt=pickgroup')),$PageRenameFmt)); PrintFmt($pagename,$HandleRenameFmt); } function HandlePostRename($pagename) { global $RedirectToRenameFmt,$GroupPattern,$WikiWordPattern; $newpagename = MakePageName($pagename, stripmagic($_POST['group'].'.'.$_POST['renametext'])); if (PageExists($newpagename)) { Abort("'$newpagename' already exists"); } else { Lock(2); $page = RetrieveAuthPage($pagename,"edit"); if ($page) $ntext = $page['text']; else Abort("cannot get '$pagename'"); $ogroup = FmtPageName('$Group',$pagename); $ngroup = FmtPageName('$Group',$newpagename); # Abort('stop for testing'); if ($_POST['addgroup']) { if ($_POST['addgroup']=='new') {$h = $ogroup; $ogroup = $ngroup; $ngroup = $h;} if ($ogroup==$ngroup) $ngroup = $ngroup.'1'; $ntext = preg_replace_callback( "/(\\[[=@].*?[=@]\\])|(\\[\\[[^#].*?\\]\\])|([`:\/])?\\b(($GroupPattern([\\/.]))?$WikiWordPattern)/", function ($m) use ($ogroup,$ngroup) { return QualifyUnqualifiedLinks($ngroup,$ogroup,$m[0]); }, $ntext); # Abort(str_replace("\n",'
',str_replace("\n\n",'

',$ntext))); } $page['text'] = $ntext; WritePage($newpagename,$page); $page['text'] = str_replace('$RenameText',$newpagename,$RedirectToRenameFmt); WritePage($pagename,$page); } Redirect($pagename); } function QualifyUnqualifiedLinks($ngroup,$ogroup,$link) { global $GroupPattern,$WikiWordPattern; $link = htmlentities(stripmagic($link)); if (preg_match("/^\\[[=@]/",$link)) return $link; preg_match("/^(\\[\\[(.*?)\\]\\])|([`:\/\$])?\\b(($GroupPattern([\\/.]))?$WikiWordPattern)$/", $link,$m); return ($m[0][0]=='[') ? '[['.QualifyFLink($ngroup,$ogroup,$m[2]).']]' : QualifyWLink($ngroup,$ogroup,$m[3],$m[4]); } function FmtGroupList($pagename,$opt) { global $SearchPatterns,$FPLFunctions; $pagelist = ListPages((array)@$SearchPatterns['normal']); sort($pagelist); $matches = array(); foreach ($pagelist as $pagefile) $matches[] = array('pagename' => $pagefile); if (preg_match('/^([^=]*)=(.*?)$/',$opt['o'],$mat)) $f[$mat[1]] = $mat[2]; $fmtfn = @$FPLFunctions[$f['fmt']]; if (!function_exists($fmtfn)) $fmtfn='FPLPickGroup'; return $fmtfn($pagename,$matches,$opt); } function FPLPickGroup($pagename,&$pagelist,$opt) { global $GroupPickListFmt; SDV($GroupPickListFmt,'$Group'); $currentgroup = FmtPageName($GroupPickListFmt,$pagename); $out = array(); foreach($pagelist as $item) { $pgroup = FmtPageName($GroupPickListFmt,$item['pagename']); if (@!$seen[$pgroup]++) { $s = ($pgroup==$currentgroup) ? " selected='selected'" : ''; $out[] = str_replace('$Select',$s,$pgroup); } } return " . "; } function FmtLinksList($pagename,$opt) { global $FPLFunctions,$FPLSimpleIFmt,$FPLSimpleSFmt,$PublishSearchChecked; global $PDFCheckboxFmt,$PDFTypesetVFmt,$PDFOptionsFmt,$HTMLVSpace; global $FPLByGroupStartFmt,$FPLByGroupEndFmt,$FPLByGroupIFmt,$FPLByGroupCFmt, $FPLByGroupSFmt; $FPLSimpleIFmt = "

  • \$Title
  • \n"; $FPLSimpleSFmt = "
  • \$Title
  • \n"; $FPLByGroupSFmt = "
    \$Title
    \n"; if ($opt['action']=='publish') { $checked = ($PublishSearchChecked) ? "checked='checked'" : ''; $FPLByGroupStartFmt = "$HTMLVSpace
    "; $FPLByGroupEndFmt = "
    $HTMLVSpace "; $FPLByGroupEndFmt .= "$PDFCheckboxFmt$PDFTypesetVFmt$PDFOptionsFmt
    "; $FPLByGroupIFmt = "
    \$Title
    \n"; } else { SDV($FPLByGroupStartFmt, "
    "); SDV($FPLByGroupEndFmt, '
    '); SDV($FPLByGroupGFmt, "
    \$Group
    \n"); SDV($FPLByGroupIFmt, "
    \$Title
    \n"); SDV($FPLByGroupCFmt, "
    \$Title?
    \n"); SDV($FPLByGroupSFmt, "
    \$Title
    \n"); } $pagelist = ListPageLinks($pagename,$opt['list']); sort($pagelist); $matches = array(); foreach ($pagelist as $pagefile) if ($pagefile!=@$lpage) { $matches[] = array('pagename' => $pagefile); $lpage = $pagefile; } if (count($matches)==0) return MarkupToHTML($pagename,"->''$[No links found].''"); if (preg_match('/^([^=]*)=(.*?)$/',$opt['o'],$mat)) $f[$mat[1]] = $mat[2]; $fmtfn = @$FPLFunctions[$f['fmt']]; if (!function_exists($fmtfn)) $fmtfn='FPLPageLinks'; return $fmtfn($pagename,$matches,$opt); } function FPLLinksByGroup($pagename, &$matches, $opt) { global $FPLByGroupStartFmt, $FPLByGroupEndFmt, $FPLByGroupGFmt, $FPLByGroupIFmt, $FPLByGroupCFmt, $FPLByGroupSFmt; SDV($FPLByGroupStartFmt,"
    "); SDV($FPLByGroupEndFmt,'
    '); SDV($FPLByGroupGFmt,"
    \$Group
    \n"); SDV($FPLByGroupIFmt,"
    \$Title
    \n"); SDV($FPLByGroupCFmt, "
    \$Title?
    \n"); SDV($FPLByGroupSFmt,"
    \$Title
    \n"); $out = array(); foreach($matches as $pc) { $pgroup = FmtPageName($FPLByGroupGFmt, $pc['pagename']); if ($pgroup != @$lgroup) { $out[] = $pgroup; $lgroup = $pgroup; } if (PageExists($pc['pagename'])) $out[] = ($pc['pagename']==$pagename) ? FmtPageName($FPLByGroupSFmt, $pc['pagename']) : FmtPageName($FPLByGroupIFmt, $pc['pagename']); } return FmtPageName($FPLByGroupStartFmt, $pagename) . implode('', $out) . FmtPageName($FPLByGroupEndFmt, $pagename); } function FPLPageLinks($pagename, &$matches, $opt) { global $FPLSimpleStartFmt, $FPLSimpleIFmt, $FPLSimpleSFmt, $FPLSimpleEndFmt; SDV($FPLSimpleStartFmt, ""); SDV($FPLSimpleIFmt, "
  • \$FullName
  • \n"); SDV($FPLSimpleSFmt,"
  • \$FullName
  • \n"); $out = array(); foreach($matches as $pc) $out[] = ($pc['pagename']==$pagename) ? FmtPageName($FPLSimpleSFmt, $pc['pagename']) : FmtPageName($FPLSimpleIFmt, $pc['pagename']); return FmtPageName($FPLSimpleStartFmt, $pagename) . implode('', $out) . FmtPageName($FPLSimpleEndFmt, $pagename); } function ListPageLinks($pagename,$list) { global $GroupPattern,$WikiWordPattern; $g = FmtPageName('$Group',$pagename); $dummy = 'AB101BA'; $r = array(); $page = RetrieveAuthPage($pagename,(($list=='all') ? 'read' : 'edit')); if ($page) $text = $page['text']; else Abort("cannot rename '$pagename'"); PCache($pagename,$page); preg_match_all("/(\\[[=@].*?[=@]\\])|(\\[\\[([^#].*?)\\]\\])|([`:\/\$])?\\b(($GroupPattern([\\/.]))?$WikiWordPattern)/", $text,$m); for ($i=0;$i