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.
|
// Setup the linking to the original page.
|
||||||
$copyContentFromField = new TreeDropdownField(
|
$copyContentFromField = new TreeDropdownField(
|
||||||
"CopyContentFromID",
|
"CopyContentFromID",
|
||||||
_t('VirtualPage.CHOOSE', "Choose a page to link to"),
|
_t('VirtualPage.CHOOSE', "Linked Page"),
|
||||||
"SiteTree"
|
"SiteTree"
|
||||||
);
|
);
|
||||||
// filter doesn't let you select children of virtual pages as as source page
|
// 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
|
$msgs = array();
|
||||||
$fields->addFieldToTab("Root.Main",
|
|
||||||
new HeaderField('VirtualPageHeader',_t('VirtualPage.HEADER', "This is a virtual page")),
|
|
||||||
"Title"
|
|
||||||
);
|
|
||||||
$fields->addFieldToTab("Root.Main", $copyContentFromField, "Title");
|
$fields->addFieldToTab("Root.Main", $copyContentFromField, "Title");
|
||||||
|
|
||||||
// Create links back to the original object in the CMS
|
// Create links back to the original object in the CMS
|
||||||
if($this->CopyContentFrom()->exists()) {
|
if($this->CopyContentFrom()->exists()) {
|
||||||
$linkToContent = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$this->CopyContentFromID\">" .
|
$link = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$this->CopyContentFromID\">"
|
||||||
_t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
|
. _t('VirtualPage.EditLink', 'edit')
|
||||||
$fields->addFieldToTab("Root.Main",
|
. "</a>";
|
||||||
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
$msgs[] = _t(
|
||||||
"Title"
|
'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;
|
return $fields;
|
||||||
|
@ -395,9 +395,9 @@ en:
|
|||||||
CANACCESS: 'You can access the archived site at this link:'
|
CANACCESS: 'You can access the archived site at this link:'
|
||||||
HAVEASKED: 'You have asked to view the content of our site on'
|
HAVEASKED: 'You have asked to view the content of our site on'
|
||||||
VirtualPage:
|
VirtualPage:
|
||||||
CHOOSE: 'Choose a page to link to'
|
CHOOSE: 'Linked Page'
|
||||||
DESCRIPTION: 'Displays the content of another 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'
|
HEADER: 'This is a virtual page'
|
||||||
PLURALNAME: 'Virtual Pags'
|
PLURALNAME: 'Virtual Pags'
|
||||||
PageTypNotAllowedOnRoot: 'Original page type "{type}" is not allowed on the root level for this virtual page'
|
PageTypNotAllowedOnRoot: 'Original page type "{type}" is not allowed on the root level for this virtual page'
|
||||||
|
Loading…
Reference in New Issue
Block a user