Commit 084f8d34 authored by Dirk Wildt's avatar Dirk Wildt
Browse files

[FEATURE] EXT:copyright: configurable properties #1152

parent 199aba46
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
* #v1152: [FEATURE] EXT:copyright: configurable properties
New files:
* Classes/Backend
* Extensionmanager.php
* Extensions/Metadata.php
* Documentation
* Administrators/Configuration
* Index.rst
* copyright_backend_04.png
* Credits/Index.rst
* Classes/Backend/Extensions/Metadata.php
* Configuration/TCA/Overrides
* sys_file_metadata
* 087
* CopyrightIsRequired.php
* CopyrightWiRTE.php
* Default
* CopyrightIsRequired.php
* CopyrightWiRTE.php
* sys_file_metadata.php
* Documentation/Administrators/Configuration
* Index.rst
* copyright_backend_04.png
* ext_conf_template.txt
0.0.1
......
......@@ -37,178 +37,29 @@ use Verdigado\Copyright\Backend\Extensionmanager;
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()
static public function CopyrightWiRTE()
{
$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;
$CopyrightWiRTE = Extensionmanager::getProperty( 'CopyrightWiRTE' );
return $CopyrightWiRTE;
}
/**
* @access private
* @access public
* @return void
* @version 0.0.1
* @since 0.0.1
*/
static private function _initVars()
static public function CopyrightIsRequired()
{
self::$csvHostsEnabled = Extensionmanager::getProperty( 'hostsEnabled' );
self::$csvHostsDisabled = Extensionmanager::getProperty( 'hostsDisabled' );
$CopyrightIsRequired = Extensionmanager::getProperty( 'CopyrightIsRequired' );
return $CopyrightIsRequired;
}
}
<?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 XXXMetadata_Hosts
{
/**
* @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,21 +7,30 @@ if( !defined( 'TYPO3_MODE' ) )
die( 'Access denied.' );
}
if( \Verdigado\Copyright\Backend\Extensions\Metadata::ExtCopyrightIsDisabled() )
if( \Verdigado\Copyright\Backend\Extensions\Metadata::CopyrightWiRTE() )
{
return;
switch( TRUE )
{
case(Typo3VersionUtility::isSmallerThan100()):
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/sys_file_metadata/087/CopyrightWiRTE.php' );
break;
default:
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/sys_file_metadata/Default/CopyrightWiRTE.php' );
break;
}
}
/* * ****************************************************************************
* TCA Override
* **************************************************************************** */
switch( TRUE )
// Order: CopyrightIsRequired must be below CopyrightWiRTE!
if( \Verdigado\Copyright\Backend\Extensions\Metadata::CopyrightIsRequired() )
{
case(Typo3VersionUtility::isSmallerThan100()):
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/087/sys_file_metadata.php' );
break;
default:
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/Default/sys_file_metadata.php' );
break;
}
\ No newline at end of file
switch( TRUE )
{
case(Typo3VersionUtility::isSmallerThan100()):
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/sys_file_metadata/087/CopyrightIsRequired.php' );
break;
default:
require( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'copyright' ) . 'Configuration/TCA/Overrides/sys_file_metadata/Default/CopyrightIsRequired.php' );
break;
}
}
<?php
$GLOBALS[ 'TCA' ][ 'sys_file_metadata' ][ 'columns' ][ 'copyright' ][ 'config' ][ 'eval' ] = 'required';
......@@ -6,6 +6,5 @@ $GLOBALS[ 'TCA' ][ 'sys_file_metadata' ][ 'columns' ][ 'copyright' ][ 'config' ]
'type' => 'text',
'cols' => 40,
'rows' => 3,
'eval' => 'required',
'enableRichtext' => true,
];
<?php
$GLOBALS[ 'TCA' ][ 'sys_file_metadata' ][ 'columns' ][ 'copyright' ][ 'config' ][ 'eval' ] = 'required';
......@@ -6,7 +6,6 @@ $GLOBALS[ 'TCA' ][ 'sys_file_metadata' ][ 'columns' ][ 'copyright' ][ 'config' ]
'type' => 'text',
'cols' => 40,
'rows' => 3,
'eval' => 'required',
'fieldControl' => [
'fullScreenRichtext' => [
'disabled' => '',
......
......@@ -19,28 +19,15 @@ 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.
Copyright reguired
------------------
You setup this property in the extension manager.
Copyright in the Backend-Form is required. This isn't recommended.
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.
Rich-Text-Editor
-----------------
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
Copyright field will extended with the Rich-Text-Editor.
Users can use the link wizard. A link will rendered in the frontend,
all other HTML tags will stripped.
\ 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 =
# cat=Copyright//101; type=boolean; label= Required:Copyright is required. This isn't recommended.
CopyrightIsRequired =
# cat=Copyright//102; type=boolean; label= Rich-Text-Editor:Copyright field will extended with the Rich-Text-Editor. Users can use the link wizard. A link will rendered in the frontend, all other HTML tags will stripped.
CopyrightWiRTE = 1
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