ENHANCEMENT Using more complete domain model from old GridfieldTest module in sample ModelAdmin, removing old model files.

This commit is contained in:
Ingo Schommer 2012-02-29 15:26:00 +01:00
parent a673bdaa90
commit a1bc8bfc13
9 changed files with 7 additions and 118 deletions

View File

@ -1,33 +0,0 @@
<?php
/**
* Test a subtree-admin that only shows the children of a FTPageHolder
*/
class CMSSubTreeAdmin extends CMSPagesController {
// These variables are 2.3-specific; in 2.2.x you will need to edit _config.php
static $url_segment = 'subtree';
static $menu_title = 'FT Pages';
function SiteTreeAsUL() {
// This piece of code just gets us a root ID to use
$ftRoot = DataObject::get_one("FTPageHolder");
if(!$ftRoot) {
$ftRoot = new FTPageHolder();
$ftRoot->write();
}
// ftRoot->ID is your root node
$siteTree = $this->getSiteTreeFor("SiteTree", $ftRoot->ID);
// This code is copied from getSiteTreeFor(), because getSiteTreeFor has it hard-coded to only generate if rootID = 0
$rootLink = $this->Link() . '0';
if($this->hasMethod('getCMSTreeTitle')) $treeTitle = $this->getCMSTreeTitle();
else $treeTitle = _t('LeftAndMain.SITECONTENTLEFT',"Site Content",PR_HIGH,'Root node on left');
$siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\"><li id=\"record-0\" class=\"Root nodelete\"><a href=\"$rootLink\"><strong>$treeTitle</strong></a>"
. $siteTree . "</li></ul>";
return $siteTree;
}
}
?>

View File

@ -1,16 +0,0 @@
<?php
class Client extends DataObject {
static $db = array(
"Name" => "Varchar",
"Notes" => "HTMLText",
);
static $many_many = array(
"Contacts" => "Contact",
);
static $belongs_many_many = array(
"Projects" => "Project",
);
}
?>

View File

@ -1,14 +0,0 @@
<?php
class Contact extends DataObject {
static $db = array(
"FirstName" => "Varchar",
"Surname" => "Varchar",
"Email" => "Varchar",
);
static $belongs_many_many = array(
"Clients" => "Client",
);
}
?>

View File

@ -1,15 +0,0 @@
<?php
class Developer extends DataObject {
static $db = array(
"FirstName" => "Varchar",
"Surname" => "Varchar",
"Email" => "Varchar",
"Username" => "Varchar",
);
static $belongs_many_many = array(
"Projects" => "Project",
);
}
?>

View File

@ -1,5 +0,0 @@
<?php
class FTPage extends Page {
}

View File

@ -1,6 +0,0 @@
<?php
class FTPageHolder extends Page {
static $default_child = 'FTPage';
static $allowed_children = array('FTPage');
}

View File

@ -1,13 +0,0 @@
<?php
class Project extends DataObject {
static $db = array(
"Name" => "Varchar",
);
static $many_many = array(
"Clients" => "Client",
"Developers" => "Developer",
);
}
?>

View File

@ -25,18 +25,13 @@ class RelationFieldsTestPage extends TestPage {
// TODO Fix legacy relation CTFs in 3.0
// $fields->addFieldToTab("Root.HasOneCTF",
// new HasOneComplexTableField($this, "FavouriteItem", "TestCTFItem", array(
// "Title" => "Item Title",
// "Author" => "Item Author")));
// new HasOneComplexTableField($this, "HasOneCompany");
// $fields->addFieldToTab("Root.HasManyCTF",
// new HasManyComplexTableField($this, "Items", "TestCTFItem", array(
// "Title" => "Item Title",
// "Author" => "Item Author")));
// new HasManyComplexTableField($this, "HasManyCompanies");
// $fields->addFieldToTab("Root.ManyManyCTF",
// new ManyManyComplexTableField($this, "CheckboxSet", "TestCategory", array(
// "Title" => "Item Title")));
// new ManyManyComplexTableField($this, "ManyManyCompanies");
// $fields->addFieldToTab("Root.Tests.ComplexTableField",
@ -49,6 +44,4 @@ class RelationFieldsTestPage extends TestPage {
class RelationFieldsTestPage_Controller extends TestPage_Controller {
}
?>
}

View File

@ -2,13 +2,11 @@
class TestModelAdmin extends ModelAdmin {
static $url_segment = 'test';
static $menu_title = 'Test MdAdm';
static $menu_title = 'Test ModelAdmin';
public static $managed_models = array(
"Client",
"Contact",
"Project",
"Developer",
"Company",
"Employee",
);
}