Skip to content

Commit

Permalink
- namespacing all classes
Browse files Browse the repository at this point in the history
- moving all phpunit tests into tests/php
- moving all extensions from _config.php into config.yml and removing obsolete _config.php
- moving GridFieldSubsiteDetailForm_ItemRequest into own file

(cherry picked from commit ee02828)
  • Loading branch information
Tim Kung authored and wernerkrauss committed May 30, 2017
1 parent d8e72f3 commit 5d3af16
Show file tree
Hide file tree
Showing 32 changed files with 750 additions and 638 deletions.
59 changes: 5 additions & 54 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,11 @@
---
Name: subsiteconfig
After:
- 'framework/*'
---
SilverStripe\Control\Director:
rules:
SubsiteXHRController: SilverStripe\Subsites\Controller\SubsiteXHRController

SilverStripe\AssetAdmin\Controller\AssetAdmin:
treats_subsite_0_as_global: true
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Model\SiteTree:
extensions:
- SilverStripe\Subsites\Extensions\SiteTreeSubsites

SilverStripe\CMS\Controllers\ContentController:
extensions:
- SilverStripe\Subsites\Extensions\ControllerSubsites

SilverStripe\CMS\Controllers\CMSPageAddController:
extensions:
- SilverStripe\Subsites\Extensions\CMSPageAddControllerExtension

SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\Subsites\Extensions\LeftAndMainSubsites
- SilverStripe\Subsites\Extensions\ControllerSubsites

SilverStripe\Security\Group:
extensions:
- SilverStripe\Subsites\Extensions\GroupSubsites

SilverStripe\Assets\File:
extensions:
- SilverStripe\Subsites\Extensions\FileSubsites

SilverStripe\CMS\Model\ErrorPage:
extensions:
- SilverStripe\Subsites\Extensions\ErrorPageSubsite

SilverStripe\SiteConfig\SiteConfig:
extensions:
- SilverStripe\Subsites\Extensions\SiteConfigSubsites

SilverStripe\Admin\SecurityAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Controllers\CMSMain:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Controllers\CMSPagesController:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\Subsites\Admin\SubsiteAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
SilverStripe\Control\Director:
rules:
SubsiteXHRController: SilverStripe\Subsites\Controller\SubsiteXHRController
65 changes: 65 additions & 0 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
Name: subsiteextensions
After:
- 'framework/*'
---
SilverStripe\CMS\Model\SiteTree:
extensions:
- SilverStripe\Subsites\Extensions\SiteTreeSubsites

SilverStripe\CMS\Controllers\ContentController:
extensions:
- SilverStripe\Subsites\Extensions\ControllerSubsites

SilverStripe\CMS\Controllers\CMSPageAddController:
extensions:
- SilverStripe\Subsites\Extensions\CMSPageAddControllerExtension

SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\Subsites\Extensions\LeftAndMainSubsites
- SilverStripe\Subsites\Extensions\ControllerSubsites

SilverStripe\Security\Group:
extensions:
- SilverStripe\Subsites\Extensions\GroupSubsites

SilverStripe\Assets\File:
extensions:
- SilverStripe\Subsites\Extensions\FileSubsites

SilverStripe\CMS\Model\ErrorPage:
extensions:
- SilverStripe\Subsites\Extensions\ErrorPageSubsite

SilverStripe\SiteConfig\SiteConfig:
extensions:
- SilverStripe\Subsites\Extensions\SiteConfigSubsites

SilverStripe\Reports\Report:
extensions:
- SilverStripe\Subsites\SubsiteReportWrapper

SilverStripe\AssetAdmin\Controller\AssetAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\Admin\SecurityAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Controllers\CMSMain:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Controllers\CMSPagesController:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\Subsites\SubsiteAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension

SilverStripe\CMS\Controllers\CMSPageSettingsController:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
2 changes: 0 additions & 2 deletions code/extensions/CMSPageAddControllerExtension.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

namespace SilverStripe\Subsites\Extensions;


use SilverStripe\Core\Extension;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Subsites\Model\Subsite;
Expand Down
4 changes: 2 additions & 2 deletions code/extensions/ControllerSubsites.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

namespace SilverStripe\Subsites\Extensions;


use SilverStripe\Core\Extension;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\View\SSViewer;
Expand All @@ -12,6 +10,7 @@
*/
class ControllerSubsites extends Extension
{

public function controllerAugmentInit()
{
if ($subsite = Subsite::currentSubsite()) {
Expand All @@ -27,4 +26,5 @@ public function CurrentSubsite()
return $subsite;
}
}

}
2 changes: 2 additions & 0 deletions code/extensions/ErrorPageSubsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class ErrorPageSubsite extends DataExtension
{

/**
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
*
Expand Down Expand Up @@ -49,4 +50,5 @@ public function alternateFilepathForErrorcode($statusCode, $locale = null)

return $filepath;
}

}
3 changes: 0 additions & 3 deletions code/extensions/FileSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace SilverStripe\Subsites\Extensions;


use SilverStripe\Assets\Folder;
use SilverStripe\Control\Session;
use SilverStripe\Forms\DropdownField;
Expand All @@ -13,8 +12,6 @@
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\Security\Permission;
use SilverStripe\Subsites\Model\Subsite;


/**
* Extension for the File object to add subsites support
*
Expand Down
24 changes: 15 additions & 9 deletions code/extensions/LeftAndMainSubsites.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
<?php

use SilverStripe\View\Requirements;
namespace SilverStripe\Subsites\Extensions;

use SilverStripe\Admin\CMSMenu;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Session;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Security\Member;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Core\Config\Config;
use SilverStripe\View\ArrayData;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Control\Session;
use SilverStripe\Admin\CMSMenu;
use SilverStripe\Security\Security;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Extension;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;

/**
* Decorator designed to add subsites support to LeftAndMain
*
* @package subsites
*/
class LeftAndMainSubsites extends Extension
{

private static $allowed_actions = array('CopyToSubsite');

/**
Expand Down Expand Up @@ -351,4 +356,5 @@ public function copytosubsite($data, $form)
$newPage->ID
));
}

}
7 changes: 4 additions & 3 deletions code/extensions/SiteConfigSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
class SiteConfigSubsites extends DataExtension
{
private static $has_one = [
'Subsite' => Subsite::class, // The subsite that this page belongs to
];
private static $has_one = [
'Subsite' => Subsite::class, // The subsite that this page belongs to
];

/**
* Update any requests to limit the results to the current site
Expand Down Expand Up @@ -66,4 +66,5 @@ public function updateCMSFields(FieldList $fields)
{
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}

}
64 changes: 33 additions & 31 deletions code/extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@

use Page;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\DataQuery;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\InlineFormAction;
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\Core\Config\Config;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\View\SSViewer;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTP;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\InlineFormAction;
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\View\SSViewer;


/**
* Extension for the SiteTree object to add subsites support
*/
class SiteTreeSubsites extends DataExtension
{

private static $has_one = [
'Subsite' => Subsite::class, // The subsite that this page belongs to
];
Expand All @@ -50,11 +51,11 @@ public function isMainSite()
return false;
}

/**
* Update any requests to limit the results to the current site
* @param SQLSelect $query
* @param DataQuery $dataQuery
*/
/**
* Update any requests to limit the results to the current site
* @param SQLSelect $query
* @param DataQuery $dataQuery
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
if (Subsite::$disable_subsite_filter) {
Expand Down Expand Up @@ -114,16 +115,16 @@ public function updateCMSFields(FieldList $fields)
$fields->addFieldsToTab(
'Root.Main',
ToggleCompositeField::create('SubsiteOperations',
_t('SiteTreeSubsites.SubsiteOperations', 'Subsite Operations'),
array(
new DropdownField("CopyToSubsiteID", _t('SiteTreeSubsites.CopyToSubsite', "Copy page to subsite"), $subsitesMap),
new CheckboxField("CopyToSubsiteWithChildren", _t('SiteTreeSubsites.CopyToSubsiteWithChildren', 'Include children pages?')),
$copyAction = new InlineFormAction(
"copytosubsite",
_t('SiteTreeSubsites.CopyAction', "Copy")
)
)
)->setHeadingLevel(4)
_t('SiteTreeSubsites.SubsiteOperations', 'Subsite Operations'),
array(
new DropdownField("CopyToSubsiteID", _t('SiteTreeSubsites.CopyToSubsite', "Copy page to subsite"), $subsitesMap),
new CheckboxField("CopyToSubsiteWithChildren", _t('SiteTreeSubsites.CopyToSubsiteWithChildren', 'Include children pages?')),
$copyAction = new InlineFormAction(
"copytosubsite",
_t('SiteTreeSubsites.CopyAction', "Copy")
)
)
)->setHeadingLevel(4)
);


Expand Down Expand Up @@ -276,10 +277,10 @@ public function duplicateToSubsite($subsiteID = null, $includeChildren = false,
Subsite::changeSubsite($oldSubsite);

if($includeChildren) {
foreach($this->owner->AllChildren() as $child) {
$child->duplicateToSubsite($subsiteID, $includeChildren, $page->ID);
}
}
foreach($this->owner->AllChildren() as $child) {
$child->duplicateToSubsite($subsiteID, $includeChildren, $page->ID);
}
}

return $page;
}
Expand Down Expand Up @@ -420,4 +421,5 @@ public function canCreate($member = null)
}
}
}

}
Loading

0 comments on commit 5d3af16

Please sign in to comment.