Skip to content

Commit

Permalink
setup files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Mc Cormack committed Sep 22, 2016
1 parent 3038a5a commit c22da59
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FilesMatch "\.(php|php3|php4|php5|phtml|inc)$">
Deny from all
</FilesMatch>
31 changes: 31 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2015, Andrew Mc Cormack <[email protected]>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

Neither the name of Andrew Mc Cormack nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Silverstripe-Block-Page
# Silverstripe Block Page
A modular approach to building pages in Silverstripe
2 changes: 2 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
if(!defined('BLOCK_PAGE_PATH')) define('BLOCK_PAGE_PATH', rtrim(basename(dirname(__FILE__))));
21 changes: 21 additions & 0 deletions code/admin/BlockPageAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

class BlockPageAdmin extends ModelAdmin {

//private static $menu_priority = 100;

private static $managed_models = array('BlockPage');

private static $url_segment = 'blockpage-admin';

private static $menu_title = 'Page Blocks';

private static $menu_icon = 'framework/admin/images/menu-icons/16x16/community.png';

public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);

return $form;
}
}
55 changes: 55 additions & 0 deletions code/extensions/BlockPage_Extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
*
*
* @package silverstripe-block-page
* @license MIT License https://github.com/cyber-duck/silverstripe-block-page/blob/master/LICENSE
* @author <[email protected]>
**/
class BlockPage_Extension extends DataExtension
{
/**
* @since version 1.0.0
*
* @config array $db
**/

private static $many_many = array(
'ContentBlocks' => 'ContentBlock'
);

private static $many_many_extraFields = array(
'ContentBlocks' => array(
'BlockSort' => 'Int'
)
);

/**
* @since version 1.0.0
*
* @config array $summary_fields
**/
private static $summary_fields = array();

/**
*
*
* @since version 1.0.0
*
* @param string $fields The current FieldList object
*
* @return FieldList
**/
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.ContentBlocks', $grid);

$blocks = $this->owner->ContentBlocks();
$editor = GridFieldConfig_RelationEditor::create()->addComponent(new GridFieldSortableRows('BlockSort'))
$grid = new GridField('ContentBlocks', 'Content Blocks', $blocks, $editor);
$fields->addFieldToTab('Root.ContentBlocks', $grid);

return $fields;
}
}
20 changes: 20 additions & 0 deletions code/model/ContentBlock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
*
*
* @package silverstripe-block-page
* @license MIT License https://github.com/cyber-duck/silverstripe-block-page/blob/master/LICENSE
* @author <[email protected]>
**/
class ContentBlock extends DataObject
{
private static $db = array(
'Name' => 'Varchar(512)',
'CssSelector' => 'Varchar(512)'
);

private static $belongs_any_many = array(
'Pages' => 'Page'
);
}
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "cyber-duck/silverstripe-block-page",
"description": "A modular approach to building pages in SilverStripe",
"type": "silverstripe-module",
"homepage": "http://github.com/cyber-duck/silverstripe-block-page",
"keywords": [
"silverstripe",
"page"
],
"license": "MIT",
"authors": [
{
"name": "Andrew Mc Cormack",
"email": "[email protected]"
}
],
"support": {
"issues": "http://github.com/cyber-duck/silverstripe-block-page/issues"
},
"extra": {
"installer-name": "block-page"
},
"prefer-stable": true
}
33 changes: 33 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# License

Copyright (c) 2016, Andrew Mc Cormack <[email protected]>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

Neither the name of Andrew Mc Cormack nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Block page Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit c22da59

Please sign in to comment.