Skip to content

Commit

Permalink
Compatibility with TYPO3 v10.4x, UI changes, updated documentation, B…
Browse files Browse the repository at this point in the history
…ug fix
  • Loading branch information
ghanshyamgohel committed Apr 29, 2020
1 parent ef9ab4f commit 5e19867
Show file tree
Hide file tree
Showing 199 changed files with 567 additions and 89,427 deletions.
86 changes: 47 additions & 39 deletions Classes/Controller/PrivacyConfigController.php
Expand Up @@ -18,6 +18,7 @@
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Annotation\Inject;

class PrivacyConfigController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
Expand Down Expand Up @@ -74,7 +75,7 @@ public function createAction(){
$privacyConfigModel->setDomain($domain);
$privacyConfigModel->setRootPageUid($rootPageUid);

$this->addFlashMessage('Successfully domain record has been added!', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->addFlashMessage('You have successfully added the domain record.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->privacyConfigRepository->add($privacyConfigModel);
$this->redirect('list');
}
Expand Down Expand Up @@ -138,57 +139,64 @@ public function updateAction(){

// JS external file
$jsexternal = $arguments['privacyconfig']['fileinclude']['js'];
foreach($jsexternal as $key=>$value){
$countModelObj = $garbage.$key;
$countModelObj = GeneralUtility::makeInstance('TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\FileInclude');
$jsFolderName = 'js';
$jsFileName = substr( md5( (int)$value['uid'] ), 0, 10 );

if(!empty($jsexternal)){
foreach($jsexternal as $key=>$value){
$jsFileName = '';
$countModelObj = $garbage.$key;
$countModelObj = GeneralUtility::makeInstance('TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\FileInclude');
$jsFolderName = 'js';
$jsFileName = substr( md5( (int)$value['uid'] ), 0, 10 );

$originalPath = $value['originalPath'];
$countModelObj->setOriginalPath($originalPath);
$path = $this->fetchExternal($originalPath, $jsFolderName, $jsFileName);
$countModelObj->setPath($path);

$pathUid = (int)$value['uid'];
if($pathUid){//updates
$countModelObj = $this->fileIncludeRepository->findByUid($pathUid);
$originalPath = $value['originalPath'];
$countModelObj->setOriginalPath($originalPath);
$path = $this->fetchExternal($originalPath, $jsFolderName, $jsFileName);
$countModelObj->setPath($path);

$pathUid = (int)$value['uid'];
if($pathUid){//updates
$countModelObj = $this->fileIncludeRepository->findByUid($pathUid);
$countModelObj->setOriginalPath($originalPath);
$countModelObj->setPath($path);
}

$objectStorage->attach($countModelObj);
}

$objectStorage->attach($countModelObj);
$privacyConfigModel->setJsPathExternal($objectStorage);
}
$privacyConfigModel->setJsPathExternal($objectStorage);

//DebuggerUtility::var_dump($objectStorage);exit;
// CSS external file
$objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage;
$cssexternal = $arguments['privacyconfig']['fileinclude']['css'];
foreach($cssexternal as $key=>$value){
$cssCountModelObj = GeneralUtility::makeInstance('TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\FileInclude');
$cssFolderName = 'css';
$cssFileName = substr( md5( (int)$value['uid'] ), 0, 10 );
if(!empty($cssexternal)){
foreach($cssexternal as $key=>$value){
$cssFileName = '';
$cssCountModelObj = GeneralUtility::makeInstance('TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\FileInclude');
$cssFolderName = 'css';
$cssFileName = substr( md5( (int)$value['uid'] ), 0, 10 );

$originalPath = $value['originalPath'];
$cssCountModelObj->setOriginalPath($originalPath);
$path = $this->fetchExternal($originalPath, $cssFolderName, $cssFileName);
$cssCountModelObj->setPath($path);

$pathUid = (int)$value['uid'];
if($pathUid){//updates
$cssCountModelObj = $this->fileIncludeRepository->findByUid($pathUid);
$originalPath = $value['originalPath'];
$cssCountModelObj->setOriginalPath($originalPath);
$path = $this->fetchExternal($originalPath, $cssFolderName, $cssFileName);
$cssCountModelObj->setPath($path);

$pathUid = (int)$value['uid'];
if($pathUid){//updates
$cssCountModelObj = $this->fileIncludeRepository->findByUid($pathUid);
$cssCountModelObj->setOriginalPath($originalPath);
$cssCountModelObj->setPath($path);
}

$objectStorage->attach($cssCountModelObj);
}

$objectStorage->attach($cssCountModelObj);
$privacyConfigModel->setCssPathExternal($objectStorage);
}
$privacyConfigModel->setCssPathExternal($objectStorage);


### write TS for Include library ###
$tsSourceFile = 'IncludeTs.txt.cp';$tsWritePath = 'Configuration/TypoScript/External/Domain/';
$this->writeTSFile($tsSourceFile,$tsWritePath,$privacyConfigModel);

$this->addFlashMessage('Configuration has been updated!', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->addFlashMessage('You have successfully updated the configuration.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
//DebuggerUtility::var_dump($privacyConfigModel);exit;
$this->privacyConfigRepository->update($privacyConfigModel);
$this->redirect('list');
Expand All @@ -202,7 +210,7 @@ public function updateAction(){
*/
public function deleteAction(\TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\PrivacyConfig $privacyConfig)
{
$this->addFlashMessage('Successfully domain record has been deleted', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->addFlashMessage('You have successfully deleted the domain record.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->privacyConfigRepository->remove($privacyConfig);
$this->redirect('list');
}
Expand All @@ -212,8 +220,8 @@ public function deleteAction(\TYPO3Liebhaber\CookieDataPrivacy\Domain\Model\Priv
**/
public function fetchExternal($externalFilePath, $folderName, $fileName){
if($externalFilePath){
$extPath = ExtensionManagementUtility::extPath('cookie_data_privacy');
$directory = $extPath.'Resources/Public/External/'.$folderName.'/';
$directory = GeneralUtility::getFileAbsFileName('fileadmin/cookie_data_privacy/External/'.$folderName.'/');

if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
Expand All @@ -222,7 +230,7 @@ public function fetchExternal($externalFilePath, $folderName, $fileName){
$getData = file_get_contents($externalFilePath);
file_put_contents($filenameAndPath, $getData);

$returnPath = 'EXT:cookie_data_privacy/Resources/Public/External/'.$folderName.'/'.$fileName.'.'.$folderName;
$returnPath = 'fileadmin/cookie_data_privacy/External/'.$folderName.'/'.$fileName.'.'.$folderName;
return $returnPath;
}else{
return '';
Expand Down
19 changes: 11 additions & 8 deletions Classes/Controller/ShowCaseController.php
Expand Up @@ -16,6 +16,7 @@
* ShowCaseController
*/
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Extbase\Annotation\Inject;

class ShowCaseController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
Expand Down Expand Up @@ -66,16 +67,18 @@ public function showAction()
}

$privacyConfigs = $this->privacyConfigRepository->findByRootPageUid($rootPageUid);

$formIdsString = '';
if($privacyConfigs[0]->getFormId()){
$formIdsArr = explode(',',$privacyConfigs[0]->getFormId());
array_walk($formIdsArr, function(&$value, $key) { $value = '#'.$value; } );
$formIdsString = implode(',',$formIdsArr);
if(!empty($privacyConfigs[0])){
if($privacyConfigs[0]->getFormId()){
$formIdsArr = explode(',',$privacyConfigs[0]->getFormId());
array_walk($formIdsArr, function(&$value, $key) { $value = '#'.$value; } );
$formIdsString = implode(',',$formIdsArr);
}
$this->view
->assign('privacyConfig', $privacyConfigs[0])
->assign('formIdsString', $formIdsString);
}
$this->view
->assign('privacyConfig', $privacyConfigs[0])
->assign('formIdsString', $formIdsString);

if (empty($cookie_status) || $cookie_status === 'allow') {
$this->view->assign('status', 1);
} elseif ($cookie_status === 'deny') {
Expand Down
2 changes: 2 additions & 0 deletions Classes/Domain/Model/PrivacyConfig.php
Expand Up @@ -15,6 +15,8 @@
/**
* PrivacyConfig
*/
use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;

class PrivacyConfig extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
Expand Down
9 changes: 8 additions & 1 deletion Classes/Domain/Repository/PrivacyConfigRepository.php
Expand Up @@ -17,5 +17,12 @@
*/
class PrivacyConfigRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{

public function initializeObject(){
// get the current settings
$querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
// change the default setting, whether the storage page ID is ignored by the plugins (FALSE) or not (TRUE - default setting)
$querySettings->setRespectStoragePage(FALSE);
// store the new setting(s)
$this->setDefaultQuerySettings($querySettings);
}
}
15 changes: 0 additions & 15 deletions Configuration/TypoScript/constants.ts
Expand Up @@ -40,18 +40,3 @@ plugin.tx_cookiedataprivacy_ext1 {
dataCheckbox2 = *Yes, I would like to receive information according to my request from the company GmbH and I agree that the company GmbH processes my personal data (name, e-mail address) to process my request. company GmbH only transfers the personal data to processors (for example, IT service providers). This consent can be revoked by you at any time free of charge and without giving reasons by sending an e-mail with the subject "Withdrawal" to <a href="mailto:office@domain.at">office(at)domain.at</a>.
}
}

module.tx_cookiedataprivacy_mod1 {
view {
# cat=module.tx_cookiedataprivacy_mod1/file; type=string; label=Path to template root (BE)
templateRootPath = EXT:cookie_data_privacy/Resources/Private/Backend/Templates/
# cat=module.tx_cookiedataprivacy_mod1/file; type=string; label=Path to template partials (BE)
partialRootPath = EXT:cookie_data_privacy/Resources/Private/Backend/Partials/
# cat=module.tx_cookiedataprivacy_mod1/file; type=string; label=Path to template layouts (BE)
layoutRootPath = EXT:cookie_data_privacy/Resources/Private/Backend/Layouts/
}
persistence {
# cat=module.tx_cookiedataprivacy_mod1//a; type=string; label=Default storage PID
storagePid =
}
}
17 changes: 1 addition & 16 deletions Configuration/TypoScript/setup.ts
Expand Up @@ -91,19 +91,4 @@ plugin.tx_cookiedataprivacy._CSS_DEFAULT_STYLE (
.typo3-messages .message-ok {
color:green;
}
)

# Module configuration
module.tx_cookiedataprivacy_tools_cookiedataprivacymod1 {
persistence {
storagePid = {$module.tx_cookiedataprivacy_mod1.persistence.storagePid}
}
view {
templateRootPaths.0 = EXT:cookie_data_privacy/Resources/Private/Backend/Templates/
templateRootPaths.1 = {$module.tx_cookiedataprivacy_mod1.view.templateRootPath}
partialRootPaths.0 = EXT:cookie_data_privacy/Resources/Private/Backend/Partials/
partialRootPaths.1 = {$module.tx_cookiedataprivacy_mod1.view.partialRootPath}
layoutRootPaths.0 = EXT:cookie_data_privacy/Resources/Private/Backend/Layouts/
layoutRootPaths.1 = {$module.tx_cookiedataprivacy_mod1.view.layoutRootPath}
}
}
)
24 changes: 10 additions & 14 deletions Documentation/Administrator/Index.rst
@@ -1,32 +1,28 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../Includes.txt


.. _admin-manual:
.. _adminmanual:

====================
Administrator Manual
====================

.. _admin-installation:

Installation
------------
============

To install the extension, perform the following steps:
You need to follow the steps to install the extension.

#. Download vhs dependency extension from TYPO3 Extension Repository and install the extension from extension manager.
#. Download cookie_data_privacy extension from TYPO3 Extension Repository.
#. Install the extension from extension manager.
- Download `vhs <https://extensions.typo3.org/extension/vhs>`__ dependency extension from TYPO3 Extension Repository and install the extension from extension manager.
- Download cookie_data_privacy extension from TYPO3 Extension Repository.
- Install the extension from extension manager.

.. figure:: ../Images/import_extension.png
:alt: Extension Manager

Static Templates
""""""""""""""""
================

Add cookie_data_privacy static template

Expand All @@ -35,12 +31,12 @@ Add cookie_data_privacy static template

.. important::

Default language label can be change from constants
You can change the default language label from constants.

.. _admin-configuration:

Backend Configuration
---------------------
=====================

Add your domain and root page ID to support multi-domain.

Expand Down
16 changes: 0 additions & 16 deletions Documentation/ChangeLog/Index.rst

This file was deleted.

27 changes: 12 additions & 15 deletions Documentation/Developer/Index.rst
@@ -1,19 +1,16 @@
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../Includes.txt


.. _developer:

================
Developer Manual
================

.. _condition:

TypoScript condition
--------------------
====================

A TypoScript condition to check cookie status.

Expand All @@ -26,32 +23,32 @@ A TypoScript condition to check cookie status.
.. _utility:

Utility
-------
=======

To get status of cookie in your controller/PHP file (status: allow or deny)

.. code-block:: php
use TYPO3Liebhaber\CookieDataPrivacy\Utility\CookieDataPrivacyUtility; // put this line before your controler start
use TYPO3Liebhaber\CookieDataPrivacy\Utility\CookieDataPrivacyUtility; // put this line before your controller start
$status = CookieDataPrivacyUtility::getStatus();
$status = CookieDataPrivacyUtility::getStatus();
.. _viewHelpers:

ViewHelpers
-----------
===========

To get status of cookie in your fluid template (status: allow or deny)

::
.. code-block:: php
{namespace cp=TYPO3Liebhaber\CookieDataPrivacy\ViewHelpers}
<cp:cookieDataPrivacy /> or inline {cp:cookieDataPrivacy()}
To get mandatory checkboxes for forms/newsletter/registration form etc. May multiple forms has different text, so add your text in locallang.xlf with different translateKey.
To get mandatory checkbox for contact form/newsletter/registration form etc. May multiple forms have different text, so You need to add your text in locallang.xlf with different translateKey.

::
.. code-block:: php
{namespace cp=TYPO3Liebhaber\CookieDataPrivacy\ViewHelpers}
Expand All @@ -60,10 +57,10 @@ To get mandatory checkboxes for forms/newsletter/registration form etc. May mult
.. _frontend:

Frontend
--------
========

Revoke button

::
.. code-block:: php
<button id="cookie-btn-open" class="btn btn-primary">Revoke</button>
Binary file modified Documentation/Images/add_static_template.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/Images/backend_configuration.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/Images/import_extension.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/Images/multi-domain-record.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/Images/tree-structure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e19867

Please sign in to comment.