comparison 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
comparison
equal deleted inserted replaced
173:fef53f6170b5 174:63c840590476
420 else 420 else
421 $s = $str; 421 $s = $str;
422 return sprintf("%-".$len."s", $s); 422 return sprintf("%-".$len."s", $s);
423 } 423 }
424 424
425
426
427 function cmLocaleInit()
428 {
429 global $pageCharset;
430
431 if (!isset($pageCharset))
432 $pageCharset = "UTF-8";
433
434 mb_internal_encoding($pageCharset);
435
436 $tmp = "en_US.".strtolower(str_replace("-", "", $pageCharset));
437 setlocale(LC_ALL, $tmp);
438 }
439
440
441 function cmPrintCSSLine($uri)
442 {
443 echo " <link rel=\"stylesheet\" href=\"".$uri."\" type=\"text/css\" />\n";
444 }
445
446
447 function cmPrintPageHeader($pageTitle, $pageExtra = "", $useContents = TRUE)
448 {
449 global $pageCSS, $pageCharset, $pageAuthor, $pageCSSData, $pageUrchin;
450
451 if (!isset($pageCSS))
452 {
453 if (!isset($pageCSSData))
454 {
455 $pageCSSData = array(
456 "cookie" => "docscss",
457 "prefix" => "http://tnsp.org/docs",
458 );
459 }
460
461 if (isset($_GET["css"]))
462 {
463 $index = intval($_GET["css"]);
464 setcookie($pageCSSData["cookie"], $index, time() + 365*24*60*60, "/"); // expire in a year
465 }
466 else
467 {
468 $index = isset($_COOKIE[$pageCSSData["cookie"]]) ? intval($_COOKIE[$pageCSSData["cookie"]]) : 1;
469 }
470 $pageCSS = $pageCSSData["prefix"].$index.".css";
471 }
472
473 echo
474 "<?xml version=\"1.0\" encoding=\"".$pageCharset."\"?>\n".
475 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n".
476 "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n".
477 "<head>\n".
478 " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$pageCharset."\" />\n".
479 " <title>".strip_tags($pageTitle)."</title>\n";
480
481 if (is_array($pageCSS))
482 {
483 foreach ($pageCSS as $uri)
484 cmPrintCSSLine($uri);
485 }
486 else
487 {
488 cmPrintCSSLine($pageCSS);
489 }
490
491 echo $pageExtra."\n".
492 "</head>\n".
493 "<body>\n";
494
495 if (isset($pageUrchin))
496 require_once $pageUrchin;
497 else
498 require_once "urchin.inc.php";
499
500 /*
501 echo
502 "<script type=\"text/javascript\" src=\"http://tnsp.org/copyright-campaign.js\" charset=\"UTF-8\"></script>\n".
503 "<script>\n",
504 "copyrightCampaign();\n",
505 "</script>\n";
506 */
507
508 if ($useContents)
509 echo "<div id=\"contents\">\n";
510 }
511
512
513 function cmPrintPageFooter($useContents = TRUE)
514 {
515 if ($useContents)
516 echo "</div>\n";
517
518 echo "</body>\n</html>\n";
519 }
520
521
522 function cmQM($msg)
523 {
524 global $pageTranslations, $pageLang;
525
526 if (isset($pageTranslations[$msg]) && isset($pageTranslations[$msg][$pageLang]))
527 $str = $pageTranslations[$msg][$pageLang];
528 else
529 $str = $msg;
530
531 foreach (func_get_args() as $argn => $argv)
532 $str = preg_replace("/\%".$argn."/", $argv, $str);
533 return $str;
534 }
535
425 ?> 536 ?>