mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
Merge pull request #51 from silverstripe-rebelalliance/3.01
Merge in beta changes for compatibility with SilverStripe 3.0.1
This commit is contained in:
commit
68bc12d74a
@ -6,7 +6,7 @@ The subsites module allows multiple websites to run from a single installation o
|
||||
|
||||
## Requirements
|
||||
|
||||
* SilverStripe 2.3
|
||||
* SilverStripe 3.0
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -15,6 +15,8 @@ Object::add_extension('LeftAndMain', 'ControllerSubsites');
|
||||
Object::add_extension('Group', 'GroupSubsites');
|
||||
Object::add_extension('File', 'FileSubsites');
|
||||
Object::add_extension('ErrorPage', 'ErrorPageSubsite');
|
||||
if (class_exists('SiteConfig')) Object::add_extension('SiteConfig', 'SiteConfigSubsites');
|
||||
Object::add_extension('SiteConfig', 'SiteConfigSubsites');
|
||||
|
||||
|
||||
SS_Report::add_excluded_reports('SubsiteReportWrapper');
|
||||
?>
|
@ -6,83 +6,26 @@
|
||||
*/
|
||||
class SubsiteAdmin extends ModelAdmin {
|
||||
|
||||
static $managed_models = array('Subsite');
|
||||
static $managed_models = array('Subsite', 'Subsite_Template');
|
||||
static $url_segment = 'subsites';
|
||||
|
||||
static $menu_title = "Subsites";
|
||||
|
||||
static $collection_controller_class = "SubsiteAdmin_CollectionController";
|
||||
}
|
||||
public $showImportForm=false;
|
||||
|
||||
class SubsiteAdmin_CollectionController extends ModelAdmin_CollectionController {
|
||||
function AddForm() {
|
||||
$form = parent::AddForm();
|
||||
public function getEditForm($id = null, $fields = null) {
|
||||
$form = parent::getEditForm($id, $fields);
|
||||
|
||||
$templates = DataObject::get('Subsite_Template', '', 'Title');
|
||||
$templateArray = array('' => "(No template)");
|
||||
if($templates) {
|
||||
$templateArray = $templateArray + $templates->map('ID', 'Title');
|
||||
if($this->modelClass=='Subsite') {
|
||||
$grid=$form->Fields()->dataFieldByName('Subsite');
|
||||
if($grid) {
|
||||
$grid->getConfig()->removeComponentsByType('GridFieldDetailForm');
|
||||
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());
|
||||
}
|
||||
}
|
||||
|
||||
$form->Fields()->addFieldsToTab('Root.Configuration', array(
|
||||
new DropdownField('Type', 'Type', array(
|
||||
'subsite' => 'New site',
|
||||
'template' => 'New template',
|
||||
)),
|
||||
new DropdownField('TemplateID', 'Copy structure from:', $templateArray)
|
||||
));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function doCreate($data, $form, $request) {
|
||||
if(isset($data['TemplateID']) && $data['TemplateID']) {
|
||||
$template = DataObject::get_by_id('Subsite_Template', $data['TemplateID']);
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
|
||||
// Create subsite from existing template
|
||||
switch($data['Type']) {
|
||||
case 'template':
|
||||
if($template) $subsite = $template->duplicate();
|
||||
else {
|
||||
$subsite = new Subsite_Template();
|
||||
$subsite->write();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'subsite':
|
||||
default:
|
||||
if($template) $subsite = $template->createInstance($data['Title']);
|
||||
else {
|
||||
$subsite = new Subsite();
|
||||
$subsite->Title = $data['Title'];
|
||||
$subsite->write();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$form->dataFieldByName('Domains')->setExtraData(array(
|
||||
"SubsiteID" => $subsite->ID,
|
||||
));
|
||||
$form->saveInto($subsite);
|
||||
$subsite->write();
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
$recordController = new ModelAdmin_RecordController($this, $request, $subsite->ID);
|
||||
return new SS_HTTPResponse(
|
||||
$recordController->EditForm()->forAjaxTemplate(),
|
||||
200,
|
||||
sprintf(
|
||||
_t('ModelAdmin.LOADEDFOREDITING', "Loaded '%s' for editing."),
|
||||
$subsite->Title
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Director::redirect(Controller::join_links($this->Link(), $subsitess->ID , 'edit'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -24,7 +24,7 @@ class SubsiteReportWrapper extends SS_ReportWrapper {
|
||||
if($fields) {
|
||||
$fields->insertBefore($subsiteField, $fields->First()->Name());
|
||||
} else {
|
||||
$fields = new FieldSet($subsiteField);
|
||||
$fields = new FieldList($subsiteField);
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Wraps around a TreedropdownField to add ability for temporary
|
||||
* switching of subsite sessions.
|
||||
*
|
||||
* @package subsites
|
||||
*/
|
||||
class SubsitesTreeDropdownField extends TreeDropdownField {
|
||||
|
||||
protected $subsiteID = 0;
|
||||
|
||||
protected $extraClasses = array('SubsitesTreeDropdownField');
|
||||
|
||||
function Field() {
|
||||
$html = parent::Field();
|
||||
|
||||
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function setSubsiteID($id) {
|
||||
$this->subsiteID = $id;
|
||||
}
|
||||
|
||||
function getSubsiteID() {
|
||||
return $this->subsiteID;
|
||||
}
|
||||
|
||||
function gettree(SS_HTTPRequest $request) {
|
||||
$oldSubsiteID = Session::get('SubsiteID');
|
||||
Session::set('SubsiteID', $this->subsiteID);
|
||||
|
||||
$results = parent::tree($request);
|
||||
|
||||
Session::set('SubsiteID', $oldSubsiteID);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getsubtree(SS_HTTPRequest $request) {
|
||||
$oldSubsiteID = Session::get('SubsiteID');
|
||||
Session::set('SubsiteID', $this->subsiteID);
|
||||
|
||||
$obj = $this->objectForKey($_REQUEST['SubtreeRootID']);
|
||||
|
||||
if(!$obj) user_error("Can't find database record $this->sourceObject with $this->keyField = $_REQUEST[SubtreeRootID]", E_USER_ERROR);
|
||||
|
||||
if($this->filterFunc) $obj->setMarkingFilterFunction($this->filterFunc);
|
||||
else if($this->sourceObject == 'Folder') $obj->setMarkingFilter('ClassName', 'Folder');
|
||||
$obj->markPartialTree();
|
||||
|
||||
$eval = '"<li id=\"selector-' . $this->name . '-$child->' . $this->keyField . '\" class=\"$child->class" . $child->markingClasses() . "\"><a>" . $child->' . $this->labelField . ' . "</a>"';
|
||||
$tree = $obj->getChildrenAsUL("", $eval, null, true);
|
||||
echo substr(trim($tree), 4,-5);
|
||||
|
||||
Session::set('SubsiteID', $oldSubsiteID);
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +1,32 @@
|
||||
<?php
|
||||
class SubsitesVirtualPage extends VirtualPage {
|
||||
static $db = array(
|
||||
public static $db = array(
|
||||
'CustomMetaTitle' => 'Varchar(255)',
|
||||
'CustomMetaKeywords' => 'Varchar(255)',
|
||||
'CustomMetaDescription' => 'Text',
|
||||
'CustomExtraMeta' => 'HTMLText'
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
public function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
|
||||
$subsites = DataObject::get('Subsite');
|
||||
if(!$subsites) $subsites = new DataObjectSet();
|
||||
if(!$subsites) {
|
||||
$subsites = new ArrayList();
|
||||
}else {
|
||||
$subsites=ArrayList::create($subsites->toArray());
|
||||
}
|
||||
|
||||
$subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
|
||||
|
||||
$subsiteSelectionField = new DropdownField(
|
||||
"CopyContentFromID_SubsiteID",
|
||||
"Subsite",
|
||||
$subsites->toDropdownMap('ID', 'Title'),
|
||||
$subsites->map('ID', 'Title'),
|
||||
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
||||
);
|
||||
$fields->addFieldToTab(
|
||||
'Root.Content.Main',
|
||||
'Root.Main',
|
||||
$subsiteSelectionField,
|
||||
'CopyContentFromID'
|
||||
);
|
||||
@ -36,36 +41,37 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
);
|
||||
|
||||
if(Controller::has_curr() && Controller::curr()->getRequest()) {
|
||||
$subsiteID = Controller::curr()->getRequest()->getVar('CopyContentFromID_SubsiteID');
|
||||
$subsiteID = Controller::curr()->getRequest()->postVar('CopyContentFromID_SubsiteID');
|
||||
$pageSelectionField->setSubsiteID($subsiteID);
|
||||
}
|
||||
$fields->replaceField('CopyContentFromID', $pageSelectionField);
|
||||
|
||||
// Create links back to the original object in the CMS
|
||||
if($this->CopyContentFromID) {
|
||||
$editLink = "admin/show/$this->CopyContentFromID/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
|
||||
$editLink = "admin/page/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.Content.Main",
|
||||
"Root.Main",
|
||||
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
||||
'Title'
|
||||
);
|
||||
$linkToContentLabelField->setAllowHTML(true);
|
||||
}
|
||||
|
||||
$fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
||||
$fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||
$fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
||||
$fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
||||
|
||||
$fields->addFieldToTab('Root.Main', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
||||
$fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||
$fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
||||
$fields->addFieldToTab('Root.Main', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function getVirtualFields() {
|
||||
public function getVirtualFields() {
|
||||
$fields = parent::getVirtualFields();
|
||||
foreach($fields as $k => $v) {
|
||||
if($v == 'SubsiteID') unset($fields[$k]);
|
||||
@ -76,14 +82,14 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function syncLinkTracking() {
|
||||
public function syncLinkTracking() {
|
||||
$oldState = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
if ($this->CopyContentFromID) $this->HasBrokenLink = DataObject::get_by_id('SiteTree', $this->CopyContentFromID) ? false : true;
|
||||
Subsite::$disable_subsite_filter = $oldState;
|
||||
}
|
||||
|
||||
function onBeforeWrite() {
|
||||
public function onBeforeWrite() {
|
||||
parent::onBeforeWrite();
|
||||
|
||||
if($this->CustomMetaTitle) $this->MetaTitle = $this->CustomMetaTitle;
|
||||
@ -104,13 +110,13 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
}
|
||||
}
|
||||
|
||||
function validURLSegment() {
|
||||
public function validURLSegment() {
|
||||
$isValid = parent::validURLSegment();
|
||||
|
||||
// Veto the validation rules if its false. In this case, some logic
|
||||
// needs to be duplicated from parent to find out the exact reason the validation failed.
|
||||
if(!$isValid) {
|
||||
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
||||
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
||||
$parentFilter = null;
|
||||
|
||||
if(self::nested_urls()) {
|
||||
@ -146,13 +152,13 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
|
||||
class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
||||
|
||||
function reloadContent() {
|
||||
public function reloadContent() {
|
||||
$this->failover->copyFrom($this->failover->CopyContentFrom());
|
||||
$this->failover->write();
|
||||
return;
|
||||
}
|
||||
|
||||
function init(){
|
||||
public function init(){
|
||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class ErrorPageSubsite extends DataObjectDecorator {
|
||||
class ErrorPageSubsite extends DataExtension {
|
||||
|
||||
/**
|
||||
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
|
44
code/FileSubsites.php → code/extensions/FileSubsites.php
Executable file → Normal file
44
code/FileSubsites.php → code/extensions/FileSubsites.php
Executable file → Normal file
@ -4,20 +4,16 @@
|
||||
*
|
||||
* @package subsites
|
||||
*/
|
||||
class FileSubsites extends DataObjectDecorator {
|
||||
class FileSubsites extends DataExtension {
|
||||
|
||||
// If this is set to true, all folders created will be default be
|
||||
// considered 'global', unless set otherwise
|
||||
static $default_root_folders_global = false;
|
||||
|
||||
function extraStatics() {
|
||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics') && $this->owner->class != 'File') return null;
|
||||
return array(
|
||||
'has_one' => array(
|
||||
'Subsite' => 'Subsite',
|
||||
),
|
||||
);
|
||||
}
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Amends the CMS tree title for folders in the Files & Images section.
|
||||
@ -31,13 +27,16 @@ class FileSubsites extends DataObjectDecorator {
|
||||
/**
|
||||
* Add subsites-specific fields to the folder editor.
|
||||
*/
|
||||
function updateCMSFields(FieldSet &$fields) {
|
||||
function updateCMSFields(FieldList $fields) {
|
||||
if($this->owner instanceof Folder) {
|
||||
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
|
||||
$dropdownValues = ($sites) ? $sites->toDropdownMap() : array();
|
||||
$dropdownValues = array();
|
||||
$dropdownValues[0] = 'All sites';
|
||||
foreach ($sites as $site) {
|
||||
$dropDownValues[$site->ID] = $site->Title;
|
||||
}
|
||||
ksort($dropdownValues);
|
||||
if($sites)$fields->addFieldToTab('Root.Details', new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
||||
if($sites)$fields->push(new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,22 +45,24 @@ class FileSubsites extends DataObjectDecorator {
|
||||
*/
|
||||
function augmentSQL(SQLQuery &$query) {
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse)
|
||||
if(!$query->where || !preg_match('/\.(\'|"|`|)ID(\'|"|`|)/', $query->where[0])) {
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
|
||||
else $subsiteID = (int) Subsite::currentSubsiteID();
|
||||
//@TODO I don't think excluding if SiteTree_ImageTracking is a good idea however because of the SS 3.0 api and ManyManyList::removeAll() changing the from table after this function is called there isn't much of a choice
|
||||
if(!array_search('SiteTree_ImageTracking', $query->getFrom())===false && (!$query->where || !preg_match('/\.(\'|"|`|)ID(\'|"|`|)/', $query->where[0]))) {
|
||||
/*if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
|
||||
else */$subsiteID = (int) Subsite::currentSubsiteID();
|
||||
|
||||
// The foreach is an ugly way of getting the first key :-)
|
||||
foreach($query->from as $tableName => $info) {
|
||||
foreach($query->getFrom() as $tableName => $info) {
|
||||
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
||||
$query->where[] = $where;
|
||||
$query->addWhere($where);
|
||||
break;
|
||||
}
|
||||
|
||||
$isCounting = strpos($query->select[0], 'COUNT') !== false;
|
||||
$sect=array_values($query->getSelect());
|
||||
$isCounting = strpos($sect[0], 'COUNT') !== false;
|
||||
|
||||
// Ordering when deleting or counting doesn't apply
|
||||
if(!$query->delete && !$isCounting) {
|
||||
$query->orderby = "\"SubsiteID\"" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
if(!$query->getDelete() && !$isCounting) {
|
||||
$query->addOrderBy("\"SubsiteID\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,7 +87,7 @@ class FileSubsites extends DataObjectDecorator {
|
||||
$this->owner->write();
|
||||
}
|
||||
|
||||
function canEdit() {
|
||||
function canEdit($member = null) {
|
||||
// Check the CMS_ACCESS_SecurityAdmin privileges on the subsite that owns this group
|
||||
$subsiteID = Session::get('SubsiteID');
|
||||
if($subsiteID&&$subsiteID == $this->owner->SubsiteID) {
|
||||
@ -109,4 +110,3 @@ class FileSubsites extends DataObjectDecorator {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,24 +4,19 @@
|
||||
*
|
||||
* @package subsites
|
||||
*/
|
||||
class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
||||
class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||
|
||||
function extraStatics() {
|
||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics')) {
|
||||
if($this->owner->class != 'Group') return null;
|
||||
}
|
||||
return array(
|
||||
'db' => array(
|
||||
'AccessAllSubsites' => 'Boolean',
|
||||
),
|
||||
'many_many' => array(
|
||||
'Subsites' => 'Subsite',
|
||||
),
|
||||
'defaults' => array(
|
||||
'AccessAllSubsites' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
public static $db=array(
|
||||
'AccessAllSubsites' => 'Boolean'
|
||||
);
|
||||
|
||||
public static $many_many=array(
|
||||
'Subsites' => 'Subsite'
|
||||
);
|
||||
|
||||
public static $defaults=array(
|
||||
'AccessAllSubsites' => true
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
@ -54,13 +49,13 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
function updateCMSFields(&$fields) {
|
||||
function updateCMSFields(FieldList $fields) {
|
||||
if($this->owner->canEdit() ){
|
||||
// i18n tab
|
||||
$fields->findOrMakeTab('Root.Subsites',_t('GroupSubsites.SECURITYTABTITLE','Subsites'));
|
||||
|
||||
$subsites = Subsite::accessible_sites(array('ADMIN', 'SECURITY_SUBSITE_GROUP'), true);
|
||||
$subsiteMap = $subsites->toDropdownMap();
|
||||
$subsiteMap = $subsites->map();
|
||||
|
||||
// Interface is different if you have the rights to modify subsite group values on
|
||||
// all subsites
|
||||
@ -116,29 +111,32 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||
if(!$query->filtersOnID()) {
|
||||
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
||||
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||
|
||||
// Don't filter by Group_Subsites if we've already done that
|
||||
$hasGroupSubsites = false;
|
||||
foreach($query->from as $item) if(strpos($item, 'Group_Subsites') !== false) {
|
||||
$hasGroupSubsites = true;
|
||||
break;
|
||||
foreach($query->getFrom() as $item) {
|
||||
if((is_array($item) && strpos($item['table'], 'Group_Subsites')!==false) || (!is_array($item) && strpos($item, 'Group_Subsites')!==false)) {
|
||||
$hasGroupSubsites = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$hasGroupSubsites) {
|
||||
if($subsiteID) {
|
||||
$query->leftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
||||
$query->addLeftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
||||
= \"Group\".\"ID\" AND \"Group_Subsites\".\"SubsiteID\" = $subsiteID");
|
||||
$query->where[] = "(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR
|
||||
\"Group\".\"AccessAllSubsites\" = 1)";
|
||||
$query->addWhere("(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR
|
||||
\"Group\".\"AccessAllSubsites\" = 1)");
|
||||
} else {
|
||||
$query->where[] = "\"Group\".\"AccessAllSubsites\" = 1";
|
||||
$query->addWhere("\"Group\".\"AccessAllSubsites\" = 1");
|
||||
}
|
||||
}
|
||||
|
||||
// WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server)
|
||||
if(!$query->select[0] == 'COUNT(*)') {
|
||||
$select=$query->getSelect();
|
||||
if(isset($select[0]) && !$select[0] == 'COUNT(*)') {
|
||||
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
}
|
||||
}
|
@ -19,6 +19,9 @@ class LeftAndMainSubsites extends Extension {
|
||||
|
||||
// Update current subsite in session
|
||||
Subsite::changeSubsite($_REQUEST['SubsiteID']);
|
||||
|
||||
//Redirect to clear the current page
|
||||
$this->owner->redirect('admin/pages');
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +39,6 @@ class LeftAndMainSubsites extends Extension {
|
||||
|
||||
public function Subsites() {
|
||||
$accessPerm = 'CMS_ACCESS_'. $this->owner->class;
|
||||
|
||||
switch($this->owner->class) {
|
||||
case "AssetAdmin":
|
||||
$subsites = Subsite::accessible_sites($accessPerm, true, "Shared files & images");
|
||||
@ -55,6 +57,10 @@ class LeftAndMainSubsites extends Extension {
|
||||
$subsites = Subsite::accessible_sites($accessPerm, $showMainSite);
|
||||
break;
|
||||
|
||||
case "SubsiteAdmin":
|
||||
$subsites = Subsite::accessible_sites('ADMIN', true);
|
||||
break;
|
||||
|
||||
default:
|
||||
$subsites = Subsite::accessible_sites($accessPerm);
|
||||
break;
|
||||
@ -64,25 +70,6 @@ class LeftAndMainSubsites extends Extension {
|
||||
}
|
||||
|
||||
public function SubsiteList() {
|
||||
if ($this->owner->class == 'AssetAdmin') {
|
||||
// See if the right decorator is there....
|
||||
$file = new File();
|
||||
if (!$file->hasExtension('FileSubsites')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Whitelist for admin sections which are subsite aware.
|
||||
// For example, don't show subsite list in reports section, it doesn't have
|
||||
// any effect there - subsites are filtered through a custom dropdown there, see SubsiteReportWrapper.
|
||||
if(!(
|
||||
$this->owner instanceof AssetAdmin
|
||||
|| $this->owner instanceof SecurityAdmin
|
||||
|| $this->owner instanceof CMSMain)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$list = $this->Subsites();
|
||||
|
||||
$currentSubsiteID = Subsite::currentSubsiteID();
|
||||
@ -101,7 +88,22 @@ class LeftAndMainSubsites extends Extension {
|
||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||
return $output;
|
||||
} else if($list->Count() == 1) {
|
||||
return $list->First()->Title;
|
||||
if($list->First()->DefaultSite==false) {
|
||||
$output = '<select id="SubsitesSelect">';
|
||||
$output .= "\n<option value=\"0\">". _t('LeftAndMainSubsites.DEFAULT_SITE', '_Default Site') . "</option>";
|
||||
foreach($list as $subsite) {
|
||||
$selected = $subsite->ID == $currentSubsiteID ? ' selected="selected"' : '';
|
||||
|
||||
$output .= "\n<option value=\"{$subsite->ID}\"$selected>". Convert::raw2xml($subsite->Title) . "</option>";
|
||||
}
|
||||
|
||||
$output .= '</select>';
|
||||
|
||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||
return $output;
|
||||
}else {
|
||||
return '<span>'.$list->First()->Title.'</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,9 +127,11 @@ class LeftAndMainSubsites extends Extension {
|
||||
|
||||
// Switch to a subsite that this user can actually access.
|
||||
$member = Member::currentUser();
|
||||
if ($member && $member->isAdmin()) return true; //admin can access all subsites
|
||||
if ($member && Permission::check('ADMIN')) {
|
||||
return true; //admin can access all subsites
|
||||
}
|
||||
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->toDropdownMap();
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->map('ID', 'Title')->toArray();
|
||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||
$siteIDs = array_keys($sites);
|
||||
Subsite::changeSubsite($siteIDs[0]);
|
||||
@ -139,7 +143,7 @@ class LeftAndMainSubsites extends Extension {
|
||||
foreach($menu as $candidate) {
|
||||
if($candidate->controller != $this->owner->class) {
|
||||
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->toDropdownMap();
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->map('ID', 'Title')->toArray();
|
||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||
$siteIDs = array_keys($sites);
|
||||
Subsite::changeSubsite($siteIDs[0]);
|
@ -3,14 +3,11 @@
|
||||
/**
|
||||
* Extension for the SiteConfig object to add subsites support
|
||||
*/
|
||||
class SiteConfigSubsites extends DataObjectDecorator {
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'has_one' => array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
)
|
||||
);
|
||||
}
|
||||
class SiteConfigSubsites extends DataExtension {
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Update any requests to limit the results to the current site
|
||||
@ -20,12 +17,14 @@ class SiteConfigSubsites extends DataObjectDecorator {
|
||||
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||
if (!$query->where || (!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]) && !preg_match('/\.?(\'|"|`|)SubsiteID(\'|"|`|)( ?)=/', $query->where[0]))) {
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
||||
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||
|
||||
$tableName = array_shift(array_keys($query->from));
|
||||
$froms=$query->getFrom();
|
||||
$froms=array_keys($froms);
|
||||
$tableName = array_shift($froms);
|
||||
if($tableName != 'SiteConfig') return;
|
||||
$query->where[] = "\"$tableName\".\"SubsiteID\" IN ($subsiteID)";
|
||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Extension for the SiteTree object to add subsites support
|
||||
*/
|
||||
class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
class SiteTreeSubsites extends DataExtension {
|
||||
static $template_variables = array(
|
||||
'((Company Name))' => 'Title'
|
||||
);
|
||||
@ -27,24 +27,26 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
}
|
||||
|
||||
|
||||
function extraStatics() {
|
||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics') && $this->owner->class != 'SiteTree') return null;
|
||||
return array(
|
||||
'has_one' => array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
'MasterPage' => 'SiteTree',// Optional; the page that is the content master
|
||||
),
|
||||
'has_many' => array(
|
||||
'RelatedPages' => 'RelatedPageLink'
|
||||
),
|
||||
'many_many' => array(
|
||||
'CrossSubsiteLinkTracking' => 'SiteTree' // Stored separately, as the logic for URL rewriting is different
|
||||
),
|
||||
'belongs_many_many' => array(
|
||||
'BackCrossSubsiteLinkTracking' => 'SiteTree'
|
||||
)
|
||||
);
|
||||
}
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
'MasterPage' => 'SiteTree',// Optional; the page that is the content master
|
||||
);
|
||||
|
||||
public static $has_many=array(
|
||||
'RelatedPages' => 'RelatedPageLink'
|
||||
);
|
||||
|
||||
public static $many_many=array(
|
||||
'CrossSubsiteLinkTracking' => 'SiteTree' // Stored separately, as the logic for URL rewriting is different
|
||||
);
|
||||
|
||||
public static $belongs_many_many=array(
|
||||
'BackCrossSubsiteLinkTracking' => 'SiteTree'
|
||||
);
|
||||
|
||||
public static $many_many_extraFields=array(
|
||||
"CrossSubsiteLinkTracking" => array("FieldName" => "Varchar")
|
||||
);
|
||||
|
||||
function isMainSite() {
|
||||
if($this->owner->SubsiteID == 0) return true;
|
||||
@ -59,7 +61,7 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
|
||||
// Don't run on delete queries, since they are always tied to
|
||||
// a specific ID.
|
||||
if ($query->delete) return;
|
||||
if ($query->getDelete()) return;
|
||||
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||
// if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
|
||||
@ -67,15 +69,15 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
|
||||
if (Subsite::$force_subsite) $subsiteID = Subsite::$force_subsite;
|
||||
else {
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
||||
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||
}
|
||||
|
||||
// The foreach is an ugly way of getting the first key :-)
|
||||
foreach($query->from as $tableName => $info) {
|
||||
foreach($query->getFrom() as $tableName => $info) {
|
||||
// The tableName should be SiteTree or SiteTree_Live...
|
||||
if(strpos($tableName,'SiteTree') === false) break;
|
||||
$query->where[] = "\"$tableName\".\"SubsiteID\" IN ($subsiteID)";
|
||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -87,19 +89,22 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
parent::onBeforeWrite();
|
||||
}
|
||||
|
||||
function updateCMSFields(&$fields) {
|
||||
if($this->owner->MasterPageID) $fields->insertFirst(new HeaderField('This page\'s content is copied from a master page: ' . $this->owner->MasterPage()->Title, 2));
|
||||
function updateCMSFields(FieldList $fields) {
|
||||
if($this->owner->MasterPageID) $fields->addFieldToTab('Root.Main', new HeaderField('This page\'s content is copied from a master page: ' . $this->owner->MasterPage()->Title, 2), 'Title');
|
||||
|
||||
// replace readonly link prefix
|
||||
$subsite = $this->owner->Subsite();
|
||||
if($subsite && $subsite->ID) {
|
||||
$baseUrl = 'http://' . $subsite->domain() . '/';
|
||||
$fields->removeByName('BaseUrlLabel');
|
||||
$fields->addFieldToTab(
|
||||
'Root.Content.Metadata',
|
||||
new LabelField('BaseUrlLabel',$baseUrl),
|
||||
'URLSegment'
|
||||
|
||||
$baseLink = Controller::join_links (
|
||||
$baseUrl,
|
||||
(SiteTree::nested_urls() && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
||||
);
|
||||
|
||||
$url = (strlen($baseLink) > 36 ? "..." .substr($baseLink, -32) : $baseLink);
|
||||
$urlsegment = $fields->dataFieldByName('URLSegment');
|
||||
$urlsegment->setURLPrefix($url);
|
||||
}
|
||||
|
||||
$relatedCount = 0;
|
||||
@ -111,21 +116,16 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
$tabName = $relatedCount ? 'Related (' . $relatedCount . ')' : 'Related';
|
||||
$tab = $fields->findOrMakeTab('Root.Related', $tabName);
|
||||
// Related pages
|
||||
$tab->push(new LiteralField('RelatedNote', '<p>You can list pages here that are related to this page.<br />When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.</p>'));
|
||||
$tab->push(new LiteralField('RelatedNote',
|
||||
'<p>You can list pages here that are related to this page.<br />When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.</p>'));
|
||||
$tab->push(
|
||||
$related = new ComplexTableField(
|
||||
$this,
|
||||
'RelatedPages',
|
||||
'RelatedPageLink',
|
||||
array(
|
||||
'RelatedPageAdminLink' => 'Page',
|
||||
'AbsoluteLink' => 'URL',
|
||||
)
|
||||
)
|
||||
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
||||
);
|
||||
|
||||
$related->setModelClass('RelatedPageLink');
|
||||
|
||||
// The 'show' link doesn't provide any useful info
|
||||
$related->setPermissions(array('add', 'edit', 'delete'));
|
||||
//$related->setPermissions(array('add', 'edit', 'delete'));
|
||||
|
||||
if($reverse) {
|
||||
$text = '<p>In addition, this page is marked as related by the following pages: </p><p>';
|
||||
@ -144,16 +144,13 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
*/
|
||||
function ReverseRelated() {
|
||||
return DataObject::get('RelatedPageLink', "\"RelatedPageLink\".\"RelatedPageID\" = {$this->owner->ID}
|
||||
AND R2.\"ID\" IS NULL", '',
|
||||
"INNER JOIN \"SiteTree\" ON \"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"
|
||||
LEFT JOIN \"RelatedPageLink\" AS R2 ON R2.\"MasterPageID\" = {$this->owner->ID}
|
||||
AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"
|
||||
"
|
||||
);
|
||||
AND R2.\"ID\" IS NULL", '')
|
||||
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
||||
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
||||
}
|
||||
|
||||
function NormalRelated() {
|
||||
$return = new DataObjectSet();
|
||||
$return = new ArrayList();
|
||||
$links = DataObject::get('RelatedPageLink', '"MasterPageID" = ' . $this->owner->ID);
|
||||
if($links) foreach($links as $link) {
|
||||
if($link->RelatedPage()->exists()) {
|
||||
@ -232,16 +229,25 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
$subsiteID = $subsite->ID;
|
||||
} else $subsite = DataObject::get_by_id('Subsite', $subsiteID);
|
||||
|
||||
$oldSubsite=Subsite::currentSubsiteID();
|
||||
if($subsiteID) {
|
||||
Subsite::changeSubsite($subsiteID);
|
||||
}else {
|
||||
$subsiteID=$oldSubsite;
|
||||
}
|
||||
|
||||
$page = $this->owner->duplicate(false);
|
||||
|
||||
$page->CheckedPublicationDifferences = $page->AddedToStage = true;
|
||||
$subsiteID = ($subsiteID ? $subsiteID : Subsite::currentSubsiteID());
|
||||
$subsiteID = ($subsiteID ? $subsiteID : $oldSubsite);
|
||||
$page->SubsiteID = $subsiteID;
|
||||
|
||||
if($isTemplate) $page->MasterPageID = $this->owner->ID;
|
||||
|
||||
$page->write();
|
||||
|
||||
Subsite::changeSubsite($oldSubsite);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
65
code/forms/GridFieldSubsiteDetailForm.php
Normal file
65
code/forms/GridFieldSubsiteDetailForm.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class GridFieldSubsiteDetailForm extends GridFieldDetailForm {
|
||||
protected $itemRequestClass='GridFieldSubsiteDetailForm_ItemRequest';
|
||||
}
|
||||
|
||||
class GridFieldSubsiteDetailForm_ItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||
/**
|
||||
* Builds an item edit form. The arguments to getCMSFields() are the popupController and
|
||||
* popupFormName, however this is an experimental API and may change.
|
||||
*
|
||||
* @todo In the future, we will probably need to come up with a tigher object representing a partially
|
||||
* complete controller with gaps for extra functionality. This, for example, would be a better way
|
||||
* of letting Security/login put its log-in form inside a UI specified elsewhere.
|
||||
*
|
||||
* @return Form
|
||||
* @see GridFieldDetailForm_ItemRequest::ItemEditForm()
|
||||
*/
|
||||
function ItemEditForm() {
|
||||
$form=parent::ItemEditForm();
|
||||
|
||||
if($this->record->ID == 0) {
|
||||
$templates = Subsite_Template::get()->sort('Title');
|
||||
$templateArray = array();
|
||||
if($templates) {
|
||||
$templateArray = $templates->map('ID', 'Title');
|
||||
}
|
||||
|
||||
$form->Fields()->addFieldToTab('Root.Configuration', new DropdownField('TemplateID', 'Copy structure from:', $templateArray, null, null, "(No template)"));
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function doSave($data, $form) {
|
||||
$new_record = $this->record->ID == 0;
|
||||
|
||||
if($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) {
|
||||
$template = Subsite_Template::get()->byID(intval($data['TemplateID']));
|
||||
if($template) {
|
||||
$this->record=$template->createInstance($data['Title']);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$form->saveInto($this->record);
|
||||
$this->record->write();
|
||||
$this->gridField->getList()->add($this->record);
|
||||
} catch(ValidationException $e) {
|
||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
||||
return Controller::curr()->redirectBack();
|
||||
}
|
||||
|
||||
// TODO Save this item into the given relationship
|
||||
|
||||
$message = sprintf(
|
||||
_t('GridFieldDetailForm.Saved', 'Saved %s %s'),
|
||||
$this->record->singular_name(),
|
||||
'<a href="' . $this->Link('edit') . '">"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"</a>'
|
||||
);
|
||||
|
||||
$form->sessionMessage($message, 'good');
|
||||
|
||||
return Controller::curr()->redirect($this->Link());
|
||||
}
|
||||
}
|
40
code/forms/SubsitesTreeDropdownField.php
Normal file
40
code/forms/SubsitesTreeDropdownField.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Wraps around a TreedropdownField to add ability for temporary
|
||||
* switching of subsite sessions.
|
||||
*
|
||||
* @package subsites
|
||||
*/
|
||||
class SubsitesTreeDropdownField extends TreeDropdownField {
|
||||
|
||||
protected $subsiteID = 0;
|
||||
|
||||
protected $extraClasses = array('SubsitesTreeDropdownField');
|
||||
|
||||
function Field($properties = array()) {
|
||||
$html = parent::Field($properties);
|
||||
|
||||
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function setSubsiteID($id) {
|
||||
$this->subsiteID = $id;
|
||||
}
|
||||
|
||||
function getSubsiteID() {
|
||||
return $this->subsiteID;
|
||||
}
|
||||
|
||||
function tree(SS_HTTPRequest $request) {
|
||||
$oldSubsiteID = Session::get('SubsiteID');
|
||||
Session::set('SubsiteID', $this->subsiteID);
|
||||
|
||||
$results = parent::tree($request);
|
||||
|
||||
Session::set('SubsiteID', $oldSubsiteID);
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
@ -17,19 +17,24 @@ class RelatedPageLink extends DataObject {
|
||||
'MasterPage' => 'SiteTree',
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'RelatedPageAdminLink' => 'Page',
|
||||
'AbsoluteLink' => 'URL',
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
||||
if(!$subsites) $subsites = new DataObjectSet();
|
||||
if(!$subsites) $subsites = new ArrayList();
|
||||
|
||||
if(Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
|
||||
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
|
||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", true);
|
||||
}
|
||||
|
||||
if($subsites->Count()) {
|
||||
$subsiteSelectionField = new DropdownField(
|
||||
"CopyContentFromID_SubsiteID",
|
||||
"Subsite",
|
||||
$subsites->toDropdownMap('ID', 'Title'),
|
||||
$subsites->map('ID', 'Title'),
|
||||
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
||||
);
|
||||
}
|
||||
@ -47,8 +52,8 @@ class RelatedPageLink extends DataObject {
|
||||
|
||||
$pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
|
||||
|
||||
if($subsites->Count()) $fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
|
||||
else $fields = new FieldSet($pageSelectionField);
|
||||
if($subsites->Count()) $fields = new FieldList($subsiteSelectionField, $pageSelectionField);
|
||||
else $fields = new FieldList($pageSelectionField);
|
||||
|
||||
return $fields;
|
||||
}
|
@ -146,7 +146,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
function domain() {
|
||||
if($this->ID) {
|
||||
$domains = DataObject::get("SubsiteDomain", "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC","", 1);
|
||||
if($domains) {
|
||||
if($domains && $domains->Count()>0) {
|
||||
$domain = $domains->First()->Domain;
|
||||
// If there are wildcards in the primary domain (not recommended), make some
|
||||
// educated guesses about what to replace them with:
|
||||
@ -178,10 +178,11 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
* Show the configuration fields for each subsite
|
||||
*/
|
||||
function getCMSFields() {
|
||||
$domainTable = new TableField("Domains", "SubsiteDomain",
|
||||
array("Domain" => "Domain <small>(use * as a wildcard)</small>", "IsPrimary" => "Primary domain?"),
|
||||
array("Domain" => "TextField", "IsPrimary" => "CheckboxField"),
|
||||
"SubsiteID", $this->ID);
|
||||
if($this->ID!=0) {
|
||||
$domainTable = new GridField("Domains", "Domains", $this->Domains(), GridFieldConfig_RecordEditor::create(10));
|
||||
}else {
|
||||
$domainTable = new LiteralField('Domains', '<p>'._t('Subsite.DOMAINSAVEFIRST', '_You can only add domains after saving for the first time').'</p>');
|
||||
}
|
||||
|
||||
$languageSelector = new DropdownField('Language', 'Language', i18n::get_common_locales());
|
||||
|
||||
@ -192,7 +193,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
}
|
||||
asort($pageTypeMap);
|
||||
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TabSet('Root',
|
||||
new Tab('Configuration',
|
||||
new HeaderField($this->getClassName() . ' configuration', 2),
|
||||
@ -238,8 +239,8 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
}
|
||||
|
||||
function getCMSActions() {
|
||||
return new FieldSet(
|
||||
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
||||
return new FieldList(
|
||||
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
||||
);
|
||||
}
|
||||
|
||||
@ -321,7 +322,7 @@ JS;
|
||||
/**
|
||||
* @todo Possible security issue, don't grant edit permissions to everybody.
|
||||
*/
|
||||
function canEdit() {
|
||||
function canEdit($member = false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -341,12 +342,12 @@ JS;
|
||||
$SQL_host = Convert::raw2sql($host);
|
||||
|
||||
$matchingDomains = DataObject::get("SubsiteDomain", "'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')",
|
||||
"\"IsPrimary\" DESC", "INNER JOIN \"Subsite\" ON \"Subsite\".\"ID\" = \"SubsiteDomain\".\"SubsiteID\" AND
|
||||
"\"IsPrimary\" DESC")->innerJoin('Subsite', "\"Subsite\".\"ID\" = \"SubsiteDomain\".\"SubsiteID\" AND
|
||||
\"Subsite\".\"IsPublic\"=1");
|
||||
|
||||
if($matchingDomains) {
|
||||
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID'));
|
||||
$subsiteDomains = array_unique($matchingDomains->column('Domain'));
|
||||
if($matchingDomains && $matchingDomains->Count()>0) {
|
||||
$subsiteIDs = array_unique($matchingDomains->map('SubsiteID')->keys());
|
||||
$subsiteDomains = array_unique($matchingDomains->map('Domain')->keys());
|
||||
if(sizeof($subsiteIDs) > 1) {
|
||||
throw new UnexpectedValueException(sprintf(
|
||||
"Multiple subsites match on '%s': %s",
|
||||
@ -402,7 +403,7 @@ JS;
|
||||
if(!is_array($permissionCodes))
|
||||
user_error('Permissions must be passed to Subsite::hasMainSitePermission as an array', E_USER_ERROR);
|
||||
|
||||
if(!$member && $member !== FALSE) $member = Member::currentMember();
|
||||
if(!$member && $member !== FALSE) $member = Member::currentUser();
|
||||
|
||||
if(!$member) return false;
|
||||
|
||||
@ -428,8 +429,8 @@ JS;
|
||||
/**
|
||||
* Duplicate this subsite
|
||||
*/
|
||||
function duplicate() {
|
||||
$newTemplate = parent::duplicate();
|
||||
function duplicate($doWrite = true) {
|
||||
$newTemplate = parent::duplicate($doWrite);
|
||||
|
||||
$oldSubsiteID = Session::get('SubsiteID');
|
||||
self::changeSubsite($this->ID);
|
||||
@ -473,12 +474,12 @@ JS;
|
||||
* @param $includeMainSite If true, the main site will be included if appropriate.
|
||||
* @param $mainSiteTitle The label to give to the main site
|
||||
* @param $member
|
||||
* @return DataObjectSet of {@link Subsite} instances
|
||||
* @return DataList of {@link Subsite} instances
|
||||
*/
|
||||
function accessible_sites($permCode, $includeMainSite = false, $mainSiteTitle = "Main site", $member = null) {
|
||||
public static function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null) {
|
||||
// Rationalise member arguments
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member) return new DataObjectSet();
|
||||
if(!$member) return new ArrayList();
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('Member', $member);
|
||||
|
||||
// Rationalise permCode argument
|
||||
@ -493,42 +494,23 @@ JS;
|
||||
|
||||
$templateClassList = "'" . implode("', '", ClassInfo::subclassesFor("Subsite_Template")) . "'";
|
||||
|
||||
$subsites = DataObject::get(
|
||||
'Subsite',
|
||||
"\"Subsite\".\"Title\" != ''",
|
||||
'',
|
||||
"LEFT JOIN \"Group_Subsites\"
|
||||
ON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"
|
||||
INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"
|
||||
OR \"Group\".\"AccessAllSubsites\" = 1
|
||||
INNER JOIN \"Group_Members\"
|
||||
ON \"Group_Members\".\"GroupID\"=\"Group\".\"ID\"
|
||||
AND \"Group_Members\".\"MemberID\" = $member->ID
|
||||
INNER JOIN \"Permission\"
|
||||
ON \"Group\".\"ID\"=\"Permission\".\"GroupID\"
|
||||
AND \"Permission\".\"Code\" IN ($SQL_codes, 'ADMIN')"
|
||||
);
|
||||
if(!$subsites) $subsites = new DataObjectSet();
|
||||
$subsites = DataList::create('Subsite')
|
||||
->where("\"Subsite\".\"Title\" != ''")
|
||||
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
||||
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
|
||||
->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, 'ADMIN')");
|
||||
|
||||
$rolesSubsites = DataObject::get(
|
||||
'Subsite',
|
||||
"\"Subsite\".\"Title\" != ''",
|
||||
'',
|
||||
"LEFT JOIN \"Group_Subsites\"
|
||||
ON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"
|
||||
INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"
|
||||
OR \"Group\".\"AccessAllSubsites\" = 1
|
||||
INNER JOIN \"Group_Members\"
|
||||
ON \"Group_Members\".\"GroupID\"=\"Group\".\"ID\"
|
||||
AND \"Group_Members\".\"MemberID\" = $member->ID
|
||||
INNER JOIN \"Group_Roles\"
|
||||
ON \"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"
|
||||
INNER JOIN \"PermissionRole\"
|
||||
ON \"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"
|
||||
INNER JOIN \"PermissionRoleCode\"
|
||||
ON \"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\"
|
||||
AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'ADMIN')"
|
||||
);
|
||||
if(!$subsites) $subsites = new ArrayList();
|
||||
|
||||
$rolesSubsites = DataList::create('Subsite')
|
||||
->where("\"Subsite\".\"Title\" != ''")
|
||||
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
||||
->innerJoin('Group', "\"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_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")
|
||||
->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")
|
||||
->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'ADMIN')");
|
||||
|
||||
if(!$subsites && $rolesSubsites) return $rolesSubsites;
|
||||
|
||||
@ -539,18 +521,22 @@ JS;
|
||||
}
|
||||
|
||||
// Include the main site
|
||||
if(!$subsites) $subsites = new DataObjectSet();
|
||||
if(!$subsites) $subsites = new ArrayList();
|
||||
if($includeMainSite) {
|
||||
if(!is_array($permCode)) $permCode = array($permCode);
|
||||
if(self::hasMainSitePermission($member, $permCode)) {
|
||||
$subsites=$subsites->toArray();
|
||||
|
||||
$mainSite = new Subsite();
|
||||
$mainSite->Title = $mainSiteTitle;
|
||||
$subsites->insertFirst($mainSite);
|
||||
array_unshift($subsites, $mainSite);
|
||||
$subsites=ArrayList::create($subsites);
|
||||
}
|
||||
}
|
||||
|
||||
self::$_cache_accessible_sites[$cacheKey] = $subsites;
|
||||
|
||||
|
||||
return $subsites;
|
||||
}
|
||||
|
||||
@ -593,10 +579,10 @@ JS;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Return the FieldSet that will build the search form in the CMS
|
||||
* Return the FieldList that will build the search form in the CMS
|
||||
*/
|
||||
function adminSearchFields() {
|
||||
return new FieldSet(
|
||||
return new FieldList(
|
||||
new TextField('Name', 'Sub-site name')
|
||||
);
|
||||
}
|
||||
@ -674,10 +660,16 @@ class Subsite_Template extends Subsite {
|
||||
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
//Change to destination subsite
|
||||
self::changeSubsite($intranet->ID);
|
||||
$childClone = $child->duplicateToSubsite($intranet);
|
||||
|
||||
$childClone->ParentID = $destParentID;
|
||||
$childClone->writeToStage('Stage');
|
||||
$childClone->publish('Stage', 'Live');
|
||||
|
||||
//Change Back to this subsite
|
||||
self::changeSubsite($this->ID);
|
||||
array_push($stack, array($child->ID, $childClone->ID));
|
||||
}
|
||||
}
|
@ -9,6 +9,11 @@ class SubsiteDomain extends DataObject {
|
||||
"Subsite" => "Subsite",
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'Domain'=>'Domain',
|
||||
'IsPrimary'=>'Is Primary Domain'
|
||||
);
|
||||
|
||||
/**
|
||||
* Whenever a Subsite Domain is written, rewrite the hostmap
|
||||
*
|
||||
@ -17,4 +22,11 @@ class SubsiteDomain extends DataObject {
|
||||
public function onAfterWrite() {
|
||||
Subsite::writeHostMap();
|
||||
}
|
||||
|
||||
public function getCMSFields() {
|
||||
return new FieldList(
|
||||
new TextField('Domain', _t('SubsiteDomain.DOMAIN', '_Domain'), null, 255),
|
||||
new CheckboxField('IsPrimary', _t('SubsiteDomain.IS_PRIMARY', '_Is Primary Domain'))
|
||||
);
|
||||
}
|
||||
}
|
@ -24,19 +24,19 @@
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.cms-login-status.subsites {
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
#SubsitesSelect,
|
||||
#SubsitesSelect option {
|
||||
font-size: 12px;
|
||||
}
|
||||
#SubsitesSelect {
|
||||
max-width: 200px;
|
||||
width: 171px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#top #MainMenu #Menu-help {
|
||||
margin-right: 260px;
|
||||
}
|
||||
|
||||
#AddSubsiteLink {
|
||||
display: block;
|
||||
font-size: 80%;
|
||||
@ -56,3 +56,7 @@
|
||||
body.SubsiteAdmin .right form #URL .fieldgroup * {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.cms-add-form #PageType li .class-SubsitesVirtualPage, .class-SubsitesVirtualPage a .jstree-pageicon {
|
||||
background-position: 0 -32px !important;
|
||||
}
|
||||
|
@ -1,53 +1,52 @@
|
||||
Behaviour.register({
|
||||
'#SubsiteActions select' : {
|
||||
onchange: function() {
|
||||
document.location.href = SiteTreeHandlers.controller_url + '?SubsiteID=' + this.value;
|
||||
}
|
||||
},
|
||||
(function($) {
|
||||
$.entwine('ss', function($) {
|
||||
$('#SubsitesSelect').live('change', function() {
|
||||
window.location.search=$.query.set('SubsiteID', $(this).val());
|
||||
});
|
||||
|
||||
// Subsite tab of Group editor
|
||||
'#Form_EditForm_AccessAllSubsites' : {
|
||||
initialize: function () {
|
||||
this.showHideSubsiteList();
|
||||
var i=0,items=this.getElementsByTagName('input');
|
||||
for(i=0;i<items.length;i++) {
|
||||
items[i].onchange = this.showHideSubsiteList;
|
||||
// Subsite tab of Group editor
|
||||
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
||||
/**
|
||||
* Constructor: onmatch
|
||||
*/
|
||||
onmatch: function () {
|
||||
this.showHideSubsiteList();
|
||||
|
||||
var ref=this;
|
||||
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
||||
ref.showHideSubsiteList();
|
||||
});
|
||||
},
|
||||
|
||||
showHideSubsiteList: function () {
|
||||
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
showHideSubsiteList : function () {
|
||||
$('Form_EditForm_Subsites').parentNode.style.display =
|
||||
Form.Element.getValue($('Form_EditForm').AccessAllSubsites)==1 ? 'none' : '';
|
||||
}
|
||||
},
|
||||
$('.cms-edit-form').entwine({
|
||||
getChangeTrackerOptions: function() {
|
||||
this.ChangeTrackerOptions.ignoreFieldSelector+=', input[name=IsSubsite]';
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
||||
* Hidden by default, unless either the toggle checkbox, or any of the
|
||||
* actual value checkboxes are selected.
|
||||
*/
|
||||
'a#PageTypeBlacklistToggle': {
|
||||
onclick: function(e) {
|
||||
jQuery('#PageTypeBlacklist').toggle();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
||||
* Hidden by default, unless either the toggle checkbox, or any of the
|
||||
* actual value checkboxes are selected.
|
||||
*/
|
||||
$('#PageTypeBlacklist').entwine({
|
||||
onmatch: function() {
|
||||
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
||||
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
||||
|
||||
'#PageTypeBlacklist': {
|
||||
initialize: function() {
|
||||
var hasLimits = Boolean(jQuery(this).find('input:checked').length);
|
||||
jQuery(this).toggle(hasLimits);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add an item to fieldsToIgnore
|
||||
Behaviour.register({
|
||||
'#Form_EditForm' : {
|
||||
initialize: function () {
|
||||
this.changeDetection_fieldsToIgnore.IsSubsite = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fitToParent('ResultTable_holder');
|
||||
//Bind listener
|
||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||
jQuery('#PageTypeBlacklist').toggle();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@ -1,54 +1,26 @@
|
||||
SubsitesTreeDropdownField = Class.extend('TreeDropdownField');
|
||||
SubsitesTreeDropdownField.prototype = {
|
||||
(function($) {
|
||||
$.entwine('ss', function($) {
|
||||
$('.TreeDropdownField').entwine({
|
||||
subsiteID: function() {
|
||||
var subsiteSel = $$('#CopyContentFromID_SubsiteID select')[0];
|
||||
subsiteSel.onchange = (function() {
|
||||
this.createTreeNode(true);
|
||||
this.ajaxGetTree((function(response) {
|
||||
this.newTreeReady(response, true);
|
||||
this.updateTreeLabel();
|
||||
}).bind(this));
|
||||
}).bind(this);
|
||||
return subsiteSel.options[subsiteSel.selectedIndex].value;
|
||||
},
|
||||
|
||||
subsiteID: function() {
|
||||
var subsiteSel = $$('#CopyContentFromID_SubsiteID select')[0];
|
||||
subsiteSel.onchange = (function() {
|
||||
this.createTreeNode(true);
|
||||
this.ajaxGetTree((function(response) {
|
||||
this.newTreeReady(response, true);
|
||||
this.updateTreeLabel();
|
||||
}).bind(this));
|
||||
}).bind(this);
|
||||
return subsiteSel.options[subsiteSel.selectedIndex].value;
|
||||
},
|
||||
getRequestParams: function() {
|
||||
var name=this.find(':input:hidden').attr('name');
|
||||
var obj={};
|
||||
|
||||
ajaxGetTree: function(after) {
|
||||
// Can't force value because it might be on a different subsite!
|
||||
var ajaxURL = this.buildURL('gettree?forceValues=' + 0); //this.inputTag.value;
|
||||
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
||||
|
||||
// Customised: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
||||
ajaxURL += '&' + this.inputTag.name + '_SubsiteID=' + parseInt(this.subsiteID());
|
||||
|
||||
ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '';
|
||||
new Ajax.Request(ajaxURL, {
|
||||
method : 'get',
|
||||
onSuccess : after,
|
||||
onFailure : function(response) { errorMessage("Error getting data", response); }
|
||||
})
|
||||
},
|
||||
|
||||
// This ajaxExpansion function is actually attached as a method on the tree object; therefore, this.getIdx() is a method
|
||||
// note also this.tree.options.dropdownField.subsiteID() must be called, not this.subsiteID()
|
||||
ajaxExpansion: function() {
|
||||
this.addNodeClass('loading');
|
||||
var ul = this.treeNodeHolder();
|
||||
ul.innerHTML = ss.i18n._t('LOADING');
|
||||
|
||||
var ajaxURL = this.options.dropdownField.buildURL('getsubtree?SubtreeRootID=' + this.getIdx());
|
||||
|
||||
// Find the root of the tree - this points to a list item in the tree, not the root div we actually want
|
||||
// @todo: We should be using framework API calls to find the tree
|
||||
var tree = this;
|
||||
while (tree && !tree.className.match(/(^| )SubsitesTreeDropdownField( |$)/)) tree = tree.parentNode;
|
||||
|
||||
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
||||
ajaxURL += '&' + this.options.dropdownField.inputTag.name + '_SubsiteID=' + parseInt(this.options.dropdownField.subsiteID());
|
||||
|
||||
new Ajax.Request(ajaxURL, {
|
||||
onSuccess : this.installSubtree.bind(this),
|
||||
onFailure : function(response) { errorMessage('error loading subtree', response); }
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SubsitesTreeDropdownField.applyTo('div.SubsitesTreeDropdownField');
|
||||
});
|
||||
})(jQuery);
|
||||
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $lang;
|
||||
|
||||
$lang['en_US']['SubsiteAdmin']['MENUTITLE'] = array(
|
||||
'Subsites',
|
||||
100,
|
||||
'Menu title'
|
||||
);
|
||||
$lang['en_US']['GroupSubsites']['ACCESSALL'] = 'All subsites';
|
||||
$lang['en_US']['GroupSubsites']['ACCESSONLY'] = 'Only these subsites';
|
||||
$lang['en_US']['GroupSubsites']['ACCESSRADIOTITLE'] = 'Give this group access to';
|
||||
$lang['en_US']['GroupSubsites']['SECURITYTABTITLE'] = 'Subsites';
|
||||
$lang['en_US']['ModelAdmin']['LOADEDFOREDITING'] = 'Loaded \'%s\' for editing.';
|
||||
$lang['en_US']['RelatedPageLink']['PLURALNAME'] = array(
|
||||
'Related Page Links',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['RelatedPageLink']['SINGULARNAME'] = array(
|
||||
'Related Page Link',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['ModelAdmin']['LOADEDFOREDITING'] = 'Loaded \'%s\' for editing.';
|
||||
$lang['en_US']['RelatedPageLink']['PLURALNAME'] = array(
|
||||
'Related Page Links',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['RelatedPageLink']['SINGULARNAME'] = array(
|
||||
'Related Page Link',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['Subsite']['PLURALNAME'] = array(
|
||||
'Subsits',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['Subsite']['SINGULARNAME'] = array(
|
||||
'Subsite',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['SubsiteDomain']['PLURALNAME'] = array(
|
||||
'Subsite Domains',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['SubsiteDomain']['SINGULARNAME'] = array(
|
||||
'Subsite Domain',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['Subsite_Template']['PLURALNAME'] = array(
|
||||
'Subsite Templats',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['Subsite_Template']['SINGULARNAME'] = array(
|
||||
'Subsite Template',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['SubsitesVirtualPage']['PLURALNAME'] = array(
|
||||
'Subsites Virtual Pags',
|
||||
50,
|
||||
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
|
||||
);
|
||||
$lang['en_US']['SubsitesVirtualPage']['SINGULARNAME'] = array(
|
||||
'Subsites Virtual Page',
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['VirtualPage']['CHOOSE'] = 'Choose a page to link to';
|
||||
$lang['en_US']['VirtualPage']['EDITCONTENT'] = 'Click here to edit the content';
|
||||
|
||||
?>
|
39
lang/en_US.yml
Normal file
39
lang/en_US.yml
Normal file
@ -0,0 +1,39 @@
|
||||
en_US:
|
||||
SubsiteAdmin:
|
||||
MENUTITLE: "Subsites"
|
||||
GroupSubsites:
|
||||
ACCESSALL: "All subsites"
|
||||
ACCESSONLY: "Only these subsites"
|
||||
ACCESSRADIOTITLE: "Give this group access to"
|
||||
SECURITYTABTITLE: "Subsites"
|
||||
ModelAdmin:
|
||||
LOADEDFOREDITING: "Loaded \'%s\' for editing."
|
||||
RelatedPageLink:
|
||||
PLURALNAME: "Related Page Links"
|
||||
SINGULARNAME: "Related Page Link"
|
||||
Subsite:
|
||||
PLURALNAME: "Subsits"
|
||||
SINGULARNAME: "Subsite"
|
||||
DOMAINSAVEFIRST: "You can only add domains after saving for the first time"
|
||||
SubsiteDomain:
|
||||
PLURALNAME: "Subsite Domains"
|
||||
SINGULARNAME: "Subsite Domain"
|
||||
DOMAIN: "Domain"
|
||||
IS_PRIMARY: "Is Primary Domain"
|
||||
Subsite_Template:
|
||||
PLURALNAME: "Subsite Templats"
|
||||
SINGULARNAME: "Subsite Template"
|
||||
SubsitesVirtualPage:
|
||||
PLURALNAME: "Subsites Virtual Pags"
|
||||
SINGULARNAME: "Subsites Virtual Page"
|
||||
VirtualPage:
|
||||
CHOOSE: "Choose a page to link to"
|
||||
EDITCONTENT: "Click here to edit the content"
|
||||
GridFieldAddFromTemplateButton:
|
||||
AddFromTemplate: "Add New from Template"
|
||||
GridFieldAddFromTemplate:
|
||||
NewFromTemplate: "New %s from template"
|
||||
TEMPLATE_NOT_FOUND: "The selected template could not be found"
|
||||
TEMPLATE: "Template"
|
||||
LeftAndMainSubsites:
|
||||
DEFAULT_SITE: "Default Site"
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Norwegian Bokmal (Norway) language pack
|
||||
* @package subsites
|
||||
* @subpackage i18n
|
||||
*/
|
||||
|
||||
i18n::include_locale_file('subsites', 'en_US');
|
||||
|
||||
global $lang;
|
||||
|
||||
if(array_key_exists('nb_NO', $lang) && is_array($lang['nb_NO'])) {
|
||||
$lang['nb_NO'] = array_merge($lang['en_US'], $lang['nb_NO']);
|
||||
} else {
|
||||
$lang['nb_NO'] = $lang['en_US'];
|
||||
}
|
||||
|
||||
$lang['nb_NO']['GroupSubsites']['SECURITYACCESS'] = 'Begrens CMS tilgang til Subdomener';
|
||||
$lang['nb_NO']['GroupSubsites']['SECURITYTABTITLE'] = 'subdomener';
|
||||
$lang['nb_NO']['Subsite']['PLURALNAME'] = 'Subdomener';
|
||||
$lang['nb_NO']['Subsite']['SINGULARNAME'] = 'Subdomene';
|
||||
$lang['nb_NO']['SubsiteAdmin']['MENUTITLE'] = 'Underdomener';
|
||||
$lang['nb_NO']['SubsitesVirtualPage']['PLURALNAME'] = 'Subdomeners Virtuelle Sider';
|
||||
$lang['nb_NO']['SubsitesVirtualPage']['SINGULARNAME'] = 'Subdomeners Virtuelle Side';
|
||||
$lang['nb_NO']['VirtualPage']['CHOOSE'] = 'Velg en side å lenke til';
|
||||
$lang['nb_NO']['VirtualPage']['EDITCONTENT'] = 'klikk her for å endre dette innholdet';
|
||||
|
||||
?>
|
40
lang/nb_NO.yml
Normal file
40
lang/nb_NO.yml
Normal file
@ -0,0 +1,40 @@
|
||||
nb_NO:
|
||||
SubsiteAdmin:
|
||||
MENUTITLE: "Underdomener"
|
||||
GroupSubsites:
|
||||
ACCESSALL: "All subsites"
|
||||
ACCESSONLY: "Only these subsites"
|
||||
ACCESSRADIOTITLE: "Give this group access to"
|
||||
SECURITYTABTITLE: "subdomener"
|
||||
SECURITYACCESS: "Begrens CMS tilgang til Subdomener"
|
||||
ModelAdmin:
|
||||
LOADEDFOREDITING: "Loaded \'%s\' for editing."
|
||||
RelatedPageLink:
|
||||
PLURALNAME: "Related Page Links"
|
||||
SINGULARNAME: "Related Page Link"
|
||||
Subsite:
|
||||
PLURALNAME: "Subdomener"
|
||||
SINGULARNAME: "Subdomene"
|
||||
DOMAINSAVEFIRST: "You can only add domains after saving for the first time"
|
||||
SubsiteDomain:
|
||||
PLURALNAME: "Subsite Domains"
|
||||
SINGULARNAME: "Subsite Domain"
|
||||
DOMAIN: "Domain"
|
||||
IS_PRIMARY: "Is Primary Domain"
|
||||
Subsite_Template:
|
||||
PLURALNAME: "Subsite Templats"
|
||||
SINGULARNAME: "Subsite Template"
|
||||
SubsitesVirtualPage:
|
||||
PLURALNAME: "Subdomeners Virtuelle Sider"
|
||||
SINGULARNAME: "Subdomeners Virtuelle Side"
|
||||
VirtualPage:
|
||||
CHOOSE: "Velg en side å lenke til"
|
||||
EDITCONTENT: "klikk her for å endre dette innholdet"
|
||||
GridFieldAddFromTemplateButton:
|
||||
AddFromTemplate: "Add New from Template"
|
||||
GridFieldAddFromTemplate:
|
||||
NewFromTemplate: "New %s from template"
|
||||
TEMPLATE_NOT_FOUND: "The selected template could not be found"
|
||||
TEMPLATE: "Template"
|
||||
LeftAndMainSubsites:
|
||||
DEFAULT_SITE: "Default Site"
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Turkish (Turkey) language pack
|
||||
* @package subsites
|
||||
* @subpackage i18n
|
||||
*/
|
||||
|
||||
i18n::include_locale_file('subsites', 'en_US');
|
||||
|
||||
global $lang;
|
||||
|
||||
if(array_key_exists('tr_TR', $lang) && is_array($lang['tr_TR'])) {
|
||||
$lang['tr_TR'] = array_merge($lang['en_US'], $lang['tr_TR']);
|
||||
} else {
|
||||
$lang['tr_TR'] = $lang['en_US'];
|
||||
}
|
||||
|
||||
$lang['tr_TR']['GroupSubsites']['SECURITYACCESS'] = 'Alt sitelere İYS erişimini kısıtla';
|
||||
$lang['tr_TR']['GroupSubsites']['SECURITYTABTITLE'] = 'Alt Siteler';
|
||||
$lang['tr_TR']['Subsite']['PLURALNAME'] = 'Alt Siteler';
|
||||
$lang['tr_TR']['Subsite']['SINGULARNAME'] = 'Alt Site';
|
||||
$lang['tr_TR']['SubsiteAdmin']['MENUTITLE'] = 'Alt Siteler';
|
||||
$lang['tr_TR']['SubsitesVirtualPage']['PLURALNAME'] = 'Alt Site Sanal Sayfalar';
|
||||
$lang['tr_TR']['SubsitesVirtualPage']['SINGULARNAME'] = 'Alt Site Sanal Sayfa';
|
||||
$lang['tr_TR']['VirtualPage']['CHOOSE'] = 'İzleyene bağlantı vermek için bir sayfa seçiniz: ';
|
||||
$lang['tr_TR']['VirtualPage']['EDITCONTENT'] = 'İçeriği düzenlemek için tıklayınız';
|
||||
|
||||
?>
|
40
lang/tr_TR.yml
Normal file
40
lang/tr_TR.yml
Normal file
@ -0,0 +1,40 @@
|
||||
tr_TR:
|
||||
SubsiteAdmin:
|
||||
MENUTITLE: "Alt Siteler"
|
||||
GroupSubsites:
|
||||
ACCESSALL: "All subsites"
|
||||
ACCESSONLY: "Only these subsites"
|
||||
ACCESSRADIOTITLE: "Give this group access to"
|
||||
SECURITYTABTITLE: "Alt Siteler"
|
||||
SECURITYACCESS: "Alt sitelere İYS erişimini kısıtla"
|
||||
ModelAdmin:
|
||||
LOADEDFOREDITING: "Loaded \'%s\' for editing."
|
||||
RelatedPageLink:
|
||||
PLURALNAME: "Related Page Links"
|
||||
SINGULARNAME: "Related Page Link"
|
||||
Subsite:
|
||||
PLURALNAME: "Alt Siteler"
|
||||
SINGULARNAME: "Alt Site"
|
||||
DOMAINSAVEFIRST: "You can only add domains after saving for the first time"
|
||||
SubsiteDomain:
|
||||
PLURALNAME: "Subsite Domains"
|
||||
SINGULARNAME: "Subsite Domain"
|
||||
DOMAIN: "Domain"
|
||||
IS_PRIMARY: "Is Primary Domain"
|
||||
Subsite_Template:
|
||||
PLURALNAME: "Subsite Templats"
|
||||
SINGULARNAME: "Subsite Template"
|
||||
SubsitesVirtualPage:
|
||||
PLURALNAME: "Alt Site Sanal Sayfalar"
|
||||
SINGULARNAME: "Alt Site Sanal Sayfa"
|
||||
VirtualPage:
|
||||
CHOOSE: "İzleyene bağlantı vermek için bir sayfa seçiniz: "
|
||||
EDITCONTENT: "İçeriği düzenlemek için tıklayınız"
|
||||
GridFieldAddFromTemplateButton:
|
||||
AddFromTemplate: "Add New from Template"
|
||||
GridFieldAddFromTemplate:
|
||||
NewFromTemplate: "New %s from template"
|
||||
TEMPLATE_NOT_FOUND: "The selected template could not be found"
|
||||
TEMPLATE: "Template"
|
||||
LeftAndMainSubsites:
|
||||
DEFAULT_SITE: "Default Site"
|
@ -1,11 +0,0 @@
|
||||
<ul id="MainMenu">
|
||||
<% control MainMenu %>
|
||||
<li class="$LinkingMode" id="Menu-$Code"><a href="$Link">$Title</a></li>
|
||||
<% end_control %>
|
||||
</ul>
|
||||
<form id="SubsiteActions">
|
||||
<fieldset>
|
||||
$SubsiteList
|
||||
<span>$ApplicationLogoText</span>
|
||||
</fieldset>
|
||||
</form>
|
@ -1,15 +0,0 @@
|
||||
<div id="Logo" style="$LogoStyle">
|
||||
<% if ApplicationLogoText %>
|
||||
<a href="$ApplicationLink">$ApplicationLogoText</a><br />
|
||||
<% end_if %>
|
||||
</div>
|
||||
<ul id="MainMenu">
|
||||
<% control MainMenu %>
|
||||
<li class="$LinkingMode" id="Menu-$Code"><a href="$Link">$Title</a></li>
|
||||
<% end_control %>
|
||||
</ul>
|
||||
<form id="SubsiteActions">
|
||||
<fieldset>
|
||||
$SubsiteList
|
||||
</fieldset>
|
||||
</form>
|
1
templates/Includes/GridFieldAddFromTemplateButton.ss
Normal file
1
templates/Includes/GridFieldAddFromTemplateButton.ss
Normal file
@ -0,0 +1 @@
|
||||
<a href="$NewFromTemplateLink" class="action ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add"><% _t('GridFieldAddFromTemplateButton.AddFromTemplate', '_Add New from Template') %></a>
|
59
templates/LeftAndMain_Menu.ss
Normal file
59
templates/LeftAndMain_Menu.ss
Normal file
@ -0,0 +1,59 @@
|
||||
<div class="cms-menu cms-panel cms-panel-layout west" id="cms-menu" data-layout-type="border">
|
||||
<div class="cms-logo-header north">
|
||||
<div class="cms-logo">
|
||||
<a href="http://www.silverstripe.org/" target="_blank" title="SilverStripe (Version - $CMSVersion)">
|
||||
SilverStripe <% if CMSVersion %><abbr class="version">$CMSVersion</abbr><% end_if %>
|
||||
</a>
|
||||
<span><% if SiteConfig %>$SiteConfig.Title<% else %>$ApplicationName<% end_if %></span>
|
||||
</div>
|
||||
|
||||
<div class="cms-login-status">
|
||||
<a href="Security/logout" class="logout-link" title="<% _t('LOGOUT','Log out') %>"><% _t('LOGOUT','Log out') %></a>
|
||||
<% control CurrentMember %>
|
||||
<span>
|
||||
<% _t('Hello','Hi') %>
|
||||
<a href="{$AbsoluteBaseURL}admin/myprofile" class="profile-link ss-ui-dialog-link" data-popupclass="edit-profile-popup">
|
||||
<% if FirstName && Surname %>$FirstName $Surname<% else_if FirstName %>$FirstName<% else %>$Email<% end_if %>
|
||||
</a>
|
||||
</span>
|
||||
<% end_control %>
|
||||
</div>
|
||||
|
||||
<div class="cms-login-status subsites">
|
||||
$SubsiteList
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cms-panel-content center">
|
||||
<ul class="cms-menu-list">
|
||||
<% control MainMenu %>
|
||||
<li class="$LinkingMode $FirstLast <% if LinkingMode == 'link' %><% else %>opened<% end_if %>" id="Menu-$Code">
|
||||
<a href="$Link" <% if Code == 'Help' %>target="_blank"<% end_if%>>
|
||||
<span class="icon icon-16 icon-{$Code.LowerCase}"> </span>
|
||||
<span class="text">$Title</span>
|
||||
</a>
|
||||
|
||||
<% if Code == 'AssetAdmin' %>
|
||||
<ul>
|
||||
<li class="first <% if Top.class == 'AssetAdmin' %>current<% end_if %>" id="Menu-AssetAdmin">
|
||||
<a href="admin/assets/">
|
||||
<span class="text">Edit & organize</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="last <% if Top.class == 'CMSFileAddController' %>current<% end_if %>" id="Menu-CMSFileAddController">
|
||||
<a href="admin/assets/add">
|
||||
<span class="text">Add files</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<% end_if %>
|
||||
</li>
|
||||
<% end_control %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="cms-panel-toggle south">
|
||||
<a class="toggle-expand" href="#"><span>»</span></a>
|
||||
<a class="toggle-collapse" href="#"><span>«</span></a>
|
||||
</div>
|
||||
</div>
|
@ -10,8 +10,8 @@ class FileSubsitesTest extends SapphireTest {
|
||||
$file->Title = 'FileTitle';
|
||||
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
||||
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
||||
$this->assertEquals('FileTitle', $file->TreeTitle());
|
||||
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertEquals('FileTitle', $file->getTreeTitle());
|
||||
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
||||
Subsite::changeSubsite(1);
|
||||
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
||||
}
|
||||
|
@ -8,18 +8,18 @@ class GroupSubsitesTest extends SapphireTest {
|
||||
function testTrivialFeatures() {
|
||||
$this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics()));
|
||||
$this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions()));
|
||||
$this->assertTrue(singleton('Group')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue(singleton('Group')->getCMSFields() instanceof FieldList);
|
||||
}
|
||||
|
||||
function testAlternateTreeTitle() {
|
||||
$group = new Group();
|
||||
$group->Title = 'The A Team';
|
||||
$group->AccessAllSubsites = true;
|
||||
$this->assertEquals($group->TreeTitle(), 'The A Team <i>(global group)</i>');
|
||||
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(global group)</i>');
|
||||
$group->AccessAllSubsites = false;
|
||||
$group->write();
|
||||
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest1'));
|
||||
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest2'));
|
||||
$this->assertEquals($group->TreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
|
||||
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
|
||||
}
|
||||
}
|
@ -41,8 +41,8 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
||||
|
||||
function testBasicSanity() {
|
||||
$this->assertTrue(singleton('SiteTree')->getSiteConfig() instanceof SiteConfig);
|
||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(is_array(singleton('SiteTreeSubsites')->extraStatics()));
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testRelatedPages() {
|
||||
$this->assertTrue(singleton('RelatedPageLink')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue(singleton('RelatedPageLink')->getCMSFields() instanceof FieldList);
|
||||
|
||||
$importantpage = $this->objFromFixture('SiteTree', 'importantpage');
|
||||
$contact = $this->objFromFixture('SiteTree', 'contact');
|
||||
@ -68,13 +68,13 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
||||
$link->RelatedPageID = $contact->ID;
|
||||
$link->write();
|
||||
$importantpage->RelatedPages()->add($link);
|
||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldList);
|
||||
|
||||
$this->assertEquals($importantpage->NormalRelated()->Count(), 1);
|
||||
$this->assertEquals($contact->ReverseRelated()->Count(), 1);
|
||||
|
||||
$this->assertTrue($importantpage->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue($contact->getCMSFields() instanceof FieldSet);
|
||||
$this->assertTrue($importantpage->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue($contact->getCMSFields() instanceof FieldList);
|
||||
|
||||
$this->assertEquals($importantpage->canView(), $link->canView());
|
||||
$this->assertEquals($importantpage->canEdit(), $link->canEdit());
|
||||
@ -164,25 +164,27 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
||||
$s1->write();
|
||||
|
||||
Subsite::changeSubsite($s1);
|
||||
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||
$this->assertArrayNotHasKey('ErrorPage',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayNotHasKey('SiteTreeSubsitesTest_ClassA',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
|
||||
Subsite::changeSubsite($s2);
|
||||
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||
$this->assertArrayHasKey('ErrorPage',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassA',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
||||
$settingsFields
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,27 +3,27 @@
|
||||
class SubsiteAdminTest extends SapphireTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
function adminLoggedInSession() {
|
||||
return new Session(array(
|
||||
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
||||
));
|
||||
}
|
||||
function adminLoggedInSession() {
|
||||
return new Session(array(
|
||||
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test generation of the view
|
||||
*/
|
||||
function testBasicView() {
|
||||
/**
|
||||
* Test generation of the view
|
||||
*/
|
||||
function testBasicView() {
|
||||
Subsite::$write_hostmap = false;
|
||||
$subsite1ID = $this->objFromFixture('Subsite','domaintest1')->ID;
|
||||
|
||||
// Open the admin area logged in as admin
|
||||
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
||||
// Open the admin area logged in as admin
|
||||
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
||||
|
||||
// Confirm that this URL gets you the entire page, with the edit form loaded
|
||||
$response2 = Director::test("admin/subsites/Subsite/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
||||
$this->assertTrue(strpos($response2->getBody(), 'id="Form_EditForm_ID"') !== false, "Testing Form_EditForm_ID exists");
|
||||
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, "Testing <head> exists");
|
||||
}
|
||||
// Confirm that this URL gets you the entire page, with the edit form loaded
|
||||
$response2 = Director::test("admin/subsites/Subsite/EditForm/field/Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
||||
$this->assertTrue(strpos($response2->getBody(), 'id="Form_ItemEditForm_ID"') !== false, "Testing Form_ItemEditForm_ID exists");
|
||||
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, "Testing <head> exists");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test searching for an intranet
|
||||
@ -31,7 +31,7 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
function XXtestIntranetSearch() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
|
||||
// Check that the logged-in member has the correct permissions
|
||||
$this->assertTrue(Permission::check('ADMIN') ? true : false);
|
||||
@ -44,49 +44,49 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
|
||||
foreach($searches as $search) {
|
||||
$response = $form->testAjaxSubmission('getResults', $search);
|
||||
$links = $response->getLinks();
|
||||
foreach($links as $link) {
|
||||
$this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad.");
|
||||
}
|
||||
$links = $response->getLinks();
|
||||
foreach($links as $link) {
|
||||
$this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad.");
|
||||
}
|
||||
}
|
||||
|
||||
$cont->popCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the intranet creation form.
|
||||
*/
|
||||
function XXtestIntranetCreation() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
/**
|
||||
* Test the intranet creation form.
|
||||
*/
|
||||
function XXtestIntranetCreation() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
|
||||
$form = $cont->AddSubsiteForm();
|
||||
$source = $form->dataFieldByName('TemplateID')->getSource();
|
||||
$form = $cont->AddSubsiteForm();
|
||||
$source = $form->dataFieldByName('TemplateID')->getSource();
|
||||
|
||||
$templateIDs = $this->allFixtureIDs('Subsite_Template');
|
||||
foreach($templateIDs as $templateID) {
|
||||
$this->assertArrayHasKey($templateID, $source);
|
||||
}
|
||||
$templateIDs = $this->allFixtureIDs('Subsite_Template');
|
||||
foreach($templateIDs as $templateID) {
|
||||
$this->assertArrayHasKey($templateID, $source);
|
||||
}
|
||||
|
||||
$templateObj = $this->objFromFixture('Subsite_Template','main');
|
||||
$this->assertEquals($templateObj->Title, $source[$templateObj->ID], "Template dropdown isn't listing Title values");
|
||||
$templateObj = $this->objFromFixture('Subsite_Template','main');
|
||||
$this->assertEquals($templateObj->Title, $source[$templateObj->ID], "Template dropdown isn't listing Title values");
|
||||
|
||||
$response = $form->testSubmission('addintranet', array(
|
||||
'Name' => 'Test Intranet',
|
||||
'Domain' => 'test.example.com',
|
||||
'TemplateID' => 1,
|
||||
'AdminEmail' => '',
|
||||
'AdminName' => '',
|
||||
));
|
||||
$response = $form->testSubmission('addintranet', array(
|
||||
'Name' => 'Test Intranet',
|
||||
'Domain' => 'test.example.com',
|
||||
'TemplateID' => 1,
|
||||
'AdminEmail' => '',
|
||||
'AdminName' => '',
|
||||
));
|
||||
|
||||
$this->assertTrue(true == preg_match('/admin\/subsites\/show\/([0-9]+)/i', $response->getHeader('Location'), $matches), "Intranet creation dowsn't redirect to new view");
|
||||
$this->assertTrue(true == preg_match('/admin\/subsites\/show\/([0-9]+)/i', $response->getHeader('Location'), $matches), "Intranet creation dowsn't redirect to new view");
|
||||
|
||||
$newIntranet = DataObject::get_by_id("Subsite", $matches[1]);
|
||||
$this->assertEquals('Test Intranet', $newIntranet->Title, "New intranet not created properly.");
|
||||
$newIntranet = DataObject::get_by_id("Subsite", $matches[1]);
|
||||
$this->assertEquals('Test Intranet', $newIntranet->Title, "New intranet not created properly.");
|
||||
|
||||
$cont->popCurrent();
|
||||
}
|
||||
$cont->popCurrent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
$ids[$subsite->ID] = true;
|
||||
}
|
||||
|
||||
$this->assertTrue($subsite->adminSearchFields() instanceof FieldSet);
|
||||
$this->assertTrue(Subsite::adminSearchFields() instanceof FieldList);
|
||||
$this->assertArrayHasKey(0, $ids, "Main site accessible");
|
||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','main'), $ids, "Site with no groups inaccesible");
|
||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','subsite1'), $ids, "Subsite1 Template inaccessible");
|
||||
|
@ -33,7 +33,7 @@ class SubsiteTest extends SapphireTest {
|
||||
|
||||
// Publish all the pages in the template, testing that DataObject::get only returns pages from the chosen subsite
|
||||
$pages = DataObject::get("SiteTree");
|
||||
$totalPages = $pages->TotalItems();
|
||||
$totalPages = $pages->Count();
|
||||
foreach($pages as $page) {
|
||||
$this->assertEquals($template->ID, $page->SubsiteID);
|
||||
$page->publish('Stage', 'Live');
|
||||
@ -52,7 +52,7 @@ class SubsiteTest extends SapphireTest {
|
||||
$subsite->activate();
|
||||
|
||||
$siteHome = DataObject::get_one('SiteTree', "\"URLSegment\" = 'home'");
|
||||
$this->assertNotNull($siteHome);
|
||||
$this->assertNotEquals($siteHome, false, 'Home Page for subsite not found');
|
||||
$this->assertEquals($subsite->ID, $siteHome->SubsiteID,
|
||||
'createInstance() copies existing pages retaining the same URLSegment'
|
||||
);
|
||||
|
@ -60,16 +60,19 @@ SiteTree:
|
||||
Title: Important Page
|
||||
SubsiteID: =>Subsite_Template.main
|
||||
subsite1_home:
|
||||
Title: Home (Subsite 1)
|
||||
Title: Home
|
||||
SubsiteID: =>Subsite_Template.subsite1
|
||||
subsite1_contactus:
|
||||
Title: Contact Us (Subsite 1)
|
||||
Title: Contact Us
|
||||
SubsiteID: =>Subsite_Template.subsite1
|
||||
subsite1_staff:
|
||||
Title: Staff
|
||||
SubsiteID: =>Subsite_Template.subsite1
|
||||
subsite2_home:
|
||||
Title: Home (Subsite 2)
|
||||
Title: Home
|
||||
SubsiteID: =>Subsite_Template.subsite2
|
||||
subsite2_contactus:
|
||||
Title: Contact Us (Subsite 2)
|
||||
Title: Contact Us
|
||||
SubsiteID: =>Subsite_Template.subsite2
|
||||
|
||||
Group:
|
||||
|
@ -199,12 +199,12 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
||||
|
||||
Subsite::changeSubsite($vp1->SubsiteID);
|
||||
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp1->ID);
|
||||
$this->assertFalse($onLive, 'SVP has been removed from live');
|
||||
$this->assertNull($onLive, 'SVP has been removed from live');
|
||||
|
||||
$subsite = $this->objFromFixture('Subsite_Template', 'subsite2');
|
||||
Subsite::changeSubsite($vp2->SubsiteID);
|
||||
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp2->ID);
|
||||
$this->assertFalse($onLive, 'SVP has been removed from live');
|
||||
$this->assertNull($onLive, 'SVP has been removed from live');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,8 +217,8 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
||||
$subsite2 = $this->objFromFixture('Subsite_Template', 'subsite2');
|
||||
Subsite::changeSubsite($subsite1->ID);
|
||||
|
||||
$subsite1Page = $this->objFromFixture('SiteTree', 'subsite1_contactus');
|
||||
$subsite1Page->URLSegment = 'contact-us';
|
||||
$subsite1Page = $this->objFromFixture('SiteTree', 'subsite1_staff');
|
||||
$subsite1Page->URLSegment = 'staff';
|
||||
$subsite1Page->write();
|
||||
|
||||
// saving on subsite1, and linking to subsite1
|
||||
@ -232,6 +232,9 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
||||
"Doesn't allow explicit URLSegment overrides when already existing in same subsite"
|
||||
);
|
||||
|
||||
//Change to subsite 2
|
||||
Subsite::changeSubsite($subsite2->ID);
|
||||
|
||||
// saving in subsite2 (which already has a page with URLSegment 'contact-us'),
|
||||
// but linking to a page in subsite1
|
||||
$subsite2Vp = new SubsitesVirtualPage();
|
||||
|
Loading…
x
Reference in New Issue
Block a user