-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from creative-commoners/pulls/CC-163-userform-o…
…n-block Allow editors to define userform on block
- Loading branch information
Showing
17 changed files
with
381 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/tests export-ignore | ||
/docs export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/.scrutinizer.yml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
inherit: true | ||
|
||
tools: | ||
external_code_coverage: false | ||
|
||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
|
||
filter: | ||
paths: [src/*, tests/*] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
language: php | ||
|
||
dist: trusty | ||
|
||
env: | ||
global: | ||
- COMPOSER_ROOT_VERSION=1.x-dev | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1 | ||
- php: 7.0 | ||
env: DB=PGSQL PHPUNIT_TEST=1 | ||
- php: 7.0 | ||
env: DB=MYSQL PHPUNIT_TEST=1 | ||
- php: 7.1 | ||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 | ||
|
||
before_script: | ||
# Init PHP | ||
- phpenv rehash | ||
- phpenv config-rm xdebug.ini | ||
|
||
# Install composer dependencies | ||
- composer validate | ||
- composer require silverstripe/recipe-cms 1.0.x-dev --no-update | ||
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi | ||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile | ||
|
||
script: | ||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi | ||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi | ||
|
||
after_success: | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# silverstripe-elemental-userforms | ||
Adds a new element for usersforms | ||
# SilverStripe Elemental UserForms | ||
|
||
[![Build Status](http://img.shields.io/travis/dnadesign/silverstripe-elemental-userforms.svg?style=flat-square)](https://travis-ci.org/dnadesign/silverstripe-elemental-userforms) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental-userforms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental-userforms/?branch=master) | ||
[![codecov](https://codecov.io/gh/dnadesign/silverstripe-elemental-userforms/branch/master/graph/badge.svg)](https://codecov.io/gh/dnadesign/silverstripe-elemental-userforms) | ||
[![Version](http://img.shields.io/packagist/v/dnadesign/silverstripe-elemental-userforms.svg?style=flat-square)](https://packagist.org/packages/dnadesign/silverstripe-elemental-userforms) | ||
[![License](http://img.shields.io/packagist/l/dnadesign/silverstripe-elemental-userforms.svg?style=flat-square)](LICENSE.md) | ||
|
||
## Introduction | ||
|
||
Adds a new form element for SilverStripe Elemental. This block allows users to | ||
construct User Forms using the SilverStripe UserForms module. | ||
|
||
## Installation | ||
|
||
``` | ||
composer require "dnadesign/silverstripe-elemental-userforms" | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
comment: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Contributing | ||
|
||
Any open source product is only as good as the community behind it. You can participate by sharing code, ideas, or | ||
simply helping others. No matter what your skill level is, every contribution counts. | ||
|
||
See our [high level overview](http://silverstripe.org/contributing-to-silverstripe) on silverstripe.org on how you can | ||
help out. | ||
|
||
Or, for more detailed guidance, read one of the following pages: | ||
|
||
* [Sharing your opinion and raising issues](http://docs.silverstripe.org/en/contributing/issues_and_bugs/) | ||
* [Providing code, whether it's creating a feature or fixing a bug](http://docs.silverstripe.org/en/contributing/code/) | ||
* [Writing and translating documentation](http://docs.silverstripe.org/en/contributing/translations/) | ||
* [Translating user-interface elements](http://docs.silverstripe.org/en/contributing/translation_process/) | ||
|
||
## Copyright | ||
|
||
**IMPORTANT: By supplying code in patches, tickets and pull requests, you agree to assign copyright of that code to | ||
DNA DESIGNED COMMUNICATIONS LIMITED, on the condition that DNA DESIGNED COMMUNICATIONS LIMITED releases that code under | ||
the BSD license.** unless otherwise noted. | ||
|
||
We ask for this so that the ownership in the license is clear and unambiguous, and so that community involvement doesn't | ||
stop us from being able to continue supporting these projects. By releasing this code under a permissive license, this | ||
copyright assignment won't prevent you from using the code in any way you see fit. | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuite name="Default"> | ||
<directory>tests/php</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src/</directory> | ||
<exclude> | ||
<directory suffix=".php">tests/php</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace DNADesign\ElementalUserForms\Control; | ||
|
||
use DNADesign\Elemental\Controllers\ElementController; | ||
use SilverStripe\Control\Controller; | ||
use SilverStripe\UserForms\Control\UserDefinedFormController; | ||
|
||
/** | ||
* Handles Form Submissions | ||
*/ | ||
class ElementFormController extends ElementController | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function __construct($element = null) | ||
{ | ||
parent::__construct($element); | ||
|
||
$current = Controller::curr(); | ||
|
||
if ($current->getRequest()->isPOST()) { | ||
// handle the post request. | ||
$user = UserDefinedFormController::create($element); | ||
$form = $user->Form(); | ||
|
||
$user->process($current->getRequest()->postVars(), $form); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $action | ||
* | ||
* @return string | ||
*/ | ||
public function Link($action = null) | ||
{ | ||
$id = $this->element->ID; | ||
$segment = Controller::join_links('element', $id, $action); | ||
$page = Director::get_current_page(); | ||
|
||
if ($page && !($page instanceof ElementController)) { | ||
return $page->Link($segment); | ||
} | ||
|
||
if ($controller = $this->getParentController()) { | ||
return $controller->Link($segment); | ||
} | ||
|
||
return $segment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace DNADesign\ElementalUserForms\Model; | ||
|
||
use SilverStripe\UserForms\Control\UserDefinedFormController; | ||
use SilverStripe\UserForms\UserForm; | ||
use SilverStripe\Control\Controller; | ||
use DNADesign\Elemental\Models\BaseElement; | ||
use DNADesign\ElementalUserForms\Control\ElementFormController; | ||
|
||
class ElementForm extends BaseElement | ||
{ | ||
use UserForm; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'ElementForm'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $title = 'Form'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $icon = 'dnadesign/silverstripe-elemental-userforms:images/form.svg'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $controller_class = ElementFormController::class; | ||
|
||
/** | ||
* @return UserForm | ||
*/ | ||
public function ElementForm() | ||
{ | ||
$controller = new UserDefinedFormController($this); | ||
$current = Controller::curr(); | ||
|
||
if ($current && $current->getAction() == 'finished') { | ||
return $controller->renderWith('ReceivedFormSubmission'); | ||
} | ||
|
||
$form = $controller->Form(); | ||
$form->setFormAction( | ||
Controller::join_links( | ||
$current->Link(), | ||
'element', | ||
$this->owner->ID | ||
) | ||
); | ||
|
||
return $form; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="formelement__form"> | ||
$ElementForm | ||
</div> |
Oops, something went wrong.