<?php /* Copyright 2003 John Rankin john.rankin@affinity.co.nz This file turns a trail page into a published book of the contents, in a form suitable for printing. */ $InlineReplacements = array_merge(array("/^----(\\d+)/" => "<hr size='\$1' noshade='on' />"), $InlineReplacements); if ($action == "publish") { $HTMLHeaderFmt .= "<style type = 'text/css'> body { background-color: #ffffff; color: #000000; font-family: Georgia, Times Roman, serif; } a:link { color: #444444; font-weight: bold; text-decoration: none; } a:visited { color: #444444; font-weight: bold; text-decoration: none; } </style>"; $DoubleBrackets["/\\[\\[mailto:($UrlPathPattern)(.*?)\\]\\]/"] = "''$2'' [[[mailto:$1 $1]]]"; $UrlLinkTextFmt = "<cite>\$LinkText</cite> [<a class='url' href='\$Url'>\$Url</a>]"; $WikiPageCreateFmt = "<a href='\$PageUrl?action=edit'>\$LinkText</a>"; $WikiPageCreateSpaceFmt = "<a href='\$PageUrl?action=edit'>\$LinkText</a>"; $GroupHeaderFmt = '$Group.GroupPrintHeader'; $GroupFooterFmt = '$Group.GroupPrintFooter'; $TrailLinkPattern = "(?:($GroupNamePattern)([\\/.]))?(($WikiWordPattern)|($FreeLinkPattern))"; $DoubleBrackets["/<<\\|($TrailLinkPattern)\\|>>/"] = "$1"; $DoubleBrackets["/\\^\\|($TrailLinkPattern)\\|\\^/"] = ''; $DoubleBrackets["/<\\|($TrailLinkPattern)\\|>/"] = ''; $SpaceWikiWords = 1; $hide = 1; } SDV($HandleActions['publish'],'HandlePublish'); SDV($PublishListRuleFmt,"5"); SDV($PublishTagFmt,"<form target='_blank' action='\$PageUrl' method='get'> <input type='hidden' name='action' value='publish' /> <input type='submit' value='Publish' /></form>"); SDV($PagePublishFmtH,"<big>From $WikiTitle</big> <h1>\$Groupspaced: \$Titlespaced</h1><p />"); SDV($PagePublishFmtF,"<p /><hr size='$PublishListRuleFmt' noshade='on' /> <small>Retrieved from “$PageUrlFmt”<br /> Published on \$LastModified</small>"); SDV($HandlePublishFmt,array(&$HTMLStartFmt,&$PagePublishFmtH, "wiki:$GroupHeaderFmt", &$PublishList, "wiki:$GroupFooterFmt", &$PagePublishFmtF,&$HTMLEndFmt)); SDV($PublishPageNotFoundFmt, 'Page \'\'$Tlink\'\' does not exist.'); SDV($InlineReplacements['/\\[\\[\\$Publish\\]\\]/e'], "FmtPageName(\$GLOBALS['PublishTagFmt'],\$pagename)"); function HandlePublish($pagename) { global $PublishListRuleFmt,$HandlePublishFmt,$TrailLinkPattern; global $PublishPageNotFoundFmt,$HTMLTitle,$GCount; $trailname = FmtWikiLink('',$pagename,NULL,'PageName'); $trailpage = ReadPage($trailname); if ($trailpage) { $trailgroup = FmtPageName('$Group',$trailname); foreach(explode("\n",$trailpage['text']) as $x) { if (preg_match("/^([#*]+)\\s*(.*)/",$x,$match)) { $depth[] = strlen($match[1]); if (preg_match("/^(\\[\\[)?($TrailLinkPattern)/",$match[2],$text)) { $pg = ($text[3]>'')?$text[2]: $trailgroup.'/'.$text[2]; $pages[] = FmtWikiLink('',$pg,NULL,'PageName',$trailpage); if (preg_match("/^\\[\\[($TrailLinkPattern)((?:\\s.*?)\\]\\])/", $match[2],$dbm)) $links[] = "[[".$pg.array_pop($dbm); else $links[] = $pg; } else { $pages[] = "textonly"; $links[] = $match[2]; } } } for($i=0;$i<count($pages);$i++) { $counter[$depth[$i]-1]++; $num = $counter[0]; if ($depth[$i]<$predepth) $counter[$predepth-1] = 0; $predepth = $depth[$i]; for($j=1;$j<$depth[$i];$j++) $num .= "." . $counter[$j]; # $PublishList[] = "function:PrintText ----$PublishListRuleFmt"; # $PublishList[] = "function:PrintText !$num $links[$i]"; $PublishList[] = "function:PrintText ----$PublishListRuleFmt\n!$num $links[$i]"; if ($pages[$i]!="textonly") { if (PageExists($pages[$i])) $PublishList[] = "wiki:$pages[$i]"; else { if (preg_match("/\\[\\[($TrailLinkPattern)\\s+/",$links[$i],$m)) { $alias=str_replace("]]",")",str_replace($m[0],"(",$links[$i])); $replname = "$m[1] $alias"; } else $replname = $links[$i]; $PublishList[] = "function:PrintText " . str_replace('$Tlink',$replname,$PublishPageNotFoundFmt); } } } } $GLOBALS['PublishList'] = $PublishList; $HTMLTitle = "Publish $pagename"; $GCount = 0; PrintFmt($pagename,$HandlePublishFmt); } ?>