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
<?php
class ReferencePage extends Page {
    
  static $allowed_children = 'none';
  static $default_parrent = 'referenzen';
  static $can_be_root = false;

  public static $db = array(
    'Date' => 'Date',
    'Category' => 'Text',
    'Site' => 'Text'
  );

  public static $has_one = array(
    'Client' => 'ClientObject',
    'Preview' => 'Image'
  );
  
  public static $has_many = array(
    'Screens' => 'ScreenObject'
  );

  function getCMSFields() {
    
    $fields = parent::getCMSFields();
    
    $fields->addFieldToTab('Root.Content.Main', $date = new DateField('Date', 'Release Date'), 'Content');
    $date->setConfig('showcalendar', true);
    
    $fields->addFieldToTab('Root.Content.Main', new TextField('Category','Web/Print/Hosting etc.'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new TextField('Site','Link zur Online Referenz (Website wenn online)'), 'Content');
    
    $clients = DataObject::get('ClientObject')->toDropDownMap('ID', 'Name');
    $fields->addFieldToTab('Root.Content.Main', new DropdownField('ClientID', 'Client', $clients, $this), 'Content');
    
    $fields->addFieldToTab('Root.Content.Screens', new ImageDataObjectManager($this, 'Screens', 'ScreenObject', 'Screen', array('Description' => 'Beschreibung'), 'getCMSFields_forPopup'));
    
    $fields->addFieldToTab("Root.Content.Preview", new ImageField('Preview', 'Preview Image 286px x 140px'));
    
    return $fields;
    
  }
  
  function NewPage(){
      $date = substr($this->Date, 0, 4);
      if ($date > 2009){
         return true;
      } else {
         return false;
      }
   }

}
class ReferencePage_Controller extends Page_Controller {

}
?>