From d3cc97c8a0bb0df92d47c5299ac26f9c255b5db8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 25 Sep 2007 21:58:42 +0000 Subject: [PATCH] Added _manifest_exclude to lang folder (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42577 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 2 +- code/LeftAndMain.php | 23 +++++++++-------- javascript/LangSelector.js | 51 +++++++++++++++++--------------------- lang/_manifest_exclude | 0 4 files changed, 37 insertions(+), 39 deletions(-) create mode 100755 lang/_manifest_exclude diff --git a/code/CMSMain.php b/code/CMSMain.php index 782a0387..5deb0c8d 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -425,7 +425,7 @@ JS; $originalItem = Translatable::get_original($className,Session::get("{$id}_originalLangID")); if ($setID) $originalItem->ID = $id; else { - $originalItem->ID = 'new'; // to avoid creating and deleting a SiteTree row + $originalItem->ID = null; Translatable::creating_from(Session::get($id.'_originalLangID')); } return $originalItem; diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 3266642e..bb5e558a 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -366,11 +366,11 @@ JS; $className = $this->stat('tree_class'); $result = ''; - $id = $_REQUEST['ID']; - if(substr($id,0,3) != 'new') { - $record = DataObject::get_one($className, "`$className`.ID = $id"); + $SQL_id = Convert::raw2sql($_REQUEST['ID']); + if(substr($SQL_id,0,3) != 'new') { + $record = DataObject::get_one($className, "`$className`.ID = {$SQL_id}"); } else { - $record = $this->getNewItem($id, false); + $record = $this->getNewItem($SQL_id, false); } // We don't want to save a new version if there are no changes @@ -428,8 +428,8 @@ JS; // $record->write(); if(Director::is_ajax()) { - if($id != $record->ID) { - FormResponse::add("$('sitetree').setNodeIdx(\"$id\", \"$record->ID\");"); + if($SQL_id != $record->ID) { + FormResponse::add("$('sitetree').setNodeIdx(\"{$SQL_id}\", \"$record->ID\");"); FormResponse::add("$('Form_EditForm').elements.ID.value = \"$record->ID\";"); } @@ -486,10 +486,13 @@ JS; // If the 'Save & Publish' button was clicked, also publish the page if (isset($urlParams['publish']) && $urlParams['publish'] == 1) { $this->performPublish($record); - // BUGFIX: Changed icon sometimes shows after "Save & Publish" button is clicked http://support.silverstripe.com/gsoc/ticket/31 - $record->setClassName( $record->ClassName ); - $newClass = $record->ClassName; - $publishedRecord = $record->newClassInstance( $newClass ); + + if(substr($SQL_id,0,3) != 'new') { + $publishedRecord = DataObject::get_one($className, "`$className`.ID = {$SQL_id}"); + } else { + $publishedRecord = $this->getNewItem($SQL_id, false); + } + return $this->tellBrowserAboutPublicationChange($publishedRecord, "Published '$record->Title' successfully"); } else { // BUGFIX: Changed icon only shows after Save button is clicked twice http://support.silverstripe.com/gsoc/ticket/76 diff --git a/javascript/LangSelector.js b/javascript/LangSelector.js index e2e72452..f9c84308 100755 --- a/javascript/LangSelector.js +++ b/javascript/LangSelector.js @@ -1,54 +1,48 @@ var _TRANSLATING_LANG = null; + +/** + * + */ LangSelector = Class.create(); LangSelector.prototype = { initialize: function() { - this.selector = $('LangSelector'); - //this.selector.addEventListener("click", this.a, null); - - if(this.selector) this.selector.holder = this; - if(this.selector.selectedIndex != 0) { + if(this.selectedIndex != 0) { this.showlangtree(); - _TRANSLATING_LANG = this.selector.value; + _TRANSLATING_LANG = this.value; } }, - destroy: function() { - if(this.selector) this.selector.holder = null; - this.selector = null; - }, - onshow: function() { - if(this.selector.value) this.showlangtree(); + if(this.value) this.showlangtree(); }, - onchange: function() { - if (this.selector.value != _TRANSLATING_LANG) { - if (this.selector.selectedIndex != 0) _TRANSLATING_LANG = this.selector.value; - else _TRANSLATING_LANG = null; + onchange: function(e, val) { + if(this.value != _TRANSLATING_LANG) { + _TRANSLATING_LANG = this.value; this.showlangtree(); } }, selectValue: function(lang) { - this.selector.value = lang; - if (this.selector.value != lang) { + this.value = lang; + if(this.value != lang) { var newLang = document.createElement('option'); newLang.text = lang; newLang.value = lang; try { - this.selector.add(newLang, null); // standards compliant + this.add(newLang, null); // standards compliant } catch(ex) { - this.selector.add(newLang); // IE only + this.add(newLang); // IE only } - this.selector.value = lang; + this.value = lang; } }, showlangtree: function() { - $('sitetree').innerHTML='  loading...'; + new Ajax.Request('admin/switchlanguage/' + this.value, { method : 'post', onSuccess: Ajax.Evaluator, onFailure : Ajax.Evaluator @@ -56,16 +50,18 @@ LangSelector.prototype = { } } }; - LangSelector.applyTo('#LangSelector'); +/** + * + */ TranslatorCreator = Class.create(); TranslatorCreator.prototype = { onSelectionChanged: function(selectedNode) { - if (_TRANSLATING_LANG && Element.hasClassName(selectedNode,'untranslated')) { + if(_TRANSLATING_LANG && Element.hasClassName(selectedNode,'untranslated')) { $start = confirm('Would you like to start a translation for this page?'); - if ($start) Element.removeClassName(selectedNode,'untranslated'); + if($start) Element.removeClassName(selectedNode,'untranslated'); return $start; } }, @@ -75,5 +71,4 @@ TranslatorCreator.prototype = { } } - TranslatorCreator.applyTo('#LangSelector_holder'); \ No newline at end of file diff --git a/lang/_manifest_exclude b/lang/_manifest_exclude new file mode 100755 index 00000000..e69de29b