mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #683 from chillu/pulls/virtualpage-1594
Better UI feedback on VirtualPage states (fixes #1594)
This commit is contained in:
commit
c922d08fb7
@ -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
|
||||
@ -185,22 +185,66 @@ class VirtualPage extends Page {
|
||||
}
|
||||
}
|
||||
|
||||
// Add fields to the tab
|
||||
$fields->addFieldToTab("Root.Main",
|
||||
new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")),
|
||||
"Title"
|
||||
);
|
||||
$msgs = array();
|
||||
|
||||
$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'
|
||||
);
|
||||
}
|
||||
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'
|
||||
);
|
||||
$linkToContentLabelField->setAllowHTML(true);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user