1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
class GlossaryTerm extends DataObject 
{ 
   static $db = array( 
      'Term' => 'Text', 
      'Definition' => 'Text' 
   );

   static $has_one = array( 
      'GlossaryPage' => 'GlossaryPage'    
   ); 

   static $default_sort = "Term ASC"; 

   static $searchable_fields = array( 
      'Term', 
      'Definition' 
   ); 

   static $search_heading = "Term"; 
   static $search_content = "Definition"; 

   static $indexes = array( 
      "SearchFields" => "fulltext (Term, Definition)", 
      "TitleSearchFields" => "fulltext (Term)" 
   ); 

   public function Title()    
   { 
      return DBField::create('Text',$this->record['Title']); 
   } 
   public function Content() 
   { 
      return DBField::create('Text',$this->record['Content']); 
   }

   public function canView() {return true;} 

   public function Link() 
   { 
      return DataObject::get_one("GlossaryPage")->Link() ."ShowTerm/".$this->ID; 
   } 

  	static $summary_fields = array(
		'Term' => 'Title'
	);

	public function getCMSFields()
	{
		$fields = new FieldSet();
		
		$fields->push(new TextField('Term'));
		$fields->push(new SimpleTinyMCEField('Definition'));

		return $fields;
	}
	
}