upgrader: upgrade code

This commit is contained in:
Werner M. Krauß 2017-05-24 13:36:04 +02:00
parent 2c84e627db
commit e33a5b4cae
15 changed files with 84 additions and 58 deletions

View File

@ -1,7 +1,7 @@
--- ---
Name: subsiteconfig Name: subsiteconfig
--- ---
AssetAdmin: SilverStripe\AssetAdmin\Controller\AssetAdmin:
treats_subsite_0_as_global: true treats_subsite_0_as_global: true
SilverStripe\Control\Director: SilverStripe\Control\Director:

View File

@ -5,6 +5,8 @@ namespace SilverStripe\Subsites\Admin;
use SilverStripe\Admin\ModelAdmin; use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Subsites\Forms\GridFieldSubsiteDetailForm; use SilverStripe\Subsites\Forms\GridFieldSubsiteDetailForm;
use SilverStripe\Subsites\Model\Subsite;
/** /**
* Admin interface to manage and create {@link Subsite} instances. * Admin interface to manage and create {@link Subsite} instances.
@ -13,7 +15,7 @@ use SilverStripe\Subsites\Forms\GridFieldSubsiteDetailForm;
*/ */
class SubsiteAdmin extends ModelAdmin { class SubsiteAdmin extends ModelAdmin {
private static $managed_models = array('Subsite'); private static $managed_models = array(Subsite::class);
private static $url_segment = 'subsites'; private static $url_segment = 'subsites';
@ -23,12 +25,12 @@ class SubsiteAdmin extends ModelAdmin {
public $showImportForm=false; public $showImportForm=false;
private static $tree_class = 'Subsite'; private static $tree_class = Subsite::class;
public function getEditForm($id = null, $fields = null) { public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields); $form = parent::getEditForm($id, $fields);
$grid=$form->Fields()->dataFieldByName('Subsite'); $grid=$form->Fields()->dataFieldByName(Subsite::class);
if($grid) { if($grid) {
$grid->getConfig()->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldDetailForm'); $grid->getConfig()->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldDetailForm');
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm()); $grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());

View File

@ -6,6 +6,8 @@ namespace SilverStripe\Subsites\Extensions;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Model\Subsite;
class ErrorPageSubsite extends DataExtension { class ErrorPageSubsite extends DataExtension {
@ -29,7 +31,7 @@ class ErrorPageSubsite extends DataExtension {
if(!$subsite) { if(!$subsite) {
$subsiteID = Subsite::getSubsiteIDForDomain(); $subsiteID = Subsite::getSubsiteIDForDomain();
if($subsiteID != 0) { if($subsiteID != 0) {
$subsite = DataObject::get_by_id("Subsite", $subsiteID); $subsite = DataObject::get_by_id(Subsite::class, $subsiteID);
} }
} }

View File

@ -13,6 +13,8 @@ use SilverStripe\Control\Session;
use SilverStripe\Security\Permission; use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Model\Subsite;
/** /**
* Extension for the File object to add subsites support * Extension for the File object to add subsites support
@ -26,7 +28,7 @@ class FileSubsites extends DataExtension {
static $default_root_folders_global = false; static $default_root_folders_global = false;
private static $has_one=array( private static $has_one=array(
'Subsite' => 'Subsite', 'Subsite' => Subsite::class,
); );
/** /**
@ -54,7 +56,7 @@ class FileSubsites extends DataExtension {
//Dropdown needed to move folders between subsites //Dropdown needed to move folders between subsites
$dropdown = new DropdownField( $dropdown = new DropdownField(
'SubsiteID', 'SubsiteID',
_t('FileSubsites.SubsiteFieldLabel','Subsite'), _t('FileSubsites.SubsiteFieldLabel',Subsite::class),
$values $values
); );
$dropdown->addExtraClass('subsites-move-dropdown'); $dropdown->addExtraClass('subsites-move-dropdown');

View File

@ -15,6 +15,8 @@ use SilverStripe\Control\Cookie;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\PermissionProvider; use SilverStripe\Security\PermissionProvider;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Security\Group;
/** /**
* Extension for the Group object to add subsites support * Extension for the Group object to add subsites support
@ -28,7 +30,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider {
); );
private static $many_many = array( private static $many_many = array(
'Subsites' => 'Subsite' 'Subsites' => Subsite::class
); );
private static $defaults = array( private static $defaults = array(
@ -40,7 +42,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider {
*/ */
function requireDefaultRecords() { function requireDefaultRecords() {
// Migration for Group.SubsiteID data from when Groups only had a single subsite // Migration for Group.SubsiteID data from when Groups only had a single subsite
$groupFields = DB::field_list('Group'); $groupFields = DB::field_list(Group::class);
// Detection of SubsiteID field is the trigger for old-style-subsiteID migration // Detection of SubsiteID field is the trigger for old-style-subsiteID migration
if(isset($groupFields['SubsiteID'])) { if(isset($groupFields['SubsiteID'])) {
@ -52,7 +54,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider {
DB::query('UPDATE "Group" SET "AccessAllSubsites" = 1 WHERE "SubsiteID" = 0'); DB::query('UPDATE "Group" SET "AccessAllSubsites" = 1 WHERE "SubsiteID" = 0');
// Move the field out of the way so that this migration doesn't get executed again // Move the field out of the way so that this migration doesn't get executed again
DB::get_schema()->renameField('Group', 'SubsiteID', '_obsolete_SubsiteID'); DB::get_schema()->renameField(Group::class, 'SubsiteID', '_obsolete_SubsiteID');
// No subsite access on anything means that we've just installed the subsites module. // No subsite access on anything means that we've just installed the subsites module.
// Make all previous groups global-access groups // Make all previous groups global-access groups

View File

@ -19,6 +19,7 @@ use SilverStripe\Control\Controller;
use SilverStripe\Core\Extension; use SilverStripe\Core\Extension;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
/** /**
* Decorator designed to add subsites support to LeftAndMain * Decorator designed to add subsites support to LeftAndMain
* *
@ -316,7 +317,7 @@ class LeftAndMainSubsites extends Extension {
function copytosubsite($data, $form) { function copytosubsite($data, $form) {
$page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $data['ID']); $page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $data['ID']);
$subsite = DataObject::get_by_id('Subsite', $data['CopyToSubsiteID']); $subsite = DataObject::get_by_id(Subsite::class, $data['CopyToSubsiteID']);
$newPage = $page->duplicateToSubsite($subsite->ID, true); $newPage = $page->duplicateToSubsite($subsite->ID, true);
$response = $this->owner->getResponse(); $response = $this->owner->getResponse();
$response->addHeader('X-Reload', true); $response->addHeader('X-Reload', true);

View File

@ -9,6 +9,8 @@ use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\HiddenField;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\SiteConfig\SiteConfig;
/** /**
@ -17,7 +19,7 @@ use SilverStripe\Subsites\Model\Subsite;
class SiteConfigSubsites extends DataExtension { class SiteConfigSubsites extends DataExtension {
private static $has_one = array( private static $has_one = array(
'Subsite' => 'Subsite', // The subsite that this page belongs to 'Subsite' => Subsite::class, // The subsite that this page belongs to
); );
/** /**
@ -39,7 +41,7 @@ class SiteConfigSubsites extends DataExtension {
$froms=$query->getFrom(); $froms=$query->getFrom();
$froms=array_keys($froms); $froms=array_keys($froms);
$tableName = array_shift($froms); $tableName = array_shift($froms);
if($tableName != 'SiteConfig') return; if($tableName != SiteConfig::class) return;
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)"); $query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
} }

View File

@ -19,6 +19,8 @@ use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use Page; use Page;
use SilverStripe\CMS\Model\SiteTree;
/** /**
@ -27,7 +29,7 @@ use Page;
class SiteTreeSubsites extends DataExtension { class SiteTreeSubsites extends DataExtension {
private static $has_one = array( private static $has_one = array(
'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(
@ -63,7 +65,7 @@ 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') === false) break; if(strpos($tableName,SiteTree::class) === false) break;
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)"); $query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
break; break;
} }

View File

@ -6,10 +6,13 @@ namespace SilverStripe\Subsites\Forms;
use SilverStripe\Forms\GridField\GridFieldDetailForm; use SilverStripe\Forms\GridField\GridFieldDetailForm;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest; use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
use Subsite;
use SilverStripe\Subsites\Forms\GridFieldSubsiteDetailForm_ItemRequest;
use SilverStripe\Subsites\Model\Subsite;
class GridFieldSubsiteDetailForm extends GridFieldDetailForm { class GridFieldSubsiteDetailForm extends GridFieldDetailForm {
protected $itemRequestClass='GridFieldSubsiteDetailForm_ItemRequest'; protected $itemRequestClass=GridFieldSubsiteDetailForm_ItemRequest::class;
} }
class GridFieldSubsiteDetailForm_ItemRequest extends GridFieldDetailForm_ItemRequest { class GridFieldSubsiteDetailForm_ItemRequest extends GridFieldDetailForm_ItemRequest {

View File

@ -9,10 +9,11 @@ use SilverStripe\Control\Session;
use SilverStripe\Forms\TreeDropdownField; use SilverStripe\Forms\TreeDropdownField;
/** /**
* Wraps around a TreedropdownField to add ability for temporary * Wraps around a TreedropdownField to add ability for temporary
* switching of subsite sessions. * switching of subsite sessions.
* *
* @package subsites * @package subsites
*/ */
class SubsitesTreeDropdownField extends TreeDropdownField { class SubsitesTreeDropdownField extends TreeDropdownField {
@ -20,35 +21,35 @@ class SubsitesTreeDropdownField extends TreeDropdownField {
private static $allowed_actions = array( private static $allowed_actions = array(
'tree' 'tree'
); );
protected $subsiteID = 0; protected $subsiteID = 0;
protected $extraClasses = array('SubsitesTreeDropdownField'); protected $extraClasses = array(SubsitesTreeDropdownField::class);
function Field($properties = array()) { function Field($properties = array()) {
$html = parent::Field($properties); $html = parent::Field($properties);
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js'); Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
return $html; return $html;
} }
function setSubsiteID($id) { function setSubsiteID($id) {
$this->subsiteID = $id; $this->subsiteID = $id;
} }
function getSubsiteID() { function getSubsiteID() {
return $this->subsiteID; return $this->subsiteID;
} }
function tree(HTTPRequest $request) { function tree(HTTPRequest $request) {
$oldSubsiteID = Session::get('SubsiteID'); $oldSubsiteID = Session::get('SubsiteID');
Session::set('SubsiteID', $this->subsiteID); Session::set('SubsiteID', $this->subsiteID);
$results = parent::tree($request); $results = parent::tree($request);
Session::set('SubsiteID', $oldSubsiteID); Session::set('SubsiteID', $oldSubsiteID);
return $results; return $results;
} }
} }

View File

@ -30,6 +30,10 @@ use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\ArrayLib; use SilverStripe\ORM\ArrayLib;
use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\Versioned;
use UnexpectedValueException; use UnexpectedValueException;
use SilverStripe\Security\Group;
use SilverStripe\Security\PermissionRole;
use SilverStripe\Security\PermissionRoleCode;
/** /**
* A dynamically created subsite. SiteTree objects can now belong to a subsite. * A dynamically created subsite. SiteTree objects can now belong to a subsite.
@ -125,7 +129,7 @@ class Subsite extends DataObject {
*/ */
public static function currentSubsite() { public static function currentSubsite() {
// get_by_id handles caching so we don't have to // get_by_id handles caching so we don't have to
return DataObject::get_by_id('Subsite', self::currentSubsiteID()); return DataObject::get_by_id(Subsite::class, self::currentSubsiteID());
} }
/** /**
@ -208,10 +212,10 @@ class Subsite extends DataObject {
$SQL_host = Convert::raw2sql($host); $SQL_host = Convert::raw2sql($host);
$matchingDomains = DataObject::get( $matchingDomains = DataObject::get(
"SubsiteDomain", SubsiteDomain::class,
"'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')", "'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')",
"\"IsPrimary\" DESC" "\"IsPrimary\" DESC"
)->innerJoin('Subsite', "\"Subsite\".\"ID\" = \"SubsiteDomain\".\"SubsiteID\" AND \"Subsite\".\"IsPublic\"=1"); )->innerJoin(Subsite::class, "\"Subsite\".\"ID\" = \"SubsiteDomain\".\"SubsiteID\" AND \"Subsite\".\"IsPublic\"=1");
} }
if($matchingDomains && $matchingDomains->Count()) { if($matchingDomains && $matchingDomains->Count()) {
@ -226,7 +230,7 @@ class Subsite extends DataObject {
} }
$subsiteID = $subsiteIDs[0]; $subsiteID = $subsiteIDs[0];
} else if($default = DataObject::get_one('Subsite', "\"DefaultSite\" = 1")) { } else if($default = DataObject::get_one(Subsite::class, "\"DefaultSite\" = 1")) {
// Check for a 'default' subsite // Check for a 'default' subsite
$subsiteID = $default->ID; $subsiteID = $default->ID;
} else { } else {
@ -352,23 +356,23 @@ class Subsite extends DataObject {
return self::$_cache_accessible_sites[$cacheKey]; return self::$_cache_accessible_sites[$cacheKey];
} }
$subsites = DataList::create('Subsite') $subsites = DataList::create(Subsite::class)
->where("\"Subsite\".\"Title\" != ''") ->where("\"Subsite\".\"Title\" != ''")
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"") ->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1") ->innerJoin(Group::class, "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID") ->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID")
->innerJoin('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')"); ->innerJoin(Permission::class, "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
if(!$subsites) $subsites = new ArrayList(); if(!$subsites) $subsites = new ArrayList();
$rolesSubsites = DataList::create('Subsite') $rolesSubsites = DataList::create(Subsite::class)
->where("\"Subsite\".\"Title\" != ''") ->where("\"Subsite\".\"Title\" != ''")
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"") ->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1") ->innerJoin(Group::class, "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID") ->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID")
->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"") ->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")
->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"") ->innerJoin(PermissionRole::class, "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")
->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')"); ->innerJoin(PermissionRoleCode::class, "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
if(!$subsites && $rolesSubsites) return $rolesSubsites; if(!$subsites && $rolesSubsites) return $rolesSubsites;
@ -411,7 +415,7 @@ class Subsite extends DataObject {
if (!$file) $file = Director::baseFolder().'/subsites/host-map.php'; if (!$file) $file = Director::baseFolder().'/subsites/host-map.php';
$hostmap = array(); $hostmap = array();
$subsites = DataObject::get('Subsite'); $subsites = DataObject::get(Subsite::class);
if ($subsites) foreach($subsites as $subsite) { if ($subsites) foreach($subsites as $subsite) {
$domains = $subsite->Domains(); $domains = $subsite->Domains();
@ -510,7 +514,7 @@ class Subsite extends DataObject {
* @var array * @var array
*/ */
private static $has_many = array( private static $has_many = array(
'Domains' => 'SubsiteDomain', 'Domains' => SubsiteDomain::class,
); );
/** /**
@ -714,7 +718,7 @@ class Subsite extends DataObject {
*/ */
public function domain() { public function domain() {
if($this->ID) { if($this->ID) {
$domains = DataObject::get("SubsiteDomain", "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC","", 1); $domains = DataObject::get(SubsiteDomain::class, "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC","", 1);
if($domains && $domains->Count()>0) { if($domains && $domains->Count()>0) {
$domain = $domains->First()->Domain; $domain = $domains->First()->Domain;
// If there are wildcards in the primary domain (not recommended), make some // If there are wildcards in the primary domain (not recommended), make some

View File

@ -37,7 +37,7 @@ class SubsiteDomain extends DataObject {
* @var array * @var array
*/ */
private static $has_one = array( private static $has_one = array(
"Subsite" => "Subsite", "Subsite" => Subsite::class,
); );
/** /**
@ -57,9 +57,9 @@ class SubsiteDomain extends DataObject {
public function onAfterWrite() { public function onAfterWrite() {
Subsite::writeHostMap(); Subsite::writeHostMap();
} }
/** /**
* *
* @return \FieldList * @return \FieldList
*/ */
public function getCMSFields() { public function getCMSFields() {
@ -73,7 +73,7 @@ class SubsiteDomain extends DataObject {
} }
/** /**
* *
* @param bool $includerelations * @param bool $includerelations
* @return array * @return array
*/ */

View File

@ -14,9 +14,12 @@ use SilverStripe\Forms\TextareaField;
use SilverStripe\Control\Session; use SilverStripe\Control\Session;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\CMS\Model\VirtualPage; use SilverStripe\CMS\Model\VirtualPage;
use SilverStripe\CMS\Model\VirtualPage_Controller; use SilverStripe\CMS\Model\VirtualPageController;
use SubsitesTreeDropdownField;
use Subsite;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Forms\SubsitesTreeDropdownField;
class SubsitesVirtualPage extends VirtualPage { class SubsitesVirtualPage extends VirtualPage {
@ -32,7 +35,7 @@ class SubsitesVirtualPage extends VirtualPage {
public function getCMSFields() { public function getCMSFields() {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$subsites = DataObject::get('Subsite'); $subsites = DataObject::get(Subsite::class);
if(!$subsites) { if(!$subsites) {
$subsites = new ArrayList(); $subsites = new ArrayList();
}else { }else {
@ -45,7 +48,7 @@ class SubsitesVirtualPage extends VirtualPage {
'Root.Main', 'Root.Main',
DropdownField::create( DropdownField::create(
"CopyContentFromID_SubsiteID", "CopyContentFromID_SubsiteID",
_t('SubsitesVirtualPage.SubsiteField',"Subsite"), _t('SubsitesVirtualPage.SubsiteField',Subsite::class),
$subsites->map('ID', 'Title') $subsites->map('ID', 'Title')
)->addExtraClass('subsitestreedropdownfield-chooser no-change-track'), )->addExtraClass('subsitestreedropdownfield-chooser no-change-track'),
'CopyContentFromID' 'CopyContentFromID'

View File

@ -9,6 +9,7 @@ use SilverStripe\Reports\ReportWrapper;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
/** /**
* Creates a subsite-aware version of another report. * Creates a subsite-aware version of another report.
* Pass another report (or its classname) into the constructor. * Pass another report (or its classname) into the constructor.
@ -47,7 +48,7 @@ class SubsiteReportWrapper extends ReportWrapper {
function columns() { function columns() {
$columns = parent::columns(); $columns = parent::columns();
$columns['Subsite.Title'] = "Subsite"; $columns['Subsite.Title'] = Subsite::class;
return $columns; return $columns;
} }

View File

@ -8,7 +8,8 @@ use SilverStripe\Dev\BuildTask;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\Subsites\Model\Subsite; use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\Versioned;
use SubsitesVirtualPage; use SilverStripe\Subsites\Pages\SubsitesVirtualPage;
/** /**
* Handy alternative to copying pages when creating a subsite through the UI. * Handy alternative to copying pages when creating a subsite through the UI.
@ -26,12 +27,12 @@ class SubsiteCopyPagesTask extends BuildTask {
function run($request) { function run($request) {
$subsiteFromId = $request->getVar('from'); $subsiteFromId = $request->getVar('from');
if(!is_numeric($subsiteFromId)) throw new InvalidArgumentException('Missing "from" parameter'); if(!is_numeric($subsiteFromId)) throw new InvalidArgumentException('Missing "from" parameter');
$subsiteFrom = DataObject::get_by_id('Subsite', $subsiteFromId); $subsiteFrom = DataObject::get_by_id(Subsite::class, $subsiteFromId);
if(!$subsiteFrom) throw new InvalidArgumentException('Subsite not found'); if(!$subsiteFrom) throw new InvalidArgumentException('Subsite not found');
$subsiteToId = $request->getVar('to'); $subsiteToId = $request->getVar('to');
if(!is_numeric($subsiteToId)) throw new InvalidArgumentException('Missing "to" parameter'); if(!is_numeric($subsiteToId)) throw new InvalidArgumentException('Missing "to" parameter');
$subsiteTo = DataObject::get_by_id('Subsite', $subsiteToId); $subsiteTo = DataObject::get_by_id(Subsite::class, $subsiteToId);
if(!$subsiteTo) throw new InvalidArgumentException('Subsite not found'); if(!$subsiteTo) throw new InvalidArgumentException('Subsite not found');
$useVirtualPages = (bool)$request->getVar('virtual'); $useVirtualPages = (bool)$request->getVar('virtual');