├── .github └── FUNDING.yml ├── _config └── config.yml ├── _config.php ├── CONTRIBUTING.md ├── templates ├── DNADesign │ └── Elemental │ │ └── Layout │ │ └── TabElementHolder.ss └── Dynamic │ └── Elements │ └── Tabset │ └── Element │ └── ElementTabSet.ss ├── .editorconfig ├── phpunit.xml.dist ├── .scrutinizer.yml ├── phpcs.xml.dist ├── .travis.yml ├── composer.json ├── LICENSE.md ├── CHANGELOG.md ├── src └── Element │ ├── ElementTabSet.php │ └── TabElement.php └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [dynamic] 2 | -------------------------------------------------------------------------------- /_config/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | Name: silverstripeelemental-tabsetconfig 3 | --- 4 | -------------------------------------------------------------------------------- /_config.php: -------------------------------------------------------------------------------- 1 | active show<% end_if %>" id="tab-{$ID}" role="tabpanel" aria-labelledby="tab-button-{$ID}"> 2 | $Element 3 | 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # For more information about the properties used in this file, 2 | # please see the EditorConfig documentation: 3 | # http://editorconfig.org 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_size = 4 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [{*.yml,package.json}] 14 | indent_size = 2 15 | 16 | # The indent size used in the package.json file cannot be changed: 17 | # https://github.com/npm/npm/pull/3180#issuecomment-16336516 18 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | tests 4 | 5 | 6 | 7 | 8 | src/ 9 | 10 | tests/ 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | inherit: true 2 | 3 | #Copied from https://www.adayinthelifeof.nl/2013/11/20/external-code-coverage-with-travis-scrutinizer/ 4 | tools: 5 | external_code_coverage: 6 | timeout: 600 7 | php_code_sniffer: 8 | config: 9 | standard: PSR2 10 | php_cs_fixer: 11 | extensions: 12 | # Default: 13 | - php 14 | fixers: [] 15 | enabled: false 16 | filter: 17 | paths: [tests/*,src/*] 18 | excluded_paths: [] 19 | coding_style: 20 | php: 21 | indentation: 22 | general: 23 | use_tabs: false 24 | 25 | checks: 26 | php: 27 | code_rating: true 28 | duplication: true 29 | 30 | build: 31 | nodes: 32 | analysis: 33 | tests: 34 | override: [php-scrutinizer-run] 35 | 36 | filter: 37 | paths: [tests/*,src/*] 38 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Coding standard for SilverStripe 4.x 4 | 5 | 6 | */vendor/* 7 | */thirdparty/* 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /templates/Dynamic/Elements/Tabset/Element/ElementTabSet.ss: -------------------------------------------------------------------------------- 1 |
2 | <% if $ShowTitle %> 3 |

$Title

4 | <% end_if %> 5 |
6 | <% if $Elements %> 7 | 14 | 15 |
16 | 17 | <% loop $Elements.Elements %> 18 |
19 | $Me 20 |
21 | <% end_loop %> 22 | 23 |
24 | <% end_if %> 25 |
26 |
27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | env: 4 | global: 5 | - COMPOSER_ROOT_VERSION=4.0.x-dev 6 | - CODECOV_TOKEN= 7 | - SCRUT_TOKEN= 8 | 9 | matrix: 10 | include: 11 | - php: 7.0 12 | env: DB=MYSQL PHPUNIT_TEST=1 PHPCS_TEST=1 13 | - php: 7.1 14 | env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 15 | - php: 5.6 16 | env: DB=MYSQL PHPUNIT_TEST=1 17 | 18 | before_script: 19 | # Init PHP 20 | - phpenv rehash 21 | - phpenv config-rm xdebug.ini 22 | - echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini 23 | 24 | # Install composer dependencies 25 | - composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2 26 | - composer update --no-suggest --prefer-dist 27 | 28 | script: 29 | - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi 30 | - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml && wget https://scrutinizer-ci.com/ocular.phar; fi 31 | - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi 32 | 33 | after_success: 34 | - 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 -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dynamic/silverstripe-elemental-tabset", 3 | "description": "Create a tabbed interface that uses elements", 4 | "authors": [ 5 | { 6 | "name": "Dynamic", 7 | "email": "dev@dynamicagency.com", 8 | "homepage": "http://www.dynamicagency.com" 9 | } 10 | ], 11 | "funding": [ 12 | { 13 | "type": "github", 14 | "url": "https://github.com/sponsors/dynamic" 15 | } 16 | ], 17 | "keywords": [ 18 | "silverstripe", "elemental", "tab", "tabset", "list" 19 | ], 20 | "type": "silverstripe-vendormodule", 21 | "license": "BSD-3-Clause", 22 | "require": { 23 | "dnadesign/silverstripe-elemental": "^4.0", 24 | "dnadesign/silverstripe-elemental-list": "^1.1", 25 | "silverstripe/vendor-plugin": "^1.0" 26 | }, 27 | "require-dev": { 28 | "phpunit/phpunit": "^5.7", 29 | "squizlabs/php_codesniffer": "*" 30 | }, 31 | "config": { 32 | "process-timeout": 600 33 | }, 34 | "autoload": { 35 | "psr-4": { 36 | "Dynamic\\Elements\\Tabset\\": "src/", 37 | "Dynamic\\Elements\\Tabset\\Test\\": "tests/" 38 | } 39 | }, 40 | "minimum-stability": "dev", 41 | "prefer-stable": true, 42 | "extra": { 43 | "branch-alias": { 44 | "dev-master": "2.0.x-dev" 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Dynamic 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 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. 9 | 10 | 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. 11 | 12 | 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. 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [2.0.1](https://github.com/dynamic/silverstripe-elemental-tabset/tree/2.0.1) (2019-03-20) 4 | [Full Changelog](https://github.com/dynamic/silverstripe-elemental-tabset/compare/2.0.0...2.0.1) 5 | 6 | **Closed issues:** 7 | 8 | - REQUIREMENTS remove @dev references for composer requirements [\#7](https://github.com/dynamic/silverstripe-elemental-tabset/issues/7) 9 | 10 | **Merged pull requests:** 11 | 12 | - UPDATE requirements to not include @dev [\#8](https://github.com/dynamic/silverstripe-elemental-tabset/pull/8) ([muskie9](https://github.com/muskie9)) 13 | 14 | ## [2.0.0](https://github.com/dynamic/silverstripe-elemental-tabset/tree/2.0.0) (2019-01-20) 15 | [Full Changelog](https://github.com/dynamic/silverstripe-elemental-tabset/compare/1.0.0...2.0.0) 16 | 17 | **Merged pull requests:** 18 | 19 | - add support for Elemental 4 [\#6](https://github.com/dynamic/silverstripe-elemental-tabset/pull/6) ([jsirish](https://github.com/jsirish)) 20 | 21 | ## [1.0.0](https://github.com/dynamic/silverstripe-elemental-tabset/tree/1.0.0) (2019-01-20) 22 | **Merged pull requests:** 23 | 24 | - remove branch alias [\#5](https://github.com/dynamic/silverstripe-elemental-tabset/pull/5) ([jsirish](https://github.com/jsirish)) 25 | - readme - composer badges [\#3](https://github.com/dynamic/silverstripe-elemental-tabset/pull/3) ([jsirish](https://github.com/jsirish)) 26 | - bugfix - vendor prefix in composer name [\#2](https://github.com/dynamic/silverstripe-elemental-tabset/pull/2) ([jsirish](https://github.com/jsirish)) 27 | - complete module setup [\#1](https://github.com/dynamic/silverstripe-elemental-tabset/pull/1) ([jsirish](https://github.com/jsirish)) 28 | 29 | 30 | 31 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /src/Element/ElementTabSet.php: -------------------------------------------------------------------------------- 1 | removeByName([ 51 | 'FileTracking', 52 | 'LinkTracking' 53 | ]); 54 | 55 | return $fields; 56 | } 57 | 58 | /** 59 | * @return DBHTMLText 60 | */ 61 | public function getSummary() 62 | { 63 | if ($this->Elements()) { 64 | $ct = $this->Elements()->Elements()->count(); 65 | if ($ct == 1) { 66 | $label = ' tab'; 67 | } else { 68 | $label = ' tabs'; 69 | } 70 | return DBField::create_field( 71 | 'HTMLText', 72 | $ct . $label 73 | )->Summary(20); 74 | } 75 | } 76 | 77 | /** 78 | * @return array 79 | */ 80 | protected function provideBlockSchema() 81 | { 82 | $blockSchema = parent::provideBlockSchema(); 83 | $blockSchema['content'] = $this->getSummary(); 84 | return $blockSchema; 85 | } 86 | 87 | /** 88 | * @return string 89 | */ 90 | public function getType() 91 | { 92 | return _t(__CLASS__ . '.BlockType', 'TabSet'); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Element/TabElement.php: -------------------------------------------------------------------------------- 1 | removeByName([ 56 | 'FileTracking', 57 | 'LinkTracking' 58 | ]); 59 | 60 | return $fields; 61 | } 62 | 63 | /** 64 | * @return DBHTMLText 65 | */ 66 | public function getSummary() 67 | { 68 | if ($this->Elements()->Elements()) { 69 | $ct = $this->Elements()->Elements()->count(); 70 | if ($ct == 1) { 71 | $label = ' block'; 72 | } else { 73 | $label = ' blocks'; 74 | } 75 | return DBField::create_field( 76 | 'HTMLText', 77 | $ct . $label 78 | )->Summary(20); 79 | } 80 | } 81 | 82 | /** 83 | * @return array 84 | */ 85 | protected function provideBlockSchema() 86 | { 87 | $blockSchema = parent::provideBlockSchema(); 88 | $blockSchema['content'] = $this->getSummary(); 89 | return $blockSchema; 90 | } 91 | 92 | /** 93 | * @return string 94 | */ 95 | public function getType() 96 | { 97 | return _t(__CLASS__ . '.BlockType', 'Tab'); 98 | } 99 | 100 | /** 101 | * @return bool 102 | */ 103 | public function First() 104 | { 105 | return ($this->Parent()->Elements()->first()->ID === $this->ID); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Silverstripe Elemental Tabset 2 | 3 | [![Build Status](https://travis-ci.com/dynamic/silverstripe-elemental-tabset.svg?token=hFT1sXd4nNmguE972zHN&branch=master)](https://travis-ci.com/dynamic/silverstripe-elemental-tabset) [![Sponsors](https://img.shields.io/badge/GitHub-Sponsors-ff69b4?logo=github)](https://github.com/sponsors/dynamic) 4 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/badges/quality-score.png?b=master&s=2af26be650b06cdd9ec5f9d0f636fcc96fc4b30f)](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/?branch=master) 5 | [![Code Coverage](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/badges/coverage.png?b=master&s=d490833fa5b373a56f5ed63058001d6178d3c090)](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/?branch=master) 6 | [![Build Status](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/badges/build.png?b=master&s=582772ff29b7a7942afebc48ae9efbc3da497709)](https://scrutinizer-ci.com/g/dynamic/silverstripe-elemental-tabset/build-status/master) 7 | 8 | 9 | [![Latest Stable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/version)](https://packagist.org/packages/dynamic/silverstripe-elemental-tabset) 10 | [![Latest Unstable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/v/unstable)](//packagist.org/packages/dynamic/silverstripe-elemental-tabset) 11 | [![Total Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/downloads)](https://packagist.org/packages/dynamic/silverstripe-elemental-tabset) 12 | [![License](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/license)](https://packagist.org/packages/dynamic/silverstripe-elemental-tabset) 13 | [![Monthly Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/d/monthly)](https://packagist.org/packages/dynamic/silverstripe-elemental-tabset) 14 | [![Daily Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-tabset/d/daily)](https://packagist.org/packages/dynamic/silverstripe-elemental-tabset) 15 | 16 | ## Requirements 17 | 18 | * silverstripe/recipe-cms: ^4@dev 19 | * dnadesign/silverstripe-elemental: ^4@dev 20 | * dnadesign/silverstripe-elemental-list: ^1.1@dev 21 | 22 | ## Installation 23 | 24 | `composer require dynamic/silverstripe-elemental-tabset` 25 | 26 | ## Example usage 27 | 28 | Create a tabbed interface that uses elements 29 | 30 | ### Template Notes 31 | 32 | The default templates are based off [Bootstrap 4](https://getbootstrap.com/) classes/styling. 33 | 34 | ## Getting more elements 35 | 36 | See [Elemental modules by Dynamic](https://github.com/dynamic/silverstripe-elemental-blocks#included-blocks) 37 | 38 | ## Configuration 39 | 40 | See [SilverStripe Elemental Configuration](https://github.com/dnadesign/silverstripe-elemental#configuration) 41 | 42 | ## Credits 43 | 44 | Thanks to [Hels](https://www.github.com/Hels666) for sharing the base code for this module 45 | --------------------------------------------------------------------------------