-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
innomedia
committed
Jan 13, 2020
1 parent
a784f99
commit 583fa82
Showing
9 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,7 @@ | ||
--- | ||
Name: thermotex | ||
--- | ||
|
||
SilverStripe\SiteConfig\SiteConfig: | ||
extensions: | ||
- GDPRSiteConfigExtension |
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,16 @@ | ||
{ | ||
"name":"innomedia/GDPR", | ||
"description": "Silverstripe 4 GDPR", | ||
"authors": [ | ||
{ | ||
"name":"Innomedia AG", | ||
"email": "bk@innomedia.de" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"GDPR\\": "src/" | ||
} | ||
} | ||
} | ||
|
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,27 @@ | ||
<?php | ||
use SilverStripe\Core\Extension; | ||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\SiteConfig\SiteConfig; | ||
class GDPRFormPageExtension extends Extension | ||
{ | ||
// Add $this->extend('updateFormWithGDPRFields', $fields,$requirements); | ||
// To Form after all Fields have been added | ||
public function updateFormWithGDPRFields($fields,$requirements) | ||
{ | ||
$siteconfig = SiteConfig::get()->first(); | ||
if($siteconfig->FormularDatenschutztext != "") | ||
{ | ||
$fields->push($GDPRField = CheckboxField::create( | ||
'DataProtection', | ||
'DataProtection' | ||
)); | ||
if($siteconfig->ExtraCSS != "") | ||
{ | ||
$GDPRField->addExtraClass($siteconfig->ExtraCSS); | ||
} | ||
$GDPRField->setTemplate("GDPRCheckboxField"); | ||
$GDPRField->setFieldHolderTemplate("GDPRFieldHolder"); | ||
$requirements->addRequiredField("DataProtection"); | ||
} | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\ORM\DataExtension; | ||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; | ||
use SilverStripe\Forms\TextField; | ||
|
||
class GDPRSiteConfigExtension extends DataExtension | ||
{ | ||
/** | ||
* Database fields | ||
* @var array | ||
*/ | ||
private static $db = array( | ||
'FormularDatenschutztext' => 'HTMLText', | ||
'ExtraCSS' =>'Text' | ||
); | ||
/** | ||
* Update Fields | ||
* @return FieldList | ||
*/ | ||
public function updateCMSFields(FieldList $fields) | ||
{ | ||
$owner = $this->owner; | ||
$fields->addFieldToTab( | ||
'Root.FormularDatenschutz', | ||
HtmlEditorField::create( | ||
'FormularDatenschutztext', | ||
'Formular Datenschutz Text' | ||
) | ||
); | ||
$fields->addFieldToTab( | ||
'Root.FormularDatenschutz', | ||
TextField::create( | ||
'ExtraCSS', | ||
'CSS' | ||
) | ||
); | ||
return $fields; | ||
} | ||
} |
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,70 @@ | ||
<?php | ||
|
||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\UserForms\Model\EditableFormField; | ||
|
||
if (!class_exists(EditableFormField::class)) { | ||
return; | ||
} | ||
/** | ||
* EditableCheckbox | ||
* | ||
* A user modifiable checkbox on a UserDefinedForm | ||
* | ||
* @package userforms | ||
*/ | ||
|
||
class GPDREditableCheckbox extends EditableFormField | ||
{ | ||
private static $singular_name = 'Datenschutz Feld'; | ||
|
||
private static $plural_name = 'Datenschutz Felder'; | ||
|
||
protected $jsEventHandler = 'click'; | ||
|
||
private static $db = [ | ||
'CheckedDefault' => 'Boolean' // from CustomSettings | ||
]; | ||
|
||
private static $table_name = 'EditableDatenschutzCheckbox'; | ||
|
||
/** | ||
* @return FieldList | ||
*/ | ||
public function getCMSFields() | ||
{ | ||
$fields = parent::getCMSFields(); | ||
|
||
$fields->replaceField('Default', CheckboxField::create( | ||
"CheckedDefault", | ||
_t('SilverStripe\\UserForms\\Model\\EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?') | ||
)); | ||
|
||
return $fields; | ||
} | ||
|
||
public function getFormField() | ||
{ | ||
$field = CheckboxField::create($this->Name, $this->Title ?: false, $this->CheckedDefault) | ||
->setFieldHolderTemplate("GDPRFieldHolder") | ||
->setTemplate("GDPRCheckboxField"); | ||
|
||
$this->doUpdateFormField($field); | ||
|
||
return $field; | ||
} | ||
|
||
public function getValueFromData($data) | ||
{ | ||
$value = (isset($data[$this->Name])) ? $data[$this->Name] : false; | ||
|
||
return ($value) | ||
? _t('SilverStripe\\UserForms\\Model\\EditableFormField.YES', 'Yes') | ||
: _t('SilverStripe\\UserForms\\Model\\EditableFormField.NO', 'No'); | ||
} | ||
|
||
public function isCheckBoxField() | ||
{ | ||
return true; | ||
} | ||
} |
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,31 @@ | ||
<div class="contactGDPR"> | ||
<input $AttributesHTML /> | ||
<label>{$SiteConfig.FormularDatenschutztext}</label> | ||
</div> | ||
<style> | ||
.contactGDPR | ||
{ | ||
margin-top:20px; | ||
} | ||
.contactGDPR label | ||
{ | ||
display:inline-block !important; | ||
position: relative; | ||
top:-3px; | ||
width: calc(100% - 40px); | ||
text-transform: none; | ||
} | ||
.contactGDPR label p:last-child | ||
{ | ||
margin-bottom:0; | ||
} | ||
.contactGDPR input.checkbox | ||
{ | ||
height:auto !important; | ||
width:30px !important; | ||
display:inline-block !important; | ||
float:left; | ||
position: relative; | ||
top:-3px; | ||
} | ||
</style> |
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 id="$HolderID" class="field $SiteConfig.ExtraCSS"> | ||
$Field | ||
</div> |
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,33 @@ | ||
<div class="contactGDPR"> | ||
<input $AttributesHTML<% if $RightTitle %>aria-describedby="{$Name}_right_title" <% end_if %>/> | ||
<label>{$SiteConfig.FormularDatenschutztext}</label> | ||
</div> | ||
<style> | ||
.contactGDPR | ||
{ | ||
margin-top:20px; | ||
} | ||
.contactGDPR label | ||
{ | ||
display:inline-block; | ||
position: relative; | ||
top:-3px; | ||
width: calc(100% - 40px); | ||
text-transform: none; | ||
padding-left:30px !important; | ||
} | ||
.contactGDPR label p:last-child | ||
{ | ||
margin-bottom:0; | ||
} | ||
.contactGDPR input.checkbox | ||
{ | ||
height:auto !important; | ||
width:30px !important; | ||
display:inline-block !important; | ||
margin-left:0; | ||
float:left; | ||
position:relative !important; | ||
top:-3px; | ||
} | ||
</style> |