本文整理匯總了PHP中Tinebase_Core::getLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tinebase_Core::getLocale方法的具體用法?PHP Tinebase_Core::getLocale怎麽用?PHP Tinebase_Core::getLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tinebase_Core
的用法示例。
在下文中一共展示了Tinebase_Core::getLocale方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getWeekStart
/**
* returns weekstart in iCal day format
*
* @param string $locale
* @return string
*/
public static function getWeekStart($locale = NULL)
{
$locale = $locale ?: Tinebase_Core::getLocale();
$weekInfo = Zend_Locale::getTranslationList('week', $locale);
if (!isset($weekInfo['firstDay'])) {
$weekInfo['firstDay'] = 'mon';
}
return Tinebase_Helper::array_value($weekInfo['firstDay'], array_flip(self::$WEEKDAY_MAP));
}
示例2: _getFirstDayOfWeek
/**
* returns number of the first day of the week (0 = sunday or 1 = monday) depending on locale
*
* @return integer
*/
protected function _getFirstDayOfWeek()
{
$locale = Tinebase_Core::getLocale();
$weekInfo = Zend_Locale_Data::getList($locale, 'week');
if (!isset($weekInfo['firstDay'])) {
$result = 1;
} else {
$result = $weekInfo['firstDay'] === 'sun' ? 0 : 1;
}
return $result;
}
示例3: time
/**
* Tine 2.0 main view
*
* @package Tinebase
* @subpackage Views
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Philipp Schuele <p.schuele@metaways.de>
* @copyright Copyright (c) 2010 Metaways Infosystems GmbH (http://www.metaways.de)
*
* @todo check if build script puts the translation files in build dir $tineBuildPath
*/
echo "<!-- Tine 2.0 static files -->\n";
// this variable gets replaced by the buildscript
$tineBuildPath = '';
$locale = Tinebase_Core::isRegistered(Tinebase_Core::LOCALE) ? Tinebase_Core::getLocale() : 'en';
switch (TINE20_BUILDTYPE) {
case 'DEVELOPMENT':
echo $this->jsb2tk->getHTML();
echo ' <script type="text/javascript" src="index.php?method=Tinebase.getJsTranslations&' . time() . '"></script>';
break;
case 'DEBUG':
case 'RELEASE':
echo "\n <link rel='stylesheet' type='text/css' href='index.php?method=Tinebase.getCssFiles' />";
echo "\n <script type=\"text/javascript\" src=\"index.php?method=Tinebase.getJsFiles\"></script>";
echo "\n <script type=\"text/javascript\" src=\"index.php?method=Tinebase.getJsTranslations\"></script>";
break;
}
if (Tinebase_Core::getConfig()->customMainscreenHeaders) {
echo "\n" . Tinebase_Core::getConfig()->customMainscreenHeaders;
}
示例4: _getFilesToWatch
/**
* @param string $_fileType
* @return array
*/
protected function _getFilesToWatch($_fileType)
{
$requiredApplications = array('Tinebase', 'Admin', 'Addressbook');
$enabledApplications = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->name;
$orderedApplications = array_merge($requiredApplications, array_diff($enabledApplications, $requiredApplications));
foreach ($orderedApplications as $application) {
switch ($_fileType) {
case 'css':
$filesToWatch[] = "{$application}/css/{$application}-FAT.css.inc";
break;
case 'js':
$filesToWatch[] = "{$application}/js/{$application}-FAT" . (TINE20_BUILDTYPE == 'DEBUG' ? '-debug' : null) . '.js.inc';
break;
case 'lang':
$fileName = "{$application}/js/{$application}-lang-" . Tinebase_Core::getLocale() . (TINE20_BUILDTYPE == 'DEBUG' ? '-debug' : null) . '.js';
$lang = Tinebase_Core::getLocale();
$customPath = Tinebase_Config::getInstance()->translations;
$basePath = is_readable("{$customPath}/{$lang}/{$fileName}") ? "{$customPath}/{$lang}" : '.';
$filesToWatch[] = "{$basePath}/{$application}/js/{$application}-lang-" . Tinebase_Core::getLocale() . (TINE20_BUILDTYPE == 'DEBUG' ? '-debug' : null) . '.js';
break;
default:
throw new Exception('no such fileType');
break;
}
}
return $filesToWatch;
}
示例5: testGetAllRegistryData
/**
* test get all registry data
*
* @return void
*
* @see 0007934: change pw button active even if it is not allowed
* @see 0008310: apps should be sorted the other way round in menu
* @see 0009130: Can't open login page on Ubuntu "due to a temporary overloading"
* @see 0012188: add copyOmitFields to modelconfig
*/
public function testGetAllRegistryData()
{
$registryData = $this->_instance->getAllRegistryData();
$currentUser = Tinebase_Core::getUser();
$this->assertEquals($currentUser->toArray(), $registryData['Tinebase']['currentAccount']);
$this->assertEquals(Addressbook_Controller_Contact::getInstance()->getContactByUserId($currentUser->getId())->toArray(), $registryData['Tinebase']['userContact']);
$this->assertEquals(TRUE, $registryData['Tinebase']['config']['changepw']['value'], 'changepw should be TRUE');
Tinebase_Config::getInstance()->set('changepw', 0);
$registryData = $this->_instance->getAllRegistryData();
$changepwValue = $registryData['Tinebase']['config']['changepw']['value'];
$this->assertEquals(FALSE, $changepwValue, 'changepw should be (bool) false');
$this->assertTrue(is_bool($changepwValue), 'changepw should be (bool) false: ' . var_export($changepwValue, TRUE));
$userApps = $registryData['Tinebase']['userApplications'];
$this->assertEquals('Admin', $userApps[0]['name'], 'first app should be Admin: ' . print_r($userApps, TRUE));
$locale = Tinebase_Core::getLocale();
$symbols = Zend_Locale::getTranslationList('symbols', $locale);
$this->assertEquals($symbols['decimal'], $registryData['Tinebase']['decimalSeparator']);
if (Sales_Config::getInstance()->featureEnabled(Sales_Config::FEATURE_INVOICES_MODULE)) {
$configuredSalesModels = array_keys($registryData['Sales']['models']);
$this->assertTrue(in_array('Invoice', $configuredSalesModels), 'Invoices is missing from configured models: ' . print_r($configuredSalesModels, true));
}
$this->assertTrue(isset($registryData['Timetracker']['models']['Timeaccount']['copyOmitFields']), 'Timeaccount copyOmitFields empty/missing');
$this->assertEquals(array('billed_in', 'invoice_id', 'status', 'cleared_at'), $registryData['Timetracker']['models']['Timeaccount']['copyOmitFields']);
}
示例6: _dateFilterTest
/**
* date filter test helper
*
* @param string $_type weekThis|inweek|monthLast
*/
protected function _dateFilterTest($_type = 'weekThis')
{
$oldLocale = Tinebase_Core::getLocale();
Tinebase_Core::set(Tinebase_Core::LOCALE, new Zend_Locale('en_US'));
// date is last/this sunday (1. day of week in the US)
$today = Tinebase_DateTime::now();
$dayOfWeek = $today->get('w');
$lastSunday = $today->subDay($dayOfWeek);
$this->_createTsAndSearch($lastSunday, $_type);
// change locale to de_DE -> timesheet should no longer be found because monday is the first day of the week
Tinebase_Core::set(Tinebase_Core::LOCALE, new Zend_Locale('de_DE'));
$search = $this->_json->searchTimesheets($this->_getTimesheetDateFilter($_type), $this->_getPaging());
// if today is sunday -> ts should be found in german locale!
$this->assertEquals($dayOfWeek == 0 ? 1 : 0, $search['totalcount'], 'filter not working in german locale');
Tinebase_Core::set(Tinebase_Core::LOCALE, $oldLocale);
}
示例7: _updateContractsFields
/**
* adds "start_date", "end_date" to contract and removes "status", "cleared", "cleared_in"
*/
protected function _updateContractsFields()
{
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
$groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
if (count($groupMembers) > 0) {
$user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
Tinebase_Core::set(Tinebase_Core::USER, $user);
// cleared, cleared_in, status gets deleted, if the update is not called on cli
$controller = Sales_Controller_Contract::getInstance();
$table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
$count = 50;
$offset = 0;
$more = true;
$updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
$appId = Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId();
$pref = Tinebase_Core::getPreference('Tinebase');
Tinebase_Core::setupUserLocale($pref->locale);
$t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
$config = Sales_Config::getInstance()->get('contractStatus');
foreach ($config['records'] as $cfg) {
$statusConfig[$cfg['id']] = $cfg['value'];
}
$config = Sales_Config::getInstance()->get('contractCleared');
foreach ($config['records'] as $cfg) {
$clearedConfig[$cfg['id']] = $cfg['value'];
}
while ($more) {
$results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
foreach ($results as $row) {
if ($row['status'] == 'CLOSED') {
$setEndDate[$row['id']] = $row['last_modified_time'];
}
$desc = $row['description'];
$desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
$contents = FALSE;
if (!empty($row['status'])) {
$desc .= $t->_('Status') . ': ';
$desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared'])) {
$desc .= $t->_('Cleared') . ': ';
$desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared_in'])) {
$desc .= $t->_('Cleared In') . ': ';
$desc .= $row['cleared_in'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if ($contents) {
$updateDescription[$row['id']] = $desc . PHP_EOL;
}
}
if (count($updateDescription) > 50) {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
$updateDescription = array();
}
if (count($results) < $count) {
$more = FALSE;
} else {
$offset = $offset + $count;
}
}
try {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
} catch (Tinebase_Exception_AccessDenied $tead) {
// could not update contracts ...
Tinebase_Exception::log($tead);
}
}
// remove deprecated sales contract fields
foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
try {
$this->_backend->dropCol('sales_contracts', $colToDrop);
} catch (Zend_Db_Statement_Exception $zdse) {
Tinebase_Exception::log($zdse);
}
}
// add new sales contract fields
$fields = array('<field>
<name>start_date</name>
<type>datetime</type>
</field>', '
<field>
<name>end_date</name>
<type>datetime</type>
</field>');
//.........這裏部分代碼省略.........
示例8: _updateContractsWithUser
protected function _updateContractsWithUser($user)
{
Tinebase_Core::set(Tinebase_Core::USER, $user);
// cleared, cleared_in, status gets deleted, if the update is not called on cli
$controller = Sales_Controller_Contract::getInstance();
$table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
$count = 50;
$offset = 0;
$more = true;
$updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
$pref = Tinebase_Core::getPreference('Tinebase');
Tinebase_Core::setupUserLocale($pref->locale);
$t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
$config = Sales_Config::getInstance()->get('contractStatus');
foreach ($config['records'] as $cfg) {
$statusConfig[$cfg['id']] = $cfg['value'];
}
$config = Sales_Config::getInstance()->get('contractCleared');
foreach ($config['records'] as $cfg) {
$clearedConfig[$cfg['id']] = $cfg['value'];
}
while ($more) {
$results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
foreach ($results as $row) {
if ($row['status'] == 'CLOSED') {
$setEndDate[$row['id']] = $row['last_modified_time'];
}
$desc = $row['description'];
$desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
$contents = FALSE;
if (!empty($row['status'])) {
$desc .= $t->_('Status') . ': ';
$desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared'])) {
$desc .= $t->_('Cleared') . ': ';
$desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared_in'])) {
$desc .= $t->_('Cleared In') . ': ';
$desc .= $row['cleared_in'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if ($contents) {
$updateDescription[$row['id']] = $desc . PHP_EOL;
}
}
if (count($updateDescription) > 50) {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
$updateDescription = array();
}
if (count($results) < $count) {
$more = FALSE;
} else {
$offset = $offset + $count;
}
}
try {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
} catch (Tinebase_Exception_AccessDenied $tead) {
// could not update contracts ...
Tinebase_Exception::log($tead);
}
}