, Copyright 2007. ####### Set up various variables $RecipeInfo['Hg']['Version'] = '2007-02-04'; SDV($hgseparator, '-'); SDV($hgmaxlevels, 7); SDV($hgname, ''); SDV($hggroup, ''); SDV($hgcleanurls, true); SDV($hglinkprefix, ''); $pagename = hgResolvePageName($pagename); if($hgcleanurls == true) $FmtPV['$PageUrl'] = 'PUE("$ScriptUrl?n=" . hgUrl($group, $name))'; $FmtPV['$g0'] = "'" . hgCountLevels($hggroup) . "'"; $FmtPV['$n0'] = "'" . hgCountLevels($hgname) . "'"; for ($i=0; $i < $hgmaxlevels; $i++) { $hg = "g" . ($i + 1); $hn = "n" . ($i + 1); $FmtPV['$' . $hg] = "'" . hgSplitName($hggroup, $i) . "'"; $FmtPV['$' . $hn] = "'" . hgSplitName($hgname, $i) . "'"; } ####### Set up hierarchical configs, headers, footers, sidebars, attributes & styles $EnablePGCust = 0; $hgc = 0; $hgh = 0; $hgf = 0; $hgs = 0; $hga = 0; if (file_exists("$LocalDir/$hggroup.$hgname.php")) { include_once("$LocalDir/$hggroup.$hgname.php"); $hgc = 1; } $hggroups = explode($hgseparator, $hggroup); while (count($hggroups) != 0) { $hg = implode ($hgseparator, $hggroups); if ($hgc == 0 && file_exists("$LocalDir/$hg.php")) { include_once("$LocalDir/$hg.php"); $hgc = 1; } if ($hgh == 0 && PageExists("$hg.GroupHeader")) { $GroupHeaderFmt = "(:include $hg.GroupHeader:)"; $hgh = 1; } if ($hgf == 0 && PageExists("$hg.GroupFooter")) { $GroupFooterFmt = "(:include $hg.GroupFooter:)"; $hgf = 1; } if ($hgs == 0 && PageExists("$hg.Sidebar")) { $FmtPV['$sidebar'] = "'" . "$hg.Sidebar" . "'"; $hgs = 1; } if ($hga == 0 && PageExists("$hg.GroupAttributes")) { $GroupAttributesFmt = "$hg/GroupAttributes"; $hga = 1; } $PageCSSListFmt["pub/css/$hg.css"] = "$PubDirUrl/css/$hg.css"; array_pop($hggroups); } ####### Set up default configs, headers, footers, sidebars & styles if ($hgc == 0 && file_exists("$LocalDir/default.php")) include_once("$LocalDir/default.php"); if ($hgh == 0 && PageExists("Site.GroupHeader")) $GroupHeaderFmt = "(:include Site.GroupHeader:)"; if ($hgf == 0 && PageExists("Site.GroupFooter")) $GroupFooterFmt = "(:include Site.GroupFooter:)"; if ($hgs == 0 && PageExists("Site.Sidebar")) $FmtPV['$sidebar'] = "'" . "Site.Sidebar" . "'"; $PageCSSListFmt["pub/css/local.css"] = "$PubDirUrl/css/local.css"; $PageCSSListFmt = array_reverse($PageCSSListFmt, true); function hgCountLevels($name) { global $hgseparator; $parts = explode($hgseparator, $name); return count($parts); } function hgSplitName($name, $ind) { global $hgseparator; $parts = explode($hgseparator, $name); if ($ind < 0 || $ind >= count($parts)) return ''; else return $parts[$ind]; } function hgResolvePageName($pagename) { global $hgseparator, $hgname, $hggroup; $r = '/'; if(! strpos($pagename, $r)) { $pagename = ResolvePageName($pagename); $hggroup = FmtPageName('$Group', $pagename); $hgname = FmtPageName('$Name', $pagename); return $pagename; } $hgpagename = explode($r, $pagename); if ($hgpagename[count($hgpagename) - 1 ] == '') array_pop($hgpagename); $hgname = $hgpagename[count($hgpagename) - 1]; array_pop($hgpagename); $hggroup = implode($hgseparator, $hgpagename); $pagename = ResolvePageName("$hggroup.$hgname"); return "$pagename"; } function hgURL($group, $name) { global $DefaultName, $hglinkprefix; $r = '/'; if ($group == $name) $name = $DefaultName; $link = str_replace("-", $r, $group) . $r . $name; return $link; } ####### Hierarchical links shortcut notation. Markup('[[hg','