mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUG: Modifying the module to work with SS 3.0
Replaced deprecated DataObjectDecorator with DataExtension Fixed hard crashes in the cms Updated to support new LeftAndMain template structure Made the subsites model admin functional Moved the LeftAndMain_Menu template up a directory so it overrides the core Fixed some errors caused by changes to the framework Re-organized the code folder Fixed permission issue causing to default to first subsite regardless if it is the default or not Fixed crashes on the subsite virtual page when creating/editing Removed toDropdownMap() calls replacing with map() Fixed the URLSegment field on subsites Fixed error when detecting subsite for a domain Improved styles on the subsite dropdown Updated LeftAndMain_Subsites.js to work with jQuery entwine Started porting the SubsitesTreeDropdownField.js to use jQuery entwine and work with the new TreeDropdownField.js Fixed issue causing crash when viewing a page who is linked to by a subsite virtual page Removed unused methods on SubsitesTreeDropdownField.js Re-added classes that were moved Fixed hard crash after saving caused by the many_many definition on SiteTreeSubsites Replaced deprecated DataObjectSet creation with ArrayList Compatibility fixes with SS 3.0 beta 2 Fixed crash in cms caused by no parameter being passed to the SubsiteReportWrapper constructor Proper fix for report wrapper Removed table list field in favor of a basic grid field Fixed updateCMSFields() for file subsites Migrated translations to yml Fixed issue causing the current page to not get cleared when changing subsites in the cms Fixed virtual page icon Fixed language files issue
This commit is contained in:
parent
a6bb5a3fb7
commit
2ef72b374c
@ -15,6 +15,8 @@ Object::add_extension('LeftAndMain', 'ControllerSubsites');
|
|||||||
Object::add_extension('Group', 'GroupSubsites');
|
Object::add_extension('Group', 'GroupSubsites');
|
||||||
Object::add_extension('File', 'FileSubsites');
|
Object::add_extension('File', 'FileSubsites');
|
||||||
Object::add_extension('ErrorPage', 'ErrorPageSubsite');
|
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 {
|
class SubsiteAdmin extends ModelAdmin {
|
||||||
|
|
||||||
static $managed_models = array('Subsite');
|
static $managed_models = array('Subsite', 'Subsite_Template');
|
||||||
static $url_segment = 'subsites';
|
static $url_segment = 'subsites';
|
||||||
|
|
||||||
static $menu_title = "Subsites";
|
static $menu_title = "Subsites";
|
||||||
|
|
||||||
|
public $showImportForm=false;
|
||||||
|
|
||||||
static $collection_controller_class = "SubsiteAdmin_CollectionController";
|
public function getEditForm($id = null) {
|
||||||
}
|
$form = parent::getEditForm($id);
|
||||||
|
|
||||||
class SubsiteAdmin_CollectionController extends ModelAdmin_CollectionController {
|
|
||||||
function AddForm() {
|
|
||||||
$form = parent::AddForm();
|
|
||||||
|
|
||||||
$templates = DataObject::get('Subsite_Template', '', 'Title');
|
|
||||||
$templateArray = array('' => "(No template)");
|
|
||||||
if($templates) {
|
|
||||||
$templateArray = $templateArray + $templates->map('ID', 'Title');
|
|
||||||
}
|
|
||||||
|
|
||||||
$form->Fields()->addFieldsToTab('Root.Configuration', array(
|
|
||||||
new DropdownField('Type', 'Type', array(
|
|
||||||
'subsite' => 'New site',
|
|
||||||
'template' => 'New template',
|
|
||||||
)),
|
|
||||||
new DropdownField('TemplateID', 'Copy structure from:', $templateArray)
|
|
||||||
));
|
|
||||||
|
|
||||||
|
if($this->modelClass=='Subsite') {
|
||||||
|
$grid=$form->Fields()->dataFieldByName('Subsite');
|
||||||
|
if($grid) {
|
||||||
|
$grid->getConfig()->addComponent(new GridFieldAddFromTemplateButton('toolbar-header-right'));
|
||||||
|
$grid->getConfig()->addComponent(new GridFieldAddFromTemplate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $form;
|
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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class SubsiteDomain extends DataObject {
|
|
||||||
static $db = array(
|
|
||||||
"Domain" => "Varchar(255)",
|
|
||||||
"IsPrimary" => "Boolean",
|
|
||||||
);
|
|
||||||
static $has_one = array(
|
|
||||||
"Subsite" => "Subsite",
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whenever a Subsite Domain is written, rewrite the hostmap
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onAfterWrite() {
|
|
||||||
Subsite::writeHostMap();
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ class SubsiteReportWrapper extends SS_ReportWrapper {
|
|||||||
if($fields) {
|
if($fields) {
|
||||||
$fields->insertBefore($subsiteField, $fields->First()->Name());
|
$fields->insertBefore($subsiteField, $fields->First()->Name());
|
||||||
} else {
|
} else {
|
||||||
$fields = new FieldSet($subsiteField);
|
$fields = new FieldList($subsiteField);
|
||||||
}
|
}
|
||||||
return $fields;
|
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
|
<?php
|
||||||
class SubsitesVirtualPage extends VirtualPage {
|
class SubsitesVirtualPage extends VirtualPage {
|
||||||
static $db = array(
|
public static $db = array(
|
||||||
'CustomMetaTitle' => 'Varchar(255)',
|
'CustomMetaTitle' => 'Varchar(255)',
|
||||||
'CustomMetaKeywords' => 'Varchar(255)',
|
'CustomMetaKeywords' => 'Varchar(255)',
|
||||||
'CustomMetaDescription' => 'Text',
|
'CustomMetaDescription' => 'Text',
|
||||||
'CustomExtraMeta' => 'HTMLText'
|
'CustomExtraMeta' => 'HTMLText'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$subsites = DataObject::get('Subsite');
|
$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)));
|
$subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
|
||||||
|
|
||||||
$subsiteSelectionField = new DropdownField(
|
$subsiteSelectionField = new DropdownField(
|
||||||
"CopyContentFromID_SubsiteID",
|
"CopyContentFromID_SubsiteID",
|
||||||
"Subsite",
|
"Subsite",
|
||||||
$subsites->toDropdownMap('ID', 'Title'),
|
$subsites->map('ID', 'Title'),
|
||||||
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Content.Main',
|
'Root.Main',
|
||||||
$subsiteSelectionField,
|
$subsiteSelectionField,
|
||||||
'CopyContentFromID'
|
'CopyContentFromID'
|
||||||
);
|
);
|
||||||
@ -36,36 +41,37 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if(Controller::has_curr() && Controller::curr()->getRequest()) {
|
if(Controller::has_curr() && Controller::curr()->getRequest()) {
|
||||||
$subsiteID = Controller::curr()->getRequest()->getVar('CopyContentFromID_SubsiteID');
|
$subsiteID = Controller::curr()->getRequest()->postVar('CopyContentFromID_SubsiteID');
|
||||||
$pageSelectionField->setSubsiteID($subsiteID);
|
$pageSelectionField->setSubsiteID($subsiteID);
|
||||||
}
|
}
|
||||||
$fields->replaceField('CopyContentFromID', $pageSelectionField);
|
$fields->replaceField('CopyContentFromID', $pageSelectionField);
|
||||||
|
|
||||||
// Create links back to the original object in the CMS
|
// Create links back to the original object in the CMS
|
||||||
if($this->CopyContentFromID) {
|
if($this->CopyContentFromID) {
|
||||||
$editLink = "admin/show/$this->CopyContentFromID/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
|
$editLink = "admin/page/edit/show/$this->CopyContentFromID/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
|
||||||
$linkToContent = "
|
$linkToContent = "
|
||||||
<a class=\"cmsEditlink\" href=\"$editLink\">" .
|
<a class=\"cmsEditlink\" href=\"$editLink\">" .
|
||||||
_t('VirtualPage.EDITCONTENT', 'Click here to edit the content') .
|
_t('VirtualPage.EDITCONTENT', 'Click here to edit the content') .
|
||||||
"</a>";
|
"</a>";
|
||||||
$fields->removeByName("VirtualPageContentLinkLabel");
|
$fields->removeByName("VirtualPageContentLinkLabel");
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
"Root.Content.Main",
|
"Root.Main",
|
||||||
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
$linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent),
|
||||||
'Title'
|
'Title'
|
||||||
);
|
);
|
||||||
$linkToContentLabelField->setAllowHTML(true);
|
$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.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
||||||
$fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||||
$fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
||||||
|
$fields->addFieldToTab('Root.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVirtualFields() {
|
public function getVirtualFields() {
|
||||||
$fields = parent::getVirtualFields();
|
$fields = parent::getVirtualFields();
|
||||||
foreach($fields as $k => $v) {
|
foreach($fields as $k => $v) {
|
||||||
if($v == 'SubsiteID') unset($fields[$k]);
|
if($v == 'SubsiteID') unset($fields[$k]);
|
||||||
@ -76,14 +82,14 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncLinkTracking() {
|
public function syncLinkTracking() {
|
||||||
$oldState = Subsite::$disable_subsite_filter;
|
$oldState = Subsite::$disable_subsite_filter;
|
||||||
Subsite::$disable_subsite_filter = true;
|
Subsite::$disable_subsite_filter = true;
|
||||||
if ($this->CopyContentFromID) $this->HasBrokenLink = DataObject::get_by_id('SiteTree', $this->CopyContentFromID) ? false : true;
|
if ($this->CopyContentFromID) $this->HasBrokenLink = DataObject::get_by_id('SiteTree', $this->CopyContentFromID) ? false : true;
|
||||||
Subsite::$disable_subsite_filter = $oldState;
|
Subsite::$disable_subsite_filter = $oldState;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBeforeWrite() {
|
public function onBeforeWrite() {
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
|
|
||||||
if($this->CustomMetaTitle) $this->MetaTitle = $this->CustomMetaTitle;
|
if($this->CustomMetaTitle) $this->MetaTitle = $this->CustomMetaTitle;
|
||||||
@ -104,7 +110,7 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validURLSegment() {
|
public function validURLSegment() {
|
||||||
$isValid = parent::validURLSegment();
|
$isValid = parent::validURLSegment();
|
||||||
|
|
||||||
// Veto the validation rules if its false. In this case, some logic
|
// Veto the validation rules if its false. In this case, some logic
|
||||||
@ -146,13 +152,13 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
|
|
||||||
class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
||||||
|
|
||||||
function reloadContent() {
|
public function reloadContent() {
|
||||||
$this->failover->copyFrom($this->failover->CopyContentFrom());
|
$this->failover->copyFrom($this->failover->CopyContentFrom());
|
||||||
$this->failover->write();
|
$this->failover->write();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(){
|
public function init(){
|
||||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||||
Subsite::$disable_subsite_filter = true;
|
Subsite::$disable_subsite_filter = true;
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @package subsites
|
* @package subsites
|
||||||
*/
|
*/
|
||||||
class ControllerSubsites extends Extension {
|
class ControllerSubsites extends Extension {
|
||||||
function controllerAugmentInit(){
|
function controllerAugmentInit(){
|
||||||
if($subsite = Subsite::currentSubsite()){
|
if($subsite = Subsite::currentSubsite()){
|
||||||
if($theme = $subsite->Theme)
|
if($theme = $subsite->Theme)
|
||||||
SSViewer::set_theme($theme);
|
SSViewer::set_theme($theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function CurrentSubsite(){
|
function CurrentSubsite(){
|
||||||
if($subsite = Subsite::currentSubsite()){
|
if($subsite = Subsite::currentSubsite()){
|
||||||
return $subsite;
|
return $subsite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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
|
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
|
27
code/FileSubsites.php → code/extensions/FileSubsites.php
Executable file → Normal file
27
code/FileSubsites.php → code/extensions/FileSubsites.php
Executable file → Normal file
@ -4,19 +4,18 @@
|
|||||||
*
|
*
|
||||||
* @package subsites
|
* @package subsites
|
||||||
*/
|
*/
|
||||||
class FileSubsites extends DataObjectDecorator {
|
class FileSubsites extends DataExtension {
|
||||||
|
|
||||||
// If this is set to true, all folders created will be default be
|
// If this is set to true, all folders created will be default be
|
||||||
// considered 'global', unless set otherwise
|
// considered 'global', unless set otherwise
|
||||||
static $default_root_folders_global = false;
|
static $default_root_folders_global = false;
|
||||||
|
|
||||||
function extraStatics() {
|
function extraStatics() {
|
||||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics') && $this->owner->class != 'File') return null;
|
|
||||||
return array(
|
return array(
|
||||||
'has_one' => array(
|
'has_one' => array(
|
||||||
'Subsite' => 'Subsite',
|
'Subsite' => 'Subsite',
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,13 +30,13 @@ class FileSubsites extends DataObjectDecorator {
|
|||||||
/**
|
/**
|
||||||
* Add subsites-specific fields to the folder editor.
|
* Add subsites-specific fields to the folder editor.
|
||||||
*/
|
*/
|
||||||
function updateCMSFields(FieldSet &$fields) {
|
function updateCMSFields(FieldList $fields) {
|
||||||
if($this->owner instanceof Folder) {
|
if($this->owner instanceof Folder) {
|
||||||
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
|
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
|
||||||
$dropdownValues = ($sites) ? $sites->toDropdownMap() : array();
|
$dropdownValues = ($sites) ? $sites->map()->toArray() : array();
|
||||||
$dropdownValues[0] = 'All sites';
|
$dropdownValues[0] = 'All sites';
|
||||||
ksort($dropdownValues);
|
ksort($dropdownValues);
|
||||||
if($sites)$fields->addFieldToTab('Root.Details', new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
if($sites)$fields->push(new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,14 +46,14 @@ class FileSubsites extends DataObjectDecorator {
|
|||||||
function augmentSQL(SQLQuery &$query) {
|
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 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(!$query->where || !preg_match('/\.(\'|"|`|)ID(\'|"|`|)/', $query->where[0])) {
|
||||||
if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
|
/*if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID;
|
||||||
else $subsiteID = (int) Subsite::currentSubsiteID();
|
else */$subsiteID = (int) Subsite::currentSubsiteID();
|
||||||
|
|
||||||
// The foreach is an ugly way of getting the first key :-)
|
// The foreach is an ugly way of getting the first key :-)
|
||||||
foreach($query->from as $tableName => $info) {
|
foreach($query->from as $tableName => $info) {
|
||||||
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
||||||
$query->where[] = $where;
|
$query->where[] = $where;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$isCounting = strpos($query->select[0], 'COUNT') !== false;
|
$isCounting = strpos($query->select[0], 'COUNT') !== false;
|
@ -4,12 +4,9 @@
|
|||||||
*
|
*
|
||||||
* @package subsites
|
* @package subsites
|
||||||
*/
|
*/
|
||||||
class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||||
|
|
||||||
function extraStatics() {
|
function extraStatics() {
|
||||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics')) {
|
|
||||||
if($this->owner->class != 'Group') return null;
|
|
||||||
}
|
|
||||||
return array(
|
return array(
|
||||||
'db' => array(
|
'db' => array(
|
||||||
'AccessAllSubsites' => 'Boolean',
|
'AccessAllSubsites' => 'Boolean',
|
||||||
@ -60,7 +57,7 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
|||||||
$fields->findOrMakeTab('Root.Subsites',_t('GroupSubsites.SECURITYTABTITLE','Subsites'));
|
$fields->findOrMakeTab('Root.Subsites',_t('GroupSubsites.SECURITYTABTITLE','Subsites'));
|
||||||
|
|
||||||
$subsites = Subsite::accessible_sites(array('ADMIN', 'SECURITY_SUBSITE_GROUP'), true);
|
$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
|
// Interface is different if you have the rights to modify subsite group values on
|
||||||
// all subsites
|
// all subsites
|
||||||
@ -116,16 +113,18 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
|||||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||||
if(!$query->filtersOnID()) {
|
if(!$query->filtersOnID()) {
|
||||||
|
|
||||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||||
|
|
||||||
// Don't filter by Group_Subsites if we've already done that
|
// Don't filter by Group_Subsites if we've already done that
|
||||||
$hasGroupSubsites = false;
|
$hasGroupSubsites = false;
|
||||||
foreach($query->from as $item) if(strpos($item, 'Group_Subsites') !== false) {
|
foreach($query->from as $item) {
|
||||||
$hasGroupSubsites = true;
|
if((is_array($item) && strpos($item['table'], 'Group_Subsites')!==false) || (!is_array($item) && strpos($item, 'Group_Subsites')!==false)) {
|
||||||
break;
|
$hasGroupSubsites = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$hasGroupSubsites) {
|
if(!$hasGroupSubsites) {
|
||||||
if($subsiteID) {
|
if($subsiteID) {
|
||||||
$query->leftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
$query->leftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
@ -16,9 +16,12 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
if(!Session::get('SubsiteID') || $_REQUEST['SubsiteID'] != Session::get('SubsiteID')) {
|
if(!Session::get('SubsiteID') || $_REQUEST['SubsiteID'] != Session::get('SubsiteID')) {
|
||||||
Session::clear("{$this->owner->class}.currentPage");
|
Session::clear("{$this->owner->class}.currentPage");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update current subsite in session
|
// Update current subsite in session
|
||||||
Subsite::changeSubsite($_REQUEST['SubsiteID']);
|
Subsite::changeSubsite($_REQUEST['SubsiteID']);
|
||||||
|
|
||||||
|
//Redirect to clear the current page
|
||||||
|
$this->owner->redirect('admin/pages');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,54 +38,10 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Subsites() {
|
public function Subsites() {
|
||||||
$accessPerm = 'CMS_ACCESS_'. $this->owner->class;
|
return Subsite::accessible_sites('ADMIN');
|
||||||
|
|
||||||
switch($this->owner->class) {
|
|
||||||
case "AssetAdmin":
|
|
||||||
$subsites = Subsite::accessible_sites($accessPerm, true, "Shared files & images");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "SecurityAdmin":
|
|
||||||
$subsites = Subsite::accessible_sites($accessPerm, true, "Groups accessing all sites");
|
|
||||||
if($subsites->find('ID',0)) {
|
|
||||||
$subsites->push(new ArrayData(array('Title' => 'All groups', 'ID' => -1)));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "CMSMain":
|
|
||||||
// If there's a default site then main site has no meaning
|
|
||||||
$showMainSite = !DataObject::get_one('Subsite',"\"DefaultSite\"=1 AND \"IsPublic\"=1");
|
|
||||||
$subsites = Subsite::accessible_sites($accessPerm, $showMainSite);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$subsites = Subsite::accessible_sites($accessPerm);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $subsites;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SubsiteList() {
|
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();
|
$list = $this->Subsites();
|
||||||
|
|
||||||
$currentSubsiteID = Subsite::currentSubsiteID();
|
$currentSubsiteID = Subsite::currentSubsiteID();
|
||||||
@ -101,7 +60,22 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||||
return $output;
|
return $output;
|
||||||
} else if($list->Count() == 1) {
|
} 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 +99,11 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
|
|
||||||
// Switch to a subsite that this user can actually access.
|
// Switch to a subsite that this user can actually access.
|
||||||
$member = Member::currentUser();
|
$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()])) {
|
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||||
$siteIDs = array_keys($sites);
|
$siteIDs = array_keys($sites);
|
||||||
Subsite::changeSubsite($siteIDs[0]);
|
Subsite::changeSubsite($siteIDs[0]);
|
||||||
@ -139,7 +115,7 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
foreach($menu as $candidate) {
|
foreach($menu as $candidate) {
|
||||||
if($candidate->controller != $this->owner->class) {
|
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()])) {
|
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||||
$siteIDs = array_keys($sites);
|
$siteIDs = array_keys($sites);
|
||||||
Subsite::changeSubsite($siteIDs[0]);
|
Subsite::changeSubsite($siteIDs[0]);
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Extension for the SiteConfig object to add subsites support
|
* Extension for the SiteConfig object to add subsites support
|
||||||
*/
|
*/
|
||||||
class SiteConfigSubsites extends DataObjectDecorator {
|
class SiteConfigSubsites extends DataExtension {
|
||||||
function extraStatics() {
|
function extraStatics() {
|
||||||
return array(
|
return array(
|
||||||
'has_one' => array(
|
'has_one' => array(
|
||||||
@ -20,8 +20,8 @@ class SiteConfigSubsites extends DataObjectDecorator {
|
|||||||
|
|
||||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
// 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 (!$query->where || (!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]) && !preg_match('/\.?(\'|"|`|)SubsiteID(\'|"|`|)( ?)=/', $query->where[0]))) {
|
||||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||||
|
|
||||||
$tableName = array_shift(array_keys($query->from));
|
$tableName = array_shift(array_keys($query->from));
|
||||||
if($tableName != 'SiteConfig') return;
|
if($tableName != 'SiteConfig') return;
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Extension for the SiteTree object to add subsites support
|
* Extension for the SiteTree object to add subsites support
|
||||||
*/
|
*/
|
||||||
class SiteTreeSubsites extends SiteTreeDecorator {
|
class SiteTreeSubsites extends DataExtension {
|
||||||
static $template_variables = array(
|
static $template_variables = array(
|
||||||
'((Company Name))' => 'Title'
|
'((Company Name))' => 'Title'
|
||||||
);
|
);
|
||||||
@ -28,7 +28,6 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
|
|
||||||
|
|
||||||
function extraStatics() {
|
function extraStatics() {
|
||||||
if(!method_exists('DataObjectDecorator', 'load_extra_statics') && $this->owner->class != 'SiteTree') return null;
|
|
||||||
return array(
|
return array(
|
||||||
'has_one' => array(
|
'has_one' => array(
|
||||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||||
@ -67,8 +66,8 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
|
|
||||||
if (Subsite::$force_subsite) $subsiteID = Subsite::$force_subsite;
|
if (Subsite::$force_subsite) $subsiteID = Subsite::$force_subsite;
|
||||||
else {
|
else {
|
||||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The foreach is an ugly way of getting the first key :-)
|
// The foreach is an ugly way of getting the first key :-)
|
||||||
@ -94,12 +93,18 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
$subsite = $this->owner->Subsite();
|
$subsite = $this->owner->Subsite();
|
||||||
if($subsite && $subsite->ID) {
|
if($subsite && $subsite->ID) {
|
||||||
$baseUrl = 'http://' . $subsite->domain() . '/';
|
$baseUrl = 'http://' . $subsite->domain() . '/';
|
||||||
$fields->removeByName('BaseUrlLabel');
|
$fields->removeByName('URLSegment');
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Content.Metadata',
|
$baseLink = Controller::join_links (
|
||||||
new LabelField('BaseUrlLabel',$baseUrl),
|
$baseUrl,
|
||||||
'URLSegment'
|
(SiteTree::nested_urls() && $this->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
||||||
|
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->owner->fieldLabel('URLSegment'));
|
||||||
|
$urlsegment->setURLPrefix($url);
|
||||||
|
$urlsegment->setHelpText(SiteTree::nested_urls() && count($this->owner->Children()) ? $this->owner->fieldLabel('LinkChangeNote'): false);
|
||||||
|
$fields->addFieldToTab('Root.Metadata', $urlsegment, 'MetaTitle');
|
||||||
}
|
}
|
||||||
|
|
||||||
$relatedCount = 0;
|
$relatedCount = 0;
|
||||||
@ -113,19 +118,13 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
// Related pages
|
// 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(
|
$tab->push(
|
||||||
$related = new ComplexTableField(
|
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
||||||
$this,
|
|
||||||
'RelatedPages',
|
|
||||||
'RelatedPageLink',
|
|
||||||
array(
|
|
||||||
'RelatedPageAdminLink' => 'Page',
|
|
||||||
'AbsoluteLink' => 'URL',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$related->setModelClass('RelatedPageLink');
|
||||||
|
|
||||||
// The 'show' link doesn't provide any useful info
|
// The 'show' link doesn't provide any useful info
|
||||||
$related->setPermissions(array('add', 'edit', 'delete'));
|
//$related->setPermissions(array('add', 'edit', 'delete'));
|
||||||
|
|
||||||
if($reverse) {
|
if($reverse) {
|
||||||
$text = '<p>In addition, this page is marked as related by the following pages: </p><p>';
|
$text = '<p>In addition, this page is marked as related by the following pages: </p><p>';
|
||||||
@ -144,16 +143,13 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
|||||||
*/
|
*/
|
||||||
function ReverseRelated() {
|
function ReverseRelated() {
|
||||||
return DataObject::get('RelatedPageLink', "\"RelatedPageLink\".\"RelatedPageID\" = {$this->owner->ID}
|
return DataObject::get('RelatedPageLink', "\"RelatedPageLink\".\"RelatedPageID\" = {$this->owner->ID}
|
||||||
AND R2.\"ID\" IS NULL", '',
|
AND R2.\"ID\" IS NULL", '')
|
||||||
"INNER JOIN \"SiteTree\" ON \"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"
|
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
||||||
LEFT JOIN \"RelatedPageLink\" AS R2 ON R2.\"MasterPageID\" = {$this->owner->ID}
|
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
||||||
AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"
|
|
||||||
"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function NormalRelated() {
|
function NormalRelated() {
|
||||||
$return = new DataObjectSet();
|
$return = new ArrayList();
|
||||||
$links = DataObject::get('RelatedPageLink', '"MasterPageID" = ' . $this->owner->ID);
|
$links = DataObject::get('RelatedPageLink', '"MasterPageID" = ' . $this->owner->ID);
|
||||||
if($links) foreach($links as $link) {
|
if($links) foreach($links as $link) {
|
||||||
if($link->RelatedPage()->exists()) {
|
if($link->RelatedPage()->exists()) {
|
148
code/forms/GridFieldAddFromTemplateButton.php
Normal file
148
code/forms/GridFieldAddFromTemplateButton.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
class GridFieldAddFromTemplateButton implements GridField_HTMLProvider {
|
||||||
|
protected $targetFragment;
|
||||||
|
|
||||||
|
public function __construct($targetFragment = 'before') {
|
||||||
|
$this->targetFragment = $targetFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHTMLFragments($gridField) {
|
||||||
|
$data = new ArrayData(array(
|
||||||
|
'NewFromTemplateLink' => $gridField->Link('newFromTemplate'),
|
||||||
|
));
|
||||||
|
return array(
|
||||||
|
$this->targetFragment => $data->renderWith('GridFieldAddFromTemplateButton'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
||||||
|
public function getURLHandlers($gridField) {
|
||||||
|
return array(
|
||||||
|
'newFromTemplate'=>'newFromTemplate',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newFromTemplate($gridField, $request) {
|
||||||
|
$controller = $gridField->getForm()->Controller();
|
||||||
|
|
||||||
|
if(is_numeric($request->param('ID'))) {
|
||||||
|
$record = $gridField->getList()->byId($request->param("ID"));
|
||||||
|
} else {
|
||||||
|
$record = Object::create($gridField->getModelClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$handler = Object::create('GridFieldAddFromTemplate_ItemRequest', $gridField, $this, $record, $controller, $this->name);
|
||||||
|
$handler->setTemplate($this->template);
|
||||||
|
|
||||||
|
return $handler->handleRequest($request, DataModel::inst());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||||
|
public function Link($action = null) {
|
||||||
|
return $this->gridField->Link('newFromTemplate');
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit($request) {
|
||||||
|
$controller = $this->getToplevelController();
|
||||||
|
$form = $this->NewFromTemplateForm($this->gridField, $request);
|
||||||
|
|
||||||
|
$return = $this->customise(array(
|
||||||
|
'Backlink' => $controller->Link(),
|
||||||
|
'ItemEditForm' => $form,
|
||||||
|
))->renderWith($this->template);
|
||||||
|
|
||||||
|
if($controller->isAjax()) {
|
||||||
|
return $return;
|
||||||
|
} else {
|
||||||
|
// If not requested by ajax, we need to render it within the controller context+template
|
||||||
|
return $controller->customise(array(
|
||||||
|
// TODO CMS coupling
|
||||||
|
'Content' => $return,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function NewFromTemplateForm() {
|
||||||
|
$templates=DataObject::get('Subsite_Template');
|
||||||
|
|
||||||
|
$fields=new FieldList(
|
||||||
|
new DropdownField('TemplateID', _t('GridFieldAddFromTemplate.TEMPLATE', '_Template'), $templates->map('ID', 'Name'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$actions=new FieldList(
|
||||||
|
FormAction::create('doCreateFromTemplate', _t('GridFieldDetailsForm.Create', 'Create'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add a Cancel link which is a button-like link and link back to one level up.
|
||||||
|
$curmbs = $this->Breadcrumbs();
|
||||||
|
if($curmbs && $curmbs->count()>=2){
|
||||||
|
$one_level_up = $curmbs->offsetGet($curmbs->count()-2);
|
||||||
|
$text = "
|
||||||
|
<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"".$one_level_up->Link."\">
|
||||||
|
Cancel
|
||||||
|
</a>";
|
||||||
|
$actions->push(new LiteralField('cancelbutton', $text));
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator=new RequiredFields('TemplateID');
|
||||||
|
|
||||||
|
$form=new Form($this, 'NewFromTemplateForm', $fields, $actions, $validator);
|
||||||
|
|
||||||
|
// TODO Coupling with CMS
|
||||||
|
$toplevelController = $this->getToplevelController();
|
||||||
|
if($toplevelController && $toplevelController instanceof LeftAndMain) {
|
||||||
|
// Always show with base template (full width, no other panels),
|
||||||
|
// regardless of overloaded CMS controller templates.
|
||||||
|
// TODO Allow customization, e.g. to display an edit form alongside a search form from the CMS controller
|
||||||
|
$form->setTemplate('LeftAndMain_EditForm');
|
||||||
|
$form->addExtraClass('cms-content cms-edit-form center ss-tabset');
|
||||||
|
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
||||||
|
// TODO Link back to controller action (and edited root record) rather than index,
|
||||||
|
// which requires more URL knowledge than the current link to this field gives us.
|
||||||
|
// The current root record is held in session only,
|
||||||
|
// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
|
||||||
|
$form->Backlink = $toplevelController->Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doCreateFromTemplate($data, Form $form) {
|
||||||
|
$template=DataObject::get_by_id('Subsite_Template', intval($data['TemplateID']));
|
||||||
|
|
||||||
|
if($template) {
|
||||||
|
$subsite=$template->createInstance($data['Title']);
|
||||||
|
$subsite->write();
|
||||||
|
|
||||||
|
$this->record($subsite);
|
||||||
|
return $this->redirect(parent::Link());
|
||||||
|
}else {
|
||||||
|
$form->sessionMessage(_t('GridFieldAddFromTemplate.TEMPLATE_NOT_FOUND', '_The selected template could not be found'), 'bad');
|
||||||
|
return $this->redirectBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CMS-specific functionality: Passes through navigation breadcrumbs
|
||||||
|
* to the template, and includes the currently edited record (if any).
|
||||||
|
* see {@link LeftAndMain->Breadcrumbs()} for details.
|
||||||
|
*
|
||||||
|
* @param boolean $unlinked
|
||||||
|
* @return ArrayData
|
||||||
|
*/
|
||||||
|
function Breadcrumbs($unlinked = false) {
|
||||||
|
if(!$this->popupController->hasMethod('Breadcrumbs')) return;
|
||||||
|
|
||||||
|
$items = $this->popupController->Breadcrumbs($unlinked);
|
||||||
|
$items->push(new ArrayData(array(
|
||||||
|
'Title' => sprintf(_t('GridFieldAddFromTemplate.NewFromTemplate', 'New %s from template'), $this->record->singular_name()),
|
||||||
|
'Link' => false
|
||||||
|
)));
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
}
|
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() {
|
||||||
|
$html = parent::Field();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,15 @@ class RelatedPageLink extends DataObject {
|
|||||||
// bind a has_many to.
|
// bind a has_many to.
|
||||||
'MasterPage' => 'SiteTree',
|
'MasterPage' => 'SiteTree',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static $summary_fields=array(
|
||||||
|
'RelatedPageAdminLink' => 'Page',
|
||||||
|
'AbsoluteLink' => 'URL',
|
||||||
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
$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"))) {
|
if(Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
|
||||||
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
|
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
|
||||||
@ -47,8 +52,8 @@ class RelatedPageLink extends DataObject {
|
|||||||
|
|
||||||
$pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
|
$pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
|
||||||
|
|
||||||
if($subsites->Count()) $fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
|
if($subsites->Count()) $fields = new FieldList($subsiteSelectionField, $pageSelectionField);
|
||||||
else $fields = new FieldSet($pageSelectionField);
|
else $fields = new FieldList($pageSelectionField);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
@ -146,7 +146,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
function domain() {
|
function domain() {
|
||||||
if($this->ID) {
|
if($this->ID) {
|
||||||
$domains = DataObject::get("SubsiteDomain", "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC","", 1);
|
$domains = DataObject::get("SubsiteDomain", "\"SubsiteID\" = $this->ID", "\"IsPrimary\" DESC","", 1);
|
||||||
if($domains) {
|
if($domains && $domains->Count()>0) {
|
||||||
$domain = $domains->First()->Domain;
|
$domain = $domains->First()->Domain;
|
||||||
// If there are wildcards in the primary domain (not recommended), make some
|
// If there are wildcards in the primary domain (not recommended), make some
|
||||||
// educated guesses about what to replace them with:
|
// educated guesses about what to replace them with:
|
||||||
@ -178,10 +178,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
* Show the configuration fields for each subsite
|
* Show the configuration fields for each subsite
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$domainTable = new TableField("Domains", "SubsiteDomain",
|
$domainTable = new GridField("Domains", "Domains", $this->Domains(), GridFieldConfig_RecordEditor::create(10));
|
||||||
array("Domain" => "Domain <small>(use * as a wildcard)</small>", "IsPrimary" => "Primary domain?"),
|
|
||||||
array("Domain" => "TextField", "IsPrimary" => "CheckboxField"),
|
|
||||||
"SubsiteID", $this->ID);
|
|
||||||
|
|
||||||
$languageSelector = new DropdownField('Language', 'Language', i18n::get_common_locales());
|
$languageSelector = new DropdownField('Language', 'Language', i18n::get_common_locales());
|
||||||
|
|
||||||
@ -192,7 +189,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
asort($pageTypeMap);
|
asort($pageTypeMap);
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TabSet('Root',
|
new TabSet('Root',
|
||||||
new Tab('Configuration',
|
new Tab('Configuration',
|
||||||
new HeaderField($this->getClassName() . ' configuration', 2),
|
new HeaderField($this->getClassName() . ' configuration', 2),
|
||||||
@ -238,7 +235,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCMSActions() {
|
function getCMSActions() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -285,7 +282,7 @@ JS;
|
|||||||
$id = self::getSubsiteIDForDomain();
|
$id = self::getSubsiteIDForDomain();
|
||||||
Session::set('SubsiteID', $id);
|
Session::set('SubsiteID', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)$id;
|
return (int)$id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,12 +338,12 @@ JS;
|
|||||||
$SQL_host = Convert::raw2sql($host);
|
$SQL_host = Convert::raw2sql($host);
|
||||||
|
|
||||||
$matchingDomains = DataObject::get("SubsiteDomain", "'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')",
|
$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");
|
\"Subsite\".\"IsPublic\"=1");
|
||||||
|
|
||||||
if($matchingDomains) {
|
if($matchingDomains && $matchingDomains->Count()>0) {
|
||||||
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID'));
|
$subsiteIDs = array_unique($matchingDomains->map('SubsiteID')->keys());
|
||||||
$subsiteDomains = array_unique($matchingDomains->column('Domain'));
|
$subsiteDomains = array_unique($matchingDomains->map('Domain')->keys());
|
||||||
if(sizeof($subsiteIDs) > 1) {
|
if(sizeof($subsiteIDs) > 1) {
|
||||||
throw new UnexpectedValueException(sprintf(
|
throw new UnexpectedValueException(sprintf(
|
||||||
"Multiple subsites match on '%s': %s",
|
"Multiple subsites match on '%s': %s",
|
||||||
@ -473,12 +470,12 @@ JS;
|
|||||||
* @param $includeMainSite If true, the main site will be included if appropriate.
|
* @param $includeMainSite If true, the main site will be included if appropriate.
|
||||||
* @param $mainSiteTitle The label to give to the main site
|
* @param $mainSiteTitle The label to give to the main site
|
||||||
* @param $member
|
* @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) {
|
function accessible_sites($permCode, $includeMainSite = false, $mainSiteTitle = "Main site", $member = null) {
|
||||||
// Rationalise member arguments
|
// Rationalise member arguments
|
||||||
if(!$member) $member = Member::currentUser();
|
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);
|
if(!is_object($member)) $member = DataObject::get_by_id('Member', $member);
|
||||||
|
|
||||||
// Rationalise permCode argument
|
// Rationalise permCode argument
|
||||||
@ -496,39 +493,22 @@ JS;
|
|||||||
$subsites = DataObject::get(
|
$subsites = DataObject::get(
|
||||||
'Subsite',
|
'Subsite',
|
||||||
"\"Subsite\".\"Title\" != ''",
|
"\"Subsite\".\"Title\" != ''",
|
||||||
'',
|
'')->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
||||||
"LEFT JOIN \"Group_Subsites\"
|
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
|
||||||
ON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"
|
->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID")
|
||||||
INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"
|
->innerJoin('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ($SQL_codes, 'ADMIN')");
|
||||||
OR \"Group\".\"AccessAllSubsites\" = 1
|
|
||||||
INNER JOIN \"Group_Members\"
|
if(!$subsites) $subsites = new ArrayList();
|
||||||
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();
|
|
||||||
|
|
||||||
$rolesSubsites = DataObject::get(
|
$rolesSubsites = DataObject::get(
|
||||||
'Subsite',
|
'Subsite',
|
||||||
"\"Subsite\".\"Title\" != ''",
|
"\"Subsite\".\"Title\" != ''",
|
||||||
'',
|
'')->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
||||||
"LEFT JOIN \"Group_Subsites\"
|
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
|
||||||
ON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"
|
->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID")
|
||||||
INNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"
|
->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")
|
||||||
OR \"Group\".\"AccessAllSubsites\" = 1
|
->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")
|
||||||
INNER JOIN \"Group_Members\"
|
->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ($SQL_codes, 'ADMIN')");
|
||||||
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 && $rolesSubsites) return $rolesSubsites;
|
if(!$subsites && $rolesSubsites) return $rolesSubsites;
|
||||||
|
|
||||||
@ -539,13 +519,16 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Include the main site
|
// Include the main site
|
||||||
if(!$subsites) $subsites = new DataObjectSet();
|
if(!$subsites) $subsites = new ArrayList();
|
||||||
if($includeMainSite) {
|
if($includeMainSite) {
|
||||||
if(!is_array($permCode)) $permCode = array($permCode);
|
if(!is_array($permCode)) $permCode = array($permCode);
|
||||||
if(self::hasMainSitePermission($member, $permCode)) {
|
if(self::hasMainSitePermission($member, $permCode)) {
|
||||||
|
$subsites=$subsites->toArray();
|
||||||
|
|
||||||
$mainSite = new Subsite();
|
$mainSite = new Subsite();
|
||||||
$mainSite->Title = $mainSiteTitle;
|
$mainSite->Title = $mainSiteTitle;
|
||||||
$subsites->insertFirst($mainSite);
|
array_unshift($subsites, $mainSite);
|
||||||
|
$subsites=ArrayList::create($subsites);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,10 +576,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() {
|
function adminSearchFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('Name', 'Sub-site name')
|
new TextField('Name', 'Sub-site name')
|
||||||
);
|
);
|
||||||
}
|
}
|
32
code/model/SubsiteDomain.php
Normal file
32
code/model/SubsiteDomain.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SubsiteDomain extends DataObject {
|
||||||
|
static $db = array(
|
||||||
|
"Domain" => "Varchar(255)",
|
||||||
|
"IsPrimary" => "Boolean",
|
||||||
|
);
|
||||||
|
static $has_one = array(
|
||||||
|
"Subsite" => "Subsite",
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $summary_fields=array(
|
||||||
|
'Domain'=>'Domain',
|
||||||
|
'IsPrimary'=>'Is Primary Domain'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whenever a Subsite Domain is written, rewrite the hostmap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
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;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cms-login-status.subsites {
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
#SubsitesSelect,
|
#SubsitesSelect,
|
||||||
#SubsitesSelect option {
|
#SubsitesSelect option {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
#SubsitesSelect {
|
#SubsitesSelect {
|
||||||
max-width: 200px;
|
width: 171px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#top #MainMenu #Menu-help {
|
|
||||||
margin-right: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#AddSubsiteLink {
|
#AddSubsiteLink {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
@ -55,4 +55,8 @@
|
|||||||
|
|
||||||
body.SubsiteAdmin .right form #URL .fieldgroup * {
|
body.SubsiteAdmin .right form #URL .fieldgroup * {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cms-add-form #PageType li .class-SubsitesVirtualPage, .class-SubsitesVirtualPage a .jstree-pageicon {
|
||||||
|
background-position: 0 -32px !important;
|
||||||
}
|
}
|
@ -1,53 +1,53 @@
|
|||||||
Behaviour.register({
|
(function($) {
|
||||||
'#SubsiteActions select' : {
|
$.entwine('ss', function($) {
|
||||||
onchange: function() {
|
$('#SubsitesSelect').live('change', function() {
|
||||||
document.location.href = SiteTreeHandlers.controller_url + '?SubsiteID=' + this.value;
|
window.location.search=$.query.set('SubsiteID', $(this).val());
|
||||||
}
|
});
|
||||||
},
|
|
||||||
|
// Subsite tab of Group editor
|
||||||
// Subsite tab of Group editor
|
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
||||||
'#Form_EditForm_AccessAllSubsites' : {
|
/**
|
||||||
initialize: function () {
|
* Constructor: onmatch
|
||||||
this.showHideSubsiteList();
|
*/
|
||||||
var i=0,items=this.getElementsByTagName('input');
|
onmatch: function () {
|
||||||
for(i=0;i<items.length;i++) {
|
this.showHideSubsiteList();
|
||||||
items[i].onchange = this.showHideSubsiteList;
|
|
||||||
}
|
var ref=this;
|
||||||
},
|
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
||||||
|
ref.showHideSubsiteList();
|
||||||
showHideSubsiteList : function () {
|
});
|
||||||
$('Form_EditForm_Subsites').parentNode.style.display =
|
},
|
||||||
Form.Element.getValue($('Form_EditForm').AccessAllSubsites)==1 ? 'none' : '';
|
|
||||||
}
|
showHideSubsiteList: function () {
|
||||||
},
|
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
||||||
|
}
|
||||||
/**
|
});
|
||||||
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
|
||||||
* Hidden by default, unless either the toggle checkbox, or any of the
|
$('.cms-edit-form').entwine({
|
||||||
* actual value checkboxes are selected.
|
getChangeTrackerOptions: function() {
|
||||||
*/
|
this.ChangeTrackerOptions.ignoreFieldSelector+=', input[name=IsSubsite]';
|
||||||
'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': {
|
*/
|
||||||
initialize: function() {
|
$('#PageTypeBlacklist').entwine({
|
||||||
var hasLimits = Boolean(jQuery(this).find('input:checked').length);
|
onmatch: function() {
|
||||||
jQuery(this).toggle(hasLimits);
|
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
||||||
}
|
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
//Bind listener
|
||||||
// Add an item to fieldsToIgnore
|
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||||
Behaviour.register({
|
jQuery('#PageTypeBlacklist').toggle();
|
||||||
'#Form_EditForm' : {
|
|
||||||
initialize: function () {
|
e.stopPropagation();
|
||||||
this.changeDetection_fieldsToIgnore.IsSubsite = true;
|
return false;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
fitToParent('ResultTable_holder');
|
})(jQuery);
|
@ -1,54 +1,26 @@
|
|||||||
SubsitesTreeDropdownField = Class.extend('TreeDropdownField');
|
(function($) {
|
||||||
SubsitesTreeDropdownField.prototype = {
|
$.entwine('ss', function($) {
|
||||||
|
$('.TreeDropdownField').entwine({
|
||||||
subsiteID: function() {
|
subsiteID: function() {
|
||||||
var subsiteSel = $$('#CopyContentFromID_SubsiteID select')[0];
|
var subsiteSel = $$('#CopyContentFromID_SubsiteID select')[0];
|
||||||
subsiteSel.onchange = (function() {
|
subsiteSel.onchange = (function() {
|
||||||
this.createTreeNode(true);
|
this.createTreeNode(true);
|
||||||
this.ajaxGetTree((function(response) {
|
this.ajaxGetTree((function(response) {
|
||||||
this.newTreeReady(response, true);
|
this.newTreeReady(response, true);
|
||||||
this.updateTreeLabel();
|
this.updateTreeLabel();
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
}).bind(this);
|
}).bind(this);
|
||||||
return subsiteSel.options[subsiteSel.selectedIndex].value;
|
return subsiteSel.options[subsiteSel.selectedIndex].value;
|
||||||
},
|
},
|
||||||
|
|
||||||
ajaxGetTree: function(after) {
|
getRequestParams: function() {
|
||||||
// Can't force value because it might be on a different subsite!
|
var name=this.find(':input:hidden').attr('name');
|
||||||
var ajaxURL = this.buildURL('gettree?forceValues=' + 0); //this.inputTag.value;
|
var obj={};
|
||||||
|
|
||||||
// Customised: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
||||||
ajaxURL += '&' + this.inputTag.name + '_SubsiteID=' + parseInt(this.subsiteID());
|
|
||||||
|
return obj;
|
||||||
ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '';
|
}
|
||||||
new Ajax.Request(ajaxURL, {
|
});
|
||||||
method : 'get',
|
});
|
||||||
onSuccess : after,
|
})(jQuery);
|
||||||
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); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SubsitesTreeDropdownField.applyTo('div.SubsitesTreeDropdownField');
|
|
||||||
|
@ -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';
|
|
||||||
|
|
||||||
?>
|
|
38
lang/en_US.yml
Normal file
38
lang/en_US.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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"
|
||||||
|
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';
|
|
||||||
|
|
||||||
?>
|
|
39
lang/nb_NO.yml
Normal file
39
lang/nb_NO.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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"
|
||||||
|
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';
|
|
||||||
|
|
||||||
?>
|
|
39
lang/tr_TR.yml
Normal file
39
lang/tr_TR.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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"
|
||||||
|
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>
|
@ -11,7 +11,7 @@ class FileSubsitesTest extends SapphireTest {
|
|||||||
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
||||||
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
||||||
$this->assertEquals('FileTitle', $file->TreeTitle());
|
$this->assertEquals('FileTitle', $file->TreeTitle());
|
||||||
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldSet);
|
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
||||||
Subsite::changeSubsite(1);
|
Subsite::changeSubsite(1);
|
||||||
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class GroupSubsitesTest extends SapphireTest {
|
|||||||
function testTrivialFeatures() {
|
function testTrivialFeatures() {
|
||||||
$this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics()));
|
$this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics()));
|
||||||
$this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions()));
|
$this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions()));
|
||||||
$this->assertTrue(singleton('Group')->getCMSFields() instanceof FieldSet);
|
$this->assertTrue(singleton('Group')->getCMSFields() instanceof FieldList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAlternateTreeTitle() {
|
function testAlternateTreeTitle() {
|
||||||
|
@ -41,8 +41,8 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
|||||||
|
|
||||||
function testBasicSanity() {
|
function testBasicSanity() {
|
||||||
$this->assertTrue(singleton('SiteTree')->getSiteConfig() instanceof SiteConfig);
|
$this->assertTrue(singleton('SiteTree')->getSiteConfig() instanceof SiteConfig);
|
||||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldSet);
|
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldList);
|
||||||
$this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldSet);
|
$this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldList);
|
||||||
$this->assertTrue(is_array(singleton('SiteTreeSubsites')->extraStatics()));
|
$this->assertTrue(is_array(singleton('SiteTreeSubsites')->extraStatics()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testRelatedPages() {
|
function testRelatedPages() {
|
||||||
$this->assertTrue(singleton('RelatedPageLink')->getCMSFields() instanceof FieldSet);
|
$this->assertTrue(singleton('RelatedPageLink')->getCMSFields() instanceof FieldList);
|
||||||
|
|
||||||
$importantpage = $this->objFromFixture('SiteTree', 'importantpage');
|
$importantpage = $this->objFromFixture('SiteTree', 'importantpage');
|
||||||
$contact = $this->objFromFixture('SiteTree', 'contact');
|
$contact = $this->objFromFixture('SiteTree', 'contact');
|
||||||
@ -68,13 +68,13 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
|||||||
$link->RelatedPageID = $contact->ID;
|
$link->RelatedPageID = $contact->ID;
|
||||||
$link->write();
|
$link->write();
|
||||||
$importantpage->RelatedPages()->add($link);
|
$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($importantpage->NormalRelated()->Count(), 1);
|
||||||
$this->assertEquals($contact->ReverseRelated()->Count(), 1);
|
$this->assertEquals($contact->ReverseRelated()->Count(), 1);
|
||||||
|
|
||||||
$this->assertTrue($importantpage->getCMSFields() instanceof FieldSet);
|
$this->assertTrue($importantpage->getCMSFields() instanceof FieldList);
|
||||||
$this->assertTrue($contact->getCMSFields() instanceof FieldSet);
|
$this->assertTrue($contact->getCMSFields() instanceof FieldList);
|
||||||
|
|
||||||
$this->assertEquals($importantpage->canView(), $link->canView());
|
$this->assertEquals($importantpage->canView(), $link->canView());
|
||||||
$this->assertEquals($importantpage->canEdit(), $link->canEdit());
|
$this->assertEquals($importantpage->canEdit(), $link->canEdit());
|
||||||
|
@ -102,7 +102,7 @@ class SubsiteAdminTest extends SapphireTest {
|
|||||||
$ids[$subsite->ID] = true;
|
$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(0, $ids, "Main site accessible");
|
||||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','main'), $ids, "Site with no groups inaccesible");
|
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','main'), $ids, "Site with no groups inaccesible");
|
||||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','subsite1'), $ids, "Subsite1 Template inaccessible");
|
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','subsite1'), $ids, "Subsite1 Template inaccessible");
|
||||||
|
Loading…
Reference in New Issue
Block a user