public function testDateFormatCustom() { i18n::set_locale('en_US'); $this->assertEquals('MMM d, y', i18n::get_date_format()); i18n::config()->date_format = 'd/MM/yyyy'; $this->assertEquals('d/MM/yyyy', i18n::get_date_format()); }
function testDateFormatCustom() { i18n::set_locale('en_US'); $this->assertEquals('MM/dd/yyyy', i18n::get_date_format()); i18n::set_date_format('d/MM/yyyy'); $this->assertEquals('d/MM/yyyy', i18n::get_date_format()); }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new TabSet('Root', new Tab('Main', _t('SiteTree.TABMAIN', 'Main'), new TextField('Title', _t('UniadsObject.db_Title', 'Title'))))); if ($this->ID) { $previewLink = Director::absoluteBaseURL() . 'admin/' . UniadsAdmin::config()->url_segment . '/UniadsObject/preview/' . $this->ID; $fields->addFieldToTab('Root.Main', new ReadonlyField('Impressions', _t('UniadsObject.db_Impressions', 'Impressions')), 'Title'); $fields->addFieldToTab('Root.Main', new ReadonlyField('Clicks', _t('UniadsObject.db_Clicks', 'Clicks')), 'Title'); $fields->addFieldsToTab('Root.Main', array(DropdownField::create('CampaignID', _t('UniadsObject.has_one_Campaign', 'Campaign'), DataList::create('UniadsCampaign')->map())->setEmptyString(_t('UniadsObject.Campaign_none', 'none')), DropdownField::create('ZoneID', _t('UniadsObject.has_one_Zone', 'Zone'), DataList::create('UniadsZone')->map())->setEmptyString(_t('UniadsObject.Zone_select', 'select one')), new NumericField('Weight', _t('UniadsObject.db_Weight', 'Weight (controls how often it will be shown relative to others)')), new TextField('TargetURL', _t('UniadsObject.db_TargetURL', 'Target URL')), new Treedropdownfield('InternalPageID', _t('UniadsObject.has_one_InternalPage', 'Internal Page Link'), 'Page'), new CheckboxField('NewWindow', _t('UniadsObject.db_NewWindow', 'Open in a new Window')), $file = new UploadField('File', _t('UniadsObject.has_one_File', 'Advertisement File')), $AdContent = new TextareaField('AdContent', _t('UniadsObject.db_AdContent', 'Advertisement Content')), $Starts = new DateField('Starts', _t('UniadsObject.db_Starts', 'Starts')), $Expires = new DateField('Expires', _t('UniadsObject.db_Expires', 'Expires')), new NumericField('ImpressionLimit', _t('UniadsObject.db_ImpressionLimit', 'Impression Limit')), new CheckboxField('Active', _t('UniadsObject.db_Active', 'Active')), new LiteralField('Preview', '<a href="' . $previewLink . '" target="_blank">' . _t('UniadsObject.Preview', 'Preview this advertisement') . "</a>"))); $app_categories = File::config()->app_categories; $file->setFolderName($this->config()->files_dir); $file->getValidator()->setAllowedMaxFileSize(array('*' => $this->config()->max_file_size)); $file->getValidator()->setAllowedExtensions(array_merge($app_categories['image'], $app_categories['flash'])); $AdContent->setRows(10); $AdContent->setColumns(20); $Starts->setConfig('showcalendar', true); $Starts->setConfig('dateformat', i18n::get_date_format()); $Starts->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('showcalendar', true); $Expires->setConfig('dateformat', i18n::get_date_format()); $Expires->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days'))); } $this->extend('updateCMSFields', $fields); return $fields; }
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) { if (!$this->locale) { $this->locale = i18n::get_locale(); } if (!$this->getConfig('dateformat')) { $this->setConfig('dateformat', i18n::get_date_format()); } parent::__construct($name, $title, $value, $form, $rightTitle); }
public function getCMSFields() { $fields = parent::getCMSFields(); $Starts = $fields->fieldByName('Root.Main.Starts'); $Starts->setConfig('showcalendar', true); $Starts->setConfig('dateformat', i18n::get_date_format()); $Starts->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires = $fields->fieldByName('Root.Main.Expires'); $Expires->setConfig('showcalendar', true); $Expires->setConfig('dateformat', i18n::get_date_format()); $Expires->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days'))); $fields->changeFieldOrder(array('Title', 'ClientID', 'Starts', 'Expires', 'Active')); return $fields; }
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) { if (!$this->locale) { $this->locale = i18n::get_locale(); } if (!$this->getConfig('dateformat')) { $this->setConfig('dateformat', i18n::get_date_format()); } foreach (self::$default_config as $defaultK => $defaultV) { if ($defaultV) { if ($defaultK == 'locale') { $this->locale = $defaultV; } else { $this->setConfig($defaultK, $defaultV); } } } parent::__construct($name, $title, $value, $form, $rightTitle); }
/** * Return the form field. * * @todo Make a jQuery safe form field. The current CalendarDropDown * breaks on the front end. */ public function getFormField() { // scripts for jquery date picker Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.core.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.datepicker.js'); $dateFormat = DateField_View_JQuery::convert_iso_to_jquery_format(i18n::get_date_format()); Requirements::customScript(<<<JS \t\t\t(function(jQuery) { \t\t\t\t\$(document).ready(function() { \t\t\t\t\t\$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({ dateFormat: '{$dateFormat}' }); \t\t\t\t}); \t\t\t})(jQuery); JS , 'UserFormsDate'); // css for jquery date picker Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui-1.8rc3.custom.css'); $default = $this->getSetting('DefaultToToday') ? date('d/m/Y') : $this->Default; return new DateField($this->Name, $this->Title, $default); }
public function __construct($name, $title = null, $value = null) { if (!$this->locale) { $this->locale = i18n::get_locale(); } $this->config = $this->config()->default_config; if (!$this->getConfig('dateformat')) { $this->setConfig('dateformat', i18n::get_date_format()); } foreach ($this->config()->default_config as $defaultK => $defaultV) { if ($defaultV) { if ($defaultK == 'locale') { $this->locale = $defaultV; } else { $this->setConfig($defaultK, $defaultV); } } } parent::__construct($name, $title, $value); }
/** * Override the default getter for DateFormat so the * default format for the user's locale is used * if the user has not defined their own. * * @return string ISO date format */ public function getDateFormat() { if ($this->getField('DateFormat')) { return $this->getField('DateFormat'); } elseif ($this->getField('Locale')) { require_once 'Zend/Date.php'; return Zend_Locale_Format::getDateFormat($this->Locale); } else { return i18n::get_date_format(); } }