Commit c7c31f0a authored by Dirk Wildt's avatar Dirk Wildt
Browse files

[FEATURE] Support for multi domain website #1151

parent 89cd138f
Pipeline #199 failed with stages
in 0 seconds
0.0.2
210513
Author: Dirk Wildt (verdigado eG), support@verdigado.com
* #v1151: [FEATURE] Support for multi domain website
Affected files:
* Configuration/TCA/Overrides/sys_file_metadata.php
* Documentation
* Administrators/Index.rst
* Index.rst
* Support/Index.rst
New files:
* Classes/Backend
* Extensionmanager.php
* Extensions/Metadata.php
* Documentation
* Administrators/Configuration
* Index.rst
* copyright_backend_04.png
* Credits/Index.rst
* ext_conf_template.txt
0.0.1
210511
Author: Dirk Wildt (verdigado eG), support@verdigado.com
......
<?php
namespace Verdigado\Copyright\Backend;
use Verdigado\Copyright\Utility\Typo3VersionUtility;
/* * *************************************************************
* Copyright notice
*
* (c) 2021 - Dirk Wildt (verdigado eG), support@verdigado.com
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */
/**
* @author Dirk Wildt (verdigado eG), support@verdigado.com
*
* @version 0.0.1
* @since 0.0.1
*/
class Extensionmanager
{
/**
* @var mixed
*/
static private $_extConf = '';
/**
* @var mixed
*/
static private $_wasSerialised = false;
/**
* _initExtConf
*
* @params string $extKey
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _initExtConf( $extKey )
{
switch( TRUE )
{
case(Typo3VersionUtility::Get() < 10000000):
self::$_extConf = $GLOBALS[ 'TYPO3_CONF_VARS' ][ 'EXT' ][ 'extConf' ][ $extKey ];
break;
case(Typo3VersionUtility::Get() >= 10000000):
default:
self::$_extConf = $GLOBALS[ 'TYPO3_CONF_VARS' ][ 'EXTENSIONS' ][ $extKey ];
break;
}
}
/**
* _ExtConfSerialize()
*
* @params string $extKey
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _ExtConfSerialize( $extKey )
{
switch( self::$_wasSerialised && Typo3VersionUtility::Get() < 10000000 )
{
case(true):
self::$_extConf = serialize( self::$_extConf );
break;
case(false):
// do nothing
break;
}
switch( TRUE )
{
case(Typo3VersionUtility::Get() < 10000000):
$GLOBALS[ 'TYPO3_CONF_VARS' ][ 'EXT' ][ 'extConf' ][ $extKey ] = self::$_extConf;
break;
case(Typo3VersionUtility::Get() >= 10000000):
default:
$GLOBALS[ 'TYPO3_CONF_VARS' ][ 'EXTENSIONS' ][ $extKey ] = self::$_extConf;
break;
}
return;
}
/**
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _ExtConfUnserialize()
{
if( !is_array( self::$_extConf ) )
{
self::$_extConf = unserialize( self::$_extConf );
self::$_wasSerialised = true;
}
}
/**
* getProperty()
*
* @param string $key: Key of the extension manager
* @param string $extKey: extension key
* @return string $value: corresponding value
* @access private
* @version 0.0.1
* @since 0.0.1
*/
static public function getProperty( $key, $extKey = 'copyright' )
{
self::_initExtConf( $extKey );
self::_ExtConfUnserialize();
$value = self::$_extConf[ $key ];
self::_ExtConfSerialize( $extKey );
return $value;
}
/**
* setProperty()
*
* @param string $key: Key of the extension manager
* @param string $value:
* @param string $extKey: extension key
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
static public function setProperty( $key, $value, $extKey = 'copyright' )
{
self::_initExtConf( $extKey );
self::_ExtConfUnserialize();
self::$_extConf[ $key ] = $value;
self::_ExtConfSerialize( $extKey );
}
}
<?php
namespace Verdigado\Copyright\Backend\Extensions;
use Verdigado\Copyright\Backend\Extensionmanager;
/* * *************************************************************
* Copyright notice
*
* (c) 2021 - Dirk Wildt (verdigado eG), support@verdigado.com
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */
/**
* @author Dirk Wildt (verdigado eG), support@verdigado.com
*
* @version 0.0.1
* @since 0.0.1
*/
class Metadata
{
/**
* @var string
*/
private static $csvHostsEnabled = '';
/**
* @var string
*/
private static $csvHostsDisabled = '';
/**
* @var boolean
*/
private static $currHostIsEnabled = '';
/**
* @var boolean
*/
private static $currHostIsDisabled = '';
/**
* @access public
* @return boolean
* @version 0.0.1
* @since 0.0.1
*/
static public function ExtCopyrightIsDisabled()
{
if( TYPO3_MODE != 'BE' )
{
return TRUE;
}
self::_init();
if( self::_hostsNotSet() )
{
$extCopyrightIsDisabled = FALSE;
return $extCopyrightIsDisabled;
}
$extCopyrightIsDisabled = !self::_hostIsEnabled();
// var_dump(__METHOD__, __LINE__, $extCopyrightIsDisabled);
// die();
return $extCopyrightIsDisabled;
}
/**
* @access private
* @return boolean
* @version 0.0.1
* @since 0.0.1
*/
static private function _hostIsEnabled()
{
switch( TRUE )
{
case(self::$currHostIsEnabled ):
// current host is enabled
return TRUE;
case(self::$csvHostsEnabled ):
// current host isn't in the list of enabled hosts
return FALSE;
case(self::$currHostIsDisabled ):
// current host is disabled
return FALSE;
default:
return TRUE;
}
}
/**
* @access private
* @return boolean
* @version 0.0.1
* @since 0.0.1
*/
static private function _hostsNotSet()
{
switch( TRUE )
{
case(!empty( self::$csvHostsEnabled )):
case(!empty( self::$csvHostsDisabled )):
return FALSE;
default:
return TRUE;
}
}
/**
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _init()
{
self::_initVars();
self::_initCurrHostIsEnabled();
self::_initCurrHostIsDisabled();
}
/**
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _initCurrHostIsDisabled()
{
$csvHostsDisabled = Extensionmanager::getProperty( 'hostsDisabled' );
//var_dump(__METHOD__, __LINE__, $csvHostsDisabled);
// Any host isn't set, current host isn't disabled
if( empty( $csvHostsDisabled ) )
{
self::$currHostIsDisabled = FALSE;
return;
}
$csvHostsDisabled = str_replace( ' ', NULL, $csvHostsDisabled );
$arrHostsDisabled = explode( ',', $csvHostsDisabled );
// Current host is in the list of disabled hosts
if( in_array( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $arrHostsDisabled ) )
{
self::$currHostIsDisabled = TRUE;
return;
}
// Current host isn't in the list of enabled hosts
self::$currHostIsDisabled = FALSE;
}
/**
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _initCurrHostIsEnabled()
{
$csvHostsEnabled = Extensionmanager::getProperty( 'hostsEnabled' );
// Any host isn't set, current host isn't enabled
if( empty( $csvHostsEnabled ) )
{
self::$currHostIsEnabled = FALSE;
return;
}
$csvHostsEnabled = str_replace( ' ', NULL, $csvHostsEnabled );
$arrHostsEnabled = explode( ',', $csvHostsEnabled );
// Current host is in the list of enabled hosts
if( in_array( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $arrHostsEnabled ) )
{
self::$currHostIsEnabled = TRUE;
return;
}
// Current host isn't in the list of enabled hosts
self::$currHostIsEnabled = FALSE;
}
/**
* @access private
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _initVars()
{
self::$csvHostsEnabled = Extensionmanager::getProperty( 'hostsEnabled' );
self::$csvHostsDisabled = Extensionmanager::getProperty( 'hostsDisabled' );
}
}
......@@ -7,6 +7,11 @@ if( !defined( 'TYPO3_MODE' ) )
die( 'Access denied.' );
}
if( \Verdigado\Copyright\Backend\Extensions\Metadata::ExtCopyrightIsDisabled() )
{
return;
}
/* * ****************************************************************************
* TCA Override
* **************************************************************************** */
......
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../../Includes.txt
.. _administrators_configuration:
.. figure:: copyright_backend_04.png
:width: 400px
:alt: Configure Extension copyright
Configure Extension copyright
Configuration
=============
**There is no need for any configuration. But** if you are hosting a **multi domain website**,
you can setup up for each domain, if a user has to enter a value in the copyright field of the file metadata.
You setup this property in the extension manager.
Enabling hosts
--------------
**All hosts are enabled by default.** But if you enable one or more hosts, all
other hosts are disabled. If both fields enabled and disabled are empty,
copyright is enabled on all hosts.
Example: with-copyright.myhost.de, myotherhost.com
See illustration below.
Disabling hosts
---------------
Disable a host will have an effect only, if no host isn't enabled above.
Example: without-copyright.myhost.de, another-domain.com
See illustration below.
\ No newline at end of file
......@@ -19,4 +19,5 @@ Administrators
:titlesonly:
Setup/Index
Configuration/Index
Debugging/Index
\ No newline at end of file
.. ==================================================
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.
.. include:: ../Includes.txt
.. _credits:
Credits
=======
The initial release is being developed by verdigado eG.
The cooperative verdigado is a central service provider for all divisions of
BÜNDNIS 90 / DIE GRÜNEN.
The cooperative develops open source software. Her projects include the
following extensions among others:
* launch, launchstart, launchstartgreen
* org
* slick
* start, startgreen
* xblog
.. figure:: verdigado_Logo.png
:width: 300px
:alt: The verigado logo
\ No newline at end of file
......@@ -62,4 +62,5 @@ Copyright
Introduction/Index
Users/Index
Administrators/Index
Credits/Index
Support/Index
......@@ -9,28 +9,22 @@
.. _support:
.. figure:: verdigado_Logo.png
:width: 600px
:alt: The verigado logo
Support
=======
Credits and Support
===================
Divisons of BÜNDNIS 90 / DIE GRÜNEN
-----------------------------------
This extension is being developed by verdigado eG. The cooperative verdigado is
a central service provider for all business areas of BÜNDNIS 90 / DIE GRÜNEN.
The cooperative develops open source software. Her projects include the
following extensions:
If you need support, please send an e-mail to support@verdigado.com
* launch, launchstart, launchstartgreen
If you like to know more about verdigado eG please visit https://verdigado.com
* slick
* start, startgreen
Others
------
* xblog
If you need support, please send an e-mail to mail@die-netzmacher.de
If you need support, please send an e-mail to support@verdigado.com
If you like to know more about Die Netzmacher please visit https://die-netzmacher.de
If you like to know more about verdigado eG please visit https://verdigado.com
\ No newline at end of file
# cat=Hosts//101; type=string; label= Enabled:Enable hosts (csv-list). If you have one or more hosts enabled, all other hosts are disabled. If both fields enabled and disabled are empty, copyright is enabled on all hosts. Example: myhost.de, myotherhost.com
hostsEnabled =
# cat=Hosts//102; type=string; label= Disabled:Disable hosts (csv-list). This will have an effect only, if no host isn't enabled above. If both fields enabled and disabled are empty, copyright is enabled on all hosts. Example: myhost.de, myotherhost.com
hostsDisabled =
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment