http://5ko.free.fr ]] prints "My website" (and title "Blog and...") If you don't have a text in parentheses, the title will be the external URL or the local target page: * [[Welcome -> Home Page]] prints "Welcome" and title "Main.HomePage" * [[http://5ko.free.fr/ | My homepage]] titles "http://5ko.free.fr/" To use this script, simply place it into the cookbook/ folder and add the line include_once('cookbook/linktitles.php'); to a local customization file. */ SDV($LinkTitleFmtSet, 0); // set to 1 in config.php to force skip LinkFmtAddTitle() foreach(array('http:','https:','mailto:','ftp:','news:','gopher:','nap:', 'file:') as $m) { $LinkFunctions[$m] = 'LinkIMapTitles'; $IMap[$m]="$m$1"; } $LinkFunctions['<:page>'] = 'LinkPageTitles'; function LinkFmtAddTitle() { global $LinkTitleFmtSet, $LinkPageSelfFmt, $LinkPageExistsFmt, $LinkPageCreateFmt, $UrlLinkFmt; if($LinkTitleFmtSet) return; if(! strpos($LinkPageSelfFmt, "title=")) $LinkPageSelfFmt = preg_replace('/^$txt" : ''; } if (!preg_match("/^\\s*([^#?]+)($QueryFragPattern)?$/",$path,$match)) return ''; $tgtname = MakePageName($pagename, $match[1]); if (!$tgtname) return ''; $qf = @$match[2]; @$LinkTargets[$tgtname]++; if (!$fmt) { if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) $fmt = preg_match('/\\s/', $txt) ? $LinkPageCreateSpaceFmt : $LinkPageCreateFmt; else $fmt = ($tgtname == $pagename && $qf == '') ? $LinkPageSelfFmt : $LinkPageExistsFmt; } if($title) { $a= $title; $t = $txt; } else { if(preg_match("/^(.*?)\(([^\(\)]*?)\)$/", $txt, $mm)) { $t = trim($mm[1]); $a = trim($mm[2]); } else { $t = $txt; $a = $tgtname; } } $a = str_replace(array('"',"'"),array('"','''),$a); $fmt = str_replace(array('$LinkUrl', '$LinkText', '$LinkAlt'), array(PageVar($tgtname, '$PageUrl').PUE($qf), $t, $a), $fmt); return FmtPageName($fmt,$tgtname); }