dmBridge PHP API
DMLocalizedString.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 abstract class DMLocalizedString {
00014 
00016    private static $strings = array();
00017    
00023    public static function getString($key, $strings_pathname = null) {
00024       if (!count(self::$strings)) {
00025          $pathname = $strings_pathname
00026             ? $strings_pathname
00027             : dirname(__FILE__) . "/../../includes/strings.txt";
00028          $fh = fopen($pathname, "rb");
00029          while (!feof($fh) ) {
00030             $line = fgets($fh);
00031             $parts = explode('=', $line);
00032             $str_key = array_shift($parts);
00033             self::$strings[trim($str_key)] = trim(implode("=", $parts));
00034          }
00035          fclose($fh);
00036       }
00037 
00038       $key = strtoupper($key);
00039       return (array_key_exists($key, self::$strings))
00040             ? self::$strings[$key] : null;
00041    }
00042 
00043 }
 All Data Structures Functions Variables