mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge remote-tracking branch 'origin/3.1'
This commit is contained in:
commit
c0302bc24d
@ -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.
|
||||
|
@ -68,7 +68,6 @@
|
||||
|
||||
$(".cms-add-form #PageType li").entwine({
|
||||
onclick: function(e) {
|
||||
e.preventDefault();
|
||||
this.setSelected(true);
|
||||
},
|
||||
setSelected: function(bool) {
|
||||
|
@ -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