diff msitegen.inc.php @ 174:63c840590476

Move common code from mcommon.inc.php to msitegen module.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 Nov 2013 10:21:11 +0200
parents fef53f6170b5
children 8f0d81f9c648
line wrap: on
line diff
--- a/msitegen.inc.php	Wed Nov 06 10:17:47 2013 +0200
+++ b/msitegen.inc.php	Wed Nov 06 10:21:11 2013 +0200
@@ -422,4 +422,115 @@
   return sprintf("%-".$len."s", $s);
 }
 
+
+
+function cmLocaleInit()
+{
+  global $pageCharset;
+
+  if (!isset($pageCharset))
+    $pageCharset = "UTF-8";
+
+  mb_internal_encoding($pageCharset);
+
+  $tmp = "en_US.".strtolower(str_replace("-", "", $pageCharset));
+  setlocale(LC_ALL, $tmp);
+}
+
+
+function cmPrintCSSLine($uri)
+{
+  echo " <link rel=\"stylesheet\" href=\"".$uri."\" type=\"text/css\" />\n";
+}
+
+
+function cmPrintPageHeader($pageTitle, $pageExtra = "", $useContents = TRUE)
+{
+  global $pageCSS, $pageCharset, $pageAuthor, $pageCSSData, $pageUrchin;
+
+  if (!isset($pageCSS))
+  {
+    if (!isset($pageCSSData))
+    {
+      $pageCSSData = array(
+        "cookie" => "docscss",
+        "prefix" => "http://tnsp.org/docs",
+      );
+    }
+
+    if (isset($_GET["css"]))
+    {
+      $index = intval($_GET["css"]);
+      setcookie($pageCSSData["cookie"], $index, time() + 365*24*60*60, "/"); // expire in a year
+    }
+    else
+    {
+      $index = isset($_COOKIE[$pageCSSData["cookie"]]) ? intval($_COOKIE[$pageCSSData["cookie"]]) : 1;
+    }
+    $pageCSS = $pageCSSData["prefix"].$index.".css";
+  }
+
+  echo
+  "<?xml version=\"1.0\" encoding=\"".$pageCharset."\"?>\n".
+  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n".
+  "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n".
+  "<head>\n".
+  " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$pageCharset."\" />\n".
+  " <title>".strip_tags($pageTitle)."</title>\n";
+
+  if (is_array($pageCSS))
+  {
+    foreach ($pageCSS as $uri)
+      cmPrintCSSLine($uri);
+  }
+  else
+  {
+    cmPrintCSSLine($pageCSS);
+  }
+
+  echo $pageExtra."\n".
+  "</head>\n".
+  "<body>\n";
+
+  if (isset($pageUrchin))
+    require_once $pageUrchin;
+  else
+    require_once "urchin.inc.php";
+  
+/*
+  echo
+  "<script type=\"text/javascript\" src=\"http://tnsp.org/copyright-campaign.js\" charset=\"UTF-8\"></script>\n".
+  "<script>\n",
+  "copyrightCampaign();\n",
+  "</script>\n";
+*/
+
+  if ($useContents)
+    echo "<div id=\"contents\">\n";
+}
+
+
+function cmPrintPageFooter($useContents = TRUE)
+{
+  if ($useContents)
+    echo "</div>\n";
+
+  echo "</body>\n</html>\n";
+}
+
+
+function cmQM($msg)
+{
+  global $pageTranslations, $pageLang;
+
+  if (isset($pageTranslations[$msg]) && isset($pageTranslations[$msg][$pageLang]))
+    $str = $pageTranslations[$msg][$pageLang];
+  else
+    $str = $msg;
+  
+  foreach (func_get_args() as $argn => $argv)
+    $str = preg_replace("/\%".$argn."/", $argv, $str);
+  return $str;
+}
+
 ?>
\ No newline at end of file