コード例 #1
0
ファイル: ToasterAdmin.php プロジェクト: shupp/toasteradmin
 /**
  * __construct 
  * 
  * Set locale for gettext
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $baseLocaleDir = FRAMEWORK_BASE_PATH . '/';
     $baseLocaleDir .= (string) Framework::$site->config->user->userLocaleDir;
     I18Nv2::setLocale($this->locale);
     bindtextdomain("messages", $baseLocaleDir);
     textdomain("messages");
 }
コード例 #2
0
 public static function getLocaleHandler()
 {
     if (self::$locale_handler === NULL) {
         require_once 'I18Nv2.php';
         // If first param is not NULL, (eg 'en_US') then I18n throws php notices on debian/ubuntu.
         //Set second param (paranoid) to TRUE so it doesn't break FPDF/TCPDF
         self::$locale_handler =& I18Nv2::createLocale(NULL, TRUE);
     }
     return self::$locale_handler;
 }
コード例 #3
0
ファイル: ToasterAdmin.php プロジェクト: shupp/toasteradmin
 /**
  * __construct 
  * 
  * Set locale for gettext
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $baseLocaleDir = FRAMEWORK_BASE_PATH . '/';
     $baseLocaleDir .= (string) Framework::$site->config->user->userLocaleDir;
     // Fix for missing _COUNTRY in negotiated locale string
     if (strlen($this->locale) == 2) {
         $this->locale = $this->locale . '_' . strtoupper($this->locale);
     }
     I18Nv2::setLocale($this->locale);
     bindtextdomain("messages", $baseLocaleDir);
     textdomain("messages");
 }
コード例 #4
0
 /**
  * Constructor (ZE2)
  * @ignore
  */
 function __construct($language = null, $encoding = null)
 {
     if (!$this->setLanguage($language)) {
         if (class_exists('I18Nv2')) {
             $l = I18Nv2::lastLocale(0, true);
             if (!isset($l) || !$this->setLanguage($l['language'])) {
                 $this->setLanguage('en');
             }
         } else {
             $this->setLanguage('en');
         }
     }
     if (!$this->setEncoding($encoding)) {
         $this->setEncoding('UTF-8');
     }
 }
コード例 #5
0
ファイル: TTi18n.class.php プロジェクト: alachaum/timetrex
 public static function tryLocale($locale)
 {
     if (!is_array($locale)) {
         $locale = (array) $locale;
     }
     //Try each Locale in array to see which one works.
     if (OPERATING_SYSTEM == 'LINUX') {
         //setLocale supports passing it an array, so thats easy.
         $valid_locale = setlocale(LC_ALL, $locale);
     } else {
         //Add caching here if we find this loop is too slow.
         self::getLocaleHandler();
         //Include I18Nv2 files.
         $windows_locales = I18Nv2::getStaticProperty('windows');
         $valid_locale = 'en_US';
         foreach ($locale as $tmp_locale) {
             //This is setting the locale
             //Match the windows locales directly, because if we use self::getLocaleHandler()->setLocale( $tmp_locale, 'LC_ALL'); instead
             //it will actually change the locale out from under us causing strange problems, and also circumventing the locale cache
             //in setLocale() (that prevents changing to the same locale we are already in)
             //
             //On windows sometimes its using 127 digits after the decimal because after setLocale() is called, localeconv() returns
             //an array that is basically empty or uses 127 for everything.
             //This is fixed in Pear::I18Nv2->setLocale(), so it defaults to english values if it fails.
             if (isset($windows_locales[$tmp_locale])) {
                 Debug::Text('Found valid windows locale: ' . $windows_locales[$tmp_locale] . ' Linux locale: ' . $tmp_locale, __FILE__, __LINE__, __METHOD__, 10);
                 $valid_locale = $tmp_locale;
                 break;
             }
             /*
             $windows_locale = self::getLocaleHandler()->setLocale( $tmp_locale, 'LC_ALL');
             if ( $windows_locale !== FALSE ) {
             	Debug::Text('Found valid windows locale: '. $windows_locale .' Linux locale: '. $tmp_locale,  __FILE__, __LINE__, __METHOD__,10);
             	//Returning $windows_locale appears to fix issues with some systems, but then it causes problems with language selection since its a long locale name that doens't match pt_PT for example.
             	$valid_locale = $tmp_locale;
             	break;
             }
             */
         }
     }
     if ($valid_locale != '') {
         Debug::Text('Found valid locale: ' . $valid_locale, __FILE__, __LINE__, __METHOD__, 10);
         return $valid_locale;
     }
     Debug::Text('FAILED TRYING LOCALE: ' . self::getLocaleArrayAsString($locale), __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
コード例 #6
0
ファイル: I18Nv2.php プロジェクト: roojs/pear
 /**
  * This one gets called automatically
  *
  * @ignore
  * @static
  * @internal
  * @access  private
  * @return  void
  */
 function _main()
 {
     // initialize the locale stack
     $last =& I18Nv2::getStaticProperty('last');
     $last = array();
     // map of "fully qualified locale" codes
     $locales =& I18Nv2::getStaticProperty('locales');
     $locales = array('af' => 'af_ZA', 'de' => 'de_DE', 'en' => 'en_US', 'fr' => 'fr_FR', 'it' => 'it_IT', 'es' => 'es_ES', 'pt' => 'pt_PT', 'sv' => 'sv_SE', 'nb' => 'nb_NO', 'nn' => 'nn_NO', 'no' => 'no_NO', 'fi' => 'fi_FI', 'is' => 'is_IS', 'da' => 'da_DK', 'nl' => 'nl_NL', 'pl' => 'pl_PL', 'sl' => 'sl_SI', 'hu' => 'hu_HU', 'ru' => 'ru_RU', 'cs' => 'cs_CZ');
     // define locale fallbacks
     $fallbacks =& I18Nv2::getStaticProperty('fallbacks');
     $fallbacks = array('no_NO' => 'nb_NO', 'nb_NO' => 'no_NO');
     // include Win32 locale codes
     if (I18Nv2_WIN) {
         include_once 'I18Nv2/Locale/Windows.php';
     }
 }
コード例 #7
0
ファイル: Locale.php プロジェクト: ookwudili/chisimba
 /**
  * Loads corresponding locale extension
  *
  * @access  public
  * @return  void
  */
 function loadExtension()
 {
     $locale = I18Nv2::lastLocale(0, true);
     if (isset($locale)) {
         $dir = dirname(__FILE__);
         foreach (array($locale['language'], $locale['locale']) as $lc) {
             if (is_file($dir . '/Locale/' . $lc . '.php')) {
                 include $dir . '/Locale/' . $lc . '.php';
             }
         }
     }
 }
コード例 #8
0
<?php

/**
* $Id: Windows.php,v 1.4 2004/06/01 17:55:04 mike Exp $
*/
$windows =& I18Nv2::getStaticProperty('windows');
$windows = array('de_DE' => 'deu', 'de_AT' => 'dea', 'de_CH' => 'des', 'en_US' => 'enu', 'en_GB' => 'eng', 'en_AU' => 'ena', 'en_BZ' => 'enb', 'en_CA' => 'enc', 'en_IE' => 'eni', 'en_JM' => 'enj', 'en_PH' => 'enp', 'en_ZA' => 'ens', 'en_NZ' => 'enz', 'fr_FR' => 'fra', 'fr_CH' => 'frs', 'fr_BE' => 'frb', 'fr_CA' => 'frc', 'fr_LU' => 'frl', 'fr_MC' => 'frm', 'it_IT' => 'ita', 'it_CH' => 'its', 'es_ES' => 'esp', 'es_PA' => 'esa', 'es_BO' => 'esb', 'es_DO' => 'esd', 'es_SV' => 'ese', 'es_EC' => 'esf', 'es_GT' => 'esg', 'es_HN' => 'esh', 'es_NI' => 'esi', 'es_CL' => 'esl', 'es_MX' => 'esm', 'es_CO' => 'eso', 'es_PE' => 'esr', 'es_AR' => 'ess', 'es_VE' => 'esv', 'es_UY' => 'esy', 'es_PY' => 'esz', 'pt_PT' => 'ptg', 'pt_BR' => 'ptb', 'sv_SE' => 'sve', 'sv_FI' => 'svf', 'no_NO' => 'nor', 'nb_NO' => 'nor', 'nn_NO' => 'non', 'fi_FI' => 'fin', 'is_IS' => 'isl', 'da_DK' => 'dan', 'nl_NL' => 'nld', 'nl_BE' => 'nlb', 'ru_RU' => 'rus', 'hu_HU' => 'hun', 'ru_RU' => 'rus', 'af_ZA' => 'afk', 'sl_SI' => 'slv', 'pl_PL' => 'plk', 'cs_CZ' => 'csy');
コード例 #9
0
 /**
  * Method to return the default language
  * @access public 
  * @return default site language
  */
 public function currentLanguage()
 {
     try {
         $this->objConfig = $this->getObject('altconfig', 'config');
         $ab = strtolower($this->objConfig->getdefaultLanguageAbbrev());
         $country = $this->objConfig->getCountry();
         $country = $ab . "_" . $country . ".1252";
         if (isset($_POST['Languages'])) {
             $_SESSION["language"] = $_POST['Languages'];
             $var = $_POST['Languages'];
             @($this->locale =& I18Nv2::createLocale("{$country}"));
             $this->lang->setLang("{$var}");
         } else {
             if (isset($_SESSION["language"])) {
                 $var = strtolower($_SESSION["language"]);
                 $country = $this->objConfig->getCountry();
                 $country = $var . "_" . $country . ".1252";
                 @($this->locale =& I18Nv2::createLocale("{$country}"));
                 $this->lang->setLang("{$var}");
             } else {
                 $var = strtolower($this->objConfig->getdefaultLanguageAbbrev());
                 $this->lang->setLang("{$var}");
             }
         }
         return $var;
     } catch (Exception $e) {
         $this->errorCallback($this->languageText('word_caught_exception') . $e->getMessage());
         exit;
     }
 }
コード例 #10
0
<?php

/**
* Retrieving locale conventions
* =============================
*
* I18Nv2 holds locale conventions returned by localeConv() stored statically, 
* so they are easily accessible through I18Nv2::getInfo(). Have a look at
* the documentation of PHPs localeConv() for all available information.
* 
* $Id: retrieving_locale_conventions.php,v 1.1 2004/05/03 15:02:17 mike Exp $
*/
require_once 'I18Nv2.php';
I18Nv2::setLocale('fr');
$dec_point = I18Nv2::getInfo('decimal_point');
echo "The decimal point for the french locale is '{$dec_point}'.\n";
echo "I18Nv2::getInfo() called without parameter returns all available information:\n";
print_r(I18Nv2::getInfo());
コード例 #11
0
<?php

/**
* Using I18Nv2_Locale
* ===================
*
* I18Nv2_Locale is a formatter object that provides functionality to format
* dates, times, numbers and currencies in locale dependent conventions.
* 
* $Id: using_I18Nv2_Locale.php,v 1.2 2005/01/05 09:26:18 mike Exp $
*/
require_once 'I18Nv2.php';
$locale =& I18Nv2::createLocale('de_AT');
echo "de_AT\n=====\n";
echo "Format a currency value of 2000: ", $locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n";
echo "Format todays date:              ", $locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n";
echo "Format current time:             ", $locale->formatTime(null, I18Nv2_DATETIME_SHORT), "\n";
$locale->setLocale('en_GB');
echo "\nen_GB\n=====\n";
echo "Format a currency value of 2000: ", $locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n";
echo "Format todays date:              ", $locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n";
echo "Format current time:             ", $locale->formatTime(null, I18Nv2_DATETIME_SHORT), "\n";
コード例 #12
0
ファイル: Application.php プロジェクト: promoso/HVAC
    function Dataface_Application($conf = null)
    {
        $this->_baseUrl = $_SERVER['PHP_SELF'];
        if (!is_array($conf)) {
            $conf = array();
        }
        if (is_readable(DATAFACE_SITE_PATH . '/conf.ini')) {
            $conf = array_merge(parse_ini_file(DATAFACE_SITE_PATH . '/conf.ini', true), $conf);
        }
        if (!isset($conf['_tables'])) {
            echo 'Error loading config file.  No tables specified.';
            exit;
        }
        if (isset($conf['db']) and is_resource($conf['db'])) {
            $this->_db = $conf['db'];
        } else {
            if (!isset($conf['_database'])) {
                echo 'Error loading config file. No database specified.';
                exit;
            }
            $dbinfo =& $conf['_database'];
            if (!is_array($dbinfo) || !isset($dbinfo['host']) || !isset($dbinfo['user']) || !isset($dbinfo['password']) || !isset($dbinfo['name'])) {
                echo 'Error loading config file.  The database information was not entered correctly.<br>
					 Please enter the database information int its own section of the config file as follows:<br>
					 <pre>
					 [_database]
					 host = localhost
					 user = foo
					 password = bar
					 name = database_name
					 </pre>';
                exit;
            }
            if (@$dbinfo['persistent']) {
                $this->_db = mysql_pconnect($dbinfo['host'], $dbinfo['user'], $dbinfo['password']);
            } else {
                $this->_db = mysql_connect($dbinfo['host'], $dbinfo['user'], $dbinfo['password']);
            }
            if (!$this->_db) {
                echo 'Error connecting to the database: ' . mysql_error();
                exit;
            }
            $this->mysqlVersion = mysql_get_server_info($this->_db);
            mysql_select_db($dbinfo['name']) or die("Could not select DB: " . mysql_error($this->_db));
        }
        if (!defined('DATAFACE_DB_HANDLE')) {
            define('DATAFACE_DB_HANDLE', $this->_db);
        }
        if (!is_array($conf['_tables'])) {
            echo "<pre>\n\t\t\t\tError reading table information from the config file.  Please enter the table information in its own section\n\t\t\t\tof the ini file as follows:\n\t\t\t\t[_tables]\n\t\t\t\ttable1 = Table 1 Label\n\t\t\t\ttable2 = Table 2 Label\n\t\t\t\t</pre>";
            exit;
        }
        $this->_tables = $conf['_tables'];
        if (count($this->_tables) <= 10) {
            $this->prefs['horizontal_tables_menu'] = 1;
        }
        // We will register a _cleanup method to run after code execution is complete.
        register_shutdown_function(array(&$this, '_cleanup'));
        // Set up memcache if it is installed.
        if (DATAFACE_EXTENSION_LOADED_MEMCACHE) {
            if (isset($conf['_memcache'])) {
                if (!isset($conf['_memcache']['host'])) {
                    $conf['_memcache']['host'] = 'localhost';
                }
                if (!isset($conf['_memcache']['port'])) {
                    $conf['_memcache']['port'] = 11211;
                }
                $this->memcache = new Memcache();
                $this->memcache->connect($conf['_memcache']['host'], $conf['_memcache']['port']) or die("Could not connect to memcache on port 11211");
            }
        }
        //
        // -------- Set up the CONF array ------------------------
        $this->_conf = $conf;
        if (!isset($this->_conf['_disallowed_tables'])) {
            $this->_conf['_disallowed_tables'] = array();
        }
        $this->_conf['_disallowed_tables']['history'] = '/__history$/';
        $this->_conf['_disallowed_tables']['cache'] = '__output_cache';
        $this->_conf['_disallowed_tables']['dataface'] = '/^dataface__/';
        if (!@$this->_conf['_modules'] or !is_array($this->_conf['_modules'])) {
            $this->_conf['_modules'] = array();
        }
        // Include XataJax module always.
        //$this->_conf['_modules']['modules_XataJax'] = 'modules/XataJax/XataJax.php';
        if (isset($this->_conf['_modules']) and count($this->_conf['_modules']) > 0) {
            import('Dataface/ModuleTool.php');
        }
        if (isset($this->_conf['languages'])) {
            $this->_conf['language_labels'] = $this->_conf['languages'];
            foreach (array_keys($this->_conf['language_labels']) as $lang_code) {
                $this->_conf['languages'][$lang_code] = $lang_code;
            }
        }
        if (@$this->_conf['support_transactions']) {
            // We will support transactions
            @mysql_query('SET AUTOCOMMIT=0', $this->_db);
            @mysql_query('START TRANSACTION', $this->_db);
        }
        if (!isset($this->_conf['default_ie'])) {
            $this->_conf['default_ie'] = 'ISO-8859-1';
        }
        if (!isset($this->_conf['default_oe'])) {
            $this->_conf['default_oe'] = 'ISO-8859-1';
        }
        if (isset($this->_conf['multilingual_content']) || isset($this->_conf['languages'])) {
            $this->_conf['oe'] = 'UTF-8';
            $this->_conf['ie'] = 'UTF-8';
            if (function_exists('mb_substr')) {
                // The mbstring extension is loaded
                ini_set('mbstring.internal_encoding', 'UTF-8');
                //ini_set('mbstring.encoding_translation', 'On');
                ini_set('mbstring.func_overload', 7);
            }
            if (!isset($this->_conf['default_language'])) {
                if (count($this->_conf['languages']) > 0) {
                    $this->_conf['default_language'] = reset($this->_conf['languages']);
                } else {
                    $this->_conf['default_language'] = 'en';
                }
            }
        } else {
            $this->_conf['oe'] = $this->_conf['default_oe'];
            $this->_conf['ie'] = $this->_conf['default_ie'];
        }
        if ($this->_conf['oe'] == 'UTF-8') {
            $res = mysql_query('set character_set_results = \'utf8\'', $this->_db);
            mysql_query("SET NAMES utf8", $this->_db);
        }
        if ($this->_conf['ie'] == 'UTF-8') {
            $res = mysql_query('set character_set_client = \'utf8\'', $this->_db);
            //if ( !$res ) trigger_error(mysql_error());
        }
        if (isset($this->_conf['use_cache']) and $this->_conf['use_cache'] and !defined('DATAFACE_USE_CACHE')) {
            define('DATAFACE_USE_CACHE', true);
        }
        if (isset($this->_conf['debug']) and $this->_conf['debug'] and !defined('DATAFACE_DEBUG')) {
            define('DATAFACE_DEBUG', true);
        } else {
            if (!defined('DATAFACE_DEBUG')) {
                define('DATAFACE_DEBUG', false);
            }
        }
        if (!@$this->_conf['config_storage']) {
            $this->_conf['config_storage'] = DATAFACE_DEFAULT_CONFIG_STORAGE;
        }
        // Set the storage type for config information.  It can either be stored in ini files or
        // in the database.  Database will give better performance, but INI files may be simpler
        // to manage for simple applications.
        if (!isset($this->_conf['garbage_collector_threshold'])) {
            /**
             * The garbage collector threshold is the number of seconds that "garbage" can
             * exist for before it is deleted.  Examples of "garbage" include import tables
             * (ie: temporary tables created as an intermediate point to importing data).
             */
            $this->_conf['garbage_collector_threshold'] = 10 * 60;
        }
        if (!isset($this->_conf['multilingual_content'])) {
            $this->_conf['multilingual_content'] = false;
        }
        // whether or not the application will use multilingual content.
        // multilingual content enables translated versions of content to be stored in
        // tables using naming conventions.
        // Default to false because this takes a performance hit (sql queries take roughly twice
        // as long because they have to be parsed first.
        if (!isset($this->_conf['cookie_prefix'])) {
            $this->_conf['cookie_prefix'] = 'dataface__';
        }
        if (!isset($this->_conf['security_level'])) {
            // Default security is strict if security is not specified.  This change is effectivce
            // for Dataface 0.6 .. 0.5.3 and earlier had a loose permissions model by default that
            // could be tightened using delegate classes.
            $this->_conf['security_level'] = 0;
            //DATAFACE_STRICT_PERMISSIONS;
        }
        if (!isset($this->_conf['default_action'])) {
            // The default action defines the action that should be set if no
            // other action is specified.
            $this->_conf['default_action'] = 'list';
        }
        if (!isset($this->_conf['default_browse_action'])) {
            $this->_conf['default_browse_action'] = 'view';
        }
        if (!isset($this->_conf['default_mode'])) {
            $this->_conf['default_mode'] = 'list';
        }
        if (!isset($this->_conf['default_limit'])) {
            $this->_conf['default_limit'] = 30;
        }
        if (!isset($this->_conf['default_table'])) {
            // The default table is the table that is used if no other table is specified.
            foreach ($this->_tables as $key => $value) {
                $this->_conf['default_table'] = $key;
                break;
            }
        }
        if (!isset($this->_conf['auto_load_results'])) {
            $this->_conf['auto_load_results'] = false;
        }
        if (!isset($this->_conf['cache_dir'])) {
            if (ini_get('upload_tmp_dir')) {
                $this->_conf['cache_dir'] = ini_get('upload_tmp_dir');
            } else {
                $this->_conf['cache_dir'] = '/tmp';
            }
        }
        if (!isset($this->_conf['default_table_role'])) {
            if ($this->_conf['security_level'] >= DATAFACE_STRICT_PERMISSIONS) {
                $this->_conf['default_table_role'] = 'NO ACCESS';
            } else {
                $this->_conf['default_table_role'] = 'ADMIN';
            }
        }
        if (!isset($this->_conf['default_field_role'])) {
            if ($this->_conf['security_level'] >= DATAFACE_STRICT_PERMISSIONS) {
                $this->_conf['default_field_role'] = 'NO ACCESS';
            } else {
                $this->_conf['default_field_role'] = 'ADMIN';
            }
        }
        if (!isset($this->_conf['default_relationship_role'])) {
            if ($this->_conf['security_level'] >= DATAFACE_STRICT_PERMISSIONS) {
                $this->_conf['default_relationship_role'] = 'READ ONLY';
            } else {
                $this->_conf['default_relationship_role'] = 'ADMIN';
            }
        }
        if (!isset($this->_conf['languages'])) {
            $this->_conf['languages'] = array('en');
        } else {
            if (!is_array($this->_conf['languages'])) {
                $this->_conf['languages'] = array($this->_conf['languages']);
            }
        }
        if (isset($this->_conf['_language_codes'])) {
            $this->_languages = array_merge($this->_languages, $this->_conf['_language_codes']);
        }
        if (isset($this->_conf['_locales'])) {
            $this->_locales = array_merge($this->_locales, $this->_conf['_locales']);
        }
        // Set the language.
        // Language is stored in a cookie.  It can be changed by passing the -lang GET var with the value
        // of a language.  e.g. fr, en, cn
        if (!isset($this->_conf['default_language'])) {
            $this->_conf['default_language'] = 'en';
        }
        $prefix = $this->_conf['cookie_prefix'];
        //print_r($_COOKIE);
        if (isset($_REQUEST['--lang'])) {
            $_REQUEST['--lang'] = basename($_REQUEST['--lang']);
            $this->_conf['lang'] = $_REQUEST['--lang'];
        } else {
            if (isset($_REQUEST['-lang'])) {
                $_REQUEST['-lang'] = basename($_REQUEST['-lang']);
                $this->_conf['lang'] = $_REQUEST['-lang'];
                if (@$_COOKIE[$prefix . 'lang'] !== $_REQUEST['-lang']) {
                    setcookie($prefix . 'lang', $_REQUEST['-lang'], null, '/');
                }
            } else {
                if (isset($_COOKIE[$prefix . 'lang'])) {
                    $this->_conf['lang'] = $_COOKIE[$prefix . 'lang'];
                } else {
                    import('I18Nv2/I18Nv2.php');
                    $negotiator = I18Nv2::createNegotiator($this->_conf['default_language'], 'UTF-8');
                    $this->_conf['lang'] = $this->getLanguageCode($negotiator->getLocaleMatch($this->getAvailableLanguages()));
                    setcookie($prefix . 'lang', $this->_conf['lang'], null, '/');
                }
            }
        }
        $this->_conf['lang'] = basename($this->_conf['lang']);
        // Set the mode (edit or view)
        if (isset($_REQUEST['-usage_mode'])) {
            $this->_conf['usage_mode'] = $_REQUEST['-usage_mode'];
            if (@$_COOKIE[$prefix . 'usage_mode'] !== $_REQUEST['-usage_mode']) {
                setcookie($prefix . 'usage_mode', $_REQUEST['-usage_mode'], null, '/');
            }
        } else {
            if (isset($_COOKIE[$prefix . 'usage_mode'])) {
                $this->_conf['usage_mode'] = $_COOKIE[$prefix . 'usage_mode'];
            } else {
                if (!isset($this->_conf['usage_mode'])) {
                    $this->_conf['usage_mode'] = 'view';
                }
            }
        }
        define('DATAFACE_USAGE_MODE', $this->_conf['usage_mode']);
        if (@$this->_conf['enable_workflow']) {
            import('Dataface/WorkflowTool.php');
        }
        // ------- Set up the current query ---------------------------------
        if (isset($_REQUEST['__keys__']) and is_array($_REQUEST['__keys__'])) {
            $query = $_REQUEST['__keys__'];
            foreach (array_keys($_REQUEST) as $key) {
                if ($key[0] == '-' and !in_array($key, array('-search', '-cursor', '-skip', '-limit'))) {
                    $query[$key] = $_REQUEST[$key];
                }
            }
        } else {
            $query = array_merge($_GET, $_POST);
        }
        $this->rawQuery = $query;
        if (!isset($query['-table'])) {
            $query['-table'] = $this->_conf['default_table'];
        }
        $this->_currentTable = $query['-table'];
        if (!@$query['-action']) {
            $query['-action'] = $this->_conf['default_action'];
            $this->_conf['using_default_action'] = true;
        }
        $query['--original_action'] = $query['-action'];
        if ($query['-action'] == 'browse') {
            if (isset($query['-relationship'])) {
                $query['-action'] = 'related_records_list';
            } else {
                if (isset($query['-new']) and $query['-new']) {
                    $query['-action'] = 'new';
                } else {
                    $query['-action'] = $this->_conf['default_browse_action'];
                    // for backwards compatibility to 0.5.x
                }
            }
        } else {
            if ($query['-action'] == 'find_list') {
                $query['-action'] = 'list';
            }
        }
        if (!isset($query['-cursor'])) {
            $query['-cursor'] = 0;
        }
        if (!isset($query['-skip'])) {
            $query['-skip'] = 0;
        }
        if (!isset($query['-limit'])) {
            $query['-limit'] = $this->_conf['default_limit'];
        }
        if (!isset($query['-mode'])) {
            $query['-mode'] = $this->_conf['default_mode'];
        }
        $this->_query =& $query;
        if (isset($query['--msg'])) {
            $query['--msg'] = preg_replace('#<[^>]*>#', '', $query['--msg']);
            if (preg_match('/^@@$/', $query['--msg'])) {
                if (@$_SESSION['--msg']) {
                    $this->addMessage(@$_SESSION['--msg']);
                    unset($_SESSION['--msg']);
                }
            } else {
                $this->addMessage($query['--msg']);
            }
        }
        if (isset($query['--error']) and trim($query['--error'])) {
            $query['--error'] = preg_replace('#<[^>]*>#', '', $query['--error']);
            $this->addError(PEAR::raiseError($query['--error']));
        }
        // Now allow custom setting of theme
        if (isset($query['-theme'])) {
            if (!isset($this->_conf['_themes'])) {
                $this->_conf['_themes'] = array();
            }
            $this->_conf['_themes'][basename($query['-theme'])] = 'themes/' . basename($query['-theme']);
        }
        // Check to see if we should set a custom default preview length
        if (isset($query['--default-preview-length'])) {
            $len = intval($query['--default-preview-length']);
            if ($len > 0 && !defined('XATAFACE_DEFAULT_PREVIEW_LENGTH')) {
                define('XATAFACE_DEFAULT_PREVIEW_LENGTH', $len);
            }
        }
    }
コード例 #13
0
 /**
  *  This method utilizes ob_iconv_handler(), so you should call it at the beginning of your script (prior to any output).
  * Automatically transform output between character sets
  *
  * @param string $ocs desired output character set
  * @param string $ics current intput character set
  * @return Returns TRUE on success, PEAR_Error on failure.
  */
 public function autoConv($ocs, $ics)
 {
     try {
         I18Nv2::autoConv($ocs, $ics);
     } catch (Exception $e) {
         $this->errorCallback('Caught exception: ' . $e->getMessage());
         exit;
     }
 }
コード例 #14
0
ファイル: Book.php プロジェクト: shupp/toasterdoc
 /**
  * setLocale 
  * 
  * Set Locate info using I18Nv2_Negotiator
  * 
  * @access protected
  * @return void
  */
 protected function setLocale()
 {
     // Not using negotiation for the time being, static selection only
     // $neg = &new I18Nv2_Negotiator;
     // I18Nv2::setLocale($neg->getLocaleMatch());
     if (isset($_GET['language'])) {
         $array = $this->xmlObjToArray($this->languages->xpath('language'), 'name');
         if (in_array($_GET['language'], $array)) {
             $_SESSION['language'] = $_GET['language'];
         }
     }
     // print_r($_GET['language']);exit;
     if (isset($_SESSION['language'])) {
         I18Nv2::setLocale($_SESSION['language']);
         bindtextdomain("messages", "./locale");
         bind_textdomain_codeset("messages", 'UTF-8');
         textdomain("messages");
     }
 }
コード例 #15
0
ファイル: gettext.php プロジェクト: altesien/FinalProject
 /**
  * Sets the current lang
  *
  * @param string $langID language ID
  *
  * @return array language data
  */
 function setLang($langID)
 {
     if (!PEAR::isError($langData = parent::setLang($langID))) {
         I18Nv2::setLocale($langID);
     }
     return $langData;
 }
コード例 #16
0
<?php

/**
* Setting a locale
* ================
*
* Because Un*x and Windows use different locale codes, PHPs setLocale() is not 
* easily portable - I18Nv2::setLocale() attempts to provide this portability.
* 
* With I18Nv2 you can use standard locale codes like 'en_US' on both, Linux
* and Windows, though the list is far not complete yet, so if you stumble
* over a not covered locale (I18Nv2::$locales in I18Nv2::_main()), just drop
* a mail to <mike(@)php.net> with the missing locale and its corresponding
* Win32 code.
* 
* $Id: setting_a_locale.php,v 1.1 2004/05/03 15:02:17 mike Exp $
*/
require_once 'I18Nv2.php';
$locale = 'en_US';
if (!I18Nv2::setLocale($locale)) {
    die("Locale '{$locale}' not available!\n");
}
コード例 #17
0
<?php

/**
* Automatically transform output charset
* ======================================
*
* I18Nv2 provides an easy way to utilize the ob_iconv_handler() through
* I18Nv2::autoConv($output_charset, $input_charset).
* 
* $Id: transform_output_charset.php,v 1.1 2004/05/03 15:02:17 mike Exp $
*/
require_once 'I18Nv2.php';
// Writing a shell app that should also display nicely in a DOS box
if (I18Nv2_WIN) {
    I18Nv2::autoConv('CP850');
}
// output some latin1 stuff
echo "δόφί\n";
コード例 #18
0
ファイル: ConfigTool.php プロジェクト: minger11/Pipeline
 /**
  * Loads configuration information from an INI file.
  * @param $type The type of configuration information to load: e.g., actions, relationships, valuelists, fields, etc..
  * @param $tablename The name of the table for which to load the configuration information.
  * @return Associative array of configuration options in the same form as they would be returned by parse_ini_file().
  */
 function &loadConfigFromINI($type = null, $tablename = '__global__')
 {
     if (!isset($tablename)) {
         $tablename = '__global__';
     }
     $app =& Dataface_Application::getInstance();
     if ($type == 'lang') {
         if (isset($this->config[$type][$app->_conf['lang']][$tablename])) {
             return $this->config[$type][$app->_conf['lang']][$tablename];
         }
     } else {
         if (isset($this->config[$type][$tablename])) {
             return $this->config[$type][$tablename];
         }
     }
     $app =& Dataface_Application::getInstance();
     $paths = array();
     $lpaths = array();
     if ($type === 'lang') {
         if ($tablename !== '__global__') {
             if (!class_exists('Dataface_Table')) {
                 import('Dataface/Table.php');
             }
             $lpaths[] = Dataface_Table::getBasePath($tablename) . '/tables/' . basename($tablename) . '/lang/' . basename($app->_conf['lang']) . '.ini';
         } else {
             $paths[] = DATAFACE_PATH . '/lang/' . basename($app->_conf['lang']) . '.ini';
             $lpaths[] = DATAFACE_SITE_PATH . '/lang/' . basename($app->_conf['lang']) . '.ini';
         }
     } else {
         if ($tablename !== '__global__') {
             //$paths = array(DATAFACE_SITE_PATH.'/tables/'.$tablename.'/'.$type.'.ini');
             // Valuelists handle their own cascading because it involves loading
             // the valuelist each time... and there may be opportunities to
             // share between tables
             if ($type != 'valuelists') {
                 $paths[] = DATAFACE_PATH . '/' . basename($type) . '.ini';
             }
             if ($type != 'valuelists') {
                 $lpaths[] = DATAFACE_SITE_PATH . '/' . basename($type) . '.ini';
             }
             $lpaths[] = Dataface_Table::getBasePath($tablename) . '/tables/' . basename($tablename) . '/' . basename($type) . '.ini';
         } else {
             $paths[] = DATAFACE_PATH . '/' . basename($type) . '.ini';
             $lpaths[] = DATAFACE_SITE_PATH . '/' . basename($type) . '.ini';
         }
     }
     // Add the ability to override settings in a module.
     // Added Feb. 28, 2007 by Steve Hannah for version 0.6.14
     if (isset($app->_conf['_modules']) and count($app->_conf['_modules']) > 0) {
         foreach ($app->_conf['_modules'] as $classname => $path) {
             $modpath = explode('_', $classname);
             array_shift($modpath);
             $modname = implode('_', $modpath);
             if ($type == 'lang') {
                 $paths[] = DATAFACE_SITE_PATH . '/modules/' . basename($modname) . '/lang/' . basename($app->_conf['lang']) . '.ini';
                 $paths[] = DATAFACE_PATH . '/modules/' . basename($modname) . '/lang/' . basename($app->_conf['lang']) . '.ini';
             } else {
                 $paths[] = DATAFACE_SITE_PATH . '/modules/' . basename($modname) . '/' . basename($type) . '.ini';
                 $paths[] = DATAFACE_PATH . '/modules/' . basename($modname) . '/' . basename($type) . '.ini';
             }
         }
     }
     // Add the ability to override settings in the database.
     // Added Feb. 27, 2007 by Steve Hannah for version 0.6.14
     if (@$app->_conf['enable_db_config'] and $type != 'permissions') {
         if ($type == 'lang') {
             if (isset($tablename)) {
                 $lpaths[] = 'db:tables/' . basename($tablename) . '/lang/' . basename($app->_conf['lang']);
             } else {
                 $paths[] = 'db:lang/' . basename($app->_conf['lang']) . '.ini';
             }
         } else {
             if (isset($tablename)) {
                 $paths[] = 'db:' . basename($type) . '.ini';
                 $lpaths[] = 'db:tables/' . basename($tablename) . '/' . basename($type) . '.ini';
             } else {
                 $paths[] = 'db:' . basename($type) . '.ini';
             }
         }
     }
     if (!$tablename) {
         $tablename = '__global__';
     }
     $paths = array_merge($paths, $lpaths);
     //print_r($paths);
     //print_r($lpaths);
     if (!isset($this->config[$type][$tablename])) {
         $this->config[$type][$tablename] = array();
     }
     //import('Config.php');
     foreach ($paths as $path) {
         if (!isset($this->iniLoaded[$path])) {
             $this->iniLoaded[$path] = true;
             if (is_readable($path) || strstr($path, 'db:') == $path) {
                 $config = $this->parse_ini_file($path, true);
                 if (isset($config['charset']) and function_exists('iconv')) {
                     I18Nv2::recursiveIconv($config, $config['charset'], 'UTF-8');
                 }
                 if (isset($config['__extends__'])) {
                     $config = array_merge_recursive_unique($this->loadConfigFromINI($type, $config['__extends__']), $config);
                 }
                 $this->rawConfig[$path] =& $config;
             } else {
                 $config = array();
                 $this->rawConfig[$path] =& $config;
             }
         } else {
             //echo "getting $path from raw config.";
             //echo "$path already loaded:".implode(',', array_keys($this->iniLoaded));
             $config =& $this->rawConfig[$path];
         }
         //echo "Conf for x".$path."x: ";
         if (!$config) {
             $config = array();
         }
         foreach (array_keys($config) as $entry) {
             if ($type == 'lang') {
                 $this->config[$type][$app->_conf['lang']][$tablename][$entry] =& $config[$entry];
             } else {
                 $sep = null;
                 if (strpos($entry, '>') !== false) {
                     $sep = '>';
                 }
                 if (strpos($entry, ' extends ') !== false) {
                     $sep = ' extends ';
                 }
                 if ($sep and is_array($config[$entry])) {
                     list($newentry, $entryParents) = explode($sep, $entry);
                     $entryParents = array_map('trim', explode(',', $entryParents));
                     $newentry = trim($newentry);
                     $cout = array();
                     foreach ($entryParents as $entryParent) {
                         if (!isset($this->config[$type][$tablename][$entryParent])) {
                             throw new Exception("Illegal extends.  Parent not found: " . $entryParent . " from rule: " . $entry . " in " . $path);
                         }
                         $pconf =& $this->config[$type][$tablename][$entryParent];
                         if (!is_array($pconf)) {
                             throw new Exception("Illegal extends.  Parent is not a section. It is a scalar: " . $entryParent . " from rule: " . $entry . " in " . $path);
                         }
                         foreach ($pconf as $pkey => $pval) {
                             $cout[$pkey] = $pval;
                         }
                         unset($pconf);
                     }
                     $centry =& $config[$entry];
                     foreach ($centry as $ckey => $cval) {
                         $cout[$ckey] = $cval;
                     }
                     unset($centry);
                     unset($this->config[$type][$tablename][$entry]);
                     unset($this->config[$type][$tablename][$newentry]);
                     $this->config[$type][$tablename][$newentry] =& $cout;
                     unset($cout);
                     //$this->config[$type][$tablename][trim($newentry)] = array_merge($this->config[$type][$tablename][trim($entryParent)],$config[$entry]);
                 } else {
                     $this->config[$type][$tablename][$entry] =& $config[$entry];
                 }
             }
         }
         unset($config);
     }
     // New in 2.1.  We load user config if it is available to override the
     // built-in config
     $user_config = $this->userConfig;
     $upaths = array();
     if ($type == 'lang') {
         $upaths[] = 'lang/' . $app->_conf['lang'] . '.ini';
         $upaths[] = 'tables/' . $tablename . '/lang/' . $app->_conf['lang'] . '.ini';
     } else {
         $upaths[] = $type . '.ini';
         $upaths[] = 'tables/' . $tablename . '/' . $type . '.ini';
     }
     foreach ($upaths as $p) {
         if (isset($user_config->{$p})) {
             if ($type == 'lang') {
                 $this->config[$type][$app->_conf['lang']][$tablename] = array_merge_recursive_unique($this->config[$type][$app->_conf['lang']][$tablename], $this->objectToArray($user_config->{$p}));
             } else {
                 $this->config[$type][$tablename] = array_merge_recursive_unique($this->config[$type][$tablename], $this->objectToArray($user_config->{$p}));
             }
         }
     }
     if ($type == 'lang') {
         return $this->config[$type][$app->_conf['lang']][$tablename];
     } else {
         return $this->config[$type][$tablename];
     }
 }
コード例 #19
0
ファイル: Book.php プロジェクト: shupp/toasterdoc
 /**
  * setLocale 
  * 
  * Set Locate info using I18Nv2_Negotiator
  * 
  * @access protected
  * @return void
  */
 protected function setLocale()
 {
     $neg =& new I18Nv2_Negotiator();
     I18Nv2::setLocale($neg->getLocaleMatch());
     bindtextdomain("messages", "./locale");
     bind_textdomain_codeset("messages", 'UTF-8');
     textdomain("messages");
 }