mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
BUG: Coding convention updates
This commit is contained in:
parent
c9d3a1f854
commit
598b0253f5
@ -10,21 +10,21 @@ class SubsiteAdmin extends ModelAdmin {
|
||||
static $url_segment = 'subsites';
|
||||
|
||||
static $menu_title = "Subsites";
|
||||
|
||||
public $showImportForm=false;
|
||||
|
||||
public $showImportForm=false;
|
||||
|
||||
public function getEditForm($id = null, $fields = null) {
|
||||
$form = parent::getEditForm($id, $fields);
|
||||
|
||||
if($this->modelClass=='Subsite') {
|
||||
$grid=$form->Fields()->dataFieldByName('Subsite');
|
||||
if($grid) {
|
||||
$grid->getConfig()->addComponent(new GridFieldAddFromTemplateButton('toolbar-header-right'));
|
||||
$grid->getConfig()->addComponent(new GridFieldAddFromTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
|
||||
$subsites = DataObject::get('Subsite');
|
||||
if(!$subsites) {
|
||||
$subsites = new ArrayList();
|
||||
}else {
|
||||
$subsites=ArrayList::create($subsites->toArray());
|
||||
}
|
||||
|
||||
$subsites = new ArrayList();
|
||||
}else {
|
||||
$subsites=ArrayList::create($subsites->toArray());
|
||||
}
|
||||
|
||||
$subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
|
||||
|
||||
$subsiteSelectionField = new DropdownField(
|
||||
@ -61,8 +61,8 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
);
|
||||
$linkToContentLabelField->setAllowHTML(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$fields->addFieldToTab('Root.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
||||
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
||||
@ -116,7 +116,7 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
// 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()) {
|
||||
@ -167,4 +167,4 @@ class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
||||
Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
@ -11,9 +11,9 @@ class FileSubsites extends DataExtension {
|
||||
static $default_root_folders_global = false;
|
||||
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite',
|
||||
);
|
||||
|
||||
'Subsite' => 'Subsite',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Amends the CMS tree title for folders in the Files & Images section.
|
||||
@ -42,19 +42,19 @@ class FileSubsites extends DataExtension {
|
||||
*/
|
||||
function augmentSQL(SQLQuery &$query) {
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse)
|
||||
//@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
|
||||
//@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->getFrom() as $tableName => $info) {
|
||||
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
||||
$query->addWhere($where);
|
||||
break;
|
||||
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
||||
$query->addWhere($where);
|
||||
break;
|
||||
}
|
||||
|
||||
$sect=array_values($query->getSelect());
|
||||
$sect=array_values($query->getSelect());
|
||||
$isCounting = strpos($sect[0], 'COUNT') !== false;
|
||||
|
||||
// Ordering when deleting or counting doesn't apply
|
||||
|
@ -7,16 +7,16 @@
|
||||
class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||
|
||||
public static $db=array(
|
||||
'AccessAllSubsites' => 'Boolean'
|
||||
);
|
||||
|
||||
'AccessAllSubsites' => 'Boolean'
|
||||
);
|
||||
|
||||
public static $many_many=array(
|
||||
'Subsites' => 'Subsite'
|
||||
);
|
||||
|
||||
'Subsites' => 'Subsite'
|
||||
);
|
||||
|
||||
public static $defaults=array(
|
||||
'AccessAllSubsites' => true
|
||||
);
|
||||
'AccessAllSubsites' => true
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
@ -117,12 +117,12 @@ class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||
// Don't filter by Group_Subsites if we've already done that
|
||||
$hasGroupSubsites = false;
|
||||
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((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->addLeftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
||||
@ -135,7 +135,7 @@ class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||
}
|
||||
|
||||
// WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server)
|
||||
$select=$query->getSelect();
|
||||
$select=$query->getSelect();
|
||||
if(isset($select[0]) && !$select[0] == 'COUNT(*)') {
|
||||
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ class LeftAndMainSubsites extends Extension {
|
||||
if(!Session::get('SubsiteID') || $_REQUEST['SubsiteID'] != Session::get('SubsiteID')) {
|
||||
Session::clear("{$this->owner->class}.currentPage");
|
||||
}
|
||||
|
||||
|
||||
// Update current subsite in session
|
||||
Subsite::changeSubsite($_REQUEST['SubsiteID']);
|
||||
|
||||
//Redirect to clear the current page
|
||||
$this->owner->redirect('admin/pages');
|
||||
|
||||
//Redirect to clear the current page
|
||||
$this->owner->redirect('admin/pages');
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class LeftAndMainSubsites extends Extension {
|
||||
}
|
||||
|
||||
public function Subsites() {
|
||||
return Subsite::accessible_sites('ADMIN');
|
||||
return Subsite::accessible_sites('ADMIN');
|
||||
}
|
||||
|
||||
public function SubsiteList() {
|
||||
@ -60,22 +60,22 @@ class LeftAndMainSubsites extends Extension {
|
||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||
return $output;
|
||||
} else if($list->Count() == 1) {
|
||||
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>';
|
||||
}
|
||||
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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,9 +100,9 @@ class LeftAndMainSubsites extends Extension {
|
||||
// Switch to a subsite that this user can actually access.
|
||||
$member = Member::currentUser();
|
||||
if ($member && Permission::check('ADMIN')) {
|
||||
return true; //admin can access all subsites
|
||||
}
|
||||
|
||||
return true; //admin can access all subsites
|
||||
}
|
||||
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->map('ID', 'Title')->toArray();
|
||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||
$siteIDs = array_keys($sites);
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
class SiteConfigSubsites extends DataExtension {
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
);
|
||||
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Update any requests to limit the results to the current site
|
||||
@ -20,8 +20,8 @@ class SiteConfigSubsites extends DataExtension {
|
||||
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||
|
||||
$froms=$query->getFrom();
|
||||
$froms=array_keys($froms);
|
||||
$froms=$query->getFrom();
|
||||
$froms=array_keys($froms);
|
||||
$tableName = array_shift($froms);
|
||||
if($tableName != 'SiteConfig') return;
|
||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||
|
@ -28,25 +28,25 @@ class SiteTreeSubsites extends DataExtension {
|
||||
|
||||
|
||||
public static $has_one=array(
|
||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||
'MasterPage' => 'SiteTree',// Optional; the page that is the content master
|
||||
);
|
||||
|
||||
'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'
|
||||
);
|
||||
|
||||
'RelatedPages' => 'RelatedPageLink'
|
||||
);
|
||||
|
||||
public static $many_many=array(
|
||||
'CrossSubsiteLinkTracking' => 'SiteTree' // Stored separately, as the logic for URL rewriting is different
|
||||
);
|
||||
|
||||
'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")
|
||||
);
|
||||
'BackCrossSubsiteLinkTracking' => 'SiteTree'
|
||||
);
|
||||
|
||||
public static $many_many_extraFields=array(
|
||||
"CrossSubsiteLinkTracking" => array("FieldName" => "Varchar")
|
||||
);
|
||||
|
||||
function isMainSite() {
|
||||
if($this->owner->SubsiteID == 0) return true;
|
||||
@ -97,17 +97,17 @@ class SiteTreeSubsites extends DataExtension {
|
||||
if($subsite && $subsite->ID) {
|
||||
$baseUrl = 'http://' . $subsite->domain() . '/';
|
||||
$fields->removeByName('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 = 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');
|
||||
|
||||
$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 = 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;
|
||||
@ -124,8 +124,8 @@ class SiteTreeSubsites extends DataExtension {
|
||||
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
||||
);
|
||||
|
||||
$related->setModelClass('RelatedPageLink');
|
||||
|
||||
$related->setModelClass('RelatedPageLink');
|
||||
|
||||
// The 'show' link doesn't provide any useful info
|
||||
//$related->setPermissions(array('add', 'edit', 'delete'));
|
||||
|
||||
@ -147,8 +147,8 @@ class SiteTreeSubsites extends DataExtension {
|
||||
function ReverseRelated() {
|
||||
return DataObject::get('RelatedPageLink', "\"RelatedPageLink\".\"RelatedPageID\" = {$this->owner->ID}
|
||||
AND R2.\"ID\" IS NULL", '')
|
||||
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
||||
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
||||
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
||||
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
||||
}
|
||||
|
||||
function NormalRelated() {
|
||||
|
@ -18,13 +18,13 @@ class GridFieldAddFromTemplateButton implements GridField_HTMLProvider {
|
||||
}
|
||||
|
||||
class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
||||
public function getURLHandlers($gridField) {
|
||||
return array(
|
||||
'newFromTemplate'=>'newFromTemplate',
|
||||
);
|
||||
}
|
||||
|
||||
public function newFromTemplate($gridField, $request) {
|
||||
public function getURLHandlers($gridField) {
|
||||
return array(
|
||||
'newFromTemplate'=>'newFromTemplate',
|
||||
);
|
||||
}
|
||||
|
||||
public function newFromTemplate($gridField, $request) {
|
||||
$controller = $gridField->getForm()->Controller();
|
||||
|
||||
if(is_numeric($request->param('ID'))) {
|
||||
@ -38,15 +38,15 @@ class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
||||
$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) {
|
||||
|
||||
function edit($request) {
|
||||
$controller = $this->getToplevelController();
|
||||
$form = $this->NewFromTemplateForm($this->gridField, $request);
|
||||
|
||||
@ -65,34 +65,34 @@ class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemReque
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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),
|
||||
@ -107,24 +107,24 @@ class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemReque
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -138,10 +138,10 @@ class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemReque
|
||||
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
|
||||
)));
|
||||
$items->push(new ArrayData(array(
|
||||
'Title' => sprintf(_t('GridFieldAddFromTemplate.NewFromTemplate', 'New %s from template'), $this->record->singular_name()),
|
||||
'Link' => false
|
||||
)));
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ class RelatedPageLink extends DataObject {
|
||||
// bind a has_many to.
|
||||
'MasterPage' => 'SiteTree',
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'RelatedPageAdminLink' => 'Page',
|
||||
'AbsoluteLink' => 'URL',
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'RelatedPageAdminLink' => 'Page',
|
||||
'AbsoluteLink' => 'URL',
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
||||
|
@ -178,11 +178,11 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
* Show the configuration fields for each subsite
|
||||
*/
|
||||
function getCMSFields() {
|
||||
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>');
|
||||
}
|
||||
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());
|
||||
|
||||
@ -240,7 +240,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
||||
|
||||
function getCMSActions() {
|
||||
return new FieldList(
|
||||
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
||||
new FormAction('callPageMethod', "Create copy", null, 'adminDuplicate')
|
||||
);
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ JS;
|
||||
$id = self::getSubsiteIDForDomain();
|
||||
Session::set('SubsiteID', $id);
|
||||
}
|
||||
|
||||
|
||||
return (int)$id;
|
||||
}
|
||||
|
||||
@ -497,10 +497,10 @@ JS;
|
||||
$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')");
|
||||
|
||||
->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')");
|
||||
|
||||
if(!$subsites) $subsites = new ArrayList();
|
||||
|
||||
$rolesSubsites = DataList::create('Subsite')
|
||||
@ -525,18 +525,18 @@ JS;
|
||||
if($includeMainSite) {
|
||||
if(!is_array($permCode)) $permCode = array($permCode);
|
||||
if(self::hasMainSitePermission($member, $permCode)) {
|
||||
$subsites=$subsites->toArray();
|
||||
|
||||
$subsites=$subsites->toArray();
|
||||
|
||||
$mainSite = new Subsite();
|
||||
$mainSite->Title = $mainSiteTitle;
|
||||
array_unshift($subsites, $mainSite);
|
||||
$subsites=ArrayList::create($subsites);
|
||||
$subsites=ArrayList::create($subsites);
|
||||
}
|
||||
}
|
||||
|
||||
self::$_cache_accessible_sites[$cacheKey] = $subsites;
|
||||
|
||||
|
||||
|
||||
return $subsites;
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,11 @@ class SubsiteDomain extends DataObject {
|
||||
"Subsite" => "Subsite",
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'Domain'=>'Domain',
|
||||
'IsPrimary'=>'Is Primary Domain'
|
||||
);
|
||||
|
||||
public static $summary_fields=array(
|
||||
'Domain'=>'Domain',
|
||||
'IsPrimary'=>'Is Primary Domain'
|
||||
);
|
||||
|
||||
/**
|
||||
* Whenever a Subsite Domain is written, rewrite the hostmap
|
||||
*
|
||||
@ -22,11 +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'))
|
||||
);
|
||||
}
|
||||
|
||||
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'))
|
||||
);
|
||||
}
|
||||
}
|
@ -1,53 +1,53 @@
|
||||
(function($) {
|
||||
$.entwine('ss', function($) {
|
||||
$('#SubsitesSelect').live('change', function() {
|
||||
window.location.search=$.query.set('SubsiteID', $(this).val());
|
||||
});
|
||||
|
||||
// Subsite tab of Group editor
|
||||
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
||||
$.entwine('ss', function($) {
|
||||
$('#SubsitesSelect').live('change', function() {
|
||||
window.location.search=$.query.set('SubsiteID', $(this).val());
|
||||
});
|
||||
|
||||
// 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':''));
|
||||
}
|
||||
});
|
||||
|
||||
$('.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.
|
||||
*/
|
||||
$('#PageTypeBlacklist').entwine({
|
||||
onmatch: function() {
|
||||
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
||||
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
||||
|
||||
|
||||
//Bind listener
|
||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||
jQuery('#PageTypeBlacklist').toggle();
|
||||
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
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':''));
|
||||
}
|
||||
});
|
||||
|
||||
$('.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.
|
||||
*/
|
||||
$('#PageTypeBlacklist').entwine({
|
||||
onmatch: function() {
|
||||
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
||||
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
||||
|
||||
|
||||
//Bind listener
|
||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||
jQuery('#PageTypeBlacklist').toggle();
|
||||
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@ -1,26 +1,26 @@
|
||||
(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;
|
||||
},
|
||||
|
||||
getRequestParams: function() {
|
||||
var name=this.find(':input:hidden').attr('name');
|
||||
$.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;
|
||||
},
|
||||
|
||||
getRequestParams: function() {
|
||||
var name=this.find(':input:hidden').attr('name');
|
||||
var obj={};
|
||||
|
||||
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
||||
|
||||
return obj;
|
||||
|
||||
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
Loading…
x
Reference in New Issue
Block a user