70 lines
3.3 KiB
PHP
70 lines
3.3 KiB
PHP
<?php
|
|
// File name: markabbr.inc.php
|
|
// Description: PHP subroutines to mark the abbreviation
|
|
// Date: 2006-03-10
|
|
// Author: imacat <imacat@pristine.com.tw>
|
|
// Copyright: Copyright (C) 2006-2007 Pristine Communications
|
|
|
|
// Set the include path
|
|
if (!defined("INCPATH_SET")) {
|
|
require_once dirname(__FILE__) . "/incpath.inc.php";
|
|
}
|
|
// Referenced subroutines
|
|
require_once "monica/echoform.inc.php";
|
|
require_once "monica/htmlchar.inc.php";
|
|
|
|
// h_abbr: Shortcut to markabbr(h())
|
|
function h_abbr($text)
|
|
{
|
|
return markabbr(h($text));
|
|
}
|
|
|
|
// markabbr: Mark the abbreviation
|
|
function markabbr($text)
|
|
{
|
|
// FAQ
|
|
$text = preg_replace("/\b(FAQ)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"frequently asked questions\">$1</abbr>", $text);
|
|
$text = preg_replace("/\b(FAQ)s\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"frequently asked questions\">$1</abbr>s", $text);
|
|
// HTTP
|
|
$text = preg_replace("/\b(HTTP)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"HyperText Transfer Protocol\">$1</abbr>", $text);
|
|
// HTML
|
|
$text = preg_replace("/\b(HTML)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"HyperText Markup Language\">$1</abbr>", $text);
|
|
// CGI
|
|
$text = preg_replace("/\b(CGI)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Common Gateway Interface\">$1</abbr>", $text);
|
|
// SSL
|
|
$text = preg_replace("/\b(SSL)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Secure Socket Layer\">$1</abbr>", $text);
|
|
// PDF
|
|
$text = preg_replace("/\b(PDF\b\.?)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Portable Document Format\">$1</abbr>", $text);
|
|
// IP
|
|
$text = preg_replace("/\b(IP)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Internet Protocol\">$1</abbr>", $text);
|
|
// S/N
|
|
$text = preg_replace("/\b(S\/N)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"serial number\">$1</abbr>", $text);
|
|
// No.
|
|
$text = preg_replace("/\b(No\.|Num\.)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"number\">$1</abbr>", $text);
|
|
// ID.
|
|
$text = preg_replace("/\b(ID\.)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"identity\">$1</abbr>", $text);
|
|
// Pic.
|
|
$text = preg_replace("/\b(Pic\.)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"picture\">$1</abbr>", $text);
|
|
// URL.
|
|
$text = preg_replace("/\b(URL\b\.?)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Uniform Resource Locator\">$1</abbr>", $text);
|
|
// E-mail.
|
|
$text = preg_replace("/\b(E-?mail)\b(?!<\/abbr>|<\/acronym>)/i", "<acronym title=\"electronic mail\">$1</acronym>", $text);
|
|
// MIME
|
|
$text = preg_replace("/\b(MIME\b\.?)(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Multipurpose Internet Mail Extensions\">$1</abbr>", $text);
|
|
// KB/MB/GB/TB from report_size()
|
|
$text = preg_replace("/(\d+) KB\)/", "$1 <abbr title=\"kilobyte\">KB</abbr>)", $text);
|
|
$text = preg_replace("/(\d+) MB\)/", "$1 <abbr title=\"megabyte\">MB</abbr>)", $text);
|
|
$text = preg_replace("/(\d+) GB\)/", "$1 <abbr title=\"gigabyte\">GB</abbr>)", $text);
|
|
$text = preg_replace("/(\d+) TB\)/", "$1 <abbr title=\"terabyte\">TB</abbr>)", $text);
|
|
// MRTG
|
|
$text = preg_replace("/\b(MRTG)\b(?!<\/abbr>|<\/acronym>)/", "<abbr title=\"Multi Router Traffic Grapher\">$1</abbr>", $text);
|
|
// Load the local extension
|
|
// Load it at last to prevent mark-up recursion
|
|
if (function_exists("markabbr_site")) {
|
|
$text = markabbr_site($text);
|
|
}
|
|
return $text;
|
|
}
|
|
|
|
?>
|