当前位置: 首页>>代码示例>>PHP>>正文


PHP TTi18n::setLocale方法代码示例

本文整理汇总了PHP中TTi18n::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP TTi18n::setLocale方法的具体用法?PHP TTi18n::setLocale怎么用?PHP TTi18n::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TTi18n的用法示例。


在下文中一共展示了TTi18n::setLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SystemSettingListFactory

 if (TTi18n::getLocaleCookie() != '' and $current_user_prefs->getLanguage() !== TTi18n::getLanguageFromLocale(TTi18n::getLocaleCookie())) {
     Debug::text('Changing User Preference Language to match cookie...', __FILE__, __LINE__, __METHOD__, 10);
     $current_user_prefs->setLanguage(TTi18n::getLanguageFromLocale(TTi18n::getLocaleCookie()));
     if ($current_user_prefs->isValid()) {
         $current_user_prefs->Save(FALSE);
     }
 } else {
     Debug::text('User Preference Language matches cookie!', __FILE__, __LINE__, __METHOD__, 10);
 }
 if (isset($_GET['language']) and $_GET['language'] != '') {
     TTi18n::setLocale($_GET['language']);
     //Sets master locale
 } else {
     TTi18n::setLanguage($current_user_prefs->getLanguage());
     TTi18n::setCountry($current_user->getCountry());
     TTi18n::setLocale();
     //Sets master locale
 }
 $profiler->stopTimer("setLocale()");
 if ($current_user->isInformationComplete() == TRUE and $current_user_prefs->isPreferencesComplete() == FALSE and (!stristr($_SERVER['SCRIPT_NAME'], 'permissiondenied') and !stristr($_SERVER['SCRIPT_NAME'], 'logout') and !stristr($_SERVER['SCRIPT_NAME'], 'about') and !stristr($_SERVER['SCRIPT_NAME'], 'punch.php') and !stristr($_SERVER['SCRIPT_NAME'], 'ajax_server') and !stristr($_SERVER['SCRIPT_NAME'], 'global.js') and !stristr($_SERVER['SCRIPT_NAME'], 'menu.js')) and !isset($_GET['incomplete']) and !isset($_POST['incomplete']) and ($permission->Check('user_preference', 'enabled') and ($permission->Check('user_preference', 'edit') or $permission->Check('user_preference', 'edit_child') or $permission->Check('user_preference', 'edit_own')))) {
     Redirect::Page(URLBuilder::getURL(array('incomplete' => 1), Environment::GetBaseURL() . 'users/EditUserPreference.php'));
 }
 //Get all system settings, so they can be used even if the user isn't logged in, such as the login page.
 $sslf = new SystemSettingListFactory();
 $system_settings = $sslf->getAllArray();
 unset($sslf);
 //Handle station functionality
 if (isset($_COOKIE['StationID'])) {
     Debug::text('Station ID Cookie found! ' . $_COOKIE['StationID'], __FILE__, __LINE__, __METHOD__, 10);
     $slf = new StationListFactory();
     $slf->getByStationIdandCompanyId($_COOKIE['StationID'], $current_company->getId());
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:31,代码来源:Interface.inc.php

示例2: chooseBestLocale

 /**
  * Determines the most appropriate locale, based on user metadata including
  * the user's saved locale preference (if any), the user's browser lang pref,
  * and the application's default locale. It also allows an override via
  * setting URL param 'ttlang' to a valid locale.
  *
  * Returns the best locale, or false if unable to find and set a locale.
  *
  * @param string|array $user_locale_pref
  * @return string|boolean
  * @author Dan Libby <dan@osc.co.cr>
  */
 public static function chooseBestLocale($user_locale_pref = NULL)
 {
     Debug::text('Choosing Best Locale...', __FILE__, __LINE__, __METHOD__, 10);
     $success = FALSE;
     $category = LC_ALL;
     //LC_MESSAGES isn't defined on Windows.
     // First, we'll check if 'ttlang' url param (override) is specified.
     //Check cookie first, as we want GET/POST to override the cookie, incase of form errors on Login page etc...
     if (TTi18n::getLocaleCookie() != FALSE) {
         Debug::text('Using Language from cookie: ' . TTi18n::getLocaleCookie(), __FILE__, __LINE__, __METHOD__, 10);
         $success = TTi18n::setLocale(TTi18n::getLocaleCookie(), $category);
     }
     if (isset($_GET['language']) and $_GET['language'] != '') {
         Debug::text('Using Language from _GET: ' . $_GET['language'], __FILE__, __LINE__, __METHOD__, 10);
         $success = self::setLocale($_GET['language']);
     }
     if (isset($_POST['language']) and $_POST['language'] != '') {
         Debug::text('Using Language from _POST: ' . $_POST['language'], __FILE__, __LINE__, __METHOD__, 10);
         $success = self::setLocale($_POST['language']);
     }
     if ($success == FALSE) {
         // Check for a user pref first.
         if ($user_locale_pref != '') {
             // Could be an array of preferred locales.
             if (is_array($user_locale_pref)) {
                 foreach ($user_locale_pref as $locale) {
                     Debug::text('aSetting Locale: ' . $user_locale_pref, __FILE__, __LINE__, __METHOD__, 10);
                     if ($success = self::setLocale($locale, $category)) {
                         break;
                     }
                 }
             } else {
                 Debug::text('bSetting Locale: ' . $user_locale_pref, __FILE__, __LINE__, __METHOD__, 10);
                 // or a single locale
                 $success = self::setLocale($user_locale_pref, $category);
             }
         }
     }
     // Otherwise, check for lang prefs from the browser
     if ($success == FALSE) {
         // browser can specify more than one, so we get an array.
         $browser_lang_prefs = self::getBrowserLanguage();
         foreach ($browser_lang_prefs as $locale) {
             //The country code needs to be upper case for locales to work correctly.
             if (strpos($locale, '_') !== FALSE) {
                 $split_locale = explode('_', $locale);
                 if (isset($split_locale[1])) {
                     $locale = $split_locale[0] . '_' . strtoupper($split_locale[1]);
                 }
             }
             Debug::text('cSetting Locale: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
             if ($success = self::setLocale($locale, $category)) {
                 break;
             }
         }
     }
     if ($success == FALSE) {
         global $config_vars;
         //Use system locale if its set from timetrex.ini.php
         if (isset($config_vars['other']['system_locale']) and $config_vars['other']['system_locale'] != '') {
             Debug::text('Using system locale from .ini: ' . $config_vars['other']['system_locale'], __FILE__, __LINE__, __METHOD__, 10);
             $success = self::setLocale($config_vars['other']['system_locale'], $category);
         }
     }
     // If it worked, then we save this for future reference.
     if ($success !== FALSE) {
         Debug::text('Using Locale: ' . self::getLocale(), __FILE__, __LINE__, __METHOD__, 10);
     } else {
         Debug::text('Unable to find and set a locale.', __FILE__, __LINE__, __METHOD__, 10);
     }
     return TRUE;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:84,代码来源:TTi18n.class.php

示例3: getLocale

 function getLocale($language = NULL, $country = NULL)
 {
     $language = Misc::trimSortPrefix($language);
     if ($language == '' and is_object($this->getCurrentUserObject()) and is_object($this->getCurrentUserObject()->getUserPreferenceObject())) {
         $language = $this->getCurrentUserObject()->getUserPreferenceObject()->getLanguage();
     }
     if ($country == '' and is_object($this->getCurrentUserObject())) {
         $country = $this->getCurrentUserObject()->getCountry();
     }
     if ($language != '') {
         TTi18n::setLanguage($language);
     }
     if ($country != '') {
         TTi18n::setCountry($country);
     }
     TTi18n::setLocale();
     //Sets master locale
     $retval = str_replace('.UTF-8', '', TTi18n::getLocale());
     Debug::text('Locale: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     return $retval;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:21,代码来源:APIAuthentication.class.php

示例4: getPayStub

 function getPayStub($pslf = NULL, $hide_employer_rows = TRUE)
 {
     if (!is_object($pslf) and $this->getId() != '') {
         $pslf = new PayStubListFactory();
         $pslf->getById($this->getId());
     }
     if (get_class($pslf) !== 'PayStubListFactory') {
         return FALSE;
     }
     $border = 0;
     if ($pslf->getRecordCount() > 0) {
         $pdf = new TTPDF('P', 'mm', 'Letter');
         $pdf->setMargins(0, 0);
         //$pdf->SetAutoPageBreak(TRUE, 30);
         $pdf->SetAutoPageBreak(FALSE);
         $pdf->SetFont('freeserif', '', 10);
         //$pdf->SetFont('FreeSans','',10);
         $i = 0;
         foreach ($pslf as $pay_stub_obj) {
             $psealf = new PayStubEntryAccountListFactory();
             Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10);
             //Get Pay Period information
             $pplf = new PayPeriodListFactory();
             $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent();
             //Use Pay Stub dates, not Pay Period dates.
             $pp_start_date = $pay_stub_obj->getStartDate();
             $pp_end_date = $pay_stub_obj->getEndDate();
             $pp_transaction_date = $pay_stub_obj->getTransactionDate();
             //Get pay period numbers
             $ppslf = new PayPeriodScheduleListFactory();
             $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent();
             //Get User information
             $ulf = new UserListFactory();
             $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
             //Get company information
             $clf = new CompanyListFactory();
             $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
             //Change locale to users own locale.
             TTi18n::setCountry($user_obj->getCountry());
             TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage());
             TTi18n::setLocale();
             //
             // Pay Stub Header
             //
             $pdf->AddPage();
             $adjust_x = 20;
             $adjust_y = 10;
             //Logo
             $pdf->Image($company_obj->getLogoFileName(), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), 50, 12, '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE);
             //Company name/address
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C');
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C');
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C');
             //Pay Period info
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R');
             $pdf->SetFont('', 'B', 10);
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R');
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y));
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y));
             $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', 0);
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y));
             $pdf->setLineWidth(0.25);
             //Get pay stub entries.
             $pself = new PayStubEntryListFactory();
             $pself->getByPayStubId($pay_stub_obj->getId());
             Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             $prev_type = NULL;
             $description_subscript_counter = 1;
             foreach ($pself as $pay_stub_entry) {
                 Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10);
                 $description_subscript = NULL;
                 $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                 //Use this to put the total for each type at the end of the array.
                 if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                     $type = $pay_stub_entry_name_obj->getType();
                 }
                 //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10);
                 if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) {
                     $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
//.........这里部分代码省略.........
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:101,代码来源:PayStubFactory.class.php

示例5: getPayStub

 function getPayStub($pslf = NULL, $hide_employer_rows = TRUE)
 {
     if (!is_object($pslf) and $this->getId() != '') {
         $pslf = TTnew('PayStubListFactory');
         $pslf->getById($this->getId());
     }
     if (get_class($pslf) !== 'PayStubListFactory') {
         return FALSE;
     }
     $border = 0;
     if ($pslf->getRecordCount() > 0) {
         $pdf = new TTPDF('P', 'mm', 'Letter');
         $pdf->setMargins(0, 0);
         //$pdf->SetAutoPageBreak(TRUE, 30);
         $pdf->SetAutoPageBreak(FALSE);
         $i = 0;
         foreach ($pslf as $pay_stub_obj) {
             $psealf = TTnew('PayStubEntryAccountListFactory');
             //Debug::text($i .'. Pay Stub Transaction Date: '. $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__,10);
             //Get Pay Period information
             $pplf = TTnew('PayPeriodListFactory');
             $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent();
             //Use Pay Stub dates, not Pay Period dates.
             $pp_start_date = $pay_stub_obj->getStartDate();
             $pp_end_date = $pay_stub_obj->getEndDate();
             $pp_transaction_date = $pay_stub_obj->getTransactionDate();
             //Get User information
             $ulf = TTnew('UserListFactory');
             $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
             //Get company information
             $clf = TTnew('CompanyListFactory');
             $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
             //Change locale to users own locale.
             TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage());
             TTi18n::setCountry($user_obj->getCountry());
             TTi18n::setLocale();
             $pdf->SetFont(TTi18n::getPDFDefaultFont($user_obj->getUserPreferenceObject()->getLanguage()), '', 10);
             //
             // Pay Stub Header
             //
             $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
             $pdf->AddPage();
             $adjust_x = 20;
             $adjust_y = 10;
             //Logo
             $pdf->Image($company_obj->getLogoFileName(NULL, TRUE, FALSE, 'large'), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), $pdf->pixelsToUnits(167), $pdf->pixelsToUnits(42), '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE);
             //Company name/address
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C', FALSE, '', 1);
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(6, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C', FALSE, '', 1);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C', FALSE, '', 1);
             //Pay Period info
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R', FALSE, '', 1);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R', FALSE, '', 1);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R', FALSE, '', 1);
             $pdf->SetFont('', 'B', 10);
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R', FALSE, '', 1);
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R', FALSE, '', 1);
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R', FALSE, '', 1);
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y));
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y));
             $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', FALSE, '', 1);
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y));
             $pdf->setLineWidth(0.25);
             //Get pay stub entries.
             $pself = TTnew('PayStubEntryListFactory');
             $pself->getByPayStubId($pay_stub_obj->getId());
             Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             $max_widths = array('units' => 0, 'rate' => 0, 'amount' => 0, 'ytd_amount' => 0);
             $prev_type = NULL;
             $description_subscript_counter = 1;
             foreach ($pself as $pay_stub_entry) {
                 //Debug::text('Pay Stub Entry Account ID: '.$pay_stub_entry->getPayStubEntryNameId()  , __FILE__, __LINE__, __METHOD__,10);
                 $description_subscript = NULL;
                 $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                 //Use this to put the total for each type at the end of the array.
                 if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                     $type = $pay_stub_entry_name_obj->getType();
                 }
                 //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10);
                 if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0 and ($type != 30 or $type == 30 and $hide_employer_rows == FALSE)) {
                     //Make sure PSA descriptions are not shown on employee pay stubs.
                     $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
                     $description_subscript = $description_subscript_counter;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:PayStubFactory.class.php


注:本文中的TTi18n::setLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。