Papyrus skin for PmWiki.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

papyrus.php 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php if (!defined('PmWiki')) exit();
  2. /* PAPYRUS skin for PmWiki
  3. Copyright 2019 Said Achmiz
  4. Version: 2019-01-28-3
  5. More info at these URLs:
  6. * https://www.pmwiki.org/wiki/Skins/Papyrus
  7. * https://www.pmwiki.org/wiki/Profiles/SaidAchmiz
  8. The Papyrus skin includes:
  9. * papyrus.php (skin script file)
  10. * papyrus.css (style sheet)
  11. * papyrus.jpg (background pattern)
  12. * papyrus.tmpl (skin template)
  13. * ReadMe.txt (instructions & info)
  14. * wikilib.d/ (directory of bundled wikipages)
  15. */
  16. global $FmtPV;
  17. $FmtPV['$SkinName'] = '"Papyrus"';
  18. $FmtPV['$SkinVersion'] = '"2019-01-28-3"';
  19. ## Append the modification time to the URL as a GET parameter; this should be ignored
  20. ## by the web server, but is seen as part of the unique URL of the remote resource by
  21. ## the browser; when it changes (because the attachment has been modified), the
  22. ## browser will see that it doesn’t have a cached version of the resource under the
  23. ## new URL, and will retrieve the updated version.
  24. $filepath = "$SkinDir/papyrus.css";
  25. $path = "$SkinDirUrl/papyrus.css";
  26. $versioned_path = $path . "?v=" . filemtime($filepath);
  27. global $VersionedAssetsReattachFileExtension;
  28. if ($VersionedAssetsReattachFileExtension == true) {
  29. ## Re-attach the file extension.
  30. preg_match("/\\.[^\\.]+$/", $path, $matches);
  31. $versioned_path .= $matches[0];
  32. }
  33. global $HTMLHeaderFmt;
  34. $HTMLHeaderFmt[] = "<link rel='stylesheet' type='text/css' href='$versioned_path' />\n";
  35. ## Define a custom PageStore for bundled pages.
  36. class PapyrusPageStore extends PageStore {
  37. function pagefile($pagename) {
  38. global $FarmD;
  39. $dfmt = $this->dirfmt;
  40. if ($pagename > '') {
  41. $pagename = str_replace('/', '.', $pagename);
  42. if ($dfmt == dirname(__FILE__).'/wikilib.d/{$FullName}')
  43. return $this->PFE(dirname(__FILE__)."/wikilib.d/$pagename");
  44. if ($dfmt == '$FarmD/pub/skins/papyrus/wikilib.d/{$FullName}')
  45. return $this->PFE("$FarmD/pub/skins/papyrus/wikilib.d/$pagename");
  46. }
  47. return $this->PFE(FmtPageName($dfmt, $pagename));
  48. }
  49. }
  50. global $WikiLibDirs, $RecipeInfo;
  51. $PageStorePath = dirname(__FILE__).'/wikilib.d/{$FullName}';
  52. $where = count($WikiLibDirs);
  53. if ($where > 1) $where--;
  54. if ($RecipeInfo['Sisterly']['Version'] != '') $where--; // If Sisterly is enabled, then the last PageStore is the SisterStore, not the PmWiki stuff. So we have to insert at an index 1 less.
  55. array_splice($WikiLibDirs, $where, 0, array(new PapyrusPageStore($PageStorePath)));
  56. ## Label the body element with a class indicating the current page action.
  57. global $HTMLFooterFmt, $action;
  58. $HTMLFooterFmt[] = "<script type='text/javascript'>document.querySelector('body').classList.add('action-{$action}');</script>";
  59. ## Enable the (:notitlegroup:) and (:titlegroup:) directives.
  60. Markup('notitlegroup', 'directives', '/\\(:notitlegroup:\\)/i', function ($m) {
  61. global $HTMLStylesFmt;
  62. $HTMLStylesFmt['papyrus-title-group'] = "#pageTitle .title-group { display: none; }";
  63. });
  64. Markup('titlegroup', 'directives', '/\\(:titlegroup:\\)/i', function ($m) {
  65. global $HTMLStylesFmt;
  66. $HTMLStylesFmt['papyrus-title-group'] = "";
  67. });