diff --git a/code/tagfield/TestTag.php b/code/tagfield/TestTag.php index 0572476..0d3ae2c 100644 --- a/code/tagfield/TestTag.php +++ b/code/tagfield/TestTag.php @@ -1,23 +1,25 @@ 'Text' - ); - - private static $belongs_many_many = array( - 'Pages' => 'TestTagFieldPage' - ); - - function requireDefaultRecords(){ - $class = $this->class; - if(!DataObject::get_one($class)) { - foreach(array('one', 'two', 'three', 'four') as $title) { - $tag = new $class(); - $tag->Title = $title; - $tag->write(); +if(class_exists('TagField')) { + class TestTag extends DataObject { + + private static $db = array( + 'Title' => 'Text' + ); + + private static $belongs_many_many = array( + 'Pages' => 'TestTagFieldPage' + ); + + function requireDefaultRecords(){ + $class = $this->class; + if(!DataObject::get_one($class)) { + foreach(array('one', 'two', 'three', 'four') as $title) { + $tag = new $class(); + $tag->Title = $title; + $tag->write(); + } + } - } } } \ No newline at end of file diff --git a/code/tagfield/TestTagFieldPage.php b/code/tagfield/TestTagFieldPage.php index 54f0159..83abdc6 100644 --- a/code/tagfield/TestTagFieldPage.php +++ b/code/tagfield/TestTagFieldPage.php @@ -1,38 +1,40 @@ 'Text', - 'FixedTags' => 'Text' - ); - - private static $many_many = array( - 'TestTags' => 'TestTag', - ); - - function getCMSFields() { - $fields = parent::getCMSFields(); +if(class_exists('TagField')) { + class TestTagFieldPage extends Page { - $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", 'TestTag'); - $fields->addFieldToTab('Root.Content.Main', $tf1); + private static $db = array( + 'TestTagString' => 'Text', + 'FixedTags' => 'Text' + ); - $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')", null, 'TestTag'); - $fields->addFieldToTab('Root.Content.Main', $tf2); + private static $many_many = array( + 'TestTags' => 'TestTag', + ); - $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); - $tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); - $fields->addFieldToTab('Root.Content.Main', $tf3); - - return $fields; - } - - function requireDefaultRecords(){ - $class = $this->class; - if(!DataObject::get_one($class)) { - $page = new $class(); - $page->Title = "Test TagField"; - $page->write(); + function getCMSFields() { + $fields = parent::getCMSFields(); + + $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", 'TestTag'); + $fields->addFieldToTab('Root.Content.Main', $tf1); + + $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')", null, 'TestTag'); + $fields->addFieldToTab('Root.Content.Main', $tf2); + + $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); + $tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); + $fields->addFieldToTab('Root.Content.Main', $tf3); + + return $fields; } + + function requireDefaultRecords(){ + $class = $this->class; + if(!DataObject::get_one($class)) { + $page = new $class(); + $page->Title = "Test TagField"; + $page->write(); + } + } + } - } \ No newline at end of file diff --git a/code/tagfield/_manifest_exclude b/code/tagfield/_manifest_exclude deleted file mode 100644 index e69de29..0000000