/usr/local/miolo2/classes/support.inc

Go to the documentation of this file.
00001 <?php
00002 #ini_set("error_report", "E_ALL & ~E_NOTICE");
00003 
00004 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00005 # Support for gettext()
00006 #---------------------------------------------------------------------
00007 if (function_exists('_'))
00008 {
00009     $TEXTDOMAIN = 'miolo';
00010     //setlocale(LC_ALL, $MIOLOCONF['i18n']['language']);
00011     //bindtextdomain($TEXTDOMAIN, $MIOLOCONF['i18n']['locale']);
00012     global $MIOLO;
00013     setlocale(LC_ALL, $MIOLO->getConf('i18n.language'));
00014     bindtextdomain($TEXTDOMAIN, $MIOLO->getConf('i18n.locale'));
00015     textdomain($TEXTDOMAIN);
00016 }
00017 
00018 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00019 # This function is a wrapper for the gettext support. In addition to
00020 # the standard gettext() function, it provides support for up to three
00021 # positional parameters represented by the placeholders <code>@1</code>,
00022 # <code>@2</code> and <code>@3</code>.
00023 #
00024 # @example
00025 # echo _M('@1 is a romance written by @2 in @3','foo','Tom Sawyer','Mark Twain','1890');
00026 # // will result in:
00027 # //   "Tom Sawyer is a romance written by Mark Twain in 1890" 
00028 #
00029 # echo _M('@2 escreveu o romance @1 em @3','foo','Tom Sawyer','Mark Twain','1890');
00030 # //
00031 # // will result in:
00032 # //   "Mark Twain escreveu o romance Tom Sawyer em 1890" 
00033 #---------------------------------------------------------------------
00034 function _M($msg, $dom = 'miolo', $p1 = null, $p2 = null, $p3 = null)
00035 {
00036     global $TEXTDOMAIN, $MIOLO;
00037 
00038     if ($msg == '')
00039     {
00040         return $msg;
00041     }
00042 
00043     if (function_exists('_'))
00044     {
00045         if ($dom != $TEXTDOMAIN)
00046         {
00047             $TEXTDOMAIN = $dom;
00048             bindtextdomain($TEXTDOMAIN, $MIOLO->getConf('i18n.locale'));
00049             textdomain($TEXTDOMAIN);
00050         }
00051 
00052         $msg = _($msg);
00053     }
00054 
00055     if ($p1 !== null)
00056     {
00057         $msg = str_replace('@1', $p1, $msg);
00058     }
00059 
00060     if ($p2 !== null)
00061     {
00062         $msg = str_replace('@2', $p2, $msg);
00063     }
00064 
00065     if ($p3 !== null)
00066     {
00067         $msg = str_replace('@3', $p3, $msg);
00068     }
00069 
00070     return $msg;
00071 }
00072 
00073 function __autoload($className)
00074 {
00075     global $autoload;
00076 
00077 //echo "<br>autoload: $className<br>";
00078     $className = strtolower($className);
00079     $file = $autoload->getFile($className);
00080 
00081     if ($file == '')
00082         echo "className: $className<br>";
00083     include_once($file);
00084 }
00085 ?>
CopyLeft (L) 2001-2006 - [MIOLO Development Team] SOLIS - Cooperativa de Soluções Livres - Lajeado/RS - Brasil