@@ -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,212 +1,212 @@ |
||
| 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 | - 'WrapperClasses' => 'Varchar(255)', |
|
| 14 | - 'HeadingClasses' => 'Varchar(255)', |
|
| 15 | - 'addMarginTop' => 'Boolean', |
|
| 16 | - 'addMarginBottom' => 'Boolean', |
|
| 17 | - 'addPaddingTop' => 'Boolean', |
|
| 18 | - 'addPaddingBottom' => 'Boolean' |
|
| 19 | - ); |
|
| 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 | + 'WrapperClasses' => 'Varchar(255)', |
|
| 14 | + 'HeadingClasses' => 'Varchar(255)', |
|
| 15 | + 'addMarginTop' => 'Boolean', |
|
| 16 | + 'addMarginBottom' => 'Boolean', |
|
| 17 | + 'addPaddingTop' => 'Boolean', |
|
| 18 | + 'addPaddingBottom' => 'Boolean' |
|
| 19 | + ); |
|
| 20 | 20 | |
| 21 | - protected static $many_many = array ( |
|
| 22 | - 'Pages' => 'Page' |
|
| 23 | - ); |
|
| 21 | + protected static $many_many = array ( |
|
| 22 | + 'Pages' => 'Page' |
|
| 23 | + ); |
|
| 24 | 24 | |
| 25 | - protected static $create_table_options = array( |
|
| 26 | - 'MySQLDatabase' => 'ENGINE=MyISAM' |
|
| 25 | + protected static $create_table_options = array( |
|
| 26 | + 'MySQLDatabase' => 'ENGINE=MyISAM' |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | - protected static $extensions = array ( |
|
| 30 | - 'StandardPermissions' |
|
| 31 | - ); |
|
| 29 | + protected static $extensions = array ( |
|
| 30 | + 'StandardPermissions' |
|
| 31 | + ); |
|
| 32 | 32 | |
| 33 | - protected static $summary_fields = array( |
|
| 34 | - 'BlockType', |
|
| 35 | - 'Title', |
|
| 36 | - 'Description', |
|
| 37 | - 'shownOn', |
|
| 38 | - 'VisibleTo' |
|
| 39 | - ); |
|
| 33 | + protected static $summary_fields = array( |
|
| 34 | + 'BlockType', |
|
| 35 | + 'Title', |
|
| 36 | + 'Description', |
|
| 37 | + 'shownOn', |
|
| 38 | + 'VisibleTo' |
|
| 39 | + ); |
|
| 40 | 40 | |
| 41 | - protected static $field_labels = array( |
|
| 42 | - 'BlockType' => 'Block type', |
|
| 43 | - 'shownOn' => 'is shown on', |
|
| 44 | - 'VisibleTo' => 'Visible to' |
|
| 45 | - ); |
|
| 41 | + protected static $field_labels = array( |
|
| 42 | + 'BlockType' => 'Block type', |
|
| 43 | + 'shownOn' => 'is shown on', |
|
| 44 | + 'VisibleTo' => 'Visible to' |
|
| 45 | + ); |
|
| 46 | 46 | |
| 47 | - public function VisibleTo() {
|
|
| 48 | - if (strlen(trim($this->MemberVisibility)) > 0) {
|
|
| 49 | - $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
|
|
| 50 | - }else{
|
|
| 51 | - $lists = '<em><All></em>'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - return new LiteralField('VisibleTo',$lists);
|
|
| 55 | - } |
|
| 47 | + public function VisibleTo() {
|
|
| 48 | + if (strlen(trim($this->MemberVisibility)) > 0) {
|
|
| 49 | + $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
|
|
| 50 | + }else{
|
|
| 51 | + $lists = '<em><All></em>'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + return new LiteralField('VisibleTo',$lists);
|
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function BlockType() {
|
|
| 58 | - return $this->singular_name(); |
|
| 59 | - } |
|
| 57 | + public function BlockType() {
|
|
| 58 | + return $this->singular_name(); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function shownOn() {
|
|
| 62 | - if ($this->showBlockbyClass) {
|
|
| 63 | - if (strlen(trim($this->shownInClass)) > 0) {
|
|
| 64 | - $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
|
|
| 65 | - }else{
|
|
| 66 | - $lists = '<em><not assigned></em>'; |
|
| 67 | - } |
|
| 68 | - }else{
|
|
| 69 | - if ($this->Pages()->count() > 0) {
|
|
| 70 | - $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
|
|
| 71 | - }else{
|
|
| 72 | - $lists = '<em><not assigned></em>'; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - return new LiteralField('shownOn',$lists);
|
|
| 76 | - } |
|
| 61 | + public function shownOn() {
|
|
| 62 | + if ($this->showBlockbyClass) {
|
|
| 63 | + if (strlen(trim($this->shownInClass)) > 0) {
|
|
| 64 | + $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
|
|
| 65 | + }else{
|
|
| 66 | + $lists = '<em><not assigned></em>'; |
|
| 67 | + } |
|
| 68 | + }else{
|
|
| 69 | + if ($this->Pages()->count() > 0) {
|
|
| 70 | + $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
|
|
| 71 | + }else{
|
|
| 72 | + $lists = '<em><not assigned></em>'; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + return new LiteralField('shownOn',$lists);
|
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function getCMSFields() {
|
|
| 79 | - $fields = parent::getCMSFields(); |
|
| 80 | - $fields->removeFieldFromTab('Root', 'Pages');
|
|
| 81 | - $fields->removeFieldsFromTab('Root.Main', array(
|
|
| 82 | - 'SortOrder', |
|
| 83 | - 'showBlockbyClass', |
|
| 84 | - 'shownInClass', |
|
| 85 | - 'MemberVisibility' |
|
| 86 | - )); |
|
| 87 | - |
|
| 88 | - $memberGroups = Group::get(); |
|
| 89 | - $sourcemap = $memberGroups->map('Code', 'Title');
|
|
| 90 | - $source = array( |
|
| 91 | - 'anonymous' => 'Anonymous visitors' |
|
| 92 | - ); |
|
| 93 | - foreach ($sourcemap as $mapping => $key) {
|
|
| 94 | - $source[$mapping] = $key; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $memberVisibility = new CheckboxSetField( |
|
| 98 | - $name = "MemberVisibility", |
|
| 99 | - $title = "Show block for specific groups", |
|
| 100 | - $source |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
|
|
| 104 | - |
|
| 105 | - $availabelClasses = $this->availableClasses(); |
|
| 106 | - $inClass = new CheckboxSetField( |
|
| 107 | - $name = "shownInClass", |
|
| 108 | - $title = "Show block for specific content types", |
|
| 109 | - $availabelClasses |
|
| 110 | - ); |
|
| 111 | - |
|
| 112 | - $filterSelector = OptionsetField::create( |
|
| 113 | - 'showBlockbyClass', |
|
| 114 | - 'Choose filter set', |
|
| 115 | - array( |
|
| 116 | - '0' => 'by page', |
|
| 117 | - '1' => 'by page/data type' |
|
| 118 | - ) |
|
| 119 | - )->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>');
|
|
| 120 | - |
|
| 121 | - $availablePages = Page::get()->exclude('ClassName', array(
|
|
| 122 | - 'ErrorPage', |
|
| 123 | - 'RedirectorPage', |
|
| 124 | - 'VirtualPage' |
|
| 125 | - )); |
|
| 126 | - $pageSelector = new CheckboxSetField( |
|
| 127 | - $name = "Pages", |
|
| 128 | - $title = "Show on Page(s)", |
|
| 129 | - $availablePages->map('ID','Title')
|
|
| 130 | - ); |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - if ($this->canConfigPageAndType(Member::currentUser())) {
|
|
| 134 | - $fields->addFieldsToTab('Root.VisibilitySettings', array(
|
|
| 135 | - $filterSelector, |
|
| 136 | - $pageSelector, |
|
| 137 | - $inClass |
|
| 138 | - )); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - if ($this->canConfigMemberVisibility(Member::currentUser())) {
|
|
| 142 | - $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
|
|
| 143 | - } |
|
| 78 | + public function getCMSFields() {
|
|
| 79 | + $fields = parent::getCMSFields(); |
|
| 80 | + $fields->removeFieldFromTab('Root', 'Pages');
|
|
| 81 | + $fields->removeFieldsFromTab('Root.Main', array(
|
|
| 82 | + 'SortOrder', |
|
| 83 | + 'showBlockbyClass', |
|
| 84 | + 'shownInClass', |
|
| 85 | + 'MemberVisibility' |
|
| 86 | + )); |
|
| 87 | + |
|
| 88 | + $memberGroups = Group::get(); |
|
| 89 | + $sourcemap = $memberGroups->map('Code', 'Title');
|
|
| 90 | + $source = array( |
|
| 91 | + 'anonymous' => 'Anonymous visitors' |
|
| 92 | + ); |
|
| 93 | + foreach ($sourcemap as $mapping => $key) {
|
|
| 94 | + $source[$mapping] = $key; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $memberVisibility = new CheckboxSetField( |
|
| 98 | + $name = "MemberVisibility", |
|
| 99 | + $title = "Show block for specific groups", |
|
| 100 | + $source |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
|
|
| 104 | + |
|
| 105 | + $availabelClasses = $this->availableClasses(); |
|
| 106 | + $inClass = new CheckboxSetField( |
|
| 107 | + $name = "shownInClass", |
|
| 108 | + $title = "Show block for specific content types", |
|
| 109 | + $availabelClasses |
|
| 110 | + ); |
|
| 111 | + |
|
| 112 | + $filterSelector = OptionsetField::create( |
|
| 113 | + 'showBlockbyClass', |
|
| 114 | + 'Choose filter set', |
|
| 115 | + array( |
|
| 116 | + '0' => 'by page', |
|
| 117 | + '1' => 'by page/data type' |
|
| 118 | + ) |
|
| 119 | + )->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>');
|
|
| 120 | + |
|
| 121 | + $availablePages = Page::get()->exclude('ClassName', array(
|
|
| 122 | + 'ErrorPage', |
|
| 123 | + 'RedirectorPage', |
|
| 124 | + 'VirtualPage' |
|
| 125 | + )); |
|
| 126 | + $pageSelector = new CheckboxSetField( |
|
| 127 | + $name = "Pages", |
|
| 128 | + $title = "Show on Page(s)", |
|
| 129 | + $availablePages->map('ID','Title')
|
|
| 130 | + ); |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + if ($this->canConfigPageAndType(Member::currentUser())) {
|
|
| 134 | + $fields->addFieldsToTab('Root.VisibilitySettings', array(
|
|
| 135 | + $filterSelector, |
|
| 136 | + $pageSelector, |
|
| 137 | + $inClass |
|
| 138 | + )); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + if ($this->canConfigMemberVisibility(Member::currentUser())) {
|
|
| 142 | + $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
|
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if (!$fields->fieldByName('Options')) {
|
|
| 146 | - $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
|
|
| 147 | - } |
|
| 145 | + if (!$fields->fieldByName('Options')) {
|
|
| 146 | + $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
|
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - $fields->addFieldsToTab('Options', array(
|
|
| 150 | - TextField::create('WrapperClasses', 'Additional block wrapper Class'),
|
|
| 151 | - TextField::create('HeadingClasses', 'Additional block title Class'),
|
|
| 152 | - CheckboxField::create('addMarginTop','Add Margin to top'),
|
|
| 153 | - CheckboxField::create('addMarginBottom','Add Margin to bottom'),
|
|
| 154 | - CheckboxField::create('addPaddingTop','Add Padding to top'),
|
|
| 155 | - CheckboxField::create('addPaddingBottom','Add Padding to bottom')
|
|
| 156 | - )); |
|
| 149 | + $fields->addFieldsToTab('Options', array(
|
|
| 150 | + TextField::create('WrapperClasses', 'Additional block wrapper Class'),
|
|
| 151 | + TextField::create('HeadingClasses', 'Additional block title Class'),
|
|
| 152 | + CheckboxField::create('addMarginTop','Add Margin to top'),
|
|
| 153 | + CheckboxField::create('addMarginBottom','Add Margin to bottom'),
|
|
| 154 | + CheckboxField::create('addPaddingTop','Add Padding to top'),
|
|
| 155 | + CheckboxField::create('addPaddingBottom','Add Padding to bottom')
|
|
| 156 | + )); |
|
| 157 | 157 | |
| 158 | - return $fields; |
|
| 159 | - } |
|
| 158 | + return $fields; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - private function availableClasses() {
|
|
| 162 | - $Classes = array_diff( |
|
| 163 | - ClassInfo::subclassesFor('Page'),
|
|
| 164 | - ClassInfo::subclassesFor('RedirectorPage'),
|
|
| 165 | - ClassInfo::subclassesFor('VirtualPage')
|
|
| 166 | - ); |
|
| 167 | - return $Classes; |
|
| 168 | - } |
|
| 161 | + private function availableClasses() {
|
|
| 162 | + $Classes = array_diff( |
|
| 163 | + ClassInfo::subclassesFor('Page'),
|
|
| 164 | + ClassInfo::subclassesFor('RedirectorPage'),
|
|
| 165 | + ClassInfo::subclassesFor('VirtualPage')
|
|
| 166 | + ); |
|
| 167 | + return $Classes; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - public function forTemplate() {
|
|
| 171 | - if ($this->canDisplayMemberCheck()) {
|
|
| 172 | - return $this->renderWith(array($this->getClassName(), 'BaseBlock')); |
|
| 173 | - } |
|
| 170 | + public function forTemplate() {
|
|
| 171 | + if ($this->canDisplayMemberCheck()) {
|
|
| 172 | + return $this->renderWith(array($this->getClassName(), 'BaseBlock')); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return false; |
|
| 176 | - } |
|
| 175 | + return false; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - private function canDisplayMemberCheck() {
|
|
| 179 | - $rawVisibility = $this->MemberVisibility; |
|
| 180 | - |
|
| 181 | - if (empty($rawVisibility)) {
|
|
| 182 | - return true; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $visibility = explode(',', $rawVisibility);
|
|
| 186 | - $member = Member::currentUser(); |
|
| 187 | - |
|
| 188 | - if (!$member && in_array('anonymous', $visibility)) {
|
|
| 189 | - return true; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - if ($member) {
|
|
| 193 | - $memberGroups = $member->Groups()->column('Code');
|
|
| 194 | - foreach ($memberGroups as $memberGroup) {
|
|
| 195 | - if (in_array($memberGroup, $visibility)) {
|
|
| 196 | - return true; |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - return false; |
|
| 202 | - } |
|
| 178 | + private function canDisplayMemberCheck() {
|
|
| 179 | + $rawVisibility = $this->MemberVisibility; |
|
| 180 | + |
|
| 181 | + if (empty($rawVisibility)) {
|
|
| 182 | + return true; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $visibility = explode(',', $rawVisibility);
|
|
| 186 | + $member = Member::currentUser(); |
|
| 187 | + |
|
| 188 | + if (!$member && in_array('anonymous', $visibility)) {
|
|
| 189 | + return true; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + if ($member) {
|
|
| 193 | + $memberGroups = $member->Groups()->column('Code');
|
|
| 194 | + foreach ($memberGroups as $memberGroup) {
|
|
| 195 | + if (in_array($memberGroup, $visibility)) {
|
|
| 196 | + return true; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - public function frontendEditable() {
|
|
| 205 | - $member = Member::currentUser(); |
|
| 206 | - return $this->canEdit($member); |
|
| 207 | - } |
|
| 204 | + public function frontendEditable() {
|
|
| 205 | + $member = Member::currentUser(); |
|
| 206 | + return $this->canEdit($member); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - public function Type2Class() {
|
|
| 210 | - return strtolower(str_replace(' ', '-', $this->singular_name()));
|
|
| 211 | - } |
|
| 209 | + public function Type2Class() {
|
|
| 210 | + return strtolower(str_replace(' ', '-', $this->singular_name()));
|
|
| 211 | + } |
|
| 212 | 212 | } |
| 213 | 213 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 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")',
|
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | 'addPaddingBottom' => 'Boolean' |
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | - protected static $many_many = array ( |
|
| 21 | + protected static $many_many = array( |
|
| 22 | 22 | 'Pages' => 'Page' |
| 23 | 23 | ); |
| 24 | 24 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'MySQLDatabase' => 'ENGINE=MyISAM' |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | - protected static $extensions = array ( |
|
| 29 | + protected static $extensions = array( |
|
| 30 | 30 | 'StandardPermissions' |
| 31 | 31 | ); |
| 32 | 32 | |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function VisibleTo() {
|
| 48 | 48 | if (strlen(trim($this->MemberVisibility)) > 0) {
|
| 49 | - $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
|
|
| 50 | - }else{
|
|
| 49 | + $lists = 'Group: '.str_replace(',', '<br />Group: ', $this->MemberVisibility);
|
|
| 50 | + } else {
|
|
| 51 | 51 | $lists = '<em><All></em>'; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return new LiteralField('VisibleTo',$lists);
|
|
| 54 | + return new LiteralField('VisibleTo', $lists);
|
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function BlockType() {
|
@@ -61,18 +61,18 @@ discard block |
||
| 61 | 61 | public function shownOn() {
|
| 62 | 62 | if ($this->showBlockbyClass) {
|
| 63 | 63 | if (strlen(trim($this->shownInClass)) > 0) {
|
| 64 | - $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
|
|
| 65 | - }else{
|
|
| 64 | + $lists = 'Type: '.str_replace(',', '<br />Type: ', $this->shownInClass);
|
|
| 65 | + } else {
|
|
| 66 | 66 | $lists = '<em><not assigned></em>'; |
| 67 | 67 | } |
| 68 | - }else{
|
|
| 68 | + } else {
|
|
| 69 | 69 | if ($this->Pages()->count() > 0) {
|
| 70 | - $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
|
|
| 71 | - }else{
|
|
| 70 | + $lists = 'Page: '.implode('<br />Page: ', $this->Pages()->column('Title'));
|
|
| 71 | + } else {
|
|
| 72 | 72 | $lists = '<em><not assigned></em>'; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | - return new LiteralField('shownOn',$lists);
|
|
| 75 | + return new LiteralField('shownOn', $lists);
|
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function getCMSFields() {
|
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $pageSelector = new CheckboxSetField( |
| 127 | 127 | $name = "Pages", |
| 128 | 128 | $title = "Show on Page(s)", |
| 129 | - $availablePages->map('ID','Title')
|
|
| 129 | + $availablePages->map('ID', 'Title')
|
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | $fields->addFieldsToTab('Options', array(
|
| 150 | 150 | TextField::create('WrapperClasses', 'Additional block wrapper Class'),
|
| 151 | 151 | TextField::create('HeadingClasses', 'Additional block title Class'),
|
| 152 | - CheckboxField::create('addMarginTop','Add Margin to top'),
|
|
| 153 | - CheckboxField::create('addMarginBottom','Add Margin to bottom'),
|
|
| 154 | - CheckboxField::create('addPaddingTop','Add Padding to top'),
|
|
| 155 | - CheckboxField::create('addPaddingBottom','Add Padding to bottom')
|
|
| 152 | + CheckboxField::create('addMarginTop', 'Add Margin to top'),
|
|
| 153 | + CheckboxField::create('addMarginBottom', 'Add Margin to bottom'),
|
|
| 154 | + CheckboxField::create('addPaddingTop', 'Add Padding to top'),
|
|
| 155 | + CheckboxField::create('addPaddingBottom', 'Add Padding to bottom')
|
|
| 156 | 156 | )); |
| 157 | 157 | |
| 158 | 158 | return $fields; |
@@ -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 |