ENHANCEMENT Removed UpdateURL.js, moved logic to CMSMain.js

ENHANCEMENT Using plain TextField for URLSegment in SiteTree->getCMSFields(), and using custom logic in CMSMain.js. The field didn't have any serverside validation anyway, and the remaining parts are quite custom

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92539 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:31:42 +00:00
parent 241bff3df9
commit 0b25cb9e14
2 changed files with 1 additions and 49 deletions

View File

@ -1621,18 +1621,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
Director::absoluteBaseURL(),
(self::nested_urls() && $this->ParentID ? $this->Parent->RelativeLink(true) : null)
)),
new UniqueRestrictedTextField("URLSegment",
"URLSegment",
"SiteTree",
_t('SiteTree.VALIDATIONURLSEGMENT1', "Another page is using that URL. URL must be unique for each page"),
"[^A-Za-z0-9-]+",
"-",
_t('SiteTree.VALIDATIONURLSEGMENT2', "URLs can only be made up of letters, digits and hyphens."),
"",
"",
"",
50
),
new TextField("URLSegment","URLSegment"),
new LabelField('TrailingSlashLabel',"/")
),
new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ?

View File

@ -1,37 +0,0 @@
Behaviour.register({
'input#Form_EditForm_Title': {
/**
* Get the URL segment to suggest a new field
*/
onchange: function() {
if(this.value.length == 0) return;
if(!$('Form_EditForm_URLSegment')) return;
var urlSegmentField = $('Form_EditForm_URLSegment');
var newSuggestion = urlSegmentField.suggestNewValue( this.value.toLowerCase() );
var isNew = urlSegmentField.value.indexOf("new") == 0;
var confirmMessage = ss.i18n.sprintf(
ss.i18n._t('UPDATEURL.CONFIRM', 'Would you like me to change the URL to:\n\n%s/\n\nClick Ok to change the URL, click Cancel to leave it as:\n\n%s'),
newSuggestion,
urlSegmentField.value
);
if(
newSuggestion == urlSegmentField.value
|| isNew
|| confirm(confirmMessage)
) {
urlSegmentField.value = newSuggestion;
}
// If you type in Page name, the Navigation Label and Meta Title should automatically update the first time
// @todo: Change file name from UpdateURL to something more geneneric since we now do more than update the URL.
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MenuTitle').value.indexOf("New") == 0 ) {
$('Form_EditForm_MenuTitle').value = this.value;
}
// @todo see if updating this is confusing (Q: why isn't my page title changing? A: Check the Meta-Data tab)
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MetaTitle').value.length == 0 ) {
$('Form_EditForm_MetaTitle').value = this.value;
}
}
}
});