本文整理汇总了PHP中timezone_identifiers_list函数的典型用法代码示例。如果您正苦于以下问题:PHP timezone_identifiers_list函数的具体用法?PHP timezone_identifiers_list怎么用?PHP timezone_identifiers_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timezone_identifiers_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Returns a new TimeZone object.
*
* @param StringLiteral $name
*
* @throws InvalidTimeZoneException
*/
public function __construct(StringLiteral $name)
{
if (!in_array($name->toNative(), timezone_identifiers_list())) {
throw new InvalidTimeZoneException($name);
}
$this->name = $name;
}
示例2: __generateTimezoneSelectOptions
static function __generateTimezoneSelectOptions($default_tz)
{
$timezone_identifiers = timezone_identifiers_list();
sort($timezone_identifiers);
$current_continent = "";
$options_list = "";
foreach ($timezone_identifiers as $timezone_identifier) {
list($continent, ) = explode("/", $timezone_identifier, 2);
if (in_array($continent, array("Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"))) {
list(, $city) = explode("/", $timezone_identifier, 2);
if (strlen($current_continent) === 0) {
$options_list .= "<optgroup label=\"" . $continent . "\">";
// Start first continent optgroup
} elseif ($current_continent != $continent) {
$options_list .= "</optgroup><optgroup label=\"" . $continent . "\">";
// End old optgroup and start new continent optgroup
}
$options_list .= "<option" . ($timezone_identifier == $default_tz ? " selected=\"selected\"" : "") . " value=\"" . $timezone_identifier . "\">" . str_replace("_", " ", $city) . "</option>";
//Timezone
}
$current_continent = $continent;
}
$options_list .= "</optgroup>";
// End last continent optgroup
return $options_list;
}
示例3: isValidTimeZone
/**
* Check valid time zone
*
* @param string $time_zone
* @return bool
*/
protected function isValidTimeZone($time_zone)
{
if (in_array($time_zone, timezone_identifiers_list())) {
return true;
}
return false;
}
示例4: getcontent
public function getcontent()
{
$merger = tlocalmerger::i();
$tabs = new tuitabs();
$html = $this->html;
$lang = tlocal::i('options');
$args = targs::i();
foreach ($merger->items as $section => $items) {
$tab = new tuitabs();
$tab->add($lang->files, $html->getinput('editor', $section . '_files', tadminhtml::specchars(implode("\n", $items['files'])), $lang->files));
$tabtext = new tuitabs();
foreach ($items['texts'] as $key => $text) {
$tabtext->add($key, $html->getinput('editor', $section . '_text_' . $key, tadminhtml::specchars($text), $key));
}
$tab->add($lang->text, $tabtext->get());
$tabs->add($section, $tab->get());
}
$tabs->add('HTML', $html->getinput('editor', 'adminhtml_files', tadminhtml::specchars(implode("\n", $merger->html)), $lang->files));
$args->formtitle = $lang->optionslocal;
$args->dateformat = litepublisher::$options->dateformat;
$dirs = tfiler::getdir(litepublisher::$paths->languages);
$args->language = tadminhtml::array2combo(array_combine($dirs, $dirs), litepublisher::$options->language);
$zones = timezone_identifiers_list();
$args->timezone = tadminhtml::array2combo(array_combine($zones, $zones), litepublisher::$options->timezone);
return $html->adminform('[text=dateformat]
[combo=language]
[combo=timezone]' . $tabs->get(), $args);
}
示例5: timezone
/**
* Constructor, given a file to open
*
*
**/
function timezone($file)
{
$this->tz_file = $file;
/* some safe default */
$this->next_update = time() + DAY_IN_SECONDS * 30;
$this->valid_names = timezone_identifiers_list();
}
示例6: __construct
public function __construct(array $options)
{
if (isset($options['value'])) {
if (!isset($options['interval'])) {
$options['interval'] = $options['value'];
}
unset($options['value']);
}
if (!isset($options['interval'])) {
throw new \InvalidArgumentException(sprintf('CronJob exception: Interval not found in @CronJob'));
}
try {
new \DateInterval($options['interval']);
} catch (\Exception $e) {
throw new \InvalidArgumentException(sprintf('CronJob exception: %s', $e->getMessage()));
}
if (!isset($options['start'])) {
$now = new \DateTime();
$options['start'] = $now->format('Y-m-d H:i:s');
}
if (!isset($options['timezone']) || !in_array($options['timezone'], timezone_identifiers_list())) {
$options['timezone'] = date_default_timezone_get();
}
foreach ($options as $key => $value) {
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException(sprintf('CronJob exception: Property "%s" does not exist', $key));
}
$this->{$key} = $value;
}
}
示例7: form_fuseau_horaire
function form_fuseau_horaire($defaut)
{
if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
$all_timezones = timezone_identifiers_list();
$liste_fuseau = array();
$cities = array();
foreach ($all_timezones as $tz) {
$spos = strpos($tz, '/');
if ($spos !== FALSE) {
$continent = substr($tz, 0, $spos);
$city = substr($tz, $spos + 1);
$liste_fuseau[$continent][] = array('tz_name' => $tz, 'city' => $city);
}
if ($tz == 'UTC') {
$liste_fuseau['UTC'][] = array('tz_name' => 'UTC', 'city' => 'UTC');
}
}
$form = '<label>' . $GLOBALS['lang']['pref_fuseau_horaire'] . '</label>' . "\n";
$form .= '<select name="fuseau_horaire">' . "\n";
foreach ($liste_fuseau as $continent => $zone) {
$form .= "\t" . '<optgroup label="' . ucfirst(strtolower($continent)) . '">' . "\n";
foreach ($zone as $fuseau) {
$form .= "\t\t" . '<option value="' . htmlentities($fuseau['tz_name']) . '"';
$form .= $defaut == $fuseau['tz_name'] ? ' selected="selected"' : '';
$timeoffset = date_offset_get(date_create('now', timezone_open($fuseau['tz_name'])));
$formated_toffset = '(UTC' . ($timeoffset < 0 ? '–' : '+') . str2(floor(abs($timeoffset) / 3600)) . ':' . str2(floor(abs($timeoffset) % 3600 / 60)) . ') ';
$form .= '>' . $formated_toffset . ' ' . htmlentities($fuseau['city']) . '</option>' . "\n";
}
$form .= "\t" . '</optgroup>' . "\n";
}
$form .= '</select>' . "\n";
return $form;
}
}
示例8: render
public function render($tpl = null)
{
//authenticate the current user to make sure they are an admin
UsersHelper::authenticateAdmin();
//display toolbar
$this->toolbar = new Toolbar();
$this->toolbar->save();
//document
$document = JFactory::getDocument();
$document->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js");
/* Menu Links **/
$menu = MenuHelper::getMenuModules();
$this->menu = $menu;
//get model
$model = new ConfigModel();
$layout = $this->getLayout();
$model->set("_layout", $layout);
//get config
$config = $model->getConfig();
//generate timezones
$list = timezone_identifiers_list();
$timezones = array();
foreach ($list as $zone) {
$timezones[$zone] = $zone;
}
//view references
$this->imap_found = function_exists('imap_open') ? TRUE : FALSE;
$this->config = $config;
$this->timezones = $timezones;
$this->time_formats = DateHelper::getTimeFormats();
$this->languages = ConfigHelper::getLanguages();
$this->language = ConfigHelper::getLanguage();
//display
return parent::render();
}
示例9: getSql
static function getSql($schema = 'Myisam')
{
if(!Piwik::isTimezoneSupportEnabled())
{
return array();
}
// @see http://bugs.php.net/46111
$timezones = timezone_identifiers_list();
$brokenTZ = array();
foreach ($timezones as $timezone) {
$testDate = "2008-08-19 13:00:00 " . $timezone;
if (!strtotime($testDate)) {
$brokenTZ[] = $timezone;
}
}
$timezoneList = '"'. implode('","', $brokenTZ) . '"';
return array(
'UPDATE '. Piwik_Common::prefixTable('site') .'
SET timezone = "UTC"
WHERE timezone IN ('. $timezoneList .')' => false,
'UPDATE `'. Piwik_Common::prefixTable('option') .'`
SET option_value = "UTC"
WHERE option_name = "SitesManager_DefaultTimezone"
AND option_value IN ('. $timezoneList .')' => false,
);
}
示例10: timezonechoice
function timezonechoice($selectedzone)
{
$all = timezone_identifiers_list();
$i = 0;
foreach ($all as $zone) {
$zone = explode('/', $zone);
$zonen[$i]['continent'] = $zone[0];
$zonen[$i]['city'] = $zone[1];
$i++;
}
asort($zonen);
foreach ($zonen as $zone) {
extract($zone);
if ($continent == 'Africa' or $continent == 'America' or $continent == 'Antarctica' or $continent == 'Arctic' or $continent == 'Asia' or $continent == 'Atlantic' or $continent == 'Australia' or $continent == 'Europe' or $continent == 'Indian' or $continent == 'Pacific') {
if (!isset($letztercontinent)) {
$structure .= '
<optgroup label="' . $continent . '">';
} elseif ($letztercontinent != $continent) {
$structure .= '</optgroup>
<optgroup label="' . $continent . '">';
}
// continent
if ($city != '') {
$structure .= "\r\n<option " . ($continent . '/' . $city == $selectedzone ? 'selected="selected "' : '') . " value=\"" . ($continent . '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>";
} else {
$structure .= "\r\n<option " . ($continent == $selectedzone ? 'selected="selected "' : '') . " value=\"" . $continent . "\">" . $continent . "</option>";
}
//Timezone
$letztercontinent = $continent;
}
}
$structure .= '
</optgroup>';
return $structure;
}
示例11: form
public function form()
{
$timezoneList = timezone_identifiers_list();
sort($timezoneList);
$timezoneList = array_combine($timezoneList, $timezoneList);
return array('elements' => array('login' => array('type' => 'text'), 'displayname' => array('type' => 'text'), 'email' => array('type' => 'text'), 'password' => array('type' => 'password', 'value' => '', 'hint' => !Yii::app()->user->isGuest ? Yii::t('cms', 'Enter your password only if you want to replace it') : ''), 'password_repeat' => array('type' => 'password'), 'active' => array('type' => 'checkbox'), 'captcha' => array('type' => 'text', 'label' => Yii::t('cms', 'Verify code') . Yii::app()->controller->widget("CCaptcha", array('captchaAction' => 'site/captcha', 'clickableImage' => true), true), 'hint' => Yii::t('cms', 'Enter the symbols from the image')), 'agreed' => array('type' => 'radio'), 'askfill' => array('type' => 'checkbox'), 'show_email' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'send_message' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'timezone' => array('type' => 'dropdownlist', 'items' => $timezoneList), 'extra_fields' => array('type' => 'Fields', 'config' => User::extraFields()), '_roles' => array('type' => 'Select2', 'related' => '_roles', 'showAttribute' => 'title')));
}
示例12: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$timeZones = array();
array_walk(timezone_identifiers_list(), function ($timeZone) use(&$timeZones) {
$timeZoneGroup = strpos($timeZone, '/') !== false ? substr($timeZone, 0, strpos($timeZone, '/')) : $timeZone;
$value = strpos($timeZone, '/') !== false ? substr($timeZone, strpos($timeZone, '/') + 1) : $timeZone;
$value = str_replace('_', ' ', $value);
$value = str_replace('/', ' - ', $value);
$timeZones[$timeZoneGroup][$timeZone] = $value;
});
$availableCacheEngines = $options['cacheService']->getAvailableCacheEngines();
$availableTemplateCacheHandlers = \CampTemplateCache::availableHandlers();
$cacheEngines = array();
$cacheTemplate = array();
foreach ($availableCacheEngines as $cacheEngineName => $engineValue) {
$cacheEngines[$engineValue] = $cacheEngineName;
}
foreach ($availableTemplateCacheHandlers as $handler => $value) {
$cacheTemplate[$handler] = $handler;
}
$cacheLifetime = array();
foreach (array(0 => 'newscoop.preferences.label.disabled', 30 => '30 Seconds', 60 => '1 Minute', 300 => '5 Minutes', 900 => '15 Minutes', 1800 => '30 Minutes', 3600 => '1 Hour', 3600 * 24 => '1 Day', 3600 * 24 * 2 => '2 Days', 3600 * 24 * 3 => '3 Days', 3600 * 24 * 4 => '4 Days', 3600 * 24 * 5 => '5 Days', 3600 * 24 * 6 => '6 Days', 3600 * 24 * 7 => '1 Week', 3600 * 24 * 14 => '2 Weeks', 3600 * 24 * 21 => '3 Weeks', 3600 * 24 * 31 => '1 Month', 3600 * 24 * 61 => '2 Months', 3600 * 24 * 91 => '3 Months', 3600 * 24 * 183 => '6 Months', 3600 * 24 * 365 => '1 Year', -1 => 'Infinite') as $k => $v) {
$cacheLifetime[$k] = $v;
}
$language_codes_639_1 = \Language::Get6391List();
asort($language_codes_639_1);
$languages = array();
foreach ($language_codes_639_1 as $geo_lang_code => $geo_lang_name) {
$languages[$geo_lang_code] = $geo_lang_name;
}
$builder->add('siteonline', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('title', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('meta_keywords', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('meta_description', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('timezone', 'choice', array('choices' => $timeZones, 'placeholder' => 'newscoop.preferences.label.disabled', 'required' => false))->add('cache_engine', 'choice', array('choices' => $cacheEngines, 'placeholder' => 'Array', 'required' => false))->add('cache_engine_host', 'text', array('error_bubbling' => true, 'required' => false))->add('cache_engine_port', 'text', array('error_bubbling' => true, 'required' => false))->add('cache_template', 'choice', array('choices' => $cacheTemplate, 'placeholder' => 'newscoop.preferences.label.disabled', 'required' => false))->add('cache_image', 'choice', array('choices' => $cacheLifetime, 'constraints' => array(new Assert\NotBlank())))->add('allow_recovery', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('secret_key', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\Length(array('max' => 32)))))->add('session_lifetime', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 86400)))))->add('separator', null, array('attr' => array('size' => '5'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 2)))))->add('captcha', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 99)))))->add('max_upload_size', null, array('attr' => array('size' => '5'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 12)))))->add('automatic_collection', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('smtp_host', null, array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('smtp_port', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 999999)))))->add('email_from', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Email(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('image_ratio', 'integer', array('attr' => array('max' => 100, 'min' => 1), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 100)))))->add('image_width', 'integer', array('constraints' => array(new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('image_height', 'integer', array('constraints' => array(new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('zoom', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('mediaRichTextCaptions', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('mediaCaptionLength', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('use_replication', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('use_replication_host', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 60)))))->add('use_replication_user', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 20)))))->add('use_replication_password', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 20)))))->add('use_replication_port', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('template_filter', 'text', array('attr' => array('size' => 30), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 50)))))->add('mysql_client_command_path', 'text', array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('center_latitude_default', 'number', array('attr' => array('size' => 10), 'precision' => 6, 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'float')))))->add('center_longitude_default', 'number', array('attr' => array('size' => 10), 'precision' => 6, 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'float')))))->add('map_display_resolution_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 99)))))->add('map_view_width_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_view_height_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_auto_cSS_file', null, array('attr' => array('size' => 50), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 80)))))->add('map_auto_focus_default', 'checkbox')->add('map_auto_focus_max_zoom', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 18)))))->add('map_auto_focus_border', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => -99, 'max' => 999)))))->add('map_provider_available_google_v3', 'checkbox')->add('map_provider_available_map_quest', 'checkbox')->add('map_provider_available_oSM', 'checkbox')->add('map_provider_default', 'choice', array('choices' => array('GoogleV3' => 'Google Maps', 'MapQuest' => 'MapQuest Open', 'OSM' => 'OpenStreetMap'), 'constraints' => array(new Assert\NotBlank())))->add('geo_search_local_geonames', 'checkbox', array('required' => false))->add('geo_search_mapquest_nominatim', 'checkbox', array('required' => false))->add('geo_search_preferred_language', 'choice', array('choices' => $languages, 'constraints' => array(new Assert\NotBlank())))->add('map_marker_directory', null, array('attr' => array('size' => 50), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 80)))))->add('map_marker_source_default', null, array())->add('map_popup_width_min', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_popup_height_min', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_you_tube', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_you_tube', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_vimeo', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_vimeo', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_flash', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_flash', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('geo_flash_server', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 80)))))->add('geo_flash_directory', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('facebook_appid', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('facebook_appsecret', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaPublicKey', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaPrivateKey', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaSecure', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'data' => 'N', 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('userGarbageActive', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('userGarbageDays', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 999)))))->add('smartyUseProtocol', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('cronJobNotificationEmail', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Email(), new Assert\Length(array('max' => 255)))))->add('cronJobSmtpSender', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\Email(), new Assert\Length(array('max' => 255)))))->add('cronJobSmtpSenderName', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\Length(array('max' => 100)))));
}
示例13: user_settings_submit
function user_settings_submit()
{
global $phpcid, $vars, $phpcdb, $phpc_user_tz, $phpc_user_lang, $phpc_prefix, $phpc_user, $phpc_script;
verify_token();
// If we have a timezone, make sure it's valid
if (!empty($vars["timezone"]) && !in_array($vars['timezone'], timezone_identifiers_list())) {
soft_error(__("Invalid timezone."));
}
// Expire 20 years in the future, give or take.
$expiration_time = time() + 20 * 365 * 24 * 60 * 60;
// One hour in the past
$past_time = time() - 3600;
if (!empty($vars["timezone"])) {
setcookie("{$phpc_prefix}tz", $vars['timezone'], $expiration_time);
} else {
setcookie("{$phpc_prefix}tz", '', $past_time);
}
if (!empty($vars["language"])) {
setcookie("{$phpc_prefix}lang", $vars['language'], $expiration_time);
} else {
setcookie("{$phpc_prefix}lang", '', $past_time);
}
if (is_user()) {
$uid = $phpc_user->get_uid();
$phpcdb->set_user_default_cid($uid, $vars['default_cid']);
$phpcdb->set_timezone($uid, $vars['timezone']);
$phpcdb->set_language($uid, $vars['language']);
$phpc_user_tz = $vars["timezone"];
$phpc_user_lang = $vars["language"];
}
return message_redirect(__('Settings updated.'), "{$phpc_script}?action=user_settings&phpcid={$phpcid}");
}
示例14: getFromList
public function getFromList(&$list)
{
//$list = array();
if (!function_exists("timezone_identifiers_list")) {
return;
}
$zones = timezone_identifiers_list();
foreach ($zones as $zone) {
$zone = explode('/', $zone);
// 0 => Continent, 1 => City
// Only use "friendly" continent names
if ($zone[0] == 'Africa' || $zone[0] == 'America' || $zone[0] == 'Antarctica' || $zone[0] == 'Arctic' || $zone[0] == 'Asia' || $zone[0] == 'Atlantic' || $zone[0] == 'Australia' || $zone[0] == 'Europe' || $zone[0] == 'Indian' || $zone[0] == 'Pacific') {
if (isset($zone[1]) != '') {
$locations[$zone[0]][$zone[0] . '/' . $zone[1]] = str_replace('_', ' ', $zone[1]);
// Creates array(DateTimeZone => 'Friendly name')
}
}
}
$continent = $this->getContinent();
if ($continent) {
$continent_list = $locations[$continent];
} else {
$continent_list = $locations['Africa'];
}
foreach ($continent_list as $name => $value) {
array_push($list, array("val" => $name, "txt" => $name, "pic" => ""));
}
//return $list;
}
示例15: getDatabaseObject
/**
* Returns the database object.
*
* If none was created before, or if {link $newInstance} is true,
* creates a new database object first.
* In case of an error, the reference argument $errorMsg is set
* to the error message.
* @author Comvation Development Team <info@comvation.com>
* @access public
* @version 1.0.0
* @param string $errorMsg Error message
* @param boolean $newInstance Force new instance
* @global array Language array
* @global array Database configuration
* @global integer ADODB fetch mode
* @return boolean True on success, false on failure
*/
function getDatabaseObject(&$errorMsg, $newInstance = false)
{
global $_DBCONFIG, $ADODB_FETCH_MODE, $_CONFIG;
static $objDatabase;
if (is_object($objDatabase) && !$newInstance) {
return $objDatabase;
} else {
// open db connection
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$objDb = ADONewConnection($_DBCONFIG['dbType']);
@$objDb->Connect($_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], $_DBCONFIG['database']);
$errorNo = $objDb->ErrorNo();
if ($errorNo != 0) {
if ($errorNo == 1049) {
$errorMsg = 'The database is unavailable';
} else {
$errorMsg = $objDb->ErrorMsg() . "<br />";
}
unset($objDb);
return false;
}
if (!empty($_CONFIG['timezone'])) {
if (!$objDb->Execute('SET TIME_ZONE="' . $_CONFIG['timezone'] . '"') && array_search($_CONFIG['timezone'], timezone_identifiers_list())) {
//calculate and set the timezone offset if the mysql timezone tables aren't loaded
$objDateTimeZone = new DateTimeZone($_CONFIG['timezone']);
$objDateTime = new DateTime('now', $objDateTimeZone);
$offset = $objDateTimeZone->getOffset($objDateTime);
$offsetHours = round(abs($offset) / 3600);
$offsetMinutes = round((abs($offset) - $offsetHours * 3600) / 60);
$offsetString = ($offset > 0 ? '+' : '-') . ($offsetHours < 10 ? '0' : '') . $offsetHours . ':' . ($offsetMinutes < 10 ? '0' : '') . $offsetMinutes;
$objDb->Execute('SET TIME_ZONE="' . $offsetString . '"');
}
}
// Disable STRICT_TRANS_TABLES mode:
$res = $objDb->Execute('SELECT @@sql_mode');
if ($res->EOF) {
$errorMsg = 'Database mode error';
return;
}
$sqlModes = explode(',', $res->fields['@@sql_mode']);
array_walk($sqlModes, 'trim');
if (($index = array_search('STRICT_TRANS_TABLES', $sqlModes)) !== false) {
unset($sqlModes[$index]);
}
$objDb->Execute('SET sql_mode = \'' . implode(',', $sqlModes) . '\'');
if (empty($_DBCONFIG['charset']) || $objDb->Execute('SET NAMES ' . $_DBCONFIG['charset']) && $objDb) {
if ($newInstance) {
return $objDb;
} else {
$objDatabase = $objDb;
return $objDb;
}
} else {
$errorMsg = 'Cannot connect to database server<i> (' . $objDb->ErrorMsg() . ')</i>';
unset($objDb);
}
return false;
}
}