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 $url_segment = 'subsites';
|
||||||
|
|
||||||
static $menu_title = "Subsites";
|
static $menu_title = "Subsites";
|
||||||
|
|
||||||
public $showImportForm=false;
|
public $showImportForm=false;
|
||||||
|
|
||||||
public function getEditForm($id = null, $fields = null) {
|
public function getEditForm($id = null, $fields = null) {
|
||||||
$form = parent::getEditForm($id, $fields);
|
$form = parent::getEditForm($id, $fields);
|
||||||
|
|
||||||
if($this->modelClass=='Subsite') {
|
if($this->modelClass=='Subsite') {
|
||||||
$grid=$form->Fields()->dataFieldByName('Subsite');
|
$grid=$form->Fields()->dataFieldByName('Subsite');
|
||||||
if($grid) {
|
if($grid) {
|
||||||
$grid->getConfig()->addComponent(new GridFieldAddFromTemplateButton('toolbar-header-right'));
|
$grid->getConfig()->addComponent(new GridFieldAddFromTemplateButton('toolbar-header-right'));
|
||||||
$grid->getConfig()->addComponent(new GridFieldAddFromTemplate());
|
$grid->getConfig()->addComponent(new GridFieldAddFromTemplate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
|
|
||||||
$subsites = DataObject::get('Subsite');
|
$subsites = DataObject::get('Subsite');
|
||||||
if(!$subsites) {
|
if(!$subsites) {
|
||||||
$subsites = new ArrayList();
|
$subsites = new ArrayList();
|
||||||
}else {
|
}else {
|
||||||
$subsites=ArrayList::create($subsites->toArray());
|
$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(
|
||||||
@ -61,8 +61,8 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
);
|
);
|
||||||
$linkToContentLabelField->setAllowHTML(true);
|
$linkToContentLabelField->setAllowHTML(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
$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('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
$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
|
// 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.
|
// needs to be duplicated from parent to find out the exact reason the validation failed.
|
||||||
if(!$isValid) {
|
if(!$isValid) {
|
||||||
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
||||||
$parentFilter = null;
|
$parentFilter = null;
|
||||||
|
|
||||||
if(self::nested_urls()) {
|
if(self::nested_urls()) {
|
||||||
@ -167,4 +167,4 @@ class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
|||||||
Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -11,9 +11,9 @@ class FileSubsites extends DataExtension {
|
|||||||
static $default_root_folders_global = false;
|
static $default_root_folders_global = false;
|
||||||
|
|
||||||
public static $has_one=array(
|
public static $has_one=array(
|
||||||
'Subsite' => 'Subsite',
|
'Subsite' => 'Subsite',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amends the CMS tree title for folders in the Files & Images section.
|
* Amends the CMS tree title for folders in the Files & Images section.
|
||||||
@ -42,19 +42,19 @@ class FileSubsites extends DataExtension {
|
|||||||
*/
|
*/
|
||||||
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)
|
||||||
//@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(!array_search('SiteTree_ImageTracking', $query->getFrom())===false && (!$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->getFrom() as $tableName => $info) {
|
foreach($query->getFrom() as $tableName => $info) {
|
||||||
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
$where = "\"$tableName\".\"SubsiteID\" IN (0, $subsiteID)";
|
||||||
$query->addWhere($where);
|
$query->addWhere($where);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sect=array_values($query->getSelect());
|
$sect=array_values($query->getSelect());
|
||||||
$isCounting = strpos($sect[0], 'COUNT') !== false;
|
$isCounting = strpos($sect[0], 'COUNT') !== false;
|
||||||
|
|
||||||
// Ordering when deleting or counting doesn't apply
|
// Ordering when deleting or counting doesn't apply
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
class GroupSubsites extends DataExtension implements PermissionProvider {
|
class GroupSubsites extends DataExtension implements PermissionProvider {
|
||||||
|
|
||||||
public static $db=array(
|
public static $db=array(
|
||||||
'AccessAllSubsites' => 'Boolean'
|
'AccessAllSubsites' => 'Boolean'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $many_many=array(
|
public static $many_many=array(
|
||||||
'Subsites' => 'Subsite'
|
'Subsites' => 'Subsite'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $defaults=array(
|
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
|
// Don't filter by Group_Subsites if we've already done that
|
||||||
$hasGroupSubsites = false;
|
$hasGroupSubsites = false;
|
||||||
foreach($query->getFrom() as $item) {
|
foreach($query->getFrom() as $item) {
|
||||||
if((is_array($item) && strpos($item['table'], 'Group_Subsites')!==false) || (!is_array($item) && strpos($item, 'Group_Subsites')!==false)) {
|
if((is_array($item) && strpos($item['table'], 'Group_Subsites')!==false) || (!is_array($item) && strpos($item, 'Group_Subsites')!==false)) {
|
||||||
$hasGroupSubsites = true;
|
$hasGroupSubsites = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$hasGroupSubsites) {
|
if(!$hasGroupSubsites) {
|
||||||
if($subsiteID) {
|
if($subsiteID) {
|
||||||
$query->addLeftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\"
|
$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)
|
// 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(*)') {
|
if(isset($select[0]) && !$select[0] == 'COUNT(*)') {
|
||||||
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
$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')) {
|
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
|
//Redirect to clear the current page
|
||||||
$this->owner->redirect('admin/pages');
|
$this->owner->redirect('admin/pages');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Subsites() {
|
public function Subsites() {
|
||||||
return Subsite::accessible_sites('ADMIN');
|
return Subsite::accessible_sites('ADMIN');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SubsiteList() {
|
public function SubsiteList() {
|
||||||
@ -60,22 +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) {
|
||||||
if($list->First()->DefaultSite==false) {
|
if($list->First()->DefaultSite==false) {
|
||||||
$output = '<select id="SubsitesSelect">';
|
$output = '<select id="SubsitesSelect">';
|
||||||
$output .= "\n<option value=\"0\">". _t('LeftAndMainSubsites.DEFAULT_SITE', '_Default Site') . "</option>";
|
$output .= "\n<option value=\"0\">". _t('LeftAndMainSubsites.DEFAULT_SITE', '_Default Site') . "</option>";
|
||||||
foreach($list as $subsite) {
|
foreach($list as $subsite) {
|
||||||
$selected = $subsite->ID == $currentSubsiteID ? ' selected="selected"' : '';
|
$selected = $subsite->ID == $currentSubsiteID ? ' selected="selected"' : '';
|
||||||
|
|
||||||
$output .= "\n<option value=\"{$subsite->ID}\"$selected>". Convert::raw2xml($subsite->Title) . "</option>";
|
$output .= "\n<option value=\"{$subsite->ID}\"$selected>". Convert::raw2xml($subsite->Title) . "</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '</select>';
|
$output .= '</select>';
|
||||||
|
|
||||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||||
return $output;
|
return $output;
|
||||||
}else {
|
}else {
|
||||||
return '<span>'.$list->First()->Title.'</span>';
|
return '<span>'.$list->First()->Title.'</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +100,9 @@ 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 && Permission::check('ADMIN')) {
|
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();
|
$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);
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
class SiteConfigSubsites extends DataExtension {
|
class SiteConfigSubsites extends DataExtension {
|
||||||
public static $has_one=array(
|
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
|
* 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;
|
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||||
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
else */$subsiteID = (int)Subsite::currentSubsiteID();
|
||||||
|
|
||||||
$froms=$query->getFrom();
|
$froms=$query->getFrom();
|
||||||
$froms=array_keys($froms);
|
$froms=array_keys($froms);
|
||||||
$tableName = array_shift($froms);
|
$tableName = array_shift($froms);
|
||||||
if($tableName != 'SiteConfig') return;
|
if($tableName != 'SiteConfig') return;
|
||||||
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
$query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)");
|
||||||
|
@ -28,25 +28,25 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
|
|
||||||
|
|
||||||
public static $has_one=array(
|
public static $has_one=array(
|
||||||
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
'Subsite' => 'Subsite', // The subsite that this page belongs to
|
||||||
'MasterPage' => 'SiteTree',// Optional; the page that is the content master
|
'MasterPage' => 'SiteTree',// Optional; the page that is the content master
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $has_many=array(
|
public static $has_many=array(
|
||||||
'RelatedPages' => 'RelatedPageLink'
|
'RelatedPages' => 'RelatedPageLink'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $many_many=array(
|
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(
|
public static $belongs_many_many=array(
|
||||||
'BackCrossSubsiteLinkTracking' => 'SiteTree'
|
'BackCrossSubsiteLinkTracking' => 'SiteTree'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $many_many_extraFields=array(
|
public static $many_many_extraFields=array(
|
||||||
"CrossSubsiteLinkTracking" => array("FieldName" => "Varchar")
|
"CrossSubsiteLinkTracking" => array("FieldName" => "Varchar")
|
||||||
);
|
);
|
||||||
|
|
||||||
function isMainSite() {
|
function isMainSite() {
|
||||||
if($this->owner->SubsiteID == 0) return true;
|
if($this->owner->SubsiteID == 0) return true;
|
||||||
@ -97,17 +97,17 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
if($subsite && $subsite->ID) {
|
if($subsite && $subsite->ID) {
|
||||||
$baseUrl = 'http://' . $subsite->domain() . '/';
|
$baseUrl = 'http://' . $subsite->domain() . '/';
|
||||||
$fields->removeByName('URLSegment');
|
$fields->removeByName('URLSegment');
|
||||||
|
|
||||||
$baseLink = Controller::join_links (
|
$baseLink = Controller::join_links (
|
||||||
$baseUrl,
|
$baseUrl,
|
||||||
(SiteTree::nested_urls() && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
(SiteTree::nested_urls() && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
||||||
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->owner->fieldLabel('URLSegment'));
|
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->owner->fieldLabel('URLSegment'));
|
||||||
$urlsegment->setURLPrefix($url);
|
$urlsegment->setURLPrefix($url);
|
||||||
$urlsegment->setHelpText(SiteTree::nested_urls() && count($this->owner->Children()) ? $this->owner->fieldLabel('LinkChangeNote'): false);
|
$urlsegment->setHelpText(SiteTree::nested_urls() && count($this->owner->Children()) ? $this->owner->fieldLabel('LinkChangeNote'): false);
|
||||||
$fields->addFieldToTab('Root.Metadata', $urlsegment, 'MetaTitle');
|
$fields->addFieldToTab('Root.Metadata', $urlsegment, 'MetaTitle');
|
||||||
}
|
}
|
||||||
|
|
||||||
$relatedCount = 0;
|
$relatedCount = 0;
|
||||||
@ -124,8 +124,8 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
$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
|
// The 'show' link doesn't provide any useful info
|
||||||
//$related->setPermissions(array('add', 'edit', 'delete'));
|
//$related->setPermissions(array('add', 'edit', 'delete'));
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
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", '')
|
||||||
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
->innerJoin('SiteTree', "\"SiteTree\".\"ID\" = \"RelatedPageLink\".\"MasterPageID\"")
|
||||||
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
->leftJoin('RelatedPageLink', "R2.\"MasterPageID\" = {$this->owner->ID} AND R2.\"RelatedPageID\" = \"RelatedPageLink\".\"MasterPageID\"", 'R2');
|
||||||
}
|
}
|
||||||
|
|
||||||
function NormalRelated() {
|
function NormalRelated() {
|
||||||
|
@ -18,13 +18,13 @@ class GridFieldAddFromTemplateButton implements GridField_HTMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
||||||
public function getURLHandlers($gridField) {
|
public function getURLHandlers($gridField) {
|
||||||
return array(
|
return array(
|
||||||
'newFromTemplate'=>'newFromTemplate',
|
'newFromTemplate'=>'newFromTemplate',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newFromTemplate($gridField, $request) {
|
public function newFromTemplate($gridField, $request) {
|
||||||
$controller = $gridField->getForm()->Controller();
|
$controller = $gridField->getForm()->Controller();
|
||||||
|
|
||||||
if(is_numeric($request->param('ID'))) {
|
if(is_numeric($request->param('ID'))) {
|
||||||
@ -38,15 +38,15 @@ class GridFieldAddFromTemplate extends GridFieldDetailForm {
|
|||||||
$handler->setTemplate($this->template);
|
$handler->setTemplate($this->template);
|
||||||
|
|
||||||
return $handler->handleRequest($request, DataModel::inst());
|
return $handler->handleRequest($request, DataModel::inst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemRequest {
|
class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemRequest {
|
||||||
public function Link($action = null) {
|
public function Link($action = null) {
|
||||||
return $this->gridField->Link('newFromTemplate');
|
return $this->gridField->Link('newFromTemplate');
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit($request) {
|
function edit($request) {
|
||||||
$controller = $this->getToplevelController();
|
$controller = $this->getToplevelController();
|
||||||
$form = $this->NewFromTemplateForm($this->gridField, $request);
|
$form = $this->NewFromTemplateForm($this->gridField, $request);
|
||||||
|
|
||||||
@ -65,34 +65,34 @@ class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemReque
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function NewFromTemplateForm() {
|
public function NewFromTemplateForm() {
|
||||||
$templates=DataObject::get('Subsite_Template');
|
$templates=DataObject::get('Subsite_Template');
|
||||||
|
|
||||||
$fields=new FieldList(
|
$fields=new FieldList(
|
||||||
new DropdownField('TemplateID', _t('GridFieldAddFromTemplate.TEMPLATE', '_Template'), $templates->map('ID', 'Name'))
|
new DropdownField('TemplateID', _t('GridFieldAddFromTemplate.TEMPLATE', '_Template'), $templates->map('ID', 'Name'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$actions=new FieldList(
|
$actions=new FieldList(
|
||||||
FormAction::create('doCreateFromTemplate', _t('GridFieldDetailsForm.Create', 'Create'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add')
|
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.
|
// Add a Cancel link which is a button-like link and link back to one level up.
|
||||||
$curmbs = $this->Breadcrumbs();
|
$curmbs = $this->Breadcrumbs();
|
||||||
if($curmbs && $curmbs->count()>=2){
|
if($curmbs && $curmbs->count()>=2){
|
||||||
$one_level_up = $curmbs->offsetGet($curmbs->count()-2);
|
$one_level_up = $curmbs->offsetGet($curmbs->count()-2);
|
||||||
$text = "
|
$text = "
|
||||||
<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"".$one_level_up->Link."\">
|
<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"".$one_level_up->Link."\">
|
||||||
Cancel
|
Cancel
|
||||||
</a>";
|
</a>";
|
||||||
$actions->push(new LiteralField('cancelbutton', $text));
|
$actions->push(new LiteralField('cancelbutton', $text));
|
||||||
}
|
}
|
||||||
|
|
||||||
$validator=new RequiredFields('TemplateID');
|
$validator=new RequiredFields('TemplateID');
|
||||||
|
|
||||||
$form=new Form($this, 'NewFromTemplateForm', $fields, $actions, $validator);
|
$form=new Form($this, 'NewFromTemplateForm', $fields, $actions, $validator);
|
||||||
|
|
||||||
// TODO Coupling with CMS
|
// TODO Coupling with CMS
|
||||||
$toplevelController = $this->getToplevelController();
|
$toplevelController = $this->getToplevelController();
|
||||||
if($toplevelController && $toplevelController instanceof LeftAndMain) {
|
if($toplevelController && $toplevelController instanceof LeftAndMain) {
|
||||||
// Always show with base template (full width, no other panels),
|
// 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/....
|
// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
|
||||||
$form->Backlink = $toplevelController->Link();
|
$form->Backlink = $toplevelController->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doCreateFromTemplate($data, Form $form) {
|
public function doCreateFromTemplate($data, Form $form) {
|
||||||
$template=DataObject::get_by_id('Subsite_Template', intval($data['TemplateID']));
|
$template=DataObject::get_by_id('Subsite_Template', intval($data['TemplateID']));
|
||||||
|
|
||||||
if($template) {
|
if($template) {
|
||||||
$subsite=$template->createInstance($data['Title']);
|
$subsite=$template->createInstance($data['Title']);
|
||||||
$subsite->write();
|
$subsite->write();
|
||||||
|
|
||||||
$this->record($subsite);
|
$this->record($subsite);
|
||||||
return $this->redirect(parent::Link());
|
return $this->redirect(parent::Link());
|
||||||
}else {
|
}else {
|
||||||
$form->sessionMessage(_t('GridFieldAddFromTemplate.TEMPLATE_NOT_FOUND', '_The selected template could not be found'), 'bad');
|
$form->sessionMessage(_t('GridFieldAddFromTemplate.TEMPLATE_NOT_FOUND', '_The selected template could not be found'), 'bad');
|
||||||
return $this->redirectBack();
|
return $this->redirectBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CMS-specific functionality: Passes through navigation breadcrumbs
|
* CMS-specific functionality: Passes through navigation breadcrumbs
|
||||||
@ -138,10 +138,10 @@ class GridFieldAddFromTemplate_ItemRequest extends GridFieldDetailForm_ItemReque
|
|||||||
if(!$this->popupController->hasMethod('Breadcrumbs')) return;
|
if(!$this->popupController->hasMethod('Breadcrumbs')) return;
|
||||||
|
|
||||||
$items = $this->popupController->Breadcrumbs($unlinked);
|
$items = $this->popupController->Breadcrumbs($unlinked);
|
||||||
$items->push(new ArrayData(array(
|
$items->push(new ArrayData(array(
|
||||||
'Title' => sprintf(_t('GridFieldAddFromTemplate.NewFromTemplate', 'New %s from template'), $this->record->singular_name()),
|
'Title' => sprintf(_t('GridFieldAddFromTemplate.NewFromTemplate', 'New %s from template'), $this->record->singular_name()),
|
||||||
'Link' => false
|
'Link' => false
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ class RelatedPageLink extends DataObject {
|
|||||||
// bind a has_many to.
|
// bind a has_many to.
|
||||||
'MasterPage' => 'SiteTree',
|
'MasterPage' => 'SiteTree',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $summary_fields=array(
|
public static $summary_fields=array(
|
||||||
'RelatedPageAdminLink' => 'Page',
|
'RelatedPageAdminLink' => 'Page',
|
||||||
'AbsoluteLink' => 'URL',
|
'AbsoluteLink' => 'URL',
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
||||||
|
@ -178,11 +178,11 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
* Show the configuration fields for each subsite
|
* Show the configuration fields for each subsite
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
if($this->ID!=0) {
|
if($this->ID!=0) {
|
||||||
$domainTable = new GridField("Domains", "Domains", $this->Domains(), GridFieldConfig_RecordEditor::create(10));
|
$domainTable = new GridField("Domains", "Domains", $this->Domains(), GridFieldConfig_RecordEditor::create(10));
|
||||||
}else {
|
}else {
|
||||||
$domainTable = new LiteralField('Domains', '<p>'._t('Subsite.DOMAINSAVEFIRST', '_You can only add domains after saving for the first time').'</p>');
|
$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());
|
$languageSelector = new DropdownField('Language', 'Language', i18n::get_common_locales());
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class Subsite extends DataObject implements PermissionProvider {
|
|||||||
|
|
||||||
function getCMSActions() {
|
function getCMSActions() {
|
||||||
return new FieldList(
|
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();
|
$id = self::getSubsiteIDForDomain();
|
||||||
Session::set('SubsiteID', $id);
|
Session::set('SubsiteID', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)$id;
|
return (int)$id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,10 +497,10 @@ JS;
|
|||||||
$subsites = DataList::create('Subsite')
|
$subsites = DataList::create('Subsite')
|
||||||
->where("\"Subsite\".\"Title\" != ''")
|
->where("\"Subsite\".\"Title\" != ''")
|
||||||
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")
|
||||||
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
|
->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")
|
||||||
->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = $member->ID")
|
->innerJoin('Group_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('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ($SQL_codes, 'ADMIN')");
|
||||||
|
|
||||||
if(!$subsites) $subsites = new ArrayList();
|
if(!$subsites) $subsites = new ArrayList();
|
||||||
|
|
||||||
$rolesSubsites = DataList::create('Subsite')
|
$rolesSubsites = DataList::create('Subsite')
|
||||||
@ -525,18 +525,18 @@ JS;
|
|||||||
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();
|
$subsites=$subsites->toArray();
|
||||||
|
|
||||||
$mainSite = new Subsite();
|
$mainSite = new Subsite();
|
||||||
$mainSite->Title = $mainSiteTitle;
|
$mainSite->Title = $mainSiteTitle;
|
||||||
array_unshift($subsites, $mainSite);
|
array_unshift($subsites, $mainSite);
|
||||||
$subsites=ArrayList::create($subsites);
|
$subsites=ArrayList::create($subsites);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_cache_accessible_sites[$cacheKey] = $subsites;
|
self::$_cache_accessible_sites[$cacheKey] = $subsites;
|
||||||
|
|
||||||
|
|
||||||
return $subsites;
|
return $subsites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ class SubsiteDomain extends DataObject {
|
|||||||
"Subsite" => "Subsite",
|
"Subsite" => "Subsite",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $summary_fields=array(
|
public static $summary_fields=array(
|
||||||
'Domain'=>'Domain',
|
'Domain'=>'Domain',
|
||||||
'IsPrimary'=>'Is Primary Domain'
|
'IsPrimary'=>'Is Primary Domain'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whenever a Subsite Domain is written, rewrite the hostmap
|
* Whenever a Subsite Domain is written, rewrite the hostmap
|
||||||
*
|
*
|
||||||
@ -22,11 +22,11 @@ class SubsiteDomain extends DataObject {
|
|||||||
public function onAfterWrite() {
|
public function onAfterWrite() {
|
||||||
Subsite::writeHostMap();
|
Subsite::writeHostMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('Domain', _t('SubsiteDomain.DOMAIN', '_Domain'), null, 255),
|
new TextField('Domain', _t('SubsiteDomain.DOMAIN', '_Domain'), null, 255),
|
||||||
new CheckboxField('IsPrimary', _t('SubsiteDomain.IS_PRIMARY', '_Is Primary Domain'))
|
new CheckboxField('IsPrimary', _t('SubsiteDomain.IS_PRIMARY', '_Is Primary Domain'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,53 +1,53 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
$.entwine('ss', function($) {
|
$.entwine('ss', function($) {
|
||||||
$('#SubsitesSelect').live('change', function() {
|
$('#SubsitesSelect').live('change', function() {
|
||||||
window.location.search=$.query.set('SubsiteID', $(this).val());
|
window.location.search=$.query.set('SubsiteID', $(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subsite tab of Group editor
|
// Subsite tab of Group editor
|
||||||
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
||||||
/**
|
/**
|
||||||
* Constructor: onmatch
|
* Constructor: onmatch
|
||||||
*/
|
*/
|
||||||
onmatch: function () {
|
onmatch: function () {
|
||||||
this.showHideSubsiteList();
|
this.showHideSubsiteList();
|
||||||
|
|
||||||
var ref=this;
|
var ref=this;
|
||||||
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
||||||
ref.showHideSubsiteList();
|
ref.showHideSubsiteList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
showHideSubsiteList: function () {
|
showHideSubsiteList: function () {
|
||||||
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.cms-edit-form').entwine({
|
$('.cms-edit-form').entwine({
|
||||||
getChangeTrackerOptions: function() {
|
getChangeTrackerOptions: function() {
|
||||||
this.ChangeTrackerOptions.ignoreFieldSelector+=', input[name=IsSubsite]';
|
this.ChangeTrackerOptions.ignoreFieldSelector+=', input[name=IsSubsite]';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
||||||
* Hidden by default, unless either the toggle checkbox, or any of the
|
* Hidden by default, unless either the toggle checkbox, or any of the
|
||||||
* actual value checkboxes are selected.
|
* actual value checkboxes are selected.
|
||||||
*/
|
*/
|
||||||
$('#PageTypeBlacklist').entwine({
|
$('#PageTypeBlacklist').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
||||||
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
||||||
|
|
||||||
|
|
||||||
//Bind listener
|
//Bind listener
|
||||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||||
jQuery('#PageTypeBlacklist').toggle();
|
jQuery('#PageTypeBlacklist').toggle();
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
@ -1,26 +1,26 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
$.entwine('ss', function($) {
|
$.entwine('ss', function($) {
|
||||||
$('.TreeDropdownField').entwine({
|
$('.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;
|
||||||
},
|
},
|
||||||
|
|
||||||
getRequestParams: function() {
|
getRequestParams: function() {
|
||||||
var name=this.find(':input:hidden').attr('name');
|
var name=this.find(':input:hidden').attr('name');
|
||||||
var obj={};
|
var obj={};
|
||||||
|
|
||||||
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
obj[name+'_SubsiteID']=parseInt(this.subsiteID());
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user