Better UI feedback on VirtualPage states (fixes #1594)

This commit is contained in:
Ingo Schommer 2013-04-16 11:47:56 +02:00
parent a15081fbcc
commit 878cf541b9
2 changed files with 58 additions and 14 deletions

View File

@ -170,7 +170,7 @@ class VirtualPage extends Page {
// Setup the linking to the original page.
$copyContentFromField = new TreeDropdownField(
"CopyContentFromID",
_t('VirtualPage.CHOOSE', "Choose a page to link to"),
_t('VirtualPage.CHOOSE', "Linked Page"),
"SiteTree"
);
// filter doesn't let you select children of virtual pages as as source page
@ -184,27 +184,71 @@ class VirtualPage extends Page {
$fields->replaceField($virtualField, $fields->dataFieldByName($virtualField)->transform($roTransformation));
}
}
$msgs = array();
// Add fields to the tab
$fields->addFieldToTab("Root.Main",
new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")),
"Title"
);
$fields->addFieldToTab("Root.Main", $copyContentFromField, "Title");
// Create links back to the original object in the CMS
if($this->CopyContentFrom()->exists()) {
$linkToContent = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$this->CopyContentFromID\">" .
_t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
$fields->addFieldToTab("Root.Main",
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
"Title"
$link = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$this->CopyContentFromID\">"
. _t('VirtualPage.EditLink', 'edit')
. "</a>";
$msgs[] = _t(
'VirtualPage.HEADERWITHLINK',
"This is a virtual page copying content from \"{title}\" ({link})",
array(
'title' => $this->CopyContentFrom()->Title,
'link' => $link
)
);
} else {
$msgs[] = _t('VirtualPage.HEADER', "This is a virtual page");
$msgs[] = _t(
'SITETREE.VIRTUALPAGEWARNING',
'Please choose a linked page and save first in order to publish this page'
);
$linkToContentLabelField->setAllowHTML(true);
}
if(
$this->CopyContentFromID
&& !Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->CopyContentFromID)
) {
$msgs[] = _t(
'SITETREE.VIRTUALPAGEDRAFTWARNING',
'Please publish the linked page in order to publish the virtual page'
);
}
$fields->addFieldToTab("Root.Main",
new LiteralField(
'VirtualPageMessage',
'<div class="message notice">' . implode('. ', $msgs) . '.</div>'
),
'CopyContentFromID'
);
return $fields;
}
public function getSettingsFields() {
$fields = parent::getSettingsFields();
if(!$this->CopyContentFrom()->exists()) {
$fields->addFieldToTab("Root.Settings",
new LiteralField(
'VirtualPageWarning',
'<div class="message notice">'
. _t(
'SITETREE.VIRTUALPAGEWARNINGSETTINGS',
'Please choose a linked page in the main content fields in order to publish'
)
. '</div>'
),
'ClassName'
);
}
return $fields;
}
/**
* We have to change it to copy all the content from the original page first.

View File

@ -395,9 +395,9 @@ en:
CANACCESS: 'You can access the archived site at this link:'
HAVEASKED: 'You have asked to view the content of our site on'
VirtualPage:
CHOOSE: 'Choose a page to link to'
CHOOSE: 'Linked Page'
DESCRIPTION: 'Displays the content of another page'
EDITCONTENT: 'click here to edit the content'
EDITCONTENT: 'Edit content on linked page'
HEADER: 'This is a virtual page'
PLURALNAME: 'Virtual Pags'
PageTypNotAllowedOnRoot: 'Original page type "{type}" is not allowed on the root level for this virtual page'