Completed
Push — master ( cd834b...e038e5 )
by Leo
03:10
created
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/BlocksAdmin.php 3 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,52 +5,52 @@
 block discarded – undo
5 5
  * Left-hand-side tab : Admin Blocks
6 6
  * */
7 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';
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 19
 		
20
-		$grid->getConfig()
21
-			->removeComponentsByType('GridFieldPaginator')
22
-			->removeComponentsByType('GridFieldAddNewButton')
23
-			->removeComponentsByType('GridFieldPrintButton')
24
-			->removeComponentsByType('GridFieldExportButton')
25
-			->addComponents(
26
-				new GridFieldPaginatorWithShowAll(30),
27
-				$multiClass = new MultiClassSelector(),
28
-				$sortable = new GridFieldOrderableRows('SortOrder')
29
-			);
20
+        $grid->getConfig()
21
+            ->removeComponentsByType('GridFieldPaginator')
22
+            ->removeComponentsByType('GridFieldAddNewButton')
23
+            ->removeComponentsByType('GridFieldPrintButton')
24
+            ->removeComponentsByType('GridFieldExportButton')
25
+            ->addComponents(
26
+                new GridFieldPaginatorWithShowAll(30),
27
+                $multiClass = new MultiClassSelector(),
28
+                $sortable = new GridFieldOrderableRows('SortOrder')
29
+            );
30 30
 			
31
-		$subBlocks = self::getAvaiableTypes();
32
-		$multiClass->setClasses($subBlocks);
33
-		$grid->setTitle('All Blcoks');
34
-		return $form;
35
-	}
31
+        $subBlocks = self::getAvaiableTypes();
32
+        $multiClass->setClasses($subBlocks);
33
+        $grid->setTitle('All Blcoks');
34
+        return $form;
35
+    }
36 36
 	
37
-	public static function getAvaiableTypes() {
38
-		$subBlocks = ClassInfo::subclassesFor('Block');
39
-		if (is_null($subBlocks)) {
40
-			$subBlocks = array('Block');
41
-		}else{
42
-			$disabledTypes = Config::inst()->get('Block','DisabledBlocks');
43
-			Debugger::inspect($disabledTypes);
44
-			if (!empty($disabledTypes)) {
45
-				foreach ($disabledTypes as $disabledType) {
46
-					unset($subBlocks[$disabledType]);
47
-				}
48
-			}
49
-			foreach ($subBlocks as $key => &$value) {
50
-				$value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name;
51
-			}
52
-		}
37
+    public static function getAvaiableTypes() {
38
+        $subBlocks = ClassInfo::subclassesFor('Block');
39
+        if (is_null($subBlocks)) {
40
+            $subBlocks = array('Block');
41
+        }else{
42
+            $disabledTypes = Config::inst()->get('Block','DisabledBlocks');
43
+            Debugger::inspect($disabledTypes);
44
+            if (!empty($disabledTypes)) {
45
+                foreach ($disabledTypes as $disabledType) {
46
+                    unset($subBlocks[$disabledType]);
47
+                }
48
+            }
49
+            foreach ($subBlocks as $key => &$value) {
50
+                $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name;
51
+            }
52
+        }
53 53
 		
54
-		return $subBlocks;
55
-	}
54
+        return $subBlocks;
55
+    }
56 56
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@
 block discarded – undo
38 38
 		$subBlocks = ClassInfo::subclassesFor('Block');
39 39
 		if (is_null($subBlocks)) {
40 40
 			$subBlocks = array('Block');
41
-		}else{
42
-			$disabledTypes = Config::inst()->get('Block','DisabledBlocks');
41
+		} else {
42
+			$disabledTypes = Config::inst()->get('Block', 'DisabledBlocks');
43 43
 			Debugger::inspect($disabledTypes);
44 44
 			if (!empty($disabledTypes)) {
45 45
 				foreach ($disabledTypes as $disabledType) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 		$subBlocks = ClassInfo::subclassesFor('Block');
39 39
 		if (is_null($subBlocks)) {
40 40
 			$subBlocks = array('Block');
41
-		}else{
41
+		} else{
42 42
 			$disabledTypes = Config::inst()->get('Block','DisabledBlocks');
43 43
 			Debugger::inspect($disabledTypes);
44 44
 			if (!empty($disabledTypes)) {
Please login to merge, or discard this patch.