Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


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
105
106
107
108
109
110
111
112
113
<?php
class GalleryImage extends DataObject
{
	static $db = array (
		'ResourceLink' => 'Text',		
		'TypeOfResource' => "Enum('None, Image, FlashVideo, Embed','None')", // this is for the radios
	);	
	static $has_one = array (
		'Resource' => 'File',
		'Image' => 'Image',
		'GalleryPage' => 'GalleryPage'
	);	
	
	
	public function getCMSFields_forPopup()
	{
// The three radiobuttons
		$RadioArray = array(
				"Image//Obrázok" => new ImageField('Image', 'Obrazok (jpg, jpeg, png, flv)'),
				"FlashVideo//FLV video - Flash" => new FileIFrameField('Resource','FLV video - Flash'),
				"Embed//Youtube alebo SlideShare" => new TextField('ResourceLink', 'Link na Youtube / SlideShare'),
		);
		
		return new FieldSet(
			new TextField('Title', 'Názov' ),			
			new MyFunc('TypeOfResource', $RadioArray),
// .. rest of the code wasnt relevant .. 

// .. MyFunc.php
<?php

class MyFunc extends SelectionGroup {

	function __construct($name, $items) {
		parent::__construct($name, $items);
	
		$count = 1;
		foreach ($items as $key => $item) {
			$item->addExtraClass('RadioItem'.$count);
			$count++;
		}
	}
// if I add function FieldSet() it wont work properly. 
	function FieldHolder() {
		
			Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
			Requirements::javascript('mysite/javascript/SelectionGroup.js');
			Requirements::css(THEMES_DIR . '/wod/css/SelectionGroup.css');
			
		return $this->renderWith($this->class);		
	}
	
}

// SelectionGroup.php for reference __constructor, FieldSet() and FieldHolde() 
<?php
/**
 * SelectionGroup represents a number of fields that are selectable by a radio button that appears at
 * the beginning of each item.  Using CSS, you can configure the field to only display its contents if
 * the corresponding radio button is selected.
 * @package forms
 * @subpackage fields-structural
 */
class SelectionGroup extends CompositeField {

	function __construct($name, $items) {
		$this->name = $name;
		
		parent::__construct($items);
		
		Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
	}
	

	function FieldSet() {
		$items = parent::FieldSet()->toArray();

		$count = 0;
		$firstSelected = $checked ="";
		foreach($items as $key => $item) {
			if(strpos($key,'//') !== false) {
				list($key,$title) = explode('//', $key,2);
			} else {
				$title = $key;
			}
			if($this->value == $key) {
				$firstSelected = " class=\"selected\"";
				$checked = " checked=\"checked\"";
				//$item->addExtraClass('selected'); // I want to add this, without hacking core file.
			}
			
			$itemID = $this->ID() . '_' . (++$count);
			$extra = array(
				"RadioButton" => "<input class=\"selector\" type=\"radio\" id=\"$itemID\" name=\"$this->name\" value=\"$key\"$checked />",
				"RadioLabel" => "<label for=\"$itemID\">$title</label>",
				"Selected" => $firstSelected,
			);
			if(is_object($item)) $newItems[] = $item->customise($extra);
			else $newItems[] = new ArrayData($extra);

			$firstSelected = $checked ="";			
		}
		return new DataObjectSet($newItems);
	}
	
	function FieldHolder() {
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
		Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
		
		return $this->renderWith("SelectionGroup");
	}
}