From fca9831e6663910075223f77795c3aabf0182a32 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 10 Oct 2012 11:15:55 +1300 Subject: [PATCH 01/11] Remove end php tag from TemplateIteratorProvider --- view/TemplateIteratorProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/view/TemplateIteratorProvider.php b/view/TemplateIteratorProvider.php index cba2cf47e..ef056bded 100644 --- a/view/TemplateIteratorProvider.php +++ b/view/TemplateIteratorProvider.php @@ -45,4 +45,3 @@ interface TemplateIteratorProvider { public function iteratorProperties($pos, $totalItems); } -?> From c99991ba7a43aa14236fd0efc65e39aee591dc2d Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 11 Oct 2012 13:45:54 +1300 Subject: [PATCH 02/11] BUG Dummy Page_Controller initiated during login now is correctly initialised via dependency injection --- security/Security.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/Security.php b/security/Security.php index 573657fe2..71a9fa6d8 100644 --- a/security/Security.php +++ b/security/Security.php @@ -341,7 +341,7 @@ class Security extends Controller { // Disable ID-based caching of the log-in page by making it a random number $tmpPage->ID = -1 * rand(1,10000000); - $controller = new Page_Controller($tmpPage); + $controller = Page_Controller::create($tmpPage); $controller->setDataModel($this->model); $controller->init(); //Controller::$currentController = $controller; @@ -436,7 +436,7 @@ class Security extends Controller { $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password'); $tmpPage->URLSegment = 'Security'; $tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children - $controller = new Page_Controller($tmpPage); + $controller = Page_Controller::create($tmpPage); $controller->init(); } else { $controller = $this; @@ -495,7 +495,7 @@ class Security extends Controller { $tmpPage->Title = _t('Security.LOSTPASSWORDHEADER'); $tmpPage->URLSegment = 'Security'; $tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children - $controller = new Page_Controller($tmpPage); + $controller = Page_Controller::create($tmpPage); $controller->init(); } else { $controller = $this; @@ -553,7 +553,7 @@ class Security extends Controller { $tmpPage->Title = _t('Security.CHANGEPASSWORDHEADER', 'Change your password'); $tmpPage->URLSegment = 'Security'; $tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children - $controller = new Page_Controller($tmpPage); + $controller = Page_Controller::create($tmpPage); $controller->init(); } else { $controller = $this; From 27a7fc34c1a00055e8978f5a9825d72aa97ff0ba Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 11 Oct 2012 15:40:55 +1300 Subject: [PATCH 03/11] Fixing misleading ImageField deprecation message --- forms/ImageField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/ImageField.php b/forms/ImageField.php index 9dd374881..b478d5344 100644 --- a/forms/ImageField.php +++ b/forms/ImageField.php @@ -20,7 +20,7 @@ * $myField->setFolderName('myFolder'); * * - * @deprecated 3.0 Use UploadField with $myField->allowedExtensions = array('jpg', 'gif', 'png') + * @deprecated 3.0 Use UploadField with $myField->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png')); * * @package forms * @subpackage fields-files From bc64de0264f1acf4e33c2029fd3798db4974a511 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 11 Oct 2012 16:58:57 +1300 Subject: [PATCH 04/11] Fixing misleading SimpleImageField deprecation message --- forms/SimpleImageField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forms/SimpleImageField.php b/forms/SimpleImageField.php index 9e2c20dfa..56c4fce38 100644 --- a/forms/SimpleImageField.php +++ b/forms/SimpleImageField.php @@ -64,14 +64,14 @@ */ /** - * @deprecated 3.0 Use UploadField with $myField->allowedExtensions = array('jpg', 'gif', 'png') + * @deprecated 3.0 Use UploadField with $myField->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png')); */ class SimpleImageField extends FileField { public function __construct($name, $title = null, $value = null) { Deprecation::notice('3.0', "SimpleImageField is deprecated. Use UploadField with " - . "\$myField->allowedExtensions = array('jpg', 'gif', 'png')", + . "\$myField->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png'))", Deprecation::SCOPE_CLASS); if(count(func_get_args()) > 3) { From 9bb190813f6c1b23195f616b764ee9e211cdc172 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 11 Oct 2012 17:12:27 +1300 Subject: [PATCH 05/11] Fixing BulkLoader to use increase_time_limit_to() --- dev/BulkLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/BulkLoader.php b/dev/BulkLoader.php index 440fe7fb9..bcd0652e0 100644 --- a/dev/BulkLoader.php +++ b/dev/BulkLoader.php @@ -135,7 +135,7 @@ abstract class BulkLoader extends ViewableData { * @return BulkLoader_Result See {@link self::processAll()} */ public function load($filepath) { - ini_set('max_execution_time', 3600); + increase_time_limit_to(3600); increase_memory_limit_to('512M'); //get all instances of the to be imported data object From 7625d103f021cb6b525f920733780f6cc556c16d Mon Sep 17 00:00:00 2001 From: Juan Molina Date: Thu, 11 Oct 2012 17:06:51 +0300 Subject: [PATCH 06/11] Update docs/en/installation/from-source.md Removed broken links and confusing contributing/collaboration text. --- docs/en/installation/from-source.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/installation/from-source.md b/docs/en/installation/from-source.md index eb0a0db8c..5ac82cac3 100644 --- a/docs/en/installation/from-source.md +++ b/docs/en/installation/from-source.md @@ -148,7 +148,7 @@ Now you need to add the original repository as `upstream`, so you can keep your (cd cms && git remote add upstream git://github.com/silverstripe/silverstripe-cms.git && git fetch upstream) (cd themes/simple && git remote add upstream git://github.com/silverstripe-themes/silverstripe-simple.git) -Now that you're set up, please read our ["Collaboration on Git"](../misc/collaboration-on-git) guide, +Now that you're set up, please read our ["Contributing Code"](../misc/contributing/code) guide, as well as our general ["Contributor guidelines"](../misc/contributing). Please read ["Module installation"](/topics/modules) to find out how to install additional modules like `blog` or `forum` from source. @@ -271,8 +271,8 @@ See [piston.rubyforge.org](http://piston.rubyforge.org/import.html). ## Related ## - * [Contributing: Submitting patches](/misc/contributing) - * [Collaboration on Git](/misc/collaboration-on-git) + * [Contributing](/misc/contributing) + * [Contributing Code](/misc/contributing/code) * [Pro git - free online book](http://progit.org/book/) * [Git cheat sheet - github.com](https://github.com/guides/git-cheat-sheet) * [Git - SVN Crash Course - git.or.cz](http://git.or.cz/course/svn.html) From 6de479cce54b6d1e7f43780a9a561fd4a685ee68 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 11 Oct 2012 17:20:00 +0200 Subject: [PATCH 07/11] Added github-compatible contributing notes --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..485fb7c59 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +# Contributing + +Any open source product is only as good as the community behind it. You can participate by sharing code, ideas, or simply helping others. No matter what your skill level is, every contribution counts. + +See our [high level overview](http://silverstripe.org/contributing-to-silverstripe) on silverstripe.org on how you can help out. + +Or, for more detailed guidance, read one of the following pages: + + * [Sharing your opinion and raising issues](http://doc.silverstripe.org/framework/en/trunk/misc/contributing/issues) + * [Providing code, whether it's creating a feature or fixing a bug](http://doc.silverstripe.org/framework/en/trunk/misc/contributing/code) + * [Writing and translating documentation](http://doc.silverstripe.org/framework/en/trunk/misc/contributing/documentation) + * [Translating user-interface elements](http://doc.silverstripe.org/framework/en/trunk/misc/contributing/translation) \ No newline at end of file From bc345803d558328c13be6b027ab2c6ffc31d7b0a Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 12 Oct 2012 09:57:11 +1300 Subject: [PATCH 08/11] BUG Fixing model not being set before populateDefaults() In cases where a getter on a DataObject calls getComponent() or other relational getter, $this->model won't have been set at this point, and a fatal error is triggered. This fixes it so $this->model is set *before* populateDefaults() in DataObject::__construct() and the getters can operate normally. --- model/DataObject.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/model/DataObject.php b/model/DataObject.php index dc5097249..114808240 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -312,7 +312,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * Singletons don't have their defaults set. */ public function __construct($record = null, $isSingleton = false, $model = null) { - parent::__construct(); // Set the fields data. @@ -366,6 +365,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity HTTP::register_modification_date($record['LastEdited']); } + // this must be called before populateDefaults(), as field getters on a DataObject + // may call getComponent() and others, which rely on $this->model being set. + $this->model = $model ? $model : DataModel::inst(); + // Must be called after parent constructor if(!$isSingleton && (!isset($this->record['ID']) || !$this->record['ID'])) { $this->populateDefaults(); @@ -373,8 +376,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // prevent populateDefaults() and setField() from marking overwritten defaults as changed $this->changed = array(); - - $this->model = $model ? $model : DataModel::inst(); } /** @@ -1303,7 +1304,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if($joinID) { $component = $this->model->$class->byID($joinID); } - + if(!isset($component) || !$component) { $component = $this->model->$class->newObject(); } From 4c35c302d27758b1224a3c6cb67b8c5299431a59 Mon Sep 17 00:00:00 2001 From: Robert Curry Date: Fri, 12 Oct 2012 17:07:42 +1300 Subject: [PATCH 09/11] Exclude test/travis/_config.php from being include in the test manifest. --- tests/travis/_manifest_exclude | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/travis/_manifest_exclude diff --git a/tests/travis/_manifest_exclude b/tests/travis/_manifest_exclude new file mode 100644 index 000000000..e69de29bb From 5186bada17cb87733c7042fcea7a11477a78e707 Mon Sep 17 00:00:00 2001 From: martimiz Date: Tue, 25 Sep 2012 18:05:13 +0200 Subject: [PATCH 10/11] FIX DateField Calendar - make dates with day- and monthnames validate In locales other than en_US, as a result of missing jQuery locale files, the DatePicker defaulted to English whenever day and monthnames were used, breaking validation. Needed to change official locale files before adding, because Zend_Date and jQuery day/monthnames not matching again breaks validation. Removed hard setting the names to uppercase, breaking validation for other locales Changed order in convert_iso_to_jquery_format(), to prevent EEE(E) settings from being overwritten Added a check for existing locale files, and made DatePicker fallback to ISO yyy-MM-dd if a missing locale file would otherwise break validation. Added documentation for the DateField --- docs/en/reference/datefield.md | 131 ++++++++++++++++++ forms/DateField.php | 70 +++++++--- thirdparty/jquery-ui/datepicker/i18n/README | 25 ++++ .../i18n/jquery.ui.datepicker-da.js | 25 ++++ .../i18n/jquery.ui.datepicker-de.js | 25 ++++ .../i18n/jquery.ui.datepicker-en-GB.js | 24 ++++ .../i18n/jquery.ui.datepicker-en.js | 25 ++++ .../i18n/jquery.ui.datepicker-es.js | 27 ++++ .../i18n/jquery.ui.datepicker-fr.js | 24 ++++ .../i18n/jquery.ui.datepicker-nb.js | 24 ++++ .../i18n/jquery.ui.datepicker-nl.js | 26 ++++ .../i18n/jquery.ui.datepicker-sv.js | 24 ++++ 12 files changed, 428 insertions(+), 22 deletions(-) create mode 100644 docs/en/reference/datefield.md create mode 100644 thirdparty/jquery-ui/datepicker/i18n/README create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-da.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-de.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en-GB.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-es.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-fr.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nb.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nl.js create mode 100644 thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-sv.js diff --git a/docs/en/reference/datefield.md b/docs/en/reference/datefield.md new file mode 100644 index 000000000..703244261 --- /dev/null +++ b/docs/en/reference/datefield.md @@ -0,0 +1,131 @@ +# DateField + +## Introduction + +This `FormField` subclass lets you display an editable date, either in +a single text input field, or in three separate fields for day, month and year. +It also provides a calendar datepicker. + +## Adding a DateField + +The following example will add a simple DateField to your Page, allowing you to +enter a date manually. + + :::php + class Page extends SiteTree { + static $db = array( + 'MyDate' => 'Date', + ); + + public function getCMSFields() { + $fields = parent::getCMSFields(); + + $fields->addFieldToTab( + 'Root.Main', + $myDate = new DateField('MyDate', 'Enter a date') + ); + + return $fields; + } + } + +## Custom Dateformat + +You can define a custom dateformat for your Datefield based on [Zend_Date constants](http://framework.zend.com/manual/1.12/en/zend.date.constants.html). + + :::php + // will display a date in the following format: 31-06-2012 + DateField::create('MyDate')->setConfig('dateformat', 'dd-MM-yyyy'); + + +## Min and Max Dates + +Set the minimum and maximum allowed datevalues using the `min` and `max` +configuration settings (in ISO format or strtotime() compatible). Example: + + :::php + DateField::create('MyDate') + ->setConfig('min', '-7 days') + ->setConfig('max', '2012-12-31') + +## Separate Day/Month/Year Fields + +The following setting will display your DateField as `three input fields` for +day, month and year separately. Any custom dateformat settings will be ignored. +HTML5 placeholders 'day', 'month' and 'year' are enabled by default. + + :::php + DateField::create('MyDate') + ->setConfig('dmyfields', true); + ->setConfig('dmyseparator', '/') // set the separator + ->setConfig('dmyplaceholders', 'true'); // enable HTML 5 Placeholders + +## Calendar Field + +The following setting will add a Calendar to a single DateField, using the +`jQuery UI DatePicker widget` + + :::php + DateField::create('MyDate')->setConfig('showcalendar', true); + + +### 'Safe' Dateformats to Use with the Calendar + +The jQuery DatePicker doesn't support every constant available for Zend_Date. +If you choose to use the calendar, the following constants should at least be safe: + +Constant | xxxxx +-------- | ----- +d | numeric day of the month (without leading zero) +dd | numeric day of the month (with leading zero) +EEE | dayname, abbreviated +EEEE | dayname +M | numeric month of the year (without leading zero) +MM | numeric month of the year (with leading zero) +MMM | monthname, abbreviated +MMMM | monthname +y | year (4 digits) +yy | year (2 digits) +yyyy | year (4 digits) + +### Calendar localization issues + +Unfortunately the day- and monthname values in Zend Date do not always match +those in the existing jQuery UI locale files, so constants like `EEE` or `MMM`, +for day and monthnames could break validation. To fix this we had to slightly +alter the jQuery locale files, situated in +*/framework/thirdparty/jquery-ui/datepicker/i18n/*, to match Zend_Date. + +At this moment not all locale files may be present. If a locale file is +missing, the DatePicker calendar will fallback to 'yyyy-MM-dd' whenever day- +and/or monthnames are used. After saving, the correct format will be displayed. + +## Contributing jQuery Locale Files + +If you find the jQuery locale file for your chosen locale is missing, the +following section will explain how to create one. If you wish to contribute +your file to the SilverStripe core, please check out the guide on +['contributing code'](http://doc.silverstripe.org/framework/en/trunk/misc/contributing/code). + +### 1. Get the Sourcefile + +You can find a list of locale files for the jQuery UI DatePicker +[in the jQuery source code](https://github.com/jquery/jquery-ui/tree/master/ui/i18n). + +### 2. Find your Zend Locale File + +The Zend locale files are located in */framework/thirdparty/Zend/Locale/Data/*. +Find the one that has the information for your locale. + +### 3. Find the Date Values + +You're looking for the `Gregorian` date values for monthnames and daynames in +the Zend locale file. Edit the DatePicker locale File so your *full day- and +monthnames* and *short monthnames* match. For your *short daynames*, use the +first three characters of the full name. Note that Zend dates are `case +sensitive`! + +### 4. Filename + +Use the original jQuery UI filename 'jquery.ui.datepicker-xx.js', where xx +stands for the locale. \ No newline at end of file diff --git a/forms/DateField.php b/forms/DateField.php index 36155cfff..538b635d9 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -113,12 +113,26 @@ class DateField extends TextField { } public function FieldHolder($properties = array()) { - // TODO Replace with properly extensible view helper system - $d = DateField_View_JQuery::create($this); - $d->onBeforeRender(); + if ($this->getConfig('showcalendar')) { + // TODO Replace with properly extensible view helper system + $d = DateField_View_JQuery::create($this); + if(!$d->regionalSettingsExist()) { + $dateformat = $this->getConfig('dateformat'); + + // if no localefile is present, the jQuery DatePicker + // month- and daynames will default to English, so the date + // will not pass Zend validatiobn. We provide a fallback + if (preg_match('/(MMM+)|(EEE+)/', $dateformat)) { + $this->setConfig('dateformat', $this->getConfig('datavalueformat')); + } + } + $d->onBeforeRender(); + } $html = parent::FieldHolder(); - $html = $d->onAfterRender($html); - + + if(!empty($d)) { + $html = $d->onAfterRender($html); + } return $html; } @@ -199,9 +213,6 @@ class DateField extends TextField { $this->value = null; $this->valueObj = null; } else { - // Quick fix for overzealous Zend validation, its case sensitive on month names (see #5990) - if(is_string($val)) $val = ucwords(strtolower($val)); - if($this->getConfig('dmyfields')) { // Setting in correct locale if(is_array($val) && $this->validateArrayValue($val)) { @@ -480,6 +491,11 @@ class DateField_View_JQuery extends Object { protected $field; + /* + * the current jQuery UI DatePicker locale file + */ + protected $jqueryLocaleFile = ''; + /** * @var array Maps values from {@link i18n::$all_locales()} to * localizations existing in jQuery UI. @@ -488,7 +504,7 @@ class DateField_View_JQuery extends Object { 'en_GB' => 'en-GB', 'en_US' => 'en', 'en_NZ' => 'en-GB', - 'fr_CH' => 'fr-CH', + 'fr_CH' => 'fr', 'pt_BR' => 'pt-BR', 'sr_SR' => 'sr-SR', 'zh_CN' => 'zh-CN', @@ -509,7 +525,24 @@ class DateField_View_JQuery extends Object { public function getField() { return $this->field; } - + + /** + * Check if jQuery UI locale settings exists for the current locale + * @return boolean + */ + function regionalSettingsExist() { + $lang = $this->getLang(); + $localeFile = THIRDPARTY_DIR . "/jquery-ui/datepicker/i18n/jquery.ui.datepicker-{$lang}.js"; + if (file_exists(Director::baseFolder() . '/' .$localeFile)){ + $this->jqueryLocaleFile = $localeFile; + return true; + } else { + // file goes before internal en_US settings, + // but both will validate + return ($lang == 'en'); + } + } + public function onBeforeRender() { } @@ -524,16 +557,9 @@ class DateField_View_JQuery extends Object { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); // Include language files (if required) - $lang = $this->getLang(); - if($lang != 'en') { - // TODO Check for existence of locale to avoid unnecessary 404s from the CDN - Requirements::javascript( - sprintf( - THIRDPARTY_DIR . '/jquery-ui/minified/i18n/jquery.ui.datepicker-%s.min.js', - // can be a mix between names (e.g. 'de') and combined locales (e.g. 'zh-TW') - $lang - )); - } + if ($this->jqueryLocaleFile){ + Requirements::javascript($this->jqueryLocaleFile); + } Requirements::javascript(FRAMEWORK_DIR . "/javascript/DateField.js"); } @@ -578,12 +604,12 @@ class DateField_View_JQuery extends Object { '/^d([^d])/' => 'd$1', '/([^d])d$/' => '$1d', '/dd/' => 'dd', - '/EEEE/' => 'DD', - '/EEE/' => 'D', '/SS/' => '', '/eee/' => 'd', '/e/' => 'N', '/D/' => '', + '/EEEE/' => 'DD', + '/EEE/' => 'D', '/w/' => '', // make single "M" lowercase '/([^M])M([^M])/' => '$1m$2', diff --git a/thirdparty/jquery-ui/datepicker/i18n/README b/thirdparty/jquery-ui/datepicker/i18n/README new file mode 100644 index 000000000..fdb56bbdb --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/README @@ -0,0 +1,25 @@ +AUTHOR: Martine Bloem (http://www.balbuss.com) +********************************************** + +jQuery UI DatePicker localization files for SilverStripe 3.0 +------------------------------------------------------------ +These files are adaptations of the official localization files that can be found here: +http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/ + +Day- and monthnames have been changed to match the values Zend Date uses, to make +the following dateformats validate: + +EEE: weekday short +EEEE: weekday +MMM: monthname short +MMMM: monthname + +For locales for which no file exists (yet), the DatePicker will revert to a numeric +format, that will validate, and after being saved will be displayed in the +required format. + +To create your own language fiel, download the original file from the URL above, +find the Zend Date locale file in framework/Zend/Locale/Data and make sure that + +- monthNames, monthNamesShort and dayNames are equivalent to Zend (Gregorian) names +- dayNamesShort should be the first 3 characters of dayNames diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-da.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-da.js new file mode 100644 index 000000000..0afa19229 --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-da.js @@ -0,0 +1,25 @@ +/* + * Danish (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['da'] = { + closeText: 'Luk', + prevText: '<Forrige', + nextText: 'Næste>', + currentText: 'Idag', + monthNames: ['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december'], + monthNamesShort: ['jan.','feb.','mar.','apr.','maj','jun.','jul.','aug.','sep.','okt.','nov.','dec.'], + dayNames: ['søndag','mandag','tirsdag','onsdag','torsdag','fredag','lørdag'], + dayNamesShort: ['søn','man','tir','ons','tor','fre','lør'], + dayNamesMin: ['Sø','Ma','Ti','On','To','Fr','Lø'], + weekHeader: 'Uge', + dateFormat: 'dd-mm-yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['da']); +}); + diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-de.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-de.js new file mode 100644 index 000000000..a6aae4bc7 --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-de.js @@ -0,0 +1,25 @@ +/* + * German (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['de'] = { + closeText: 'schließen', + prevText: '<zurück', + nextText: 'Vor>', + currentText: 'heute', + monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'], + monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'], + dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], + dayNamesShort: ['Son','Mon','Die','Mit','Don','Fre','Sam'], + dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], + weekHeader: 'Wo', + dateFormat: 'dd.mm.yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['de']); +}); + diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en-GB.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en-GB.js new file mode 100644 index 000000000..148146aee --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en-GB.js @@ -0,0 +1,24 @@ +/* + * English/UK (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['en-GB'] = { + closeText: 'Done', + prevText: 'Prev', + nextText: 'Next', + currentText: 'Today', + monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], + weekHeader: 'Wk', + dateFormat: 'dd/mm/yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['en-GB']); +}); \ No newline at end of file diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en.js new file mode 100644 index 000000000..6880295a1 --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en.js @@ -0,0 +1,25 @@ +/* + * English (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['en'] = { + closeText: 'Done', + prevText: 'Prev', + nextText: 'Next', + currentText: 'Today', + monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'], // For formatting + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting + dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], + weekHeader: 'Wk', + dateFormat: 'mm/dd/yy', + firstDay: 0, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: '' + $.datepicker.setDefaults($.datepicker.regional['en']); +}); + diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-es.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-es.js new file mode 100644 index 000000000..e7fd01402 --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-es.js @@ -0,0 +1,27 @@ +/* + * Spanish (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['es'] = { + closeText: 'Cerrar', + prevText: '<Ant', + nextText: 'Sig>', + currentText: 'Hoy', + monthNames: ['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'], + monthNamesShort: ['ene','feb','mar','abr','may','jun','jul','ago','sep','oct','nov','dic'], + dayNames: ['domingo','lunes','martes','miércoles','jueves','viernes','sábado'], + dayNamesShort: ['dom','lun','mar','mié','juv','vie','sáb'], + dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'], + weekHeader: 'Sm', + dateFormat: 'dd/mm/yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['es']); +}); + + + diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-fr.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-fr.js new file mode 100644 index 000000000..b7162de9f --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-fr.js @@ -0,0 +1,24 @@ +/* + * French (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['fr'] = { + closeText: 'Fermer', + prevText: '<Préc', + nextText: 'Suiv>', + currentText: 'Courant', + monthNames: ['janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'], + monthNamesShort: ['janv.','févr.','mars','avr.','mai','juin','juil.','août','sept.','oct.','nov.','déc.'], + dayNames: ['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'], + dayNamesShort: ['dim','lun','mar','mer','jeu','ven','sam'], + dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'], + weekHeader: 'Sm', + dateFormat: 'dd/mm/yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['fr']); +}); diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nb.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nb.js new file mode 100644 index 000000000..709b1472d --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nb.js @@ -0,0 +1,24 @@ +/* + * Norwegian (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['no'] = { + closeText: 'Lukk', + prevText: '«Forrige', + nextText: 'Neste»', + currentText: 'I dag', + monthNames: ['januar','februar','mars','april','mai','juni','juli','august','september','oktober','november','desember'], + monthNamesShort: ['jan.','feb.','mar.','apr.','mai','juni','juli','aug.','sep.','okt.','nov.','des.'], + dayNames: ['søndag','mandag','tirsdag','onsdag','torsdag','fredag','lørdag'], + dayNamesShort: ['søn','man','tir','ons','tor','fre','lør'], + dayNamesMin: ['Sø','Ma','Ti','On','To','Fr','Lø'], + weekHeader: 'Uke', + dateFormat: 'yy-mm-dd', + firstDay: 0, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['no']); +}); diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nl.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nl.js new file mode 100644 index 000000000..1eaa7805d --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-nl.js @@ -0,0 +1,26 @@ +/* + * Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['nl'] = { + closeText: 'Sluiten', + prevText: '←', + nextText: '→', + currentText: 'Vandaag', + monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni','juli', 'augustus', 'september', 'oktober', 'november', 'december'], + monthNamesShort: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei.', 'jun.','jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'], + dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'], + dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'], + dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'], + weekHeader: 'Wk', + dateFormat: 'dd-mm-yy', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['nl']); +}); + + diff --git a/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-sv.js b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-sv.js new file mode 100644 index 000000000..f07fdd16c --- /dev/null +++ b/thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-sv.js @@ -0,0 +1,24 @@ +/* + * Swedish (UTF-8) initialisation for the jQuery UI date picker plugin. + * Adapted to match the Zend Data localization for SilverStripe CMS + * See: README + */ +jQuery(function($){ + $.datepicker.regional['sv'] = { + closeText: 'Stäng', + prevText: '«Förra', + nextText: 'Nästa»', + currentText: 'Idag', + monthNames: ['januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december'], + monthNamesShort: ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'], + dayNames: ['söndag','måndag','tisdag','onsdag','torsdag','fredag','lördag'], + dayNamesShort: ['sön','mån','tis','ons','tor','fre','lör'], + dayNamesMin: ['Sö','Må','Ti','On','To','Fr','Lö'], + weekHeader: 'Ve', + dateFormat: 'yy-mm-dd', + firstDay: 1, + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['sv']); +}); From 574c53d5ba522f43650d9cd4de2d51dd57b53a32 Mon Sep 17 00:00:00 2001 From: jean Date: Mon, 8 Oct 2012 09:18:13 +1300 Subject: [PATCH 11/11] FIX 7927 Redirect to the parent controller after deleting an item in a gridfield (edit form) --- forms/gridfield/GridFieldDetailForm.php | 55 ++++++++++++++++--------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/forms/gridfield/GridFieldDetailForm.php b/forms/gridfield/GridFieldDetailForm.php index 69a15a551..a32acbe14 100644 --- a/forms/gridfield/GridFieldDetailForm.php +++ b/forms/gridfield/GridFieldDetailForm.php @@ -326,7 +326,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { $this->component->getValidator() ); if($this->record->ID !== 0) { - $form->loadDataFrom($this->record); + $form->loadDataFrom($this->record); } // TODO Coupling with CMS @@ -341,16 +341,9 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { if($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); $form->addExtraClass('ss-tabset cms-tabset'); - } - - if($toplevelController->hasMethod('Backlink')) { - $form->Backlink = $toplevelController->Backlink(); - } elseif($this->popupController->hasMethod('Breadcrumbs')) { - $parents = $this->popupController->Breadcrumbs(false)->items; - $form->Backlink = array_pop($parents)->Link; - } else { - $form->Backlink = $toplevelController->Link(); } + + $form->Backlink = $this->getBackLink(); } $cb = $this->component->getItemEditFormCallback(); @@ -373,6 +366,25 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { } return $c; } + + protected function getBackLink(){ + // TODO Coupling with CMS + $backlink = ''; + $toplevelController = $this->getToplevelController(); + if($toplevelController && $toplevelController instanceof LeftAndMain) { + if($toplevelController->hasMethod('Backlink')) { + $backlink = $toplevelController->Backlink(); + } elseif($this->popupController->hasMethod('Breadcrumbs')) { + $parents = $this->popupController->Breadcrumbs(false)->items; + $backlink = array_pop($parents)->Link; + } else { + $backlink = $toplevelController->Link(); + } + } + return $backlink; + } + + public function doSave($data, $form) { $new_record = $this->record->ID == 0; @@ -424,14 +436,14 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { } public function doDelete($data, $form) { + $title = $this->record->Title; try { - $toDelete = $this->record; - if (!$toDelete->canDelete()) { + if (!$this->record->canDelete()) { throw new ValidationException( _t('GridFieldDetailForm.DeletePermissionsFailure',"No delete permissions"),0); } - $toDelete->delete(); + $this->record->delete(); } catch(ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return Controller::curr()->redirectBack(); @@ -440,17 +452,22 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { $message = sprintf( _t('GridFieldDetailForm.Deleted', 'Deleted %s %s'), $this->record->singular_name(), - '"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"' + htmlspecialchars($title, ENT_QUOTES) ); + + $toplevelController = $this->getToplevelController(); + if($toplevelController && $toplevelController instanceof LeftAndMain) { + $backForm = $toplevelController->getEditForm(); + $backForm->sessionMessage($message, 'good'); + } else { + $form->sessionMessage($message, 'good'); + } - $form->sessionMessage($message, 'good'); - - //when an item is deleted, redirect to the revelant admin section without the action parameter + //when an item is deleted, redirect to the parent controller $controller = Controller::curr(); - $noActionURL = $controller->removeAction($data['url']); $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh - return $controller->redirect($noActionURL, 302); //redirect back to admin section + return $controller->redirect($this->getBacklink(), 302); //redirect back to admin section } /**