2008-10-03 00:05:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
|
|
|
|
*/
|
|
|
|
class TestCategory extends DataObject {
|
|
|
|
static $db = array(
|
|
|
|
"Title" => "Varchar",
|
|
|
|
);
|
|
|
|
static $belongs_many_many = array(
|
|
|
|
"RelationPages" => "RelationFieldsTestPage",
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a dropdown map of all objects of this class
|
|
|
|
*/
|
|
|
|
static function map() {
|
2008-10-08 06:00:59 +02:00
|
|
|
$categories = DataObject::get('TestCategory');
|
2012-02-29 14:27:36 +01:00
|
|
|
if($categories) return $categories->map('ID', 'Title')->toArray();
|
2008-10-08 06:00:59 +02:00
|
|
|
else return array();
|
2008-10-03 00:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function requireDefaultRecords(){
|
|
|
|
$class = $this->class;
|
|
|
|
if(!DataObject::get_one($class)) {
|
|
|
|
foreach(array("A","B","C","D") as $item) {
|
|
|
|
$page = new $class();
|
|
|
|
$page->Title = "Test Category $item";
|
|
|
|
$page->write();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|