Completed
Push — master ( e158ae...702428 )
by Leo
03:11
created
code/ExtendedBlocks/TriColumnBlock.php 2 patches
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 TriColumnBlock extends Block {
4
-	protected static $db = array (
5
-		'LeftColumn'		=>	'HTMLText',
6
-		'MiddleColumn'	=>	'HTMLText',
7
-		'RightColumn'	=>	'HTMLText'
8
-	);
4
+    protected static $db = array (
5
+        'LeftColumn'		=>	'HTMLText',
6
+        'MiddleColumn'	=>	'HTMLText',
7
+        'RightColumn'	=>	'HTMLText'
8
+    );
9 9
 }
10 10
\ 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
@@ -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.
code/ExtendedBlocks/DualColumnBlock.php 2 patches
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 DualColumnBlock extends Block {
4
-	protected static $db = array (
5
-		'LeftColumn'		=>	'HTMLText',
6
-		'RightColumn'	=>	'HTMLText'
7
-	);
4
+    protected static $db = array (
5
+        'LeftColumn'		=>	'HTMLText',
6
+        'RightColumn'	=>	'HTMLText'
7
+    );
8 8
 }
9 9
\ 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
@@ -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.
code/ExtendedBlocks/SingleColumnBlock.php 2 patches
Indentation   +3 added lines, -3 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 (
5
-		'Content'	=>	'HTMLText'
6
-	);
4
+    protected static $db = array (
5
+        'Content'	=>	'HTMLText'
6
+    );
7 7
 }
8 8
\ 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
@@ -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.
code/BlocksAdmin.php 3 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @file BlocksAdmin.php
4
- *
5
- * Left-hand-side tab : Admin Blocks
6
- * */
7
-	class BlocksAdmin extends ModelAdmin {
8
-		private static $managed_models = array('Block');
9
-		private static $url_segment = 'blocks';
10
-		private static $menu_title = 'Blocks';
11
-		private static $menu_priority = 10;
12
-		private static $menu_icon = 'silverstripe-block/images/icon-block.png';
3
+     * @file BlocksAdmin.php
4
+     *
5
+     * Left-hand-side tab : Admin Blocks
6
+     * */
7
+    class BlocksAdmin extends ModelAdmin {
8
+        private static $managed_models = array('Block');
9
+        private static $url_segment = 'blocks';
10
+        private static $menu_title = 'Blocks';
11
+        private static $menu_priority = 10;
12
+        private static $menu_icon = 'silverstripe-block/images/icon-block.png';
13 13
 			
14
-		public function getEditForm($id = null, $fields = null) {
15
-			$form = parent::getEditForm($id, $fields);
14
+        public function getEditForm($id = null, $fields = null) {
15
+            $form = parent::getEditForm($id, $fields);
16 16
 			
17
-			$grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
17
+            $grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
18 18
 			
19
-			$grid->getConfig()
20
-				->removeComponentsByType('GridFieldPaginator')
21
-				->removeComponentsByType('GridFieldAddNewButton')
22
-				->removeComponentsByType('GridFieldPrintButton')
23
-				->removeComponentsByType('GridFieldExportButton')
24
-				->addComponents(
25
-					new GridFieldPaginatorWithShowAll(30),
26
-					$multiClass = new GridFieldAddNewMultiClass(),
27
-					$sortable = new GridFieldOrderableRows('SortOrder')
28
-				);
19
+            $grid->getConfig()
20
+                ->removeComponentsByType('GridFieldPaginator')
21
+                ->removeComponentsByType('GridFieldAddNewButton')
22
+                ->removeComponentsByType('GridFieldPrintButton')
23
+                ->removeComponentsByType('GridFieldExportButton')
24
+                ->addComponents(
25
+                    new GridFieldPaginatorWithShowAll(30),
26
+                    $multiClass = new GridFieldAddNewMultiClass(),
27
+                    $sortable = new GridFieldOrderableRows('SortOrder')
28
+                );
29 29
 			
30
-			$subBlocks = ClassInfo::subclassesFor('Block');
31
-			if (is_null($subBlocks)) {
32
-				$subBlocks = array('Block');
33
-			}else{
34
-				unset($subBlocks['Block']);
35
-			}
30
+            $subBlocks = ClassInfo::subclassesFor('Block');
31
+            if (is_null($subBlocks)) {
32
+                $subBlocks = array('Block');
33
+            }else{
34
+                unset($subBlocks['Block']);
35
+            }
36 36
 			
37
-			$multiClass->setClasses($subBlocks);
38
-			$grid->setTitle('All Blcoks');
39
-			return $form;
40
-		}
41
-	}
42 37
\ No newline at end of file
38
+            $multiClass->setClasses($subBlocks);
39
+            $grid->setTitle('All Blcoks');
40
+            return $form;
41
+        }
42
+    }
43 43
\ 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
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 			$subBlocks = ClassInfo::subclassesFor('Block');
31 31
 			if (is_null($subBlocks)) {
32 32
 				$subBlocks = array('Block');
33
-			}else{
33
+			} else {
34 34
 				unset($subBlocks['Block']);
35 35
 			}
36 36
 			
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else{
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
Please login to merge, or discard this patch.
code/Extensions/BlockinPage.php 3 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@
 block discarded – undo
1 1
 <?php
2 2
 class BlockinPage extends Extension {
3
-	protected static $belongs_many_many = array (
4
-		'Blocks'			=>	'Block'
5
-	);
3
+    protected static $belongs_many_many = array (
4
+        'Blocks'			=>	'Block'
5
+    );
6 6
 	
7
-	public function updateCMSFields( FieldList $fields ) {
8
-		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
9
-		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10
-			$blocks = $this->owner->Blocks();
11
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
12
-			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
7
+    public function updateCMSFields( FieldList $fields ) {
8
+        $ancestry = ClassInfo::ancestry($this->owner->ClassName);
9
+        if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10
+            $blocks = $this->owner->Blocks();
11
+            $blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
12
+            $docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
13 13
 			
14
-			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
15
-			$fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
16
-		}
17
-	}
14
+            $fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
15
+            $fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
16
+        }
17
+    }
18 18
 	
19
-	private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
20
-		/*
19
+    private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
20
+        /*
21 21
 		GridFieldConfig_Base
22 22
 		GridFieldConfig_RecordViewer
23 23
 		GridFieldConfig_RecordEditor
24 24
 		GridFieldConfig_RelationEditor
25 25
 		*/
26
-		if ($label == '') { $label = $name; }
27
-		$grid = new GridField($name, $label, $source);
28
-		$config = $gridHeaderType::create();
29
-		$config->removeComponentsByType('GridFieldAddNewButton');
30
-		if ( $canAdd ) {
31
-			$config->addComponents(
32
-				$multiClass = new GridFieldAddNewMultiClass(),
33
-				$sortable = new GridFieldOrderableRows('SortOrder')
34
-			);
35
-			$subBlocks = ClassInfo::subclassesFor('Block');
36
-			if (is_null($subBlocks)) {
37
-				$subBlocks = array('Block');
38
-			}else{
39
-				unset($subBlocks['Block']);
40
-			}
41
-			$multiClass->setClasses($subBlocks);
42
-		}
43
-		$grid->setConfig($config);
44
-		return $grid;
45
-	}
26
+        if ($label == '') { $label = $name; }
27
+        $grid = new GridField($name, $label, $source);
28
+        $config = $gridHeaderType::create();
29
+        $config->removeComponentsByType('GridFieldAddNewButton');
30
+        if ( $canAdd ) {
31
+            $config->addComponents(
32
+                $multiClass = new GridFieldAddNewMultiClass(),
33
+                $sortable = new GridFieldOrderableRows('SortOrder')
34
+            );
35
+            $subBlocks = ClassInfo::subclassesFor('Block');
36
+            if (is_null($subBlocks)) {
37
+                $subBlocks = array('Block');
38
+            }else{
39
+                unset($subBlocks['Block']);
40
+            }
41
+            $multiClass->setClasses($subBlocks);
42
+        }
43
+        $grid->setConfig($config);
44
+        return $grid;
45
+    }
46 46
 		
47
-	private function dockedBlocks() {
48
-		$blocks = Block::get();
49
-		$IDs = array();
50
-		$ClassName = $this->owner->ClassName;
51
-		$Classes = $blocks->map('ID', 'shownInClass');
52
-		foreach ($Classes as $BlockID => $Class) {
53
-			$listedClasses = explode(',', $Class);
54
-			if (in_array($ClassName, $listedClasses)) {
55
-				$IDs[] = $BlockID;
56
-			}
57
-		}
58
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
59
-		return $blocks;
60
-	}
47
+    private function dockedBlocks() {
48
+        $blocks = Block::get();
49
+        $IDs = array();
50
+        $ClassName = $this->owner->ClassName;
51
+        $Classes = $blocks->map('ID', 'shownInClass');
52
+        foreach ($Classes as $BlockID => $Class) {
53
+            $listedClasses = explode(',', $Class);
54
+            if (in_array($ClassName, $listedClasses)) {
55
+                $IDs[] = $BlockID;
56
+            }
57
+        }
58
+        $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
59
+        return $blocks;
60
+    }
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 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')
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else {
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				$IDs[] = $BlockID;
56 56
 			}
57 57
 		}
58
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
58
+		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder', 'ASC');
59 59
 		return $blocks;
60 60
 	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else{
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
Please login to merge, or discard this patch.
code/Block.php 3 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,186 +1,186 @@
 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
-	);
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
+    );
14 14
 	
15
-	protected static $many_many = array (
16
-		'Pages'				=>	'Page'
17
-	);
15
+    protected static $many_many = array (
16
+        'Pages'				=>	'Page'
17
+    );
18 18
 		
19
-	protected static $create_table_options = array(
20
-		'MySQLDatabase'		=> 'ENGINE=MyISAM'
19
+    protected static $create_table_options = array(
20
+        'MySQLDatabase'		=> 'ENGINE=MyISAM'
21 21
     );
22 22
 	
23
-	protected static $extensions = array (
24
-		'StandardPermissions'
25
-	);
23
+    protected static $extensions = array (
24
+        'StandardPermissions'
25
+    );
26 26
 	
27
-	protected static $summary_fields = array(
28
-		'BlockType',
29
-		'Title', 
30
-		'Description',
31
-		'shownOn',
32
-		'VisibleTo'
33
-	);
27
+    protected static $summary_fields = array(
28
+        'BlockType',
29
+        'Title', 
30
+        'Description',
31
+        'shownOn',
32
+        'VisibleTo'
33
+    );
34 34
 	
35
-	protected static $field_labels = array(
36
-		'BlockType'			=>	'Block type',
37
-		'shownOn'			=>	'is shown on',
38
-		'VisibleTo'			=>	'Visible to'
39
-	);
35
+    protected static $field_labels = array(
36
+        'BlockType'			=>	'Block type',
37
+        'shownOn'			=>	'is shown on',
38
+        'VisibleTo'			=>	'Visible to'
39
+    );
40 40
 	
41
-	public function VisibleTo() {
42
-		if (strlen(trim($this->MemberVisibility)) > 0) {
43
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
44
-		}else{
45
-			$lists = '<em>&lt;All&gt;</em>';
46
-		}
41
+    public function VisibleTo() {
42
+        if (strlen(trim($this->MemberVisibility)) > 0) {
43
+            $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
44
+        }else{
45
+            $lists = '<em>&lt;All&gt;</em>';
46
+        }
47 47
 		
48
-		return new LiteralField('VisibleTo',$lists);
49
-	}
48
+        return new LiteralField('VisibleTo',$lists);
49
+    }
50 50
 	
51
-	public function BlockType() {
52
-		return $this->singular_name();
53
-	}
51
+    public function BlockType() {
52
+        return $this->singular_name();
53
+    }
54 54
 	
55
-	public function shownOn() {
56
-		if ($this->showBlockbyClass) {
57
-			if (strlen(trim($this->shownInClass)) > 0) {
58
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
59
-			}else{
60
-				$lists = '<em>&lt;not assigned&gt;</em>';
61
-			}
62
-		}else{
63
-			if ($this->Pages()->count() > 0) {
64
-				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
65
-			}else{
66
-				$lists = '<em>&lt;not assigned&gt;</em>';
67
-			}
68
-		}
69
-		return new LiteralField('shownOn',$lists);
70
-	}
55
+    public function shownOn() {
56
+        if ($this->showBlockbyClass) {
57
+            if (strlen(trim($this->shownInClass)) > 0) {
58
+                $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
59
+            }else{
60
+                $lists = '<em>&lt;not assigned&gt;</em>';
61
+            }
62
+        }else{
63
+            if ($this->Pages()->count() > 0) {
64
+                $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
65
+            }else{
66
+                $lists = '<em>&lt;not assigned&gt;</em>';
67
+            }
68
+        }
69
+        return new LiteralField('shownOn',$lists);
70
+    }
71 71
 	
72
-	public function getCMSFields() {
73
-		$fields = parent::getCMSFields();
74
-		$fields->removeFieldFromTab('Root', 'Pages');
75
-		$fields->removeFieldsFromTab('Root.Main', array(
76
-			'SortOrder',
77
-			'showBlockbyClass',
78
-			'shownInClass',
79
-			'MemberVisibility'
80
-		));
72
+    public function getCMSFields() {
73
+        $fields = parent::getCMSFields();
74
+        $fields->removeFieldFromTab('Root', 'Pages');
75
+        $fields->removeFieldsFromTab('Root.Main', array(
76
+            'SortOrder',
77
+            'showBlockbyClass',
78
+            'shownInClass',
79
+            'MemberVisibility'
80
+        ));
81 81
 		
82
-		$memberGroups = Group::get();
83
-		$sourcemap = $memberGroups->map('Code', 'Title');
84
-		$source = array(
85
-			'anonymous'		=>	'Anonymous visitors'
86
-		);
87
-		foreach ($sourcemap as $mapping => $key) {
88
-			$source[$mapping] = $key;
89
-		}
82
+        $memberGroups = Group::get();
83
+        $sourcemap = $memberGroups->map('Code', 'Title');
84
+        $source = array(
85
+            'anonymous'		=>	'Anonymous visitors'
86
+        );
87
+        foreach ($sourcemap as $mapping => $key) {
88
+            $source[$mapping] = $key;
89
+        }
90 90
 		
91
-		$memberVisibility = new CheckboxSetField(
92
-			$name = "MemberVisibility",
93
-			$title = "Show block for specific groups",
94
-			$source
95
-		);
91
+        $memberVisibility = new CheckboxSetField(
92
+            $name = "MemberVisibility",
93
+            $title = "Show block for specific groups",
94
+            $source
95
+        );
96 96
 		
97
-		$memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
97
+        $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
98 98
 		
99
-		$availabelClasses = $this->availableClasses();
100
-		$inClass = new CheckboxSetField(
101
-			$name = "shownInClass",
102
-			$title = "Show block for specific content types",
103
-			$availabelClasses
104
-		);
99
+        $availabelClasses = $this->availableClasses();
100
+        $inClass = new CheckboxSetField(
101
+            $name = "shownInClass",
102
+            $title = "Show block for specific content types",
103
+            $availabelClasses
104
+        );
105 105
 		
106
-		$filterSelector = OptionsetField::create(
107
-			'showBlockbyClass',
108
-			'Choose filter set',
109
-			array(
110
-				'0'			=>	'by page',
111
-				'1'			=>	'by page/data type'
112
-			)
113
-		)->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>');
106
+        $filterSelector = OptionsetField::create(
107
+            'showBlockbyClass',
108
+            'Choose filter set',
109
+            array(
110
+                '0'			=>	'by page',
111
+                '1'			=>	'by page/data type'
112
+            )
113
+        )->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>');
114 114
 		
115
-		$availablePages = Page::get()->exclude('ClassName', array(
116
-			'ErrorPage',
117
-			'RedirectorPage',
118
-			'VirtualPage'
119
-		));
120
-		$pageSelector = new CheckboxSetField(
121
-			$name = "Pages",
122
-			$title = "Show on Page(s)",
123
-			$availablePages
124
-		);
115
+        $availablePages = Page::get()->exclude('ClassName', array(
116
+            'ErrorPage',
117
+            'RedirectorPage',
118
+            'VirtualPage'
119
+        ));
120
+        $pageSelector = new CheckboxSetField(
121
+            $name = "Pages",
122
+            $title = "Show on Page(s)",
123
+            $availablePages
124
+        );
125 125
 		
126
-		$fields->addFieldsToTab('Root.VisibilitySettings', array(
127
-			$filterSelector,
128
-			$pageSelector,
129
-			$inClass,
130
-			$memberVisibility
131
-		));
132
-		return $fields;
133
-	}
126
+        $fields->addFieldsToTab('Root.VisibilitySettings', array(
127
+            $filterSelector,
128
+            $pageSelector,
129
+            $inClass,
130
+            $memberVisibility
131
+        ));
132
+        return $fields;
133
+    }
134 134
 	
135
-	private function availableClasses() {
136
-		$Classes = array_diff(
137
-			ClassInfo::subclassesFor('Page'),
138
-			ClassInfo::subclassesFor('RedirectorPage'),
139
-			ClassInfo::subclassesFor('VirtualPage')
140
-		);
141
-		return $Classes;
142
-	}
135
+    private function availableClasses() {
136
+        $Classes = array_diff(
137
+            ClassInfo::subclassesFor('Page'),
138
+            ClassInfo::subclassesFor('RedirectorPage'),
139
+            ClassInfo::subclassesFor('VirtualPage')
140
+        );
141
+        return $Classes;
142
+    }
143 143
 	
144
-	public function forTemplate() {
145
-		if ($this->canDisplayMemberCheck()) {
146
-			return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
147
-		}
144
+    public function forTemplate() {
145
+        if ($this->canDisplayMemberCheck()) {
146
+            return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
147
+        }
148 148
 		
149
-		return false;
150
-	}
149
+        return false;
150
+    }
151 151
 	
152
-	private function canDisplayMemberCheck() {
153
-		$rawVisibility = $this->MemberVisibility;
152
+    private function canDisplayMemberCheck() {
153
+        $rawVisibility = $this->MemberVisibility;
154 154
 		
155
-		if (empty($rawVisibility)) {
156
-			return true;
157
-		}
155
+        if (empty($rawVisibility)) {
156
+            return true;
157
+        }
158 158
 		
159
-		$visibility = explode(',', $rawVisibility);
160
-		$member = Member::currentUser();
159
+        $visibility = explode(',', $rawVisibility);
160
+        $member = Member::currentUser();
161 161
 		
162
-		if (!$member && in_array('anonymous', $visibility)) {
163
-			return true;
164
-		}
162
+        if (!$member && in_array('anonymous', $visibility)) {
163
+            return true;
164
+        }
165 165
 		
166
-		if ($member) {
167
-			$memberGroups = $member->Groups()->column('Code');
168
-			foreach ($memberGroups as $memberGroup) {
169
-				if (in_array($memberGroup, $visibility)) {
170
-					return true;
171
-				}
172
-			}
173
-		}
166
+        if ($member) {
167
+            $memberGroups = $member->Groups()->column('Code');
168
+            foreach ($memberGroups as $memberGroup) {
169
+                if (in_array($memberGroup, $visibility)) {
170
+                    return true;
171
+                }
172
+            }
173
+        }
174 174
 		
175
-		return false;
176
-	}
175
+        return false;
176
+    }
177 177
 	
178
-	public function frontendEditable() {
179
-		$member = Member::currentUser();		
180
-		return $this->canEdit($member);
181
-	}
178
+    public function frontendEditable() {
179
+        $member = Member::currentUser();		
180
+        return $this->canEdit($member);
181
+    }
182 182
 	
183
-	public function Type2Class() {
184
-		return strtolower(str_replace(' ', '-', $this->singular_name()));
185
-	}
183
+    public function Type2Class() {
184
+        return strtolower(str_replace(' ', '-', $this->singular_name()));
185
+    }
186 186
 }
187 187
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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")',
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 		'shownInClass'		=>	'Text'
13 13
 	);
14 14
 	
15
-	protected static $many_many = array (
15
+	protected static $many_many = array(
16 16
 		'Pages'				=>	'Page'
17 17
 	);
18 18
 		
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		'MySQLDatabase'		=> 'ENGINE=MyISAM'
21 21
     );
22 22
 	
23
-	protected static $extensions = array (
23
+	protected static $extensions = array(
24 24
 		'StandardPermissions'
25 25
 	);
26 26
 	
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	
41 41
 	public function VisibleTo() {
42 42
 		if (strlen(trim($this->MemberVisibility)) > 0) {
43
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
44
-		}else{
43
+			$lists = 'Group: ' . str_replace(',', '<br />Group: ', $this->MemberVisibility);
44
+		} else {
45 45
 			$lists = '<em>&lt;All&gt;</em>';
46 46
 		}
47 47
 		
48
-		return new LiteralField('VisibleTo',$lists);
48
+		return new LiteralField('VisibleTo', $lists);
49 49
 	}
50 50
 	
51 51
 	public function BlockType() {
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 	public function shownOn() {
56 56
 		if ($this->showBlockbyClass) {
57 57
 			if (strlen(trim($this->shownInClass)) > 0) {
58
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
59
-			}else{
58
+				$lists = 'Type: ' . str_replace(',', '<br />Type: ', $this->shownInClass);
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
 		}
69
-		return new LiteralField('shownOn',$lists);
69
+		return new LiteralField('shownOn', $lists);
70 70
 	}
71 71
 	
72 72
 	public function getCMSFields() {
Please login to merge, or discard this patch.
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.
_config.php 1 patch
Spacing   +3 added lines, -3 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' );
5
-Requirements::css(BLOCK_DIR.'/css/blocks.css');
6 3
\ No newline at end of file
4
+define('BLOCK_DIR', basename(dirname(__FILE__)));
5
+LeftAndMain::require_javascript(BLOCK_DIR . '/js/silverstripe-block.script.js');
6
+Requirements::css(BLOCK_DIR . '/css/blocks.css');
7 7
\ No newline at end of file
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('SortOrder', 'ASC');
13
-	}
11
+    public function getMyBlocks() {
12
+        return $this->owner->Blocks()->sort('SortOrder', '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.