Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Oct 2, 2018
0 parents commit 56de8a8
Show file tree
Hide file tree
Showing 19 changed files with 358 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# For more information about the properties used in this file,
# please see the EditorConfig documentation:
# http://editorconfig.org

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yml,package.json}]
indent_size = 2

# The indent size used in the package.json file cannot be changed:
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/tests export-ignore
/docs export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm-debug.log
node_modules/
37 changes: 37 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
inherit: true

#Copied from https://www.adayinthelifeof.nl/2013/11/20/external-code-coverage-with-travis-scrutinizer/
tools:
external_code_coverage:
timeout: 600
php_code_sniffer:
config:
standard: PSR2
php_cs_fixer:
extensions:
# Default:
- php
fixers: []
enabled: false
filter:
paths: [tests/*,src/*]
excluded_paths: []
coding_style:
php:
indentation:
general:
use_tabs: false

checks:
php:
code_rating: true
duplication: true

build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]

filter:
paths: [tests/*,src/*]
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
language: php

env:
global:
- COMPOSER_ROOT_VERSION=4.0.x-dev
- CODECOV_TOKEN=
- SCRUT_TOKEN=

matrix:
include:
- php: 7.0
env: DB=MYSQL PHPUNIT_TEST=1 PHPCS_TEST=1
- php: 7.1
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
- php: 5.6
env: DB=MYSQL PHPUNIT_TEST=1

before_script:
# Init PHP
- phpenv rehash
- phpenv config-rm xdebug.ini
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

# Install composer dependencies
- composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2
- composer update --no-suggest --prefer-dist

script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml && wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi

after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -t $CODECOV_TOKEN && travis_retry php ocular.phar code-coverage:upload --format=php-clover --access-token=$SCRUT_TOKEN coverage.xml; fi
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0]
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing

Contributions are welcome! Create an issue, explaining a bug or proposal. Submit pull requests if you feel brave.
12 changes: 12 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2018, Dynamic
All rights reserved.

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

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

2. 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.

3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# silverstripe-elemental-filelist

a multi file block for SilverStripe Elemental

## Requirements

- SilverStripe 3.2

## Installation

This is how you install silverstripe-elemental-filelist.

## Example usage

You use silverstripe-elemental-filelist like this.

## Documentation

See the [docs/en](docs/en/index.md) folder.
4 changes: 4 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

define('SILVERSTRIPE_ELEMENTAL-FILELIST_PATH', __DIR__);
define('SILVERSTRIPE_ELEMENTAL-FILELIST_DIR', basename(__DIR__));
3 changes: 3 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
Name: silverstripeelemental-filelistconfig
---
41 changes: 41 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "dynamic/silverstripe-elemental-filelist",
"description": "A multi file block for SilverStripe Elemental",
"authors": [
{
"name": "Dynamic",
"email": "dev@dynamicagency.com",
"homepage": "http://www.dynamicagency.com"
}
],
"keywords": [
"silverstripe"
],
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"require": {
"dnadesign/silverstripe-elemental": "^2@dev || ^3@dev",
"silverstripe/recipe-cms": "^1@dev || ^4@dev",
"silverstripe/vendor-plugin": "^1@dev"
},
"require-dev": {
"phpunit/PHPUnit": "^5.7",
"squizlabs/php_codesniffer": "*"
},
"config": {
"process-timeout": 600
},
"autoload": {
"psr-4": {
"Dynamic\\Elements\\FileList\\": "src/",
"Dynamic\\Elements\\FileList\\Test\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
5 changes: 5 additions & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# silverstripe-elemental-filelist

a multi file block for SilverStripe Elemental

## Getting started
3 changes: 3 additions & 0 deletions docs/en/userguide/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# User Guide

This guide provides helpful tips for people using silverstripe-elemental-filelist.
24 changes: 24 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset name="SS4">
<description>Coding standard for SilverStripe 4.x</description>

<!-- Don't sniff third party libraries -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/thirdparty/*</exclude-pattern>

<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="sp"/>
<arg name="colors"/>

<!-- Use PSR-2 as a base standard -->
<rule ref="PSR2">
<!-- Allow classes to not declare a namespace -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

<!-- Allow underscores in class names -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>

<!-- Allow non camel cased method names -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>
</ruleset>
14 changes: 14 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="silverstripe-elemental-blocks">
<directory>tests</directory>
</testsuite>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
54 changes: 54 additions & 0 deletions src/Elements/ElementFileList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Dynamic\Elements\FileList\Elements;

use DNADesign\Elemental\Models\BaseElement;
use Dynamic\Elements\FileList\Model\FileListObject;

class ElementFileList extends BaseElement
{
/**
* @var string
*/
private static $singular_name = 'File List Element';

/**
* @var string
*/
private static $plural_name = 'File List Elements';

/**
* @var string
*/
private static $table_name = 'ElementFileList';

/**
* @var array
*/
private static $has_many = [
'Files' => FileListObject::class,
];

/**
* @var array
*/
private static $owns = [
'Files',
];

/**
* @return DBHTMLText
*/
public function ElementSummary()
{
return DBField::create_field('HTMLText', '<p>File List</p>')->Summary(20);
}

/**
* @return string
*/
public function getType()
{
return _t(__CLASS__.'.BlockType', 'File List');
}
}
58 changes: 58 additions & 0 deletions src/Model/FileListObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Dynamic\Elements\FileList\Model;

use Dynamic\Elements\FileList\Elements\ElementFileList;
use SilverStripe\Assets\File;
use SilverStripe\ORM\DataObject;

class FileListObject extends DataObject
{
/**
* @var string
*/
private static $singular_name = 'File';

/**
* @var string
*/
private static $plural_name = 'Files';

/**
* @var array
*/
private static $db = [
'Title' => 'Varchar(255)',
];

/**
* @var array
*/
private static $has_one = [
'FileList' => ElementFileList::class,
'File' => File::class,
];

private static $owns = [
'File',
];

/**
* @var string
*/
private static $table_name = 'FileListObject';

/**
* @return \SilverStripe\Forms\FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->removeByName([
'FileListID',
]);

return $fields;
}
}
16 changes: 16 additions & 0 deletions src/ORM/FileDataExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Dynamic\Elements\FileList\ORM;

use Dynamic\Elements\FileList\Elements\ElementFileList;
use SilverStripe\ORM\DataExtension;

class FileDataExtension extends DataExtension
{
/**
* @var array
*/
private static $has_one = [
'FileList' => ElementFileList::class,
];
}

0 comments on commit 56de8a8

Please sign in to comment.