Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #190 from silverstripe-rebelalliance/open/5971

NEW Add warning if viewed SiteTree object class is obsolete
  • Loading branch information...
commit af2c890168eff0309558b66a86c0ae3cb10a9a29 2 parents fd8e852 + d9243cd
@hafriedlander hafriedlander authored
Showing with 16 additions and 2 deletions.
  1. +1 −1  code/controllers/CMSMain.php
  2. +15 −1 code/model/SiteTree.php
View
2  code/controllers/CMSMain.php
@@ -781,7 +781,7 @@ public function save($data, $form) {
$record->HasBrokenLink = 0;
$record->HasBrokenFile = 0;
- $record->writeWithoutVersion();
+ if (!$record->ObsoleteClassName) $record->writeWithoutVersion();
// Update the class instance if necessary
if(isset($data['ClassName']) && $data['ClassName'] != $record->ClassName) {
View
16 code/model/SiteTree.php
@@ -1803,7 +1803,7 @@ function getCMSFields() {
if($this->HasBrokenLink || $this->HasBrokenFile) {
$statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
}
-
+
$dependentNote = '';
$dependentTable = new LiteralField('DependentNote', '<p></p>');
@@ -1877,6 +1877,20 @@ function getCMSFields() {
$tabMain->setTitle(_t('SiteTree.TABCONTENT', "Main Content"));
+ if($this->ObsoleteClassName) {
+ $obsoleteWarning = _t(
+ 'SiteTree.OBSOLETECLASS',
+ "This page is of obsolete type {type}. Saving will reset it's type and you may lose data",
+ array('type' => $this->ObsoleteClassName)
+ );
+
+ $fields->addFieldToTab(
+ "Root.Main",
+ new LiteralField("ObsoleteWarningHeader", "<p class=\"message warning\">$obsoleteWarning</p>"),
+ "Title"
+ );
+ }
+
if(file_exists(BASE_PATH . '/install.php')) {
$fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader",
"<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
Please sign in to comment.
Something went wrong with that request. Please try again.