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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

class ProductPage extends Page {

  public static $db = array(
  "GallerySwitch" => "Boolean",
  "CarouselButtonName" => "Text",
  "CarouselSubTitle01" => "Text",
  "CarouselSubTitle02" => "Text",
  "CarouselSubTitle03" => "Text",
  'CareInfo' => 'HTMLText'
  );

  public static $has_one = array(
    'Photo01' => 'Image',
    'Photo02' => 'Image',
    'Photo03' => 'Image',
    'LargePhoto01' => 'Image',
    'LargePhoto02' => 'Image',
    'LargePhoto03' => 'Image'
  );

  public static $many_many = array(
    'ProductStyles' => 'ProductStyle',
    'NormalColors' => 'NormalColor'
  );

  function getCMSFields() {
    $fields = parent::getCMSFields();

    $stylesTablefield = new ManyManyComplexTableField(
      $this,
      'ProductStyles',
      'ProductStyle',
      array(
        'StyleSeason' => 'Season',
        'StyleGender' => 'Gender',
        'StyleNumber' => 'Style #',
        'StyleName' => 'Name',
        'StyleColor' => 'Color #',
        'StyleCategory' => 'Category',
        'StyleSubCategory' => 'Sub category',
        'StyleSize' => 'Sizes',
        'StyleMaterial' => 'Material',
        'StyleDescription' => 'Description'
      ),
      'getCMSFields_forPopup'
    );
    $stylesTablefield->setParentClass('ProductPage');
    $stylesTablefield->setPageSize(100);
    $stylesTablefield->setAddTitle( 'a Product Style' );

    $normalcolorsTablefield = new ManyManyComplexTableField(
      $this,
      'NormalColors',
      'NormalColor',
      array(
        'ColorName' => 'Color name',
        'ColorCode' => 'Color code',
        'ColorHexValue' => 'HTML color - hex',
        'ColorRemarks' => 'Remarks'
      ),
      'getCMSFields_forPopup'
    );
    $normalcolorsTablefield->setParentClass('ProductPage');
    $normalcolorsTablefield->setPageSize(100);
    $normalcolorsTablefield->setAddTitle( 'a Color' );

    $fields->removeFieldFromTab("Root.Content","Background");

    $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('CareInfo', 'Care information (Materials are prefetched from the products styles list.)'));

    $fields->addFieldToTab( 'Root.Content.Images', new HeaderField("For the product page image gallery, you can set a minimum of 2 and a maximum of 3 images.", "5"));
    $fields->addFieldToTab( 'Root.Content.Images', new CheckboxField("GallerySwitch", "Enable gallery. If disabled, just image 1 will be shown."));
    $fields->addFieldToTab('Root.Content.Images', new TextField('CarouselButtonName', 'Carousel button text'));
    $fields->addFieldToTab('Root.Content.Images', new LiteralField('Divider', '<br/><hr/><br/>'));

    $fields->addFieldToTab('Root.Content.Images', new ImageField('Photo01', 'Image 1. This image should be 348 x 348 px.'));
    $fields->addFieldToTab('Root.Content.Images', new TextField('CarouselSubTitle01', 'Gallery subtitle (Also for carousel.)'));
    $fields->addFieldToTab('Root.Content.Images', new ImageField('LargePhoto01', 'Large image 1. This image should be 696 x 696 px.'));
    $fields->addFieldToTab('Root.Content.Images', new LiteralField('Divider', '<br/><hr/><br/>'));

    $fields->addFieldToTab('Root.Content.Images', new ImageField('Photo02', 'Image 2. This image should be 348 x 348 px.'));
    $fields->addFieldToTab('Root.Content.Images', new TextField('CarouselSubTitle02', 'Gallery subtitle (Also for carousel.)'));
    $fields->addFieldToTab('Root.Content.Images', new ImageField('LargePhoto02', 'Large image 2. This image should be 696 x 696 px.'));
    $fields->addFieldToTab('Root.Content.Images', new LiteralField('Divider', '<br/><hr/><br/>'));

    $fields->addFieldToTab('Root.Content.Images', new ImageField('Photo03', 'Image 3. This image should be 348 x 348 px.'));
    $fields->addFieldToTab('Root.Content.Images', new TextField('CarouselSubTitle03', 'Gallery subtitle (Also for carousel.)'));
    $fields->addFieldToTab('Root.Content.Images', new ImageField('LargePhoto03', 'Large image 3. This image should be 696 x 696 px.'));

    $fields->addFieldToTab( 'Root.Content.ProductStyles', $stylesTablefield );
    $fields->addFieldToTab( 'Root.Content.NormalColors', $normalcolorsTablefield );

    return $fields;
  }

}

class ProductPage_Controller extends Page_Controller {

}

?>