Skip to content

Commit

Permalink
Merge branch '3.2' into 3
Browse files Browse the repository at this point in the history
# Conflicts:
#	yarn.lock
  • Loading branch information
GuySartorelli committed Jun 20, 2024
2 parents ce4987f + 41e5132 commit 08c3eae
Show file tree
Hide file tree
Showing 12 changed files with 508 additions and 897 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/add-prs-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Add new PRs to github project

on:
pull_request_target:
types:
- opened
- ready_for_review

permissions: {}

jobs:
addprtoproject:
name: Add PR to GitHub Project
# Only run on the silverstripe account
if: github.repository_owner == 'silverstripe'
runs-on: ubuntu-latest
steps:
- name: Add PR to github project
uses: silverstripe/gha-add-pr-to-project@v1
with:
app_id: ${{ vars.PROJECT_PERMISSIONS_APP_ID }}
private_key: ${{ secrets.PROJECT_PERMISSIONS_APP_PRIVATE_KEY }}
1 change: 0 additions & 1 deletion .stylelintignore

This file was deleted.

10 changes: 1 addition & 9 deletions client/src/styles/LeftAndMain_Subsites.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@
height: 51px;
border-bottom: 3px solid #d4d0c8;
color: #fff;
}

#SubsiteActions {
fieldset {
padding: 3px;
border-style: none;
margin-top: 1px;
background: none;
}
}

#SubsiteActions {
fieldset {
span {
padding: 3px;
}
Expand All @@ -44,7 +38,7 @@
.dropdown {
span {
padding-left: 5px;
color: black;
color: #000;
}
}
}
Expand Down Expand Up @@ -75,9 +69,7 @@
.field {
margin-left: 100px;
}
}

#Form_AddSubsiteForm {
label.left {
float: left;
width: 100px;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://github.com/silverstripe/silverstripe-subsites#readme",
"dependencies": {},
"devDependencies": {
"@silverstripe/eslint-config": "^1.2.1",
"@silverstripe/eslint-config": "^1.3.0",
"@silverstripe/webpack-config": "^2.1.0",
"webpack": "^5.74.0",
"webpack-cli": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SubsiteXHRController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public function getResponseNegotiator(): PjaxResponseNegotiator
*/
public function SubsiteList()
{
return $this->renderWith(['type' => 'Includes', self::class . '_subsitelist']);
return $this->renderWith(['type' => 'Includes', SubsiteXHRController::class . '_subsitelist']);
}
}
2 changes: 1 addition & 1 deletion src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public static function contentcontrollerInit($controller)
SSViewer::set_themes(ThemeResolver::singleton()->getThemeList($subsite));
}

$ignore_subsite_locale = Config::inst()->get(self::class, 'ignore_subsite_locale');
$ignore_subsite_locale = Config::inst()->get(SiteTreeSubsites::class, 'ignore_subsite_locale');

if (!$ignore_subsite_locale
&& $subsite
Expand Down
38 changes: 19 additions & 19 deletions src/Model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Subsite extends DataObject
*/
public static function set_allowed_themes($themes)
{
self::$allowed_themes = $themes;
Subsite::$allowed_themes = $themes;
}

/**
Expand Down Expand Up @@ -250,8 +250,8 @@ public static function getSubsiteIDForDomain($host = null, $checkPermissions = t

$currentUserId = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
$cacheKey = implode('_', [$host, $currentUserId, static::config()->get('check_is_public')]);
if (isset(self::$cache_subsite_for_domain[$cacheKey])) {
return self::$cache_subsite_for_domain[$cacheKey];
if (isset(Subsite::$cache_subsite_for_domain[$cacheKey])) {
return Subsite::$cache_subsite_for_domain[$cacheKey];
}

$SQL_host = Convert::raw2sql($host);
Expand Down Expand Up @@ -301,7 +301,7 @@ public static function getSubsiteIDForDomain($host = null, $checkPermissions = t
}

if ($cacheKey) {
self::$cache_subsite_for_domain[$cacheKey] = $subsiteID;
Subsite::$cache_subsite_for_domain[$cacheKey] = $subsiteID;
}

return $subsiteID;
Expand Down Expand Up @@ -329,15 +329,15 @@ public static function get_from_all_subsites($className, $filter = '', $sort = '
*/
public static function disable_subsite_filter($disabled = true)
{
self::$disable_subsite_filter = $disabled;
Subsite::$disable_subsite_filter = $disabled;
}

public static function withDisabledSubsiteFilter(callable $callable, bool $disabled = true): mixed
{
$orig = self::$disable_subsite_filter;
self::disable_subsite_filter($disabled);
$orig = Subsite::$disable_subsite_filter;
Subsite::disable_subsite_filter($disabled);
$ret = $callable();
self::disable_subsite_filter($orig);
Subsite::disable_subsite_filter($orig);
return $ret;
}

Expand All @@ -346,8 +346,8 @@ public static function withDisabledSubsiteFilter(callable $callable, bool $disab
*/
public static function on_db_reset()
{
self::$cache_accessible_sites = [];
self::$cache_subsite_for_domain = [];
Subsite::$cache_accessible_sites = [];
Subsite::$cache_subsite_for_domain = [];
}

/**
Expand Down Expand Up @@ -453,8 +453,8 @@ public static function accessible_sites(

// Cache handling
$cacheKey = $SQL_codes . '-' . $member->ID . '-' . $includeMainSite . '-' . $mainSiteTitle;
if (isset(self::$cache_accessible_sites[$cacheKey])) {
return self::$cache_accessible_sites[$cacheKey];
if (isset(Subsite::$cache_accessible_sites[$cacheKey])) {
return Subsite::$cache_accessible_sites[$cacheKey];
}

$subsites = DataList::create(Subsite::class)
Expand Down Expand Up @@ -517,7 +517,7 @@ public static function accessible_sites(
if (!is_array($permCode)) {
$permCode = [$permCode];
}
if (self::hasMainSitePermission($member, $permCode)) {
if (Subsite::hasMainSitePermission($member, $permCode)) {
$subsites = $subsites->toArray();

$mainSite = new Subsite();
Expand All @@ -527,7 +527,7 @@ public static function accessible_sites(
}
}

self::$cache_accessible_sites[$cacheKey] = $subsites;
Subsite::$cache_accessible_sites[$cacheKey] = $subsites;

return $subsites;
}
Expand Down Expand Up @@ -771,7 +771,7 @@ public function fieldLabels($includerelations = true)
*/
public function allowedThemes()
{
if (($themes = self::$allowed_themes) || ($themes = ThemeResolver::singleton()->getCustomThemeOptions())) {
if (($themes = Subsite::$allowed_themes) || ($themes = ThemeResolver::singleton()->getCustomThemeOptions())) {
return ArrayLib::valuekey($themes);
}

Expand Down Expand Up @@ -958,7 +958,7 @@ public function duplicate(bool $doWrite = true, ?array $manyMany = null): static
$duplicate = parent::duplicate($doWrite);

$oldSubsiteID = SubsiteState::singleton()->getSubsiteId();
self::changeSubsite($this->ID);
Subsite::changeSubsite($this->ID);

/*
* Copy data from this object to the given subsite. Does this using an iterative depth-first search.
Expand All @@ -973,21 +973,21 @@ public function duplicate(bool $doWrite = true, ?array $manyMany = null): static

if ($children) {
foreach ($children as $child) {
self::changeSubsite($duplicate->ID); //Change to destination subsite
Subsite::changeSubsite($duplicate->ID); //Change to destination subsite

$childClone = $child->duplicateToSubsite($duplicate, false);
$childClone->ParentID = $destParentID;
$childClone->writeToStage('Stage');
$childClone->copyVersionToStage('Stage', 'Live');

self::changeSubsite($this->ID); //Change Back to this subsite
Subsite::changeSubsite($this->ID); //Change Back to this subsite

array_push($stack, [$child->ID, $childClone->ID]);
}
}
}

self::changeSubsite($oldSubsiteID);
Subsite::changeSubsite($oldSubsiteID);

return $duplicate;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Model/SubsiteDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public function onAfterWrite()
public function getCMSFields()
{
$protocols = [
self::PROTOCOL_HTTP => _t(__CLASS__ . '.PROTOCOL_HTTP', 'http://'),
self::PROTOCOL_HTTPS => _t(__CLASS__ . '.PROTOCOL_HTTPS', 'https://'),
self::PROTOCOL_AUTOMATIC => _t(__CLASS__ . '.PROTOCOL_AUTOMATIC', 'Automatic')
SubsiteDomain::PROTOCOL_HTTP => _t(__CLASS__ . '.PROTOCOL_HTTP', 'http://'),
SubsiteDomain::PROTOCOL_HTTPS => _t(__CLASS__ . '.PROTOCOL_HTTPS', 'https://'),
SubsiteDomain::PROTOCOL_AUTOMATIC => _t(__CLASS__ . '.PROTOCOL_AUTOMATIC', 'Automatic')
];
$fields = FieldList::create(
WildcardDomainField::create('Domain', $this->fieldLabel('Domain'), null, 255)
Expand All @@ -119,7 +119,7 @@ public function getCMSFields()
'Hostname of this subsite (exclude protocol). Allows wildcards (*).'
)),
OptionsetField::create('Protocol', $this->fieldLabel('Protocol'), $protocols)
->setValue($this->Protocol ?: self::PROTOCOL_AUTOMATIC)
->setValue($this->Protocol ?: SubsiteDomain::PROTOCOL_AUTOMATIC)
->setDescription(_t(
__CLASS__ . '.PROTOCOL_DESCRIPTION',
'When generating links to this subsite, use the selected protocol. <br />' .
Expand Down Expand Up @@ -169,9 +169,9 @@ public function Link()
public function getFullProtocol()
{
switch ($this->Protocol) {
case self::PROTOCOL_HTTPS:
case SubsiteDomain::PROTOCOL_HTTPS:
return 'https://';
case self::PROTOCOL_HTTP:
case SubsiteDomain::PROTOCOL_HTTP:
return 'http://';
default:
return Director::protocol();
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/SubsitesVirtualPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getVirtualFields()
}
}

foreach (self::$db as $field => $type) {
foreach (SubsitesVirtualPage::$db as $field => $type) {
if (in_array($field, $fields ?? [])) {
unset($fields[array_search($field, $fields)]);
}
Expand Down
11 changes: 6 additions & 5 deletions src/Reports/SubsiteReportWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class SubsiteReportWrapper extends ReportWrapper
public function parameterFields()
{
$subsites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true);
$options = [self::SUBSITE_ID_ALL => _t(__CLASS__ . '.ReportDropdownAll', 'All')] + $subsites->map()->toArray();
$text = _t(__CLASS__ . '.ReportDropdownAll', 'All');
$options = [SubsiteReportWrapper::SUBSITE_ID_ALL => $text] + $subsites->map()->toArray();

$subsiteField = DropdownField::create(
'Subsite',
Expand Down Expand Up @@ -56,8 +57,8 @@ public function columns()

public function sourceQuery($params)
{
$subsiteID = (int) ($params['Subsite'] ?? self::SUBSITE_ID_ALL);
if ($subsiteID === self::SUBSITE_ID_ALL) {
$subsiteID = (int) ($params['Subsite'] ?? SubsiteReportWrapper::SUBSITE_ID_ALL);
if ($subsiteID === SubsiteReportWrapper::SUBSITE_ID_ALL) {
return Subsite::withDisabledSubsiteFilter(function () use ($params) {
return parent::sourceQuery($params);
});
Expand All @@ -70,8 +71,8 @@ public function sourceQuery($params)

public function sourceRecords($params = [], $sort = null, $limit = null)
{
$subsiteID = (int) ($params['Subsite'] ?? self::SUBSITE_ID_ALL);
if ($subsiteID === self::SUBSITE_ID_ALL) {
$subsiteID = (int) ($params['Subsite'] ?? SubsiteReportWrapper::SUBSITE_ID_ALL);
if ($subsiteID === SubsiteReportWrapper::SUBSITE_ID_ALL) {
return Subsite::withDisabledSubsiteFilter(function () use ($params, $sort, $limit) {
return parent::sourceRecords($params, $sort, $limit);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/php/SiteTreeSubsitesTest/TestErrorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class TestErrorPage extends ErrorPage implements TestOnly
*/
public static function get_error_filename_spy($statusCode)
{
return self::get_error_filename($statusCode);
return TestErrorPage::get_error_filename($statusCode);
}
}
Loading

0 comments on commit 08c3eae

Please sign in to comment.