mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
merge #2
This commit is contained in:
parent
9862cf5ea6
commit
b8f98323ae
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
|
||||||
use SilverStripe\Admin\ModelAdmin;
|
|
||||||
/**
|
|
||||||
* Admin interface to manage and create {@link Subsite} instances.
|
|
||||||
*
|
|
||||||
* @package subsites
|
|
||||||
*/
|
|
||||||
class SubsiteAdmin extends ModelAdmin
|
|
||||||
{
|
|
||||||
private static $managed_models = array('Subsite');
|
|
||||||
|
|
||||||
private static $url_segment = 'subsites';
|
|
||||||
|
|
||||||
private static $menu_title = "Subsites";
|
|
||||||
|
|
||||||
private static $menu_icon = "subsites/images/subsites.png";
|
|
||||||
|
|
||||||
public $showImportForm=false;
|
|
||||||
|
|
||||||
private static $tree_class = 'Subsite';
|
|
||||||
|
|
||||||
public function getEditForm($id = null, $fields = null)
|
|
||||||
{
|
|
||||||
$form = parent::getEditForm($id, $fields);
|
|
||||||
|
|
||||||
$grid=$form->Fields()->dataFieldByName('Subsite');
|
|
||||||
if ($grid) {
|
|
||||||
$grid->getConfig()->removeComponentsByType(GridFieldDetailForm::class);
|
|
||||||
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use SilverStripe\Forms\TreeMultiselectField;
|
|
||||||
use SilverStripe\Forms\FieldList;
|
|
||||||
use SilverStripe\Reports\ReportWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a subsite-aware version of another report.
|
|
||||||
* Pass another report (or its classname) into the constructor.
|
|
||||||
*/
|
|
||||||
class SubsiteReportWrapper extends ReportWrapper
|
|
||||||
{
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Filtering
|
|
||||||
|
|
||||||
public function parameterFields()
|
|
||||||
{
|
|
||||||
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true);
|
|
||||||
$options = $subsites->toDropdownMap('ID', 'Title');
|
|
||||||
|
|
||||||
$subsiteField = new TreeMultiselectField(
|
|
||||||
'Subsites',
|
|
||||||
_t('SubsiteReportWrapper.ReportDropdown', 'Sites'),
|
|
||||||
$options
|
|
||||||
);
|
|
||||||
$subsiteField->setValue(array_keys($options));
|
|
||||||
|
|
||||||
// We don't need to make the field editable if only one subsite is available
|
|
||||||
if (sizeof($options) <= 1) {
|
|
||||||
$subsiteField = $subsiteField->performReadonlyTransformation();
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields = parent::parameterFields();
|
|
||||||
if ($fields) {
|
|
||||||
$fields->insertBefore($subsiteField, $fields->First()->Name());
|
|
||||||
} else {
|
|
||||||
$fields = new FieldList($subsiteField);
|
|
||||||
}
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Columns
|
|
||||||
|
|
||||||
public function columns()
|
|
||||||
{
|
|
||||||
$columns = parent::columns();
|
|
||||||
$columns['Subsite.Title'] = "Subsite";
|
|
||||||
return $columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Querying
|
|
||||||
|
|
||||||
public function beforeQuery($params)
|
|
||||||
{
|
|
||||||
// The user has select a few specific sites
|
|
||||||
if (!empty($params['Subsites'])) {
|
|
||||||
Subsite::$force_subsite = $params['Subsites'];
|
|
||||||
|
|
||||||
// Default: restrict to all accessible sites
|
|
||||||
} else {
|
|
||||||
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain');
|
|
||||||
$options = $subsites->toDropdownMap('ID', 'Title');
|
|
||||||
Subsite::$force_subsite = join(',', array_keys($options));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function afterQuery()
|
|
||||||
{
|
|
||||||
// Manually manage the subsite filtering
|
|
||||||
Subsite::$force_subsite = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use SilverStripe\Security\Permission;
|
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section-agnostic PJAX controller.
|
|
||||||
*/
|
|
||||||
class SubsiteXHRController extends LeftAndMain
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Relax the access permissions, so anyone who has access to any CMS subsite can access this controller.
|
|
||||||
*/
|
|
||||||
public function canView($member = null)
|
|
||||||
{
|
|
||||||
if (parent::canView()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Subsite::all_accessible_sites()->count()>0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow access if user allowed into the CMS at all.
|
|
||||||
*/
|
|
||||||
public function canAccess()
|
|
||||||
{
|
|
||||||
// Allow if any cms access is available
|
|
||||||
return Permission::check(array(
|
|
||||||
'CMS_ACCESS', // Supported by 3.1.14 and up
|
|
||||||
'CMS_ACCESS_LeftAndMain'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResponseNegotiator()
|
|
||||||
{
|
|
||||||
$negotiator = parent::getResponseNegotiator();
|
|
||||||
$self = $this;
|
|
||||||
|
|
||||||
// Register a new callback
|
|
||||||
$negotiator->setCallback('SubsiteList', function () use (&$self) {
|
|
||||||
return $self->SubsiteList();
|
|
||||||
});
|
|
||||||
|
|
||||||
return $negotiator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the list of available subsites as a cms-section-agnostic PJAX handler.
|
|
||||||
*/
|
|
||||||
public function SubsiteList()
|
|
||||||
{
|
|
||||||
return $this->renderWith('SubsiteList');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,206 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
|
||||||
use SilverStripe\ORM\ArrayList;
|
|
||||||
use SilverStripe\View\ArrayData;
|
|
||||||
use SilverStripe\Forms\DropdownField;
|
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
|
||||||
use SilverStripe\Control\Controller;
|
|
||||||
use SilverStripe\Forms\LabelField;
|
|
||||||
use SilverStripe\Forms\TextField;
|
|
||||||
use SilverStripe\Forms\TextareaField;
|
|
||||||
use SilverStripe\Control\Session;
|
|
||||||
use SilverStripe\CMS\Model\VirtualPage;
|
|
||||||
|
|
||||||
class SubsitesVirtualPage extends VirtualPage
|
|
||||||
{
|
|
||||||
private static $description = 'Displays the content of a page on another subsite';
|
|
||||||
|
|
||||||
private static $db = array(
|
|
||||||
'CustomMetaTitle' => 'Varchar(255)',
|
|
||||||
'CustomMetaKeywords' => 'Varchar(255)',
|
|
||||||
'CustomMetaDescription' => 'Text',
|
|
||||||
'CustomExtraMeta' => 'HTMLText'
|
|
||||||
);
|
|
||||||
|
|
||||||
public function getCMSFields()
|
|
||||||
{
|
|
||||||
$fields = parent::getCMSFields();
|
|
||||||
|
|
||||||
$subsites = DataObject::get('Subsite');
|
|
||||||
if (!$subsites) {
|
|
||||||
$subsites = new ArrayList();
|
|
||||||
} else {
|
|
||||||
$subsites=ArrayList::create($subsites->toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
$subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
|
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
DropdownField::create(
|
|
||||||
"CopyContentFromID_SubsiteID",
|
|
||||||
_t('SubsitesVirtualPage.SubsiteField', "Subsite"),
|
|
||||||
$subsites->map('ID', 'Title')
|
|
||||||
)->addExtraClass('subsitestreedropdownfield-chooser no-change-track'),
|
|
||||||
'CopyContentFromID'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Setup the linking to the original page.
|
|
||||||
$pageSelectionField = new SubsitesTreeDropdownField(
|
|
||||||
"CopyContentFromID",
|
|
||||||
_t('VirtualPage.CHOOSE', "Choose a page to link to"),
|
|
||||||
SiteTree::class,
|
|
||||||
"ID",
|
|
||||||
"MenuTitle"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Controller::has_curr() && Controller::curr()->getRequest()) {
|
|
||||||
$subsiteID = Controller::curr()->getRequest()->requestVar('CopyContentFromID_SubsiteID');
|
|
||||||
$pageSelectionField->setSubsiteID($subsiteID);
|
|
||||||
}
|
|
||||||
$fields->replaceField('CopyContentFromID', $pageSelectionField);
|
|
||||||
|
|
||||||
// Create links back to the original object in the CMS
|
|
||||||
if ($this->CopyContentFromID) {
|
|
||||||
$editLink = "admin/pages/edit/show/$this->CopyContentFromID/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
|
|
||||||
$linkToContent = "
|
|
||||||
<a class=\"cmsEditlink\" href=\"$editLink\">" .
|
|
||||||
_t('VirtualPage.EDITCONTENT', 'Click here to edit the content') .
|
|
||||||
"</a>";
|
|
||||||
$fields->removeByName("VirtualPageContentLinkLabel");
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
"Root.Main",
|
|
||||||
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
|
||||||
'Title'
|
|
||||||
);
|
|
||||||
$linkToContentLabelField->setAllowHTML(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
TextField::create(
|
|
||||||
'CustomMetaTitle',
|
|
||||||
$this->fieldLabel('CustomMetaTitle')
|
|
||||||
)->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')),
|
|
||||||
'MetaTitle'
|
|
||||||
);
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
TextareaField::create(
|
|
||||||
'CustomMetaKeywords',
|
|
||||||
$this->fieldLabel('CustomMetaTitle')
|
|
||||||
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
|
|
||||||
'MetaKeywords'
|
|
||||||
);
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
TextareaField::create(
|
|
||||||
'CustomMetaDescription',
|
|
||||||
$this->fieldLabel('CustomMetaTitle')
|
|
||||||
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
|
|
||||||
'MetaDescription'
|
|
||||||
);
|
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
TextField::create(
|
|
||||||
'CustomExtraMeta',
|
|
||||||
$this->fieldLabel('CustomMetaTitle')
|
|
||||||
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
|
|
||||||
'ExtraMeta'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fieldLabels($includerelations = true)
|
|
||||||
{
|
|
||||||
$labels = parent::fieldLabels($includerelations);
|
|
||||||
$labels['CustomMetaTitle'] = _t('Subsite.CustomMetaTitle', 'Title');
|
|
||||||
$labels['CustomMetaKeywords'] = _t('Subsite.CustomMetaKeywords', 'Keywords');
|
|
||||||
$labels['CustomMetaDescription'] = _t('Subsite.CustomMetaDescription', 'Description');
|
|
||||||
$labels['CustomExtraMeta'] = _t('Subsite.CustomExtraMeta', 'Custom Meta Tags');
|
|
||||||
|
|
||||||
return $labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCopyContentFromID_SubsiteID()
|
|
||||||
{
|
|
||||||
return ($this->CopyContentFromID) ? (int)$this->CopyContentFrom()->SubsiteID : (int)Session::get('SubsiteID');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVirtualFields()
|
|
||||||
{
|
|
||||||
$fields = parent::getVirtualFields();
|
|
||||||
foreach ($fields as $k => $v) {
|
|
||||||
if ($v == 'SubsiteID') {
|
|
||||||
unset($fields[$k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (self::$db as $field => $type) {
|
|
||||||
if (in_array($field, $fields)) {
|
|
||||||
unset($fields[array_search($field, $fields)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function syncLinkTracking()
|
|
||||||
{
|
|
||||||
$oldState = Subsite::$disable_subsite_filter;
|
|
||||||
Subsite::$disable_subsite_filter = true;
|
|
||||||
if ($this->CopyContentFromID) {
|
|
||||||
$this->HasBrokenLink = DataObject::get_by_id(SiteTree::class, $this->CopyContentFromID) ? false : true;
|
|
||||||
}
|
|
||||||
Subsite::$disable_subsite_filter = $oldState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onBeforeWrite()
|
|
||||||
{
|
|
||||||
parent::onBeforeWrite();
|
|
||||||
|
|
||||||
if ($this->CustomMetaTitle) {
|
|
||||||
$this->MetaTitle = $this->CustomMetaTitle;
|
|
||||||
} else {
|
|
||||||
$this->MetaTitle = $this->ContentSource()->MetaTitle ? $this->ContentSource()->MetaTitle : $this->MetaTitle;
|
|
||||||
}
|
|
||||||
if ($this->CustomMetaKeywords) {
|
|
||||||
$this->MetaKeywords = $this->CustomMetaKeywords;
|
|
||||||
} else {
|
|
||||||
$this->MetaKeywords = $this->ContentSource()->MetaKeywords ? $this->ContentSource()->MetaKeywords : $this->MetaKeywords;
|
|
||||||
}
|
|
||||||
if ($this->CustomMetaDescription) {
|
|
||||||
$this->MetaDescription = $this->CustomMetaDescription;
|
|
||||||
} else {
|
|
||||||
$this->MetaDescription = $this->ContentSource()->MetaDescription ? $this->ContentSource()->MetaDescription : $this->MetaDescription;
|
|
||||||
}
|
|
||||||
if ($this->CustomExtraMeta) {
|
|
||||||
$this->ExtraMeta = $this->CustomExtraMeta;
|
|
||||||
} else {
|
|
||||||
$this->ExtraMeta = $this->ContentSource()->ExtraMeta ? $this->ContentSource()->ExtraMeta : $this->ExtraMeta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//class SubsitesVirtualPage_Controller extends VirtualPage_Controller
|
|
||||||
//{
|
|
||||||
// public function reloadContent()
|
|
||||||
// {
|
|
||||||
// $this->failover->copyFrom($this->failover->CopyContentFrom());
|
|
||||||
// $this->failover->write();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public function init()
|
|
||||||
// {
|
|
||||||
// $origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
|
||||||
// Subsite::$disable_subsite_filter = true;
|
|
||||||
//
|
|
||||||
// parent::init();
|
|
||||||
//
|
|
||||||
// Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -34,7 +34,7 @@ class SubsiteAdmin extends ModelAdmin
|
|||||||
|
|
||||||
$grid = $form->Fields()->dataFieldByName(Subsite::class);
|
$grid = $form->Fields()->dataFieldByName(Subsite::class);
|
||||||
if ($grid) {
|
if ($grid) {
|
||||||
$grid->getConfig()->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldDetailForm');
|
$grid->getConfig()->removeComponentsByType(GridFieldDetailForm::class);
|
||||||
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());
|
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\Subsites\Controller;
|
|||||||
|
|
||||||
|
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Subsites\Model\Subsite;
|
use SilverStripe\Subsites\Model\Subsite;
|
||||||
|
|
||||||
|
|
||||||
@ -30,13 +31,15 @@ class SubsiteXHRController extends LeftAndMain
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar as above, but for the LeftAndMainSubsites - allow access if user allowed into the CMS at all.
|
* Allow access if user allowed into the CMS at all.
|
||||||
*/
|
*/
|
||||||
public function canAccess()
|
public function canAccess()
|
||||||
{
|
{
|
||||||
if (Subsite::all_accessible_sites()->count() > 0) {
|
// Allow if any cms access is available
|
||||||
return true;
|
return Permission::check(array(
|
||||||
}
|
'CMS_ACCESS', // Supported by 3.1.14 and up
|
||||||
|
'CMS_ACCESS_LeftAndMain'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResponseNegotiator()
|
public function getResponseNegotiator()
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Subsites\Extensions;
|
||||||
|
|
||||||
|
|
||||||
|
use Page;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
@ -18,15 +22,17 @@ use SilverStripe\Control\Director;
|
|||||||
use SilverStripe\Control\HTTP;
|
use SilverStripe\Control\HTTP;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\Subsites\Model\Subsite;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for the SiteTree object to add subsites support
|
* Extension for the SiteTree object to add subsites support
|
||||||
*/
|
*/
|
||||||
class SiteTreeSubsites extends DataExtension
|
class SiteTreeSubsites extends DataExtension
|
||||||
{
|
{
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
'Subsite' => Subsite::class, // The subsite that this page belongs to
|
||||||
);
|
];
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'CrossSubsiteLinkTracking' => SiteTree::class // Stored separately, as the logic for URL rewriting is different
|
'CrossSubsiteLinkTracking' => SiteTree::class // Stored separately, as the logic for URL rewriting is different
|
||||||
@ -74,7 +80,8 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
// The foreach is an ugly way of getting the first key :-)
|
// The foreach is an ugly way of getting the first key :-)
|
||||||
foreach ($query->getFrom() as $tableName => $info) {
|
foreach ($query->getFrom() as $tableName => $info) {
|
||||||
// The tableName should be SiteTree or SiteTree_Live...
|
// The tableName should be SiteTree or SiteTree_Live...
|
||||||
if (strpos($tableName, SiteTree::class) === false) {
|
$siteTreeTableName = SiteTree::getSchema()->tableName(SiteTree::class);
|
||||||
|
if (strpos($tableName, $siteTreeTableName) === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||||
@ -285,7 +292,7 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
$subsite = Subsite::currentSubsite();
|
$subsite = Subsite::currentSubsite();
|
||||||
|
|
||||||
if ($subsite && $subsite->Theme) {
|
if ($subsite && $subsite->Theme) {
|
||||||
Config::inst()->update(SSViewer::class, 'theme', Subsite::currentSubsite()->Theme);
|
Config::modify()->set(SSViewer::class, 'theme', Subsite::currentSubsite()->Theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\Subsites\Pages;
|
namespace SilverStripe\Subsites\Pages;
|
||||||
|
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\CMS\Model\VirtualPage;
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\Session;
|
use SilverStripe\Control\Session;
|
||||||
@ -49,7 +50,7 @@ class SubsitesVirtualPage extends VirtualPage
|
|||||||
'Root.Main',
|
'Root.Main',
|
||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
"CopyContentFromID_SubsiteID",
|
"CopyContentFromID_SubsiteID",
|
||||||
_t('SubsitesVirtualPage.SubsiteField', Subsite::class),
|
_t('SubsitesVirtualPage.SubsiteField', "Subsite"),
|
||||||
$subsites->map('ID', 'Title')
|
$subsites->map('ID', 'Title')
|
||||||
)->addExtraClass('subsitestreedropdownfield-chooser no-change-track'),
|
)->addExtraClass('subsitestreedropdownfield-chooser no-change-track'),
|
||||||
'CopyContentFromID'
|
'CopyContentFromID'
|
||||||
@ -162,8 +163,7 @@ class SubsitesVirtualPage extends VirtualPage
|
|||||||
$oldState = Subsite::$disable_subsite_filter;
|
$oldState = Subsite::$disable_subsite_filter;
|
||||||
Subsite::$disable_subsite_filter = true;
|
Subsite::$disable_subsite_filter = true;
|
||||||
if ($this->CopyContentFromID) {
|
if ($this->CopyContentFromID) {
|
||||||
$this->HasBrokenLink = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree',
|
$this->HasBrokenLink = DataObject::get_by_id(SiteTree::class, $this->CopyContentFromID) ? false : true;
|
||||||
$this->CopyContentFromID) ? false : true;
|
|
||||||
}
|
}
|
||||||
Subsite::$disable_subsite_filter = $oldState;
|
Subsite::$disable_subsite_filter = $oldState;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ class SubsitesVirtualPage extends VirtualPage
|
|||||||
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
||||||
$parentFilter = null;
|
$parentFilter = null;
|
||||||
|
|
||||||
if (Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls')) {
|
if (Config::inst()->get(SiteTree::class, 'nested_urls')) {
|
||||||
if ($this->ParentID) {
|
if ($this->ParentID) {
|
||||||
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID";
|
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID";
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Filtering
|
// Filtering
|
||||||
|
|
||||||
function parameterFields()
|
public function parameterFields()
|
||||||
{
|
{
|
||||||
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true);
|
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true);
|
||||||
$options = $subsites->toDropdownMap('ID', 'Title');
|
$options = $subsites->toDropdownMap('ID', 'Title');
|
||||||
@ -47,7 +47,7 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Columns
|
// Columns
|
||||||
|
|
||||||
function columns()
|
public function columns()
|
||||||
{
|
{
|
||||||
$columns = parent::columns();
|
$columns = parent::columns();
|
||||||
$columns['Subsite.Title'] = Subsite::class;
|
$columns['Subsite.Title'] = Subsite::class;
|
||||||
@ -57,7 +57,7 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Querying
|
// Querying
|
||||||
|
|
||||||
function beforeQuery($params)
|
public function beforeQuery($params)
|
||||||
{
|
{
|
||||||
// The user has select a few specific sites
|
// The user has select a few specific sites
|
||||||
if (!empty($params['Subsites'])) {
|
if (!empty($params['Subsites'])) {
|
||||||
@ -70,8 +70,7 @@ class SubsiteReportWrapper extends ReportWrapper
|
|||||||
Subsite::$force_subsite = join(',', array_keys($options));
|
Subsite::$force_subsite = join(',', array_keys($options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function afterQuery()
|
||||||
function afterQuery()
|
|
||||||
{
|
{
|
||||||
// Manually manage the subsite filtering
|
// Manually manage the subsite filtering
|
||||||
Subsite::$force_subsite = null;
|
Subsite::$force_subsite = null;
|
||||||
|
@ -11,7 +11,7 @@ use SilverStripe\BehatExtension\Context\BasicContext;
|
|||||||
use SilverStripe\BehatExtension\Context\LoginContext;
|
use SilverStripe\BehatExtension\Context\LoginContext;
|
||||||
use SilverStripe\BehatExtension\Context\FixtureContext;
|
use SilverStripe\BehatExtension\Context\FixtureContext;
|
||||||
use SilverStripe\Framework\Test\Behaviour\CmsFormsContext;
|
use SilverStripe\Framework\Test\Behaviour\CmsFormsContext;
|
||||||
use SilverStripe\Framework\Test\Behaviour\CmsUiContext;l
|
use SilverStripe\Framework\Test\Behaviour\CmsUiContext;
|
||||||
use SilverStripe\Cms\Test\Behaviour;
|
use SilverStripe\Cms\Test\Behaviour;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user