@@ -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 |
@@ -30,7 +30,7 @@ |
||
| 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 | |
@@ -4,41 +4,41 @@ |
||
| 4 | 4 | * |
| 5 | 5 | * Left-hand-side tab : Admin Blocks |
| 6 | 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'; |
|
| 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 MultiClassSelector(), |
|
| 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 MultiClassSelector(), |
|
| 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 | - foreach ($subBlocks as $key => &$value) { |
|
| 36 | - $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
| 37 | - } |
|
| 38 | - } |
|
| 30 | + $subBlocks = ClassInfo::subclassesFor('Block'); |
|
| 31 | + if (is_null($subBlocks)) { |
|
| 32 | + $subBlocks = array('Block'); |
|
| 33 | + }else{ |
|
| 34 | + unset($subBlocks['Block']); |
|
| 35 | + foreach ($subBlocks as $key => &$value) { |
|
| 36 | + $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $multiClass->setClasses($subBlocks); |
|
| 41 | - $grid->setTitle('All Blcoks'); |
|
| 42 | - return $form; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | 40 | \ No newline at end of file |
| 41 | + $multiClass->setClasses($subBlocks); |
|
| 42 | + $grid->setTitle('All Blcoks'); |
|
| 43 | + return $form; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | \ 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') |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
@@ -1,65 +1,65 @@ |
||
| 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 MultiClassSelector(), |
|
| 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']); |
|
| 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 MultiClassSelector(), |
|
| 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 | 40 | |
| 41 | - foreach ($subBlocks as $key => &$value) { |
|
| 42 | - $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - $multiClass->setClasses($subBlocks); |
|
| 46 | - } |
|
| 47 | - $grid->setConfig($config); |
|
| 48 | - return $grid; |
|
| 49 | - } |
|
| 41 | + foreach ($subBlocks as $key => &$value) { |
|
| 42 | + $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + $multiClass->setClasses($subBlocks); |
|
| 46 | + } |
|
| 47 | + $grid->setConfig($config); |
|
| 48 | + return $grid; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - private function dockedBlocks() { |
|
| 52 | - $blocks = Block::get(); |
|
| 53 | - $IDs = array(); |
|
| 54 | - $ClassName = $this->owner->ClassName; |
|
| 55 | - $Classes = $blocks->map('ID', 'shownInClass'); |
|
| 56 | - foreach ($Classes as $BlockID => $Class) { |
|
| 57 | - $listedClasses = explode(',', $Class); |
|
| 58 | - if (in_array($ClassName, $listedClasses)) { |
|
| 59 | - $IDs[] = $BlockID; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC'); |
|
| 63 | - return $blocks; |
|
| 64 | - } |
|
| 51 | + private function dockedBlocks() { |
|
| 52 | + $blocks = Block::get(); |
|
| 53 | + $IDs = array(); |
|
| 54 | + $ClassName = $this->owner->ClassName; |
|
| 55 | + $Classes = $blocks->map('ID', 'shownInClass'); |
|
| 56 | + foreach ($Classes as $BlockID => $Class) { |
|
| 57 | + $listedClasses = explode(',', $Class); |
|
| 58 | + if (in_array($ClassName, $listedClasses)) { |
|
| 59 | + $IDs[] = $BlockID; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC'); |
|
| 63 | + return $blocks; |
|
| 64 | + } |
|
| 65 | 65 | } |
| 66 | 66 | \ No newline at end of file |
@@ -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,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -define('BLOCK_DIR',basename(dirname(__FILE__)));
|
|
| 4 | -LeftAndMain::require_javascript( BLOCK_DIR. '/js/silverstripe-block.script.js' ); |
|
| 3 | +define('BLOCK_DIR', basename(dirname(__FILE__)));
|
|
| 4 | +LeftAndMain::require_javascript(BLOCK_DIR.'/js/silverstripe-block.script.js'); |
|
| 5 | 5 | Requirements::css(BLOCK_DIR.'/css/blocks.css'); |
| 6 | 6 | \ No newline at end of file |
@@ -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 |