\$_LinkText"); SDV($VarLinkMissingFmt,"\$_LinkText"); $DoubleBrackets["/^:\\$($WikiWordPattern):/"] = ":[[#$1]]\$$1:"; $LinkPatterns[780]["\\$$WikiWordPattern"] = 'FmtVarLink'; $InlineReplacements['/\\[\\[\\$Varindex\\]\\]/e'] = 'Keep(VarIndexList())'; # FmtVarLink(...) is called when the $LinkPattern (above) is seen, # it returns a string based on whether a variable has been documented function FmtVarLink($pat,$ref,$txt) { global $VarIndex,$VarLinkExistsFmt,$VarLinkMissingFmt; if (!isset($VarIndex)) { VarIndexLoad(); } $link = substr($ref,1); $rtxt = (!is_null($txt)) ? $txt : $ref; if (!$VarIndex[$link]['url']) return str_replace('$_LinkText',$rtxt,$VarLinkMissingFmt); return str_replace(array('$_LinkText','$_Url'), array($rtxt,$VarIndex[$link]['url']),$VarLinkExistsFmt); } # VarIndexLoad() loads $VarIndex with the variable definitions from the # pages given by $VarPagesFmt function VarIndexLoad() { global $VarPagesFmt,$VarIndex,$WikiWordPattern; if (!isset($VarIndex)) $VarIndex=array(); foreach($VarPagesFmt as $v) { $vname = FmtPageName('$PageName',$v); $vpage = ReadPage($v); if (!$vpage) continue; if (!preg_match_all("/\n:\\$($WikiWordPattern):/",$vpage['text'],$match)) continue; foreach($match[1] as $n) { $VarIndex[$n]['page']=$vname; $VarIndex[$n]['url']=FmtPageName("\$PageUrl#$n",$vname); } } } # VarIndexList() generates a table of all indexed variables. function VarIndexList() { global $VarIndex; if (!isset($VarIndex)) VarIndexLoad(); ksort($VarIndex); $out = "\n"; foreach($VarIndex as $v=>$a) $out .= FmtPageName("\n",$a['page']); $out .= "
VariableDocumented in
$$v\$Title
"; return $out; } ?>