diff --git a/code/extensions/SiteTreeSubsites.php b/code/extensions/SiteTreeSubsites.php
index 5db49e8..43efcd2 100644
--- a/code/extensions/SiteTreeSubsites.php
+++ b/code/extensions/SiteTreeSubsites.php
@@ -6,22 +6,13 @@
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
- );
-
- public static $has_many=array(
- 'RelatedPages' => 'RelatedPageLink'
+ 'Subsite' => 'Subsite', // The subsite that this page belongs to
);
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")
);
@@ -75,27 +66,6 @@ class SiteTreeSubsites extends DataExtension {
unset($subsitesMap[$this->owner->SubsiteID]);
}
- // Master page notice
- if($this->owner->MasterPageID) {
- $masterPage = $this->owner->MasterPage();
- $masterNoteField = new LiteralField(
- 'MasterLink',
- sprintf(
- _t(
- 'SiteTreeSubsites.MasterLinkNote',
- '
This page\'s content is copied from the %s master page (edit)
'
- ),
- $masterPage->AbsoluteLink(),
- $masterPage->Title,
- Controller::join_links(
- singleton('CMSMain')->Link('show'),
- $masterPage->ID
- )
- )
- );
- $fields->addFieldToTab('Root.Main',$masterNoteField);
- }
-
// Master page edit field (only allowed from default subsite to avoid inconsistent relationships)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;
if($isDefaultSubsite && $subsitesMap) {
@@ -116,22 +86,8 @@ class SiteTreeSubsites extends DataExtension {
)
);
$copyAction->includeDefaultJS(false);
- } else {
- $defaultSubsite = DataObject::get_one('Subsite', '"DefaultSite" = 1');
- if($defaultSubsite) {
- $fields->addFieldToTab('Root.Main',
- $masterPageField = new SubsitesTreeDropdownField(
- "MasterPageID",
- _t('VirtualPage.MasterPage', "Master page"),
- "SiteTree",
- "ID",
- "MenuTitle"
- )
- );
- $masterPageField->setSubsiteID($defaultSubsite->ID);
- }
}
-
+
// replace readonly link prefix
$subsite = $this->owner->Subsite();
if($subsite && $subsite->ID) {
@@ -146,59 +102,6 @@ class SiteTreeSubsites extends DataExtension {
$urlsegment = $fields->dataFieldByName('URLSegment');
$urlsegment->setURLPrefix($url);
}
-
- $relatedCount = 0;
- $reverse = $this->ReverseRelated();
- if($reverse) $relatedCount += $reverse->Count();
- $normalRelated = $this->NormalRelated();
- if($normalRelated) $relatedCount += $normalRelated->Count();
-
- $tabName = $relatedCount ? 'Related (' . $relatedCount . ')' : 'Related';
- $tab = $fields->findOrMakeTab('Root.Related', $tabName);
- // Related pages
- $tab->push(new LiteralField('RelatedNote',
- 'You can list pages here that are related to this page.
When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.
'));
- $tab->push(
- $related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
- );
-
- $related->setModelClass('RelatedPageLink');
-
- // The 'show' link doesn't provide any useful info
- //$related->setPermissions(array('add', 'edit', 'delete'));
-
- if($reverse) {
- $text = 'In addition, this page is marked as related by the following pages:
';
- foreach($reverse as $rpage) {
- $text .= $rpage->RelatedPageAdminLink(true) . " - " . $rpage->AbsoluteLink(true) . "
\n";
- }
- $text .= '
';
-
- $tab->push(new LiteralField('ReverseRelated', $text));
- }
-
- }
-
- /**
- * Returns the RelatedPageLink objects that are reverse-associated with this page.
- */
- 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');
- }
-
- function NormalRelated() {
- $return = new ArrayList();
- $links = DataObject::get('RelatedPageLink', '"MasterPageID" = ' . $this->owner->ID);
- if($links) foreach($links as $link) {
- if($link->RelatedPage()->exists()) {
- $return->push($link->RelatedPage());
- }
- }
-
- return $return->Count() > 0 ? $return : false;
}
function alternateSiteConfig() {
@@ -280,6 +183,8 @@ class SiteTreeSubsites extends DataExtension {
$page->CheckedPublicationDifferences = $page->AddedToStage = true;
$subsiteID = ($subsiteID ? $subsiteID : $oldSubsite);
$page->SubsiteID = $subsiteID;
+
+ // MasterPageID is here for legacy purposes, to satisfy the subsites_relatedpages module
$page->MasterPageID = $this->owner->ID;
$page->write();
@@ -368,4 +273,4 @@ class SiteTreeSubsites extends DataExtension {
if(in_array($this->owner->class, $blacklisted)) return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/code/model/RelatedPageLink.php b/code/model/RelatedPageLink.php
deleted file mode 100644
index 46c60d3..0000000
--- a/code/model/RelatedPageLink.php
+++ /dev/null
@@ -1,89 +0,0 @@
- 'SiteTree',
- // Note: The *last* matching has_one relation to SiteTree is used as the link field for the
- // has_many (RelatedPages) on SiteTree. This isn't obvious and the framework could be
- // extended in a future version to allow for explicit selection of a has_one relation to
- // bind a has_many to.
- 'MasterPage' => 'SiteTree',
- );
-
- public static $summary_fields=array(
- 'RelatedPageAdminLink' => 'Page',
- 'AbsoluteLink' => 'URL',
- );
-
- function getCMSFields() {
- $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
- if(!$subsites) $subsites = new ArrayList();
-
- if(Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
- $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", true);
- }
-
- if($subsites->Count()) {
- $subsiteSelectionField = new DropdownField(
- "CopyContentFromID_SubsiteID",
- "Subsite",
- $subsites->map('ID', 'Title'),
- ($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
- );
- }
-
- // Setup the linking to the original page.
- $pageSelectionField = new SubsitesTreeDropdownField(
- "RelatedPageID",
- _t('VirtualPage.CHOOSE', "Choose a page to link to"),
- "SiteTree",
- "ID",
- "MenuTitle"
- );
-
- if (isset($_GET['RelatedPageID_SubsiteID'])) $pageSelectionField->setSubsiteID($_GET['RelatedPageID_SubsiteID']);
-
- $pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
-
- if($subsites->Count()) $fields = new FieldList($subsiteSelectionField, $pageSelectionField);
- else $fields = new FieldList($pageSelectionField);
-
- return $fields;
- }
-
- function RelatedPageAdminLink($master = false) {
- $page = $master ? Dataobject::get_by_id("SiteTree", $this->MasterPageID) : Dataobject::get_by_id("SiteTree", $this->RelatedPageID);
- $otherPage = $master ? Dataobject::get_by_id("SiteTree", $this->RelatedPageID) : Dataobject::get_by_id("SiteTree", $this->MasterPageID);
- if(!$page || !$otherPage) return;
-
- // Use cmsEditlink only when moving between different pages in the same subsite.
- $classClause = ($page->SubsiteID == $otherPage->SubsiteID) ? ' class="cmsEditlink"' : '';
- return '" . Convert::raw2xml($page->Title) . '';
- }
-
- function AbsoluteLink($master = false) {
- $page = $master ? Dataobject::get_by_id("SiteTree", $this->MasterPageID) : Dataobject::get_by_id("SiteTree", $this->RelatedPageID);
- if(!$page) return;
-
-
- $url = $page->AbsoluteLink();
- }
-
- function canView($member = null) {
- return $this->MasterPage()->canView($member);
- }
- function canEdit($member = null) {
- return $this->MasterPage()->canView($member);
- }
- function canDelete($member = null) {
- return $this->MasterPage()->canDelete($member);
- }
-}
-
diff --git a/tests/SiteTreeSubsitesTest.php b/tests/SiteTreeSubsitesTest.php
index 66b3283..e8fa7d5 100644
--- a/tests/SiteTreeSubsitesTest.php
+++ b/tests/SiteTreeSubsitesTest.php
@@ -57,32 +57,6 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
$this->assertEquals($expected_path, $path);
}
- function testRelatedPages() {
- $this->assertTrue(singleton('RelatedPageLink')->getCMSFields() instanceof FieldList);
-
- $importantpage = $this->objFromFixture('Page', 'importantpage');
- $contact = $this->objFromFixture('Page', 'contact');
-
- $link = new RelatedPageLink();
- $link->MasterPageID = $importantpage->ID;
- $link->RelatedPageID = $contact->ID;
- $link->write();
- $importantpage->RelatedPages()->add($link);
- $this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldList);
-
- $this->assertEquals($importantpage->NormalRelated()->Count(), 1);
- $this->assertEquals($contact->ReverseRelated()->Count(), 1);
-
- $this->assertTrue($importantpage->getCMSFields() instanceof FieldList);
- $this->assertTrue($contact->getCMSFields() instanceof FieldList);
-
- $this->assertEquals($importantpage->canView(), $link->canView());
- $this->assertEquals($importantpage->canEdit(), $link->canEdit());
- $this->assertEquals($importantpage->canDelete(), $link->canDelete());
- $link->AbsoluteLink(true);
- $this->assertEquals($link->RelatedPageAdminLink(), 'Contact Us');
- }
-
function testCanEditSiteTree() {
$admin = $this->objFromFixture('Member', 'admin');
$subsite1member = $this->objFromFixture('Member', 'subsite1member');