@@ -1,7 +1,7 @@ |
||
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 | ); |
@@ -1,9 +1,9 @@ |
||
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 |
@@ -1,7 +1,7 @@ |
||
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 |
@@ -1,8 +1,8 @@ |
||
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 |
@@ -1,7 +1,7 @@ |
||
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 | ); |
@@ -1,10 +1,10 @@ |
||
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 |
@@ -1,14 +1,14 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -1,57 +1,57 @@ |
||
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 |
@@ -41,7 +41,7 @@ discard block |
||
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><All></em>'; |
46 | 46 | } |
47 | 47 | |
@@ -56,13 +56,13 @@ discard block |
||
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><not assigned></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><not assigned></em>'; |
67 | 67 | } |
68 | 68 | } |
@@ -1,7 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use SaltedHerring\Debugger as Debugger; |
|
4 | - |
|
5 | 3 | class Block extends DataObject { |
6 | 4 | protected static $db = array ( |
7 | 5 | 'SortOrder' => 'Int', |
@@ -3,248 +3,248 @@ |
||
3 | 3 | use SaltedHerring\Debugger as Debugger; |
4 | 4 | |
5 | 5 | class Block extends DataObject { |
6 | - protected static $db = array ( |
|
7 | - 'SortOrder' => 'Int', |
|
8 | - 'Title' => 'Varchar(64)', |
|
9 | - 'TitleWrapper' => 'Enum("h2,h3,h4,h5,h6")', |
|
10 | - 'hideTitle' => 'Boolean', |
|
11 | - 'showBlockbyClass' => 'Boolean', |
|
12 | - 'Description' => 'Varchar(128)', |
|
13 | - 'MemberVisibility' => 'Varchar(255)', |
|
14 | - 'shownInClass' => 'Text', |
|
15 | - 'addMarginTop' => 'Boolean', |
|
16 | - 'addMarginBottom' => 'Boolean' |
|
17 | - ); |
|
18 | - |
|
19 | - protected static $many_many = array ( |
|
20 | - 'Pages' => 'Page' |
|
21 | - ); |
|
22 | - |
|
23 | - protected static $default_sort = array( |
|
24 | - 'SortOrder' => 'ASC', |
|
25 | - 'ID' => 'DESC' |
|
26 | - ); |
|
27 | - |
|
28 | - protected static $create_table_options = array( |
|
29 | - 'MySQLDatabase' => 'ENGINE=MyISAM' |
|
6 | + protected static $db = array ( |
|
7 | + 'SortOrder' => 'Int', |
|
8 | + 'Title' => 'Varchar(64)', |
|
9 | + 'TitleWrapper' => 'Enum("h2,h3,h4,h5,h6")', |
|
10 | + 'hideTitle' => 'Boolean', |
|
11 | + 'showBlockbyClass' => 'Boolean', |
|
12 | + 'Description' => 'Varchar(128)', |
|
13 | + 'MemberVisibility' => 'Varchar(255)', |
|
14 | + 'shownInClass' => 'Text', |
|
15 | + 'addMarginTop' => 'Boolean', |
|
16 | + 'addMarginBottom' => 'Boolean' |
|
30 | 17 | ); |
31 | 18 | |
32 | - protected static $extensions = array ( |
|
33 | - 'StandardPermissions' |
|
34 | - ); |
|
35 | - |
|
36 | - protected static $summary_fields = array( |
|
37 | - 'BlockType', |
|
38 | - 'Title', |
|
39 | - 'Description', |
|
40 | - 'shownOn', |
|
41 | - 'VisibleTo', |
|
42 | - 'Published' |
|
43 | - ); |
|
44 | - |
|
45 | - protected static $field_labels = array( |
|
46 | - 'BlockType' => 'Block type', |
|
47 | - 'shownOn' => 'is shown on', |
|
48 | - 'VisibleTo' => 'Visible to' |
|
49 | - ); |
|
50 | - |
|
51 | - public function VisibleTo() { |
|
52 | - if (strlen(trim($this->MemberVisibility)) > 0) { |
|
53 | - $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility); |
|
54 | - }else{ |
|
55 | - $lists = '<em><All></em>'; |
|
56 | - } |
|
57 | - |
|
58 | - return new LiteralField('VisibleTo',$lists); |
|
59 | - } |
|
60 | - |
|
61 | - public function BlockType() { |
|
62 | - return $this->singular_name(); |
|
63 | - } |
|
64 | - |
|
65 | - public function shownOn() { |
|
66 | - if ($this->showBlockbyClass) { |
|
67 | - if (strlen(trim($this->shownInClass)) > 0) { |
|
68 | - $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass); |
|
69 | - }else{ |
|
70 | - $lists = '<em><not assigned></em>'; |
|
71 | - } |
|
72 | - }else{ |
|
73 | - if ($this->Pages()->count() > 0) { |
|
74 | - $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title')); |
|
75 | - }else{ |
|
76 | - $lists = '<em><not assigned></em>'; |
|
77 | - } |
|
78 | - } |
|
79 | - return new LiteralField('shownOn',$lists); |
|
80 | - } |
|
81 | - |
|
82 | - public function getCMSFields() { |
|
83 | - $fields = parent::getCMSFields(); |
|
84 | - $fields->removeFieldFromTab('Root', 'Pages'); |
|
85 | - $fields->removeFieldsFromTab('Root.Main', array( |
|
86 | - 'SortOrder', |
|
87 | - 'showBlockbyClass', |
|
88 | - 'shownInClass', |
|
89 | - 'MemberVisibility' |
|
90 | - )); |
|
91 | - |
|
92 | - $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Status: ' . $this->Published()), 'Title'); |
|
93 | - |
|
94 | - $memberGroups = Group::get(); |
|
95 | - $sourcemap = $memberGroups->map('Code', 'Title'); |
|
96 | - $source = array( |
|
97 | - 'anonymous' => 'Anonymous visitors' |
|
98 | - ); |
|
99 | - foreach ($sourcemap as $mapping => $key) { |
|
100 | - $source[$mapping] = $key; |
|
101 | - } |
|
102 | - |
|
103 | - $memberVisibility = new CheckboxSetField( |
|
104 | - $name = "MemberVisibility", |
|
105 | - $title = "Show block for specific groups", |
|
106 | - $source |
|
107 | - ); |
|
108 | - |
|
109 | - $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.'); |
|
110 | - |
|
111 | - $availabelClasses = $this->availableClasses(); |
|
112 | - $inClass = new CheckboxSetField( |
|
113 | - $name = "shownInClass", |
|
114 | - $title = "Show block for specific content types", |
|
115 | - $availabelClasses |
|
116 | - ); |
|
117 | - |
|
118 | - $filterSelector = OptionsetField::create( |
|
119 | - 'showBlockbyClass', |
|
120 | - 'Choose filter set', |
|
121 | - array( |
|
122 | - '0' => 'by page', |
|
123 | - '1' => 'by page/data type' |
|
124 | - ) |
|
125 | - )->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>'); |
|
126 | - |
|
127 | - $availablePages = Page::get()->exclude('ClassName', array( |
|
128 | - 'ErrorPage', |
|
129 | - 'RedirectorPage', |
|
130 | - 'VirtualPage' |
|
131 | - )); |
|
132 | - $pageSelector = new CheckboxSetField( |
|
133 | - $name = "Pages", |
|
134 | - $title = "Show on Page(s)", |
|
135 | - $availablePages->map('ID','Title') |
|
136 | - ); |
|
137 | - |
|
138 | - |
|
139 | - if ($this->canConfigPageAndType(Member::currentUser())) { |
|
140 | - $fields->addFieldsToTab('Root.VisibilitySettings', array( |
|
141 | - $filterSelector, |
|
142 | - $pageSelector, |
|
143 | - $inClass |
|
144 | - )); |
|
145 | - } |
|
146 | - |
|
147 | - if ($this->canConfigMemberVisibility(Member::currentUser())) { |
|
148 | - $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility); |
|
149 | - } |
|
150 | - |
|
151 | - if (!$fields->fieldByName('Options')) { |
|
152 | - $fields->insertBefore($right = RightSidebar::create('Options'), 'Root'); |
|
153 | - } |
|
154 | - |
|
155 | - $fields->addFieldsToTab('Options', array( |
|
156 | - CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), |
|
157 | - CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper') |
|
158 | - )); |
|
159 | - |
|
160 | - return $fields; |
|
161 | - } |
|
19 | + protected static $many_many = array ( |
|
20 | + 'Pages' => 'Page' |
|
21 | + ); |
|
162 | 22 | |
163 | - public function doPublish() { |
|
164 | - $this->writeToStage('Live'); |
|
165 | - } |
|
166 | - |
|
167 | - public function onBeforeWrite() { |
|
168 | - parent::onBeforeWrite(); |
|
169 | - if (empty($this->byPass)) { |
|
170 | - $this->readmode = Versioned::get_reading_mode(); |
|
171 | - Versioned::set_reading_mode('Stage.Stage'); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - public function onAfterWrite() { |
|
176 | - parent::onAfterWrite(); |
|
177 | - if (isset($this->readmode)) { |
|
178 | - Versioned::set_reading_mode('Stage.' . $this->readmode); |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - public function availableClasses() { |
|
183 | - $Classes = array_diff( |
|
184 | - ClassInfo::subclassesFor('Page'), |
|
185 | - ClassInfo::subclassesFor('RedirectorPage'), |
|
186 | - ClassInfo::subclassesFor('VirtualPage') |
|
187 | - ); |
|
188 | - return $Classes; |
|
189 | - } |
|
190 | - |
|
191 | - public function forTemplate() { |
|
192 | - if ($this->canDisplayMemberCheck()) { |
|
193 | - return $this->renderWith(array($this->getClassName(), 'BaseBlock')); |
|
194 | - } |
|
195 | - |
|
196 | - return false; |
|
197 | - } |
|
198 | - |
|
199 | - public function canDisplayMemberCheck() { |
|
200 | - $rawVisibility = $this->MemberVisibility; |
|
201 | - |
|
202 | - if (empty($rawVisibility)) { |
|
203 | - return true; |
|
204 | - } |
|
205 | - |
|
206 | - $visibility = explode(',', $rawVisibility); |
|
207 | - $member = Member::currentUser(); |
|
208 | - |
|
209 | - if (!$member && in_array('anonymous', $visibility)) { |
|
210 | - return true; |
|
211 | - } |
|
212 | - |
|
213 | - if ($member) { |
|
214 | - $memberGroups = $member->Groups()->column('Code'); |
|
215 | - foreach ($memberGroups as $memberGroup) { |
|
216 | - if (in_array($memberGroup, $visibility)) { |
|
217 | - return true; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - return false; |
|
223 | - } |
|
224 | - |
|
225 | - public function frontendEditable() { |
|
226 | - $member = Member::currentUser(); |
|
227 | - return $this->canEdit($member); |
|
228 | - } |
|
229 | - |
|
230 | - public function Type2Class() { |
|
231 | - return strtolower(str_replace(' ', '-', $this->singular_name())); |
|
232 | - } |
|
233 | - |
|
234 | - /*public function doPublish() { |
|
23 | + protected static $default_sort = array( |
|
24 | + 'SortOrder' => 'ASC', |
|
25 | + 'ID' => 'DESC' |
|
26 | + ); |
|
27 | + |
|
28 | + protected static $create_table_options = array( |
|
29 | + 'MySQLDatabase' => 'ENGINE=MyISAM' |
|
30 | + ); |
|
31 | + |
|
32 | + protected static $extensions = array ( |
|
33 | + 'StandardPermissions' |
|
34 | + ); |
|
35 | + |
|
36 | + protected static $summary_fields = array( |
|
37 | + 'BlockType', |
|
38 | + 'Title', |
|
39 | + 'Description', |
|
40 | + 'shownOn', |
|
41 | + 'VisibleTo', |
|
42 | + 'Published' |
|
43 | + ); |
|
44 | + |
|
45 | + protected static $field_labels = array( |
|
46 | + 'BlockType' => 'Block type', |
|
47 | + 'shownOn' => 'is shown on', |
|
48 | + 'VisibleTo' => 'Visible to' |
|
49 | + ); |
|
50 | + |
|
51 | + public function VisibleTo() { |
|
52 | + if (strlen(trim($this->MemberVisibility)) > 0) { |
|
53 | + $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility); |
|
54 | + }else{ |
|
55 | + $lists = '<em><All></em>'; |
|
56 | + } |
|
57 | + |
|
58 | + return new LiteralField('VisibleTo',$lists); |
|
59 | + } |
|
60 | + |
|
61 | + public function BlockType() { |
|
62 | + return $this->singular_name(); |
|
63 | + } |
|
64 | + |
|
65 | + public function shownOn() { |
|
66 | + if ($this->showBlockbyClass) { |
|
67 | + if (strlen(trim($this->shownInClass)) > 0) { |
|
68 | + $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass); |
|
69 | + }else{ |
|
70 | + $lists = '<em><not assigned></em>'; |
|
71 | + } |
|
72 | + }else{ |
|
73 | + if ($this->Pages()->count() > 0) { |
|
74 | + $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title')); |
|
75 | + }else{ |
|
76 | + $lists = '<em><not assigned></em>'; |
|
77 | + } |
|
78 | + } |
|
79 | + return new LiteralField('shownOn',$lists); |
|
80 | + } |
|
81 | + |
|
82 | + public function getCMSFields() { |
|
83 | + $fields = parent::getCMSFields(); |
|
84 | + $fields->removeFieldFromTab('Root', 'Pages'); |
|
85 | + $fields->removeFieldsFromTab('Root.Main', array( |
|
86 | + 'SortOrder', |
|
87 | + 'showBlockbyClass', |
|
88 | + 'shownInClass', |
|
89 | + 'MemberVisibility' |
|
90 | + )); |
|
91 | + |
|
92 | + $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Status: ' . $this->Published()), 'Title'); |
|
93 | + |
|
94 | + $memberGroups = Group::get(); |
|
95 | + $sourcemap = $memberGroups->map('Code', 'Title'); |
|
96 | + $source = array( |
|
97 | + 'anonymous' => 'Anonymous visitors' |
|
98 | + ); |
|
99 | + foreach ($sourcemap as $mapping => $key) { |
|
100 | + $source[$mapping] = $key; |
|
101 | + } |
|
102 | + |
|
103 | + $memberVisibility = new CheckboxSetField( |
|
104 | + $name = "MemberVisibility", |
|
105 | + $title = "Show block for specific groups", |
|
106 | + $source |
|
107 | + ); |
|
108 | + |
|
109 | + $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.'); |
|
110 | + |
|
111 | + $availabelClasses = $this->availableClasses(); |
|
112 | + $inClass = new CheckboxSetField( |
|
113 | + $name = "shownInClass", |
|
114 | + $title = "Show block for specific content types", |
|
115 | + $availabelClasses |
|
116 | + ); |
|
117 | + |
|
118 | + $filterSelector = OptionsetField::create( |
|
119 | + 'showBlockbyClass', |
|
120 | + 'Choose filter set', |
|
121 | + array( |
|
122 | + '0' => 'by page', |
|
123 | + '1' => 'by page/data type' |
|
124 | + ) |
|
125 | + )->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>'); |
|
126 | + |
|
127 | + $availablePages = Page::get()->exclude('ClassName', array( |
|
128 | + 'ErrorPage', |
|
129 | + 'RedirectorPage', |
|
130 | + 'VirtualPage' |
|
131 | + )); |
|
132 | + $pageSelector = new CheckboxSetField( |
|
133 | + $name = "Pages", |
|
134 | + $title = "Show on Page(s)", |
|
135 | + $availablePages->map('ID','Title') |
|
136 | + ); |
|
137 | + |
|
138 | + |
|
139 | + if ($this->canConfigPageAndType(Member::currentUser())) { |
|
140 | + $fields->addFieldsToTab('Root.VisibilitySettings', array( |
|
141 | + $filterSelector, |
|
142 | + $pageSelector, |
|
143 | + $inClass |
|
144 | + )); |
|
145 | + } |
|
146 | + |
|
147 | + if ($this->canConfigMemberVisibility(Member::currentUser())) { |
|
148 | + $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility); |
|
149 | + } |
|
150 | + |
|
151 | + if (!$fields->fieldByName('Options')) { |
|
152 | + $fields->insertBefore($right = RightSidebar::create('Options'), 'Root'); |
|
153 | + } |
|
154 | + |
|
155 | + $fields->addFieldsToTab('Options', array( |
|
156 | + CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), |
|
157 | + CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper') |
|
158 | + )); |
|
159 | + |
|
160 | + return $fields; |
|
161 | + } |
|
162 | + |
|
163 | + public function doPublish() { |
|
164 | + $this->writeToStage('Live'); |
|
165 | + } |
|
166 | + |
|
167 | + public function onBeforeWrite() { |
|
168 | + parent::onBeforeWrite(); |
|
169 | + if (empty($this->byPass)) { |
|
170 | + $this->readmode = Versioned::get_reading_mode(); |
|
171 | + Versioned::set_reading_mode('Stage.Stage'); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + public function onAfterWrite() { |
|
176 | + parent::onAfterWrite(); |
|
177 | + if (isset($this->readmode)) { |
|
178 | + Versioned::set_reading_mode('Stage.' . $this->readmode); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + public function availableClasses() { |
|
183 | + $Classes = array_diff( |
|
184 | + ClassInfo::subclassesFor('Page'), |
|
185 | + ClassInfo::subclassesFor('RedirectorPage'), |
|
186 | + ClassInfo::subclassesFor('VirtualPage') |
|
187 | + ); |
|
188 | + return $Classes; |
|
189 | + } |
|
190 | + |
|
191 | + public function forTemplate() { |
|
192 | + if ($this->canDisplayMemberCheck()) { |
|
193 | + return $this->renderWith(array($this->getClassName(), 'BaseBlock')); |
|
194 | + } |
|
195 | + |
|
196 | + return false; |
|
197 | + } |
|
198 | + |
|
199 | + public function canDisplayMemberCheck() { |
|
200 | + $rawVisibility = $this->MemberVisibility; |
|
201 | + |
|
202 | + if (empty($rawVisibility)) { |
|
203 | + return true; |
|
204 | + } |
|
205 | + |
|
206 | + $visibility = explode(',', $rawVisibility); |
|
207 | + $member = Member::currentUser(); |
|
208 | + |
|
209 | + if (!$member && in_array('anonymous', $visibility)) { |
|
210 | + return true; |
|
211 | + } |
|
212 | + |
|
213 | + if ($member) { |
|
214 | + $memberGroups = $member->Groups()->column('Code'); |
|
215 | + foreach ($memberGroups as $memberGroup) { |
|
216 | + if (in_array($memberGroup, $visibility)) { |
|
217 | + return true; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + return false; |
|
223 | + } |
|
224 | + |
|
225 | + public function frontendEditable() { |
|
226 | + $member = Member::currentUser(); |
|
227 | + return $this->canEdit($member); |
|
228 | + } |
|
229 | + |
|
230 | + public function Type2Class() { |
|
231 | + return strtolower(str_replace(' ', '-', $this->singular_name())); |
|
232 | + } |
|
233 | + |
|
234 | + /*public function doPublish() { |
|
235 | 235 | $this->writeToStage('Live'); |
236 | 236 | }*/ |
237 | 237 | |
238 | - public function Published() { |
|
239 | - return $this->isPublished() ? 'Yes' : 'No'; |
|
240 | - } |
|
238 | + public function Published() { |
|
239 | + return $this->isPublished() ? 'Yes' : 'No'; |
|
240 | + } |
|
241 | 241 | |
242 | - public function isPublished() { |
|
243 | - if (!empty(Versioned::get_by_stage('Block', 'Live')->byID($this->ID))) { |
|
244 | - return true; |
|
245 | - } |
|
242 | + public function isPublished() { |
|
243 | + if (!empty(Versioned::get_by_stage('Block', 'Live')->byID($this->ID))) { |
|
244 | + return true; |
|
245 | + } |
|
246 | 246 | |
247 | - return false; |
|
248 | - } |
|
247 | + return false; |
|
248 | + } |
|
249 | 249 | |
250 | 250 | } |
251 | 251 | \ No newline at end of file |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use SaltedHerring\Debugger as Debugger; |
4 | 4 | |
5 | 5 | class Block extends DataObject { |
6 | - protected static $db = array ( |
|
6 | + protected static $db = array( |
|
7 | 7 | 'SortOrder' => 'Int', |
8 | 8 | 'Title' => 'Varchar(64)', |
9 | 9 | 'TitleWrapper' => 'Enum("h2,h3,h4,h5,h6")', |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | 'addMarginBottom' => 'Boolean' |
17 | 17 | ); |
18 | 18 | |
19 | - protected static $many_many = array ( |
|
19 | + protected static $many_many = array( |
|
20 | 20 | 'Pages' => 'Page' |
21 | 21 | ); |
22 | 22 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | 'MySQLDatabase' => 'ENGINE=MyISAM' |
30 | 30 | ); |
31 | 31 | |
32 | - protected static $extensions = array ( |
|
32 | + protected static $extensions = array( |
|
33 | 33 | 'StandardPermissions' |
34 | 34 | ); |
35 | 35 | |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | |
51 | 51 | public function VisibleTo() { |
52 | 52 | if (strlen(trim($this->MemberVisibility)) > 0) { |
53 | - $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility); |
|
54 | - }else{ |
|
53 | + $lists = 'Group: '.str_replace(',', '<br />Group: ', $this->MemberVisibility); |
|
54 | + } else { |
|
55 | 55 | $lists = '<em><All></em>'; |
56 | 56 | } |
57 | 57 | |
58 | - return new LiteralField('VisibleTo',$lists); |
|
58 | + return new LiteralField('VisibleTo', $lists); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function BlockType() { |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | public function shownOn() { |
66 | 66 | if ($this->showBlockbyClass) { |
67 | 67 | if (strlen(trim($this->shownInClass)) > 0) { |
68 | - $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass); |
|
69 | - }else{ |
|
68 | + $lists = 'Type: '.str_replace(',', '<br />Type: ', $this->shownInClass); |
|
69 | + } else { |
|
70 | 70 | $lists = '<em><not assigned></em>'; |
71 | 71 | } |
72 | - }else{ |
|
72 | + } else { |
|
73 | 73 | if ($this->Pages()->count() > 0) { |
74 | - $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title')); |
|
75 | - }else{ |
|
74 | + $lists = 'Page: '.implode('<br />Page: ', $this->Pages()->column('Title')); |
|
75 | + } else { |
|
76 | 76 | $lists = '<em><not assigned></em>'; |
77 | 77 | } |
78 | 78 | } |
79 | - return new LiteralField('shownOn',$lists); |
|
79 | + return new LiteralField('shownOn', $lists); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | public function getCMSFields() { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'MemberVisibility' |
90 | 90 | )); |
91 | 91 | |
92 | - $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Status: ' . $this->Published()), 'Title'); |
|
92 | + $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Status: '.$this->Published()), 'Title'); |
|
93 | 93 | |
94 | 94 | $memberGroups = Group::get(); |
95 | 95 | $sourcemap = $memberGroups->map('Code', 'Title'); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $pageSelector = new CheckboxSetField( |
133 | 133 | $name = "Pages", |
134 | 134 | $title = "Show on Page(s)", |
135 | - $availablePages->map('ID','Title') |
|
135 | + $availablePages->map('ID', 'Title') |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function onAfterWrite() { |
176 | 176 | parent::onAfterWrite(); |
177 | 177 | if (isset($this->readmode)) { |
178 | - Versioned::set_reading_mode('Stage.' . $this->readmode); |
|
178 | + Versioned::set_reading_mode('Stage.'.$this->readmode); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 |
@@ -1,37 +1,37 @@ |
||
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 |
@@ -2,11 +2,11 @@ discard block |
||
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 |
||
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; |
@@ -1,46 +1,46 @@ |
||
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 |
@@ -20,7 +20,7 @@ |
||
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 |
@@ -1,27 +1,27 @@ |
||
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 |
@@ -38,8 +38,8 @@ |
||
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) { |
@@ -38,7 +38,7 @@ |
||
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)) { |
@@ -1,4 +1,4 @@ |
||
1 | -<?php use SaltedHerring\Debugger as Debugger; |
|
1 | +<?php |
|
2 | 2 | /** |
3 | 3 | * @file BlocksAdmin.php |
4 | 4 | * |
@@ -5,60 +5,60 @@ |
||
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 | - $grid->getConfig() |
|
20 | - ->removeComponentsByType('GridFieldPaginator') |
|
21 | - ->removeComponentsByType('GridFieldAddNewButton') |
|
22 | - ->removeComponentsByType('GridFieldPrintButton') |
|
23 | - ->removeComponentsByType('GridFieldExportButton') |
|
24 | - ->removeComponentsByType('GridFieldDetailForm') |
|
25 | - ->addComponents( |
|
26 | - new VersionedForm(), |
|
27 | - new GridFieldPaginatorWithShowAll(30), |
|
28 | - $multiClass = new MultiClassSelector(), |
|
29 | - $sortable = new GridFieldOrderableRows('SortOrder') |
|
30 | - ); |
|
19 | + $grid->getConfig() |
|
20 | + ->removeComponentsByType('GridFieldPaginator') |
|
21 | + ->removeComponentsByType('GridFieldAddNewButton') |
|
22 | + ->removeComponentsByType('GridFieldPrintButton') |
|
23 | + ->removeComponentsByType('GridFieldExportButton') |
|
24 | + ->removeComponentsByType('GridFieldDetailForm') |
|
25 | + ->addComponents( |
|
26 | + new VersionedForm(), |
|
27 | + new GridFieldPaginatorWithShowAll(30), |
|
28 | + $multiClass = new MultiClassSelector(), |
|
29 | + $sortable = new GridFieldOrderableRows('SortOrder') |
|
30 | + ); |
|
31 | 31 | |
32 | - $subBlocks = self::getAvaiableTypes(); |
|
33 | - $multiClass->setClasses($subBlocks); |
|
34 | - $grid->setTitle('All Blcoks'); |
|
35 | - return $form; |
|
36 | - } |
|
32 | + $subBlocks = self::getAvaiableTypes(); |
|
33 | + $multiClass->setClasses($subBlocks); |
|
34 | + $grid->setTitle('All Blcoks'); |
|
35 | + return $form; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getList() { |
|
39 | - $list = Versioned::get_by_stage('Block', 'Stage'); |
|
38 | + public function getList() { |
|
39 | + $list = Versioned::get_by_stage('Block', 'Stage'); |
|
40 | 40 | |
41 | - return $list; |
|
41 | + return $list; |
|
42 | 42 | } |
43 | 43 | |
44 | - public static function getAvaiableTypes() { |
|
45 | - $subBlocks = ClassInfo::subclassesFor('Block'); |
|
46 | - if (is_null($subBlocks)) { |
|
47 | - $subBlocks = array('Block'); |
|
48 | - }else{ |
|
49 | - $disabledTypes = Config::inst()->get('Block','DisabledBlocks'); |
|
50 | - if (!empty($disabledTypes)) { |
|
51 | - foreach ($disabledTypes as $disabledType) { |
|
52 | - unset($subBlocks[$disabledType]); |
|
53 | - } |
|
54 | - } |
|
55 | - foreach ($subBlocks as $key => &$value) { |
|
56 | - $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
57 | - } |
|
58 | - } |
|
44 | + public static function getAvaiableTypes() { |
|
45 | + $subBlocks = ClassInfo::subclassesFor('Block'); |
|
46 | + if (is_null($subBlocks)) { |
|
47 | + $subBlocks = array('Block'); |
|
48 | + }else{ |
|
49 | + $disabledTypes = Config::inst()->get('Block','DisabledBlocks'); |
|
50 | + if (!empty($disabledTypes)) { |
|
51 | + foreach ($disabledTypes as $disabledType) { |
|
52 | + unset($subBlocks[$disabledType]); |
|
53 | + } |
|
54 | + } |
|
55 | + foreach ($subBlocks as $key => &$value) { |
|
56 | + $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - return $subBlocks; |
|
61 | - } |
|
60 | + return $subBlocks; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | } |