Completed
Push — master ( cd834b...e038e5 )
by Leo
03:10
created
code/ExtendedBlocks/DualColumnBlock.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'LeftColumn'		=>	'HTMLText',
6 6
 		'RightColumn'	=>	'HTMLText'
7 7
 	);
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $singular_name = 'Dual-column Block';
5
-	protected static $db = array (
6
-		'LeftColumn'		=>	'HTMLText',
7
-		'RightColumn'	=>	'HTMLText'
8
-	);
4
+    protected static $singular_name = 'Dual-column Block';
5
+    protected static $db = array (
6
+        'LeftColumn'		=>	'HTMLText',
7
+        'RightColumn'	=>	'HTMLText'
8
+    );
9 9
 }
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
code/ExtendedBlocks/SingleColumnBlock.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class SingleColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'Content'	=>	'HTMLText'
6 6
 	);
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class SingleColumnBlock extends SHBlock {
4
-	protected static $singular_name = 'Single-column Block';
5
-	protected static $db = array (
6
-		'Content'	=>	'HTMLText'
7
-	);
4
+    protected static $singular_name = 'Single-column Block';
5
+    protected static $db = array (
6
+        'Content'	=>	'HTMLText'
7
+    );
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
code/ExtendedBlocks/TriColumnBlock.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'LeftColumn'		=>	'HTMLText',
6 6
 		'RightColumn'	=>	'HTMLText'
7 7
 	);
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class TriColumnBlock extends SHBlock {
4
-	protected static $singular_name = 'Triple-column Block';
5
-	protected static $db = array (
6
-		'LeftColumn'		=>	'HTMLText',
7
-		'MiddleColumn'	=>	'HTMLText',
8
-		'RightColumn'	=>	'HTMLText'
9
-	);
4
+    protected static $singular_name = 'Triple-column Block';
5
+    protected static $db = array (
6
+        'LeftColumn'		=>	'HTMLText',
7
+        'MiddleColumn'	=>	'HTMLText',
8
+        'RightColumn'	=>	'HTMLText'
9
+    );
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
code/Extensions/BlockinPage.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class BlockinPage extends Extension {
3
-	protected static $belongs_many_many = array (
3
+	protected static $belongs_many_many = array(
4 4
 		'Blocks'			=>	'Block'
5 5
 	);
6 6
 	
7
-	public function updateCMSFields( FieldList $fields ) {
7
+	public function updateCMSFields(FieldList $fields) {
8 8
 		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
9 9
 		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10 10
 			$blocks = $this->owner->Blocks();
11
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
11
+			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true, 'GridFieldConfig_RelationEditor');
12 12
 			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
13 13
 			
14 14
 			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		$grid = new GridField($name, $label, $source);
28 28
 		$config = $gridHeaderType::create();
29 29
 		$config->removeComponentsByType('GridFieldAddNewButton');
30
-		if ( $canAdd ) {
30
+		if ($canAdd) {
31 31
 			$config->addComponents(
32 32
 				$multiClass = new GridFieldAddNewMultiClass(),
33 33
 				$sortable = new GridFieldOrderableRows('SortOrder')
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 				$IDs[] = $BlockID;
52 52
 			}
53 53
 		}
54
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
54
+		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder', 'ASC');
55 55
 		return $blocks;
56 56
 	}
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,57 +1,57 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class BlockinPage extends Extension {
4
-	protected static $belongs_many_many = array (
5
-		'Blocks'			=>	'Block'
6
-	);
4
+    protected static $belongs_many_many = array (
5
+        'Blocks'			=>	'Block'
6
+    );
7 7
 	
8
-	public function updateCMSFields( FieldList $fields ) {
9
-		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
10
-		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
11
-			$blocks = $this->owner->Blocks();
12
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
13
-			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
8
+    public function updateCMSFields( FieldList $fields ) {
9
+        $ancestry = ClassInfo::ancestry($this->owner->ClassName);
10
+        if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
11
+            $blocks = $this->owner->Blocks();
12
+            $blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
13
+            $docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
14 14
 			
15
-			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
16
-			$fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
17
-		}
18
-	}
15
+            $fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
16
+            $fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
17
+        }
18
+    }
19 19
 	
20
-	private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
21
-		/*
20
+    private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
21
+        /*
22 22
 		GridFieldConfig_Base
23 23
 		GridFieldConfig_RecordViewer
24 24
 		GridFieldConfig_RecordEditor
25 25
 		GridFieldConfig_RelationEditor
26 26
 		*/
27
-		if ($label == '') { $label = $name; }
28
-		$grid = new GridField($name, $label, $source);
29
-		$config = $gridHeaderType::create();
30
-		$config->removeComponentsByType('GridFieldAddNewButton');
31
-		if ( $canAdd ) {
32
-			$config->addComponents(
33
-				$multiClass = new MultiClassSelector(),
34
-				$sortable = new GridFieldOrderableRows('SortOrder')
35
-			);
36
-			$subBlocks = BlocksAdmin::getAvaiableTypes();
37
-			$multiClass->setClasses($subBlocks);
38
-		}
39
-		$grid->setConfig($config);
40
-		return $grid;
41
-	}
27
+        if ($label == '') { $label = $name; }
28
+        $grid = new GridField($name, $label, $source);
29
+        $config = $gridHeaderType::create();
30
+        $config->removeComponentsByType('GridFieldAddNewButton');
31
+        if ( $canAdd ) {
32
+            $config->addComponents(
33
+                $multiClass = new MultiClassSelector(),
34
+                $sortable = new GridFieldOrderableRows('SortOrder')
35
+            );
36
+            $subBlocks = BlocksAdmin::getAvaiableTypes();
37
+            $multiClass->setClasses($subBlocks);
38
+        }
39
+        $grid->setConfig($config);
40
+        return $grid;
41
+    }
42 42
 		
43
-	private function dockedBlocks() {
44
-		$blocks = Block::get();
45
-		$IDs = array();
46
-		$ClassName = $this->owner->ClassName;
47
-		$Classes = $blocks->map('ID', 'shownInClass');
48
-		foreach ($Classes as $BlockID => $Class) {
49
-			$listedClasses = explode(',', $Class);
50
-			if (in_array($ClassName, $listedClasses)) {
51
-				$IDs[] = $BlockID;
52
-			}
53
-		}
54
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
55
-		return $blocks;
56
-	}
43
+    private function dockedBlocks() {
44
+        $blocks = Block::get();
45
+        $IDs = array();
46
+        $ClassName = $this->owner->ClassName;
47
+        $Classes = $blocks->map('ID', 'shownInClass');
48
+        foreach ($Classes as $BlockID => $Class) {
49
+            $listedClasses = explode(',', $Class);
50
+            if (in_array($ClassName, $listedClasses)) {
51
+                $IDs[] = $BlockID;
52
+            }
53
+        }
54
+        $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
55
+        return $blocks;
56
+    }
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
code/Block.php 3 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public function VisibleTo() {
42 42
 		if (strlen(trim($this->MemberVisibility)) > 0) {
43 43
 			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
44
-		}else{
44
+		} else{
45 45
 			$lists = '<em>&lt;All&gt;</em>';
46 46
 		}
47 47
 		
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		if ($this->showBlockbyClass) {
57 57
 			if (strlen(trim($this->shownInClass)) > 0) {
58 58
 				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
59
-			}else{
59
+			} else{
60 60
 				$lists = '<em>&lt;not assigned&gt;</em>';
61 61
 			}
62
-		}else{
62
+		} else{
63 63
 			if ($this->Pages()->count() > 0) {
64 64
 				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
65
-			}else{
65
+			} else{
66 66
 				$lists = '<em>&lt;not assigned&gt;</em>';
67 67
 			}
68 68
 		}
Please login to merge, or discard this patch.
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,204 +1,204 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class Block extends DataObject {
4
-	protected static $db = array (
5
-		'SortOrder'			=>	'Int',
6
-		'Title'				=>	'Varchar(64)',
7
-		'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
8
-		'hideTitle'			=>	'Boolean',
9
-		'showBlockbyClass'	=>	'Boolean',
10
-		'Description'		=>	'Varchar(128)',
11
-		'MemberVisibility'	=>	'Varchar(255)',
12
-		'shownInClass'		=>	'Text',
13
-		'addMarginTop'		=>	'Boolean',
14
-		'addMarginBottom'	=>	'Boolean'
15
-	);
4
+    protected static $db = array (
5
+        'SortOrder'			=>	'Int',
6
+        'Title'				=>	'Varchar(64)',
7
+        'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
8
+        'hideTitle'			=>	'Boolean',
9
+        'showBlockbyClass'	=>	'Boolean',
10
+        'Description'		=>	'Varchar(128)',
11
+        'MemberVisibility'	=>	'Varchar(255)',
12
+        'shownInClass'		=>	'Text',
13
+        'addMarginTop'		=>	'Boolean',
14
+        'addMarginBottom'	=>	'Boolean'
15
+    );
16 16
 	
17
-	protected static $many_many = array (
18
-		'Pages'				=>	'Page'
19
-	);
17
+    protected static $many_many = array (
18
+        'Pages'				=>	'Page'
19
+    );
20 20
 		
21
-	protected static $create_table_options = array(
22
-		'MySQLDatabase'		=> 'ENGINE=MyISAM'
21
+    protected static $create_table_options = array(
22
+        'MySQLDatabase'		=> 'ENGINE=MyISAM'
23 23
     );
24 24
 	
25
-	protected static $extensions = array (
26
-		'StandardPermissions'
27
-	);
25
+    protected static $extensions = array (
26
+        'StandardPermissions'
27
+    );
28 28
 	
29
-	protected static $summary_fields = array(
30
-		'BlockType',
31
-		'Title', 
32
-		'Description',
33
-		'shownOn',
34
-		'VisibleTo'
35
-	);
29
+    protected static $summary_fields = array(
30
+        'BlockType',
31
+        'Title', 
32
+        'Description',
33
+        'shownOn',
34
+        'VisibleTo'
35
+    );
36 36
 	
37
-	protected static $field_labels = array(
38
-		'BlockType'			=>	'Block type',
39
-		'shownOn'			=>	'is shown on',
40
-		'VisibleTo'			=>	'Visible to'
41
-	);
37
+    protected static $field_labels = array(
38
+        'BlockType'			=>	'Block type',
39
+        'shownOn'			=>	'is shown on',
40
+        'VisibleTo'			=>	'Visible to'
41
+    );
42 42
 	
43
-	public function VisibleTo() {
44
-		if (strlen(trim($this->MemberVisibility)) > 0) {
45
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
46
-		}else{
47
-			$lists = '<em>&lt;All&gt;</em>';
48
-		}
49
-		
50
-		return new LiteralField('VisibleTo',$lists);
51
-	}
43
+    public function VisibleTo() {
44
+        if (strlen(trim($this->MemberVisibility)) > 0) {
45
+            $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
46
+        }else{
47
+            $lists = '<em>&lt;All&gt;</em>';
48
+        }
49
+		
50
+        return new LiteralField('VisibleTo',$lists);
51
+    }
52 52
 	
53
-	public function BlockType() {
54
-		return $this->singular_name();
55
-	}
53
+    public function BlockType() {
54
+        return $this->singular_name();
55
+    }
56 56
 	
57
-	public function shownOn() {
58
-		if ($this->showBlockbyClass) {
59
-			if (strlen(trim($this->shownInClass)) > 0) {
60
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
61
-			}else{
62
-				$lists = '<em>&lt;not assigned&gt;</em>';
63
-			}
64
-		}else{
65
-			if ($this->Pages()->count() > 0) {
66
-				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
67
-			}else{
68
-				$lists = '<em>&lt;not assigned&gt;</em>';
69
-			}
70
-		}
71
-		return new LiteralField('shownOn',$lists);
72
-	}
57
+    public function shownOn() {
58
+        if ($this->showBlockbyClass) {
59
+            if (strlen(trim($this->shownInClass)) > 0) {
60
+                $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
61
+            }else{
62
+                $lists = '<em>&lt;not assigned&gt;</em>';
63
+            }
64
+        }else{
65
+            if ($this->Pages()->count() > 0) {
66
+                $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
67
+            }else{
68
+                $lists = '<em>&lt;not assigned&gt;</em>';
69
+            }
70
+        }
71
+        return new LiteralField('shownOn',$lists);
72
+    }
73 73
 	
74
-	public function getCMSFields() {
75
-		$fields = parent::getCMSFields();
76
-		$fields->removeFieldFromTab('Root', 'Pages');
77
-		$fields->removeFieldsFromTab('Root.Main', array(
78
-			'SortOrder',
79
-			'showBlockbyClass',
80
-			'shownInClass',
81
-			'MemberVisibility'
82
-		));
83
-		
84
-		$memberGroups = Group::get();
85
-		$sourcemap = $memberGroups->map('Code', 'Title');
86
-		$source = array(
87
-			'anonymous'		=>	'Anonymous visitors'
88
-		);
89
-		foreach ($sourcemap as $mapping => $key) {
90
-			$source[$mapping] = $key;
91
-		}
92
-		
93
-		$memberVisibility = new CheckboxSetField(
94
-			$name = "MemberVisibility",
95
-			$title = "Show block for specific groups",
96
-			$source
97
-		);
98
-		
99
-		$memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
100
-		
101
-		$availabelClasses = $this->availableClasses();
102
-		$inClass = new CheckboxSetField(
103
-			$name = "shownInClass",
104
-			$title = "Show block for specific content types",
105
-			$availabelClasses
106
-		);
107
-		
108
-		$filterSelector = OptionsetField::create(
109
-			'showBlockbyClass',
110
-			'Choose filter set',
111
-			array(
112
-				'0'			=>	'by page',
113
-				'1'			=>	'by page/data type'
114
-			)
115
-		)->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
116
-		
117
-		$availablePages = Page::get()->exclude('ClassName', array(
118
-			'ErrorPage',
119
-			'RedirectorPage',
120
-			'VirtualPage'
121
-		));
122
-		$pageSelector = new CheckboxSetField(
123
-			$name = "Pages",
124
-			$title = "Show on Page(s)",
125
-			$availablePages->map('ID','Title')
126
-		);
127
-		
128
-		
129
-		if ($this->canConfigPageAndType(Member::currentUser())) {
130
-			$fields->addFieldsToTab('Root.VisibilitySettings', array(
131
-				$filterSelector,
132
-				$pageSelector,
133
-				$inClass
134
-			));
135
-		}
136
-		
137
-		if ($this->canConfigMemberVisibility(Member::currentUser())) {
138
-			$fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
139
-		}
140
-		
141
-		if (!$fields->fieldByName('Options')) {
142
-			$fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
143
-	    }
74
+    public function getCMSFields() {
75
+        $fields = parent::getCMSFields();
76
+        $fields->removeFieldFromTab('Root', 'Pages');
77
+        $fields->removeFieldsFromTab('Root.Main', array(
78
+            'SortOrder',
79
+            'showBlockbyClass',
80
+            'shownInClass',
81
+            'MemberVisibility'
82
+        ));
83
+		
84
+        $memberGroups = Group::get();
85
+        $sourcemap = $memberGroups->map('Code', 'Title');
86
+        $source = array(
87
+            'anonymous'		=>	'Anonymous visitors'
88
+        );
89
+        foreach ($sourcemap as $mapping => $key) {
90
+            $source[$mapping] = $key;
91
+        }
92
+		
93
+        $memberVisibility = new CheckboxSetField(
94
+            $name = "MemberVisibility",
95
+            $title = "Show block for specific groups",
96
+            $source
97
+        );
98
+		
99
+        $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
100
+		
101
+        $availabelClasses = $this->availableClasses();
102
+        $inClass = new CheckboxSetField(
103
+            $name = "shownInClass",
104
+            $title = "Show block for specific content types",
105
+            $availabelClasses
106
+        );
107
+		
108
+        $filterSelector = OptionsetField::create(
109
+            'showBlockbyClass',
110
+            'Choose filter set',
111
+            array(
112
+                '0'			=>	'by page',
113
+                '1'			=>	'by page/data type'
114
+            )
115
+        )->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
116
+		
117
+        $availablePages = Page::get()->exclude('ClassName', array(
118
+            'ErrorPage',
119
+            'RedirectorPage',
120
+            'VirtualPage'
121
+        ));
122
+        $pageSelector = new CheckboxSetField(
123
+            $name = "Pages",
124
+            $title = "Show on Page(s)",
125
+            $availablePages->map('ID','Title')
126
+        );
127
+		
128
+		
129
+        if ($this->canConfigPageAndType(Member::currentUser())) {
130
+            $fields->addFieldsToTab('Root.VisibilitySettings', array(
131
+                $filterSelector,
132
+                $pageSelector,
133
+                $inClass
134
+            ));
135
+        }
136
+		
137
+        if ($this->canConfigMemberVisibility(Member::currentUser())) {
138
+            $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
139
+        }
140
+		
141
+        if (!$fields->fieldByName('Options')) {
142
+            $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
143
+        }
144 144
 	
145
-	    $fields->addFieldsToTab('Options', array(
146
-			CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'),
147
-			CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')
148
-	    ));
145
+        $fields->addFieldsToTab('Options', array(
146
+            CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'),
147
+            CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')
148
+        ));
149 149
 
150
-		return $fields;
151
-	}
150
+        return $fields;
151
+    }
152 152
 	
153
-	public function availableClasses() {
154
-		$Classes = array_diff(
155
-			ClassInfo::subclassesFor('Page'),
156
-			ClassInfo::subclassesFor('RedirectorPage'),
157
-			ClassInfo::subclassesFor('VirtualPage')
158
-		);
159
-		return $Classes;
160
-	}
153
+    public function availableClasses() {
154
+        $Classes = array_diff(
155
+            ClassInfo::subclassesFor('Page'),
156
+            ClassInfo::subclassesFor('RedirectorPage'),
157
+            ClassInfo::subclassesFor('VirtualPage')
158
+        );
159
+        return $Classes;
160
+    }
161 161
 	
162
-	public function forTemplate() {
163
-		if ($this->canDisplayMemberCheck()) {
164
-			return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
165
-		}
162
+    public function forTemplate() {
163
+        if ($this->canDisplayMemberCheck()) {
164
+            return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
165
+        }
166 166
 		
167
-		return false;
168
-	}
167
+        return false;
168
+    }
169 169
 	
170
-	public function canDisplayMemberCheck() {
171
-		$rawVisibility = $this->MemberVisibility;
172
-		
173
-		if (empty($rawVisibility)) {
174
-			return true;
175
-		}
176
-		
177
-		$visibility = explode(',', $rawVisibility);
178
-		$member = Member::currentUser();
179
-		
180
-		if (!$member && in_array('anonymous', $visibility)) {
181
-			return true;
182
-		}
183
-		
184
-		if ($member) {
185
-			$memberGroups = $member->Groups()->column('Code');
186
-			foreach ($memberGroups as $memberGroup) {
187
-				if (in_array($memberGroup, $visibility)) {
188
-					return true;
189
-				}
190
-			}
191
-		}
192
-		
193
-		return false;
194
-	}
170
+    public function canDisplayMemberCheck() {
171
+        $rawVisibility = $this->MemberVisibility;
172
+		
173
+        if (empty($rawVisibility)) {
174
+            return true;
175
+        }
176
+		
177
+        $visibility = explode(',', $rawVisibility);
178
+        $member = Member::currentUser();
179
+		
180
+        if (!$member && in_array('anonymous', $visibility)) {
181
+            return true;
182
+        }
183
+		
184
+        if ($member) {
185
+            $memberGroups = $member->Groups()->column('Code');
186
+            foreach ($memberGroups as $memberGroup) {
187
+                if (in_array($memberGroup, $visibility)) {
188
+                    return true;
189
+                }
190
+            }
191
+        }
192
+		
193
+        return false;
194
+    }
195 195
 	
196
-	public function frontendEditable() {
197
-		$member = Member::currentUser();		
198
-		return $this->canEdit($member);
199
-	}
196
+    public function frontendEditable() {
197
+        $member = Member::currentUser();		
198
+        return $this->canEdit($member);
199
+    }
200 200
 	
201
-	public function Type2Class() {
202
-		return strtolower(str_replace(' ', '-', $this->singular_name()));
203
-	}
201
+    public function Type2Class() {
202
+        return strtolower(str_replace(' ', '-', $this->singular_name()));
203
+    }
204 204
 }
205 205
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class Block extends DataObject {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'SortOrder'			=>	'Int',
6 6
 		'Title'				=>	'Varchar(64)',
7 7
 		'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		'addMarginBottom'	=>	'Boolean'
15 15
 	);
16 16
 	
17
-	protected static $many_many = array (
17
+	protected static $many_many = array(
18 18
 		'Pages'				=>	'Page'
19 19
 	);
20 20
 		
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		'MySQLDatabase'		=> 'ENGINE=MyISAM'
23 23
     );
24 24
 	
25
-	protected static $extensions = array (
25
+	protected static $extensions = array(
26 26
 		'StandardPermissions'
27 27
 	);
28 28
 	
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	
43 43
 	public function VisibleTo() {
44 44
 		if (strlen(trim($this->MemberVisibility)) > 0) {
45
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
46
-		}else{
45
+			$lists = 'Group: '.str_replace(',', '<br />Group: ', $this->MemberVisibility);
46
+		} else {
47 47
 			$lists = '<em>&lt;All&gt;</em>';
48 48
 		}
49 49
 		
50
-		return new LiteralField('VisibleTo',$lists);
50
+		return new LiteralField('VisibleTo', $lists);
51 51
 	}
52 52
 	
53 53
 	public function BlockType() {
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 	public function shownOn() {
58 58
 		if ($this->showBlockbyClass) {
59 59
 			if (strlen(trim($this->shownInClass)) > 0) {
60
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
61
-			}else{
60
+				$lists = 'Type: '.str_replace(',', '<br />Type: ', $this->shownInClass);
61
+			} else {
62 62
 				$lists = '<em>&lt;not assigned&gt;</em>';
63 63
 			}
64
-		}else{
64
+		} else {
65 65
 			if ($this->Pages()->count() > 0) {
66
-				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
67
-			}else{
66
+				$lists = 'Page: '.implode('<br />Page: ', $this->Pages()->column('Title'));
67
+			} else {
68 68
 				$lists = '<em>&lt;not assigned&gt;</em>';
69 69
 			}
70 70
 		}
71
-		return new LiteralField('shownOn',$lists);
71
+		return new LiteralField('shownOn', $lists);
72 72
 	}
73 73
 	
74 74
 	public function getCMSFields() {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		$pageSelector = new CheckboxSetField(
123 123
 			$name = "Pages",
124 124
 			$title = "Show on Page(s)",
125
-			$availablePages->map('ID','Title')
125
+			$availablePages->map('ID', 'Title')
126 126
 		);
127 127
 		
128 128
 		
Please login to merge, or discard this patch.
code/Extensions/CustomBlockPermissions.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3 3
 class CustomBlockPermission extends DataExtension implements PermissionProvider {
4
-	public function canConfigPageAndType($member = false) {
5
-		return Permission::check(get_class($this->owner) . '_config_page_and_type');
6
-	}
4
+    public function canConfigPageAndType($member = false) {
5
+        return Permission::check(get_class($this->owner) . '_config_page_and_type');
6
+    }
7 7
 	
8
-	public function canConfigMemberVisibility($member = false) {
9
-		return Permission::check(get_class($this->owner) . '_config_member_visibility');
10
-	}
8
+    public function canConfigMemberVisibility($member = false) {
9
+        return Permission::check(get_class($this->owner) . '_config_member_visibility');
10
+    }
11 11
 	
12
-	public function providePermissions() {
13
-		$permissions = array();
14
-		foreach ($this->getClassList() as $class) {
15
-			foreach (array(
16
-				'config_page_and_type',
17
-				'config_member_visibility'
18
-			) as $name) {
19
-				$permissions[$class . '_' . $name] = $class . '_' . $name;
20
-			}
21
-		}
22
-		return $permissions;
23
-	}
12
+    public function providePermissions() {
13
+        $permissions = array();
14
+        foreach ($this->getClassList() as $class) {
15
+            foreach (array(
16
+                'config_page_and_type',
17
+                'config_member_visibility'
18
+            ) as $name) {
19
+                $permissions[$class . '_' . $name] = $class . '_' . $name;
20
+            }
21
+        }
22
+        return $permissions;
23
+    }
24 24
 	
25
-	private function getClassList() {
26
-		$classes = array();
27
-		foreach (ClassInfo::subclassesFor('DataObject') as $class => $file) {
28
-			$extensions = Config::inst()->get($class, 'extensions');
29
-			if (!is_null($extensions)) {
30
-				if (in_array(get_class($this), $extensions)) {
31
-					$classes[] = $class;
32
-				}
33
-			}
34
-		}
35
-		return $classes;
36
-	}
25
+    private function getClassList() {
26
+        $classes = array();
27
+        foreach (ClassInfo::subclassesFor('DataObject') as $class => $file) {
28
+            $extensions = Config::inst()->get($class, 'extensions');
29
+            if (!is_null($extensions)) {
30
+                if (in_array(get_class($this), $extensions)) {
31
+                    $classes[] = $class;
32
+                }
33
+            }
34
+        }
35
+        return $classes;
36
+    }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 class CustomBlockPermission extends DataExtension implements PermissionProvider {
4 4
 	public function canConfigPageAndType($member = false) {
5
-		return Permission::check(get_class($this->owner) . '_config_page_and_type');
5
+		return Permission::check(get_class($this->owner).'_config_page_and_type');
6 6
 	}
7 7
 	
8 8
 	public function canConfigMemberVisibility($member = false) {
9
-		return Permission::check(get_class($this->owner) . '_config_member_visibility');
9
+		return Permission::check(get_class($this->owner).'_config_member_visibility');
10 10
 	}
11 11
 	
12 12
 	public function providePermissions() {
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 				'config_page_and_type',
17 17
 				'config_member_visibility'
18 18
 			) as $name) {
19
-				$permissions[$class . '_' . $name] = $class . '_' . $name;
19
+				$permissions[$class.'_'.$name] = $class.'_'.$name;
20 20
 			}
21 21
 		}
22 22
 		return $permissions;
Please login to merge, or discard this patch.
_config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('BLOCK_DIR',basename(dirname(__FILE__)));
4
-LeftAndMain::require_javascript( BLOCK_DIR. '/js/silverstripe-block.script.js' );
3
+define('BLOCK_DIR', basename(dirname(__FILE__)));
4
+LeftAndMain::require_javascript(BLOCK_DIR.'/js/silverstripe-block.script.js');
5 5
 Requirements::css(BLOCK_DIR.'/css/blocks.css');
6 6
\ No newline at end of file
Please login to merge, or discard this patch.
code/MultiClassSelector.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class MultiClassSelector extends GridFieldAddNewMultiClass {
4
-	private static $allowed_actions = array(
5
-		'handleAdd'
6
-	);
4
+    private static $allowed_actions = array(
5
+        'handleAdd'
6
+    );
7 7
 
8
-	// Should we add an empty string to the add class dropdown?
9
-	private static $showEmptyString = true;
8
+    // Should we add an empty string to the add class dropdown?
9
+    private static $showEmptyString = true;
10 10
 
11
-	private $fragment;
11
+    private $fragment;
12 12
 
13
-	private $title;
13
+    private $title;
14 14
 
15
-	private $classes;
15
+    private $classes;
16 16
 
17
-	private $defaultClass;
17
+    private $defaultClass;
18 18
 
19 19
 
20
-	public function getHTMLFragments($grid) {
21
-		$classes = $this->getClasses($grid);
20
+    public function getHTMLFragments($grid) {
21
+        $classes = $this->getClasses($grid);
22 22
 
23
-		if(!count($classes)) {
24
-			return array();
25
-		}
23
+        if(!count($classes)) {
24
+            return array();
25
+        }
26 26
 
27
-		GridFieldExtensions::include_requirements();
27
+        GridFieldExtensions::include_requirements();
28 28
 
29
-		$field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes, $this->defaultClass);
30
-		$field->setAttribute('id', uniqid());
31
-		if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
32
-			$field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
33
-		}
34
-		$field->addExtraClass('no-change-track');
29
+        $field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes, $this->defaultClass);
30
+        $field->setAttribute('id', uniqid());
31
+        if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
32
+            $field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
33
+        }
34
+        $field->addExtraClass('no-change-track');
35 35
 
36
-		$data = new ArrayData(array(
37
-			'Title'      => $this->getTitle(),
38
-			'Link'       => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'),
39
-			'ClassField' => $field
40
-		));
36
+        $data = new ArrayData(array(
37
+            'Title'      => $this->getTitle(),
38
+            'Link'       => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'),
39
+            'ClassField' => $field
40
+        ));
41 41
 
42
-		return array(
43
-			$this->getFragment() => $data->renderWith('GridFieldAddNewMultiClass')
44
-		);
45
-	}
42
+        return array(
43
+            $this->getFragment() => $data->renderWith('GridFieldAddNewMultiClass')
44
+        );
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	public function getHTMLFragments($grid) {
21 21
 		$classes = $this->getClasses($grid);
22 22
 
23
-		if(!count($classes)) {
23
+		if (!count($classes)) {
24 24
 			return array();
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
code/Extensions/PrintBlocks.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2 2
 class PrintBlocks extends Extension {
3 3
 	
4
-	public function getAllBlocks() {
5
-		$blocks = new ArrayList();
6
-		$blocks->merge($this->getMyBlocks());
7
-		$blocks->merge($this->getDockedBlocks());
8
-		return $blocks;
9
-	}
4
+    public function getAllBlocks() {
5
+        $blocks = new ArrayList();
6
+        $blocks->merge($this->getMyBlocks());
7
+        $blocks->merge($this->getDockedBlocks());
8
+        return $blocks;
9
+    }
10 10
 		
11
-	public function getMyBlocks() {
12
-		return $this->owner->Blocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'ASC'));
13
-	}
11
+    public function getMyBlocks() {
12
+        return $this->owner->Blocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'ASC'));
13
+    }
14 14
 	
15
-	public function getDockedBlocks() {
16
-		$blocks = Block::get()->filter('showBlockbyClass', true);
17
-		$blocks_map = $blocks->map('ID', 'shownInClass');
18
-		foreach ($blocks_map as $blockID => $Classes) {
19
-			$Classes = explode(',', $Classes);
20
-			if (!in_array($this->owner->ClassName, $Classes)) {
21
-				$blocks = $blocks->exclude('ID', $blockID);
22
-			}
23
-		}
15
+    public function getDockedBlocks() {
16
+        $blocks = Block::get()->filter('showBlockbyClass', true);
17
+        $blocks_map = $blocks->map('ID', 'shownInClass');
18
+        foreach ($blocks_map as $blockID => $Classes) {
19
+            $Classes = explode(',', $Classes);
20
+            if (!in_array($this->owner->ClassName, $Classes)) {
21
+                $blocks = $blocks->exclude('ID', $blockID);
22
+            }
23
+        }
24 24
 		
25
-		return $blocks->sort('SortOrder', 'ASC');
26
-	}
25
+        return $blocks->sort('SortOrder', 'ASC');
26
+    }
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.