Disabled TestTagFieldPage and TestTag classes

Due to changed class parsing in 3.1, the class_exists() checks
are no longer recognized, leading to errors when the class
is only condtionally autoloaded (or the tagfield isn't present)
This commit is contained in:
Ingo Schommer 2013-04-30 00:53:22 +02:00
parent 752d38490b
commit 2ddb78e6f4
2 changed files with 56 additions and 60 deletions

View File

@ -1,25 +1,23 @@
<?php <?php
if(class_exists('TagField')) { // class TestTag extends DataObject {
class TestTag extends DataObject {
private static $db = array( // private static $db = array(
'Title' => 'Text' // 'Title' => 'Text'
); // );
private static $belongs_many_many = array( // private static $belongs_many_many = array(
'Pages' => 'TestTagFieldPage' // 'Pages' => 'TestTagFieldPage'
); // );
function requireDefaultRecords(){ // function requireDefaultRecords(){
$class = $this->class; // $class = $this->class;
if(!DataObject::get_one($class)) { // if(!DataObject::get_one($class)) {
foreach(array('one', 'two', 'three', 'four') as $title) { // foreach(array('one', 'two', 'three', 'four') as $title) {
$tag = new $class(); // $tag = new $class();
$tag->Title = $title; // $tag->Title = $title;
$tag->write(); // $tag->write();
} // }
} // }
} // }
} // }
}

View File

@ -1,42 +1,40 @@
<?php <?php
if(class_exists('TagField')) { // class TestTagFieldPage extends Page {
class TestTagFieldPage extends Page {
private static $db = array( // private static $db = array(
'TestTagString' => 'Text', // 'TestTagString' => 'Text',
'FixedTags' => 'Text' // 'FixedTags' => 'Text'
); // );
private static $many_many = array( // private static $many_many = array(
'TestTags' => 'TestTag', // 'TestTags' => 'TestTag',
); // );
function getCMSFields() { // function getCMSFields() {
$fields = parent::getCMSFields(); // $fields = parent::getCMSFields();
$tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", null, 'TestTagFieldPage'); // $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", null, 'TestTagFieldPage');
$fields->addFieldToTab('Root.Main', $tf1); // $fields->addFieldToTab('Root.Main', $tf1);
$tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')"); // $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')");
$fields->addFieldToTab('Root.Main', $tf2); // $fields->addFieldToTab('Root.Main', $tf2);
$tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); // $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag');
$tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); // $tf3->setCustomTags(array('PHP', 'Ruby', 'Python'));
$fields->addFieldToTab('Root.Main', $tf3); // $fields->addFieldToTab('Root.Main', $tf3);
return $fields; // return $fields;
} // }
function requireDefaultRecords(){ // function requireDefaultRecords(){
$class = $this->class; // $class = $this->class;
if(!DataObject::get_one($class)) { // if(!DataObject::get_one($class)) {
$page = new $class(); // $page = new $class();
$page->Title = "Test TagField"; // $page->Title = "Test TagField";
$page->write(); // $page->write();
} // }
} // }
} // }
class TestTagFieldPage_Controller extends Page_Controller {} // class TestTagFieldPage_Controller extends Page_Controller {}
}