Field for each field being accessed, eg: MyHolidayField /holidays/wiki/wiki.d/ so that the directive can find the field page file to load. Note that the field name used in the directive is appended with the suffix "Field" to find the InterMap listing. - Keep in mind that intra-site links in included pages must work in other field contexts, so prepend them with InterMap entries, eg: MyHolidayAttach: /holidays/wiki/uploads/ Then the wikilink in the included page text would be MyHolidayAttach:MyGroup/mypicture.jpg rather than just Attach: - All wiki authorization is bypassed in including a page; the included page is read directly from the source file. - This cookbook extension uses the globals $Imap, $FmtV, and the functions ParseArgs(), and LinkIMap(), which may change over versions *Attention* This script works only with PmWiki 2.0! */ # returns the original directive statement if it fails, otherwise returns appropriate wikitext function IncludeFieldPageText($pagename, $inclspec) { # generally borrowed and modified from IncludeText() in pmwiki.php global $MaxIncludes, $InclCount, $IMap, $FmtV; SDV($MaxIncludes,50); $namepattern = '[[:alpha:]][-\\w]*'; if ($InclCount++>=$MaxIncludes) return Keep($inclspec); $args = ParseArgs($inclspec); if (array_key_exists('field', $args)) { $fieldname = $args[field]; $fieldintermapname = $fieldname . 'Field:'; if (!isset($IMap[$fieldintermapname])) return (Keep($inclspec)); } else { return (Keep($inclspec)); } while (count($args['#'])>0) { $lvalue = array_shift($args['#']); $rvalue = array_shift($args['#']); if ($lvalue=='') { # should be a page name preg_match('/^([^#\\s]*)(.*)$/', $rvalue, $match); if ($match[1]) { # include a page if (isset($itext)) continue; $thePageName = $match[1]; $result = LinkIMap('',$fieldintermapname,$thePageName,'',''); #to get side effect in $FmtV, next line $iname = $FmtV['$LinkUrl']; if ($iname=='') continue; $filespec = $_SERVER['DOCUMENT_ROOT'] . $iname; if (!fileexists($filespec)) continue; $dirspec = dirname($filespec); $repository = new PageStore($dirspec . '/$FullName'); $ipage = $repository->read($thePageName); $itext = @$ipage['text'] . "\n"; # workaround - "\n" added to allow pickup of last line with lines= } if (preg_match("/^#($namepattern)?(\\.\\.)?(#($namepattern)?)?$/", $match[2], $match2)) { @list($x, $aa, $dots, $b, $bb) = $match2; if (!$dots && !$b) $bb = $namepattern; if ($b == '#') $bb = $namepattern; if ($aa) $itext=preg_replace("/^.*?([^\n]*\\[\\[#$aa\\]\\])/s",'$1',$itext,1); # $itext=preg_replace("/^.*?(\\[\\[#$aa\\]\\])/s",'$1',$itext,1); # allow name tags embedded in paragraphs if ($bb) $itext=preg_replace("/(.)[^\n]*\\[\\[#$bb\\]\\].*$/s",'$1',$itext,1); # $itext=preg_replace("/(.)\\[\\[#$bb\\]\\].*$/s",'$1',$itext,1); # allow name tags embedded in paragraphs } continue; } if (isset($itext) && in_array($lvalue, array('lines'))) { preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $rvalue, $match); @list($x, $a, $dots, $b) = $match; $upat = ($lvalue{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*\n"; if (!$dots) { $b=$a; $a=0; } if ($a>0) $a--; $itext=preg_replace("/^(($upat)\{0,$b}).*$/s",'$1',$itext,1); $itext=preg_replace("/^($upat)\{0,$a}/s",'',$itext,1); continue; } } if (!isset($itext)) return Keep($inclspec); return PVS(htmlspecialchars(@$itext, ENT_NOQUOTES)); } function fileexists($pagefile) { return ($pagefile && file_exists($pagefile)); } ## (:includefieldpage:) - generally borrowed and modifed from (:include:) Markup('includefieldpage', '>if', '/\\(:includefieldpage\\s+(\\S.*?):\\)/ei', "PRR().IncludeFieldPageText(\$pagename, '$1')"); ?>