14 Commits

10 changed files with 106 additions and 122 deletions

View File

@ -1,5 +1,5 @@
{ {
"name":"cgoit/contao-aeo-bundle", "name":"cgo-it/contao-aeo-bundle",
"description":"Contao 4 Advanced eMail Obfuscation Bundle", "description":"Contao 4 Advanced eMail Obfuscation Bundle",
"keywords":["contao","aeo","bundle"], "keywords":["contao","aeo","bundle"],
"type":"contao-bundle", "type":"contao-bundle",
@ -14,12 +14,12 @@
], ],
"support":{ "support":{
"issues":"https://git.cgo-it.de/contao/aeo/issues", "issues":"https://git.cgo-it.de/contao/aeo/issues",
"source":"https://git.cgo-it.de/contao/aeo", "source":"https://git.cgo-it.de/contao/aeo.git",
"forum":"https://community.contao.org/de/showthread.php?31684-Advanced-eMail-Obfuscation" "forum":"https://community.contao.org/de/showthread.php?31684-Advanced-eMail-Obfuscation"
}, },
"require":{ "require":{
"php": ">=5.6.0", "php": ">=7.0.0",
"contao/core-bundle": "~4.3" "contao/core-bundle": "~4.5"
}, },
"require-dev": { "require-dev": {
"contao/manager-plugin": "^2.0" "contao/manager-plugin": "^2.0"
@ -43,9 +43,6 @@
] ]
}, },
"extra": { "extra": {
"branch-alias": { "contao-manager-plugin": "cgoIT\\aeo\\ContaoManagerPlugin"
"dev-develop": "3.6.x-dev"
},
"contao-manager-plugin": "cgoIT\\aeo\\ContaoManager\\Plugin"
} }
} }

View File

@ -7,7 +7,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
/** /**
* Configures the Contao aeo bundle. * Configures the Contao aeo bundle.
* *
* @author Carsten G<EFBFBD>tzinger * @author Carsten Götzinger
*/ */
class CgoITAeoBundle extends Bundle class CgoITAeoBundle extends Bundle
{ {

View File

@ -1,7 +1,8 @@
<?php <?php
namespace cgoIT\aeo\ContaoManager; namespace cgoIT\aeo;
use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
@ -9,9 +10,9 @@ use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
/** /**
* Plugin for the Contao Manager. * Plugin for the Contao Manager.
* *
* @author Carsten Götzinger * @author Carsten Götzinger
*/ */
class Plugin implements BundlePluginInterface class ContaoManagerPlugin implements BundlePluginInterface
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -19,10 +20,9 @@ class Plugin implements BundlePluginInterface
public function getBundles(ParserInterface $parser) public function getBundles(ParserInterface $parser)
{ {
return [ return [
BundleConfig::create('cgoIT\aeo\CgoITAeoBundle') BundleConfig::create(CgoITAeoBundle::class)
->setLoadAfter(['Contao\CoreBundle\ContaoCoreBundle']) ->setLoadAfter([ContaoCoreBundle::class])
->setLoadAfter(['*']) ->setReplace(['aeo']),
->setReplace(['aeo']);
]; ];
} }
} }

View File

@ -36,12 +36,6 @@ namespace cgoIT\aeo;
class AeoJavaScript class AeoJavaScript
{ {
/**
* Current object instance (Singleton)
* @var Cache
*/
protected static $objInstance;
/** /**
* Template * Template
* @var string * @var string
@ -59,7 +53,7 @@ class AeoJavaScript
*/ */
final private function __clone() {} final private function __clone() {}
public function getContent($folder, $rot13 = true) { public static function getContent($folder, $rot13 = true) {
$Template = new \FrontendTemplate(self::$strTemplate); $Template = new \FrontendTemplate(self::$strTemplate);
$Template->rot13 = $rot13; $Template->rot13 = $rot13;
$Template->folder = $folder; $Template->folder = $folder;
@ -67,18 +61,6 @@ class AeoJavaScript
$Template->tooltip_js_off = $GLOBALS['TL_LANG']['aeo']['tooltip_no_js']; $Template->tooltip_js_off = $GLOBALS['TL_LANG']['aeo']['tooltip_no_js'];
return $Template->parse(); return $Template->parse();
} }
/**
* Instantiate a new cache object and return it (Factory)
* @return Cache
*/
public static function getInstance() {
if (!is_object(self::$objInstance)) {
self::$objInstance = new self();
}
return self::$objInstance;
}
} }
?> ?>

View File

@ -67,7 +67,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['aeo_virtual_path'] = array
'default' => '', 'default' => '',
'exclude' => true, 'exclude' => true,
'inputType' => 'text', 'inputType' => 'text',
'eval' => array('decodeEntities'=>true, 'mandatory'=>true, 'tl_class'=>'w50', 'trailingSlash'=>false) 'eval' => array('decodeEntities'=>true, 'mandatory'=>true, 'tl_class'=>'w50', 'rgxp'=>'alias')
); );
$GLOBALS['TL_DCA']['tl_settings']['fields']['aeo_obfuscation_method'] = array $GLOBALS['TL_DCA']['tl_settings']['fields']['aeo_obfuscation_method'] = array
@ -100,14 +100,14 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['aeo_jump_to_no_js'] = array
'default' => '', 'default' => '',
'exclude' => true, 'exclude' => true,
'inputType' => 'checkbox', 'inputType' => 'checkbox',
'eval' => array(doNotCopy => true, multiple => false, 'tl_class' => 'm12', 'style' => 'width:50px; padding-bottom: 3px;', 'includeBlankOption' => true), 'eval' => array('doNotCopy' => true, 'multiple' => false, 'tl_class' => 'm12', 'style' => 'width:50px; padding-bottom: 3px;', 'includeBlankOption' => true),
), ),
'aeo_language' => array( 'aeo_language' => array(
'label' => &$GLOBALS['TL_LANG']['tl_settings']['aeo_language'], 'label' => &$GLOBALS['TL_LANG']['tl_settings']['aeo_language'],
'exclude' => true, 'exclude' => true,
'inputType' => 'select', 'inputType' => 'select',
'options_callback' => array("tl_settings_aeo", "getAvailableLanguages"), 'options_callback' => array("tl_settings_aeo", "getAvailableLanguages"),
'eval' => array(doNotCopy => true, 'mandatory' => true, 'tl_class' => 'm12', 'style' => 'width:210px; padding-bottom: 3px; margin-top: 3px;', 'includeBlankOption' => true), 'eval' => array('doNotCopy' => true, 'mandatory' => true, 'tl_class' => 'm12', 'style' => 'width:210px; padding-bottom: 3px; margin-top: 3px;', 'includeBlankOption' => true),
), ),
'aeo_redirecturl' => array( 'aeo_redirecturl' => array(
'label' => &$GLOBALS['TL_LANG']['tl_settings']['aeo_redirecturl'], 'label' => &$GLOBALS['TL_LANG']['tl_settings']['aeo_redirecturl'],
@ -211,7 +211,6 @@ class tl_settings_aeo extends \Backend
*/ */
public function checkForModuleOrCE($varVal, \DataContainer $dc) { public function checkForModuleOrCE($varVal, \DataContainer $dc) {
$this->import('\\Database', 'Database'); $this->import('\\Database', 'Database');
$this->import('aeo\\AeoUtil', 'AeoUtil');
$arrValue = deserialize($varVal); $arrValue = deserialize($varVal);
foreach ($arrValue as $key => $value) { foreach ($arrValue as $key => $value) {

View File

@ -30,6 +30,9 @@
namespace cgoIT\aeo; namespace cgoIT\aeo;
use cgoIT\aeo\AeoUtil;
use cgoIT\aeo\AeoJavaScript;
/** /**
* Class AeoFrontendUtil * Class AeoFrontendUtil
*/ */
@ -76,6 +79,8 @@ class AeoFrontendUtil extends \Frontend {
*/ */
protected $aeo; protected $aeo;
protected $aeoUtil;
/** /**
* Initialize the object * Initialize the object
* @param array * @param array
@ -85,7 +90,7 @@ class AeoFrontendUtil extends \Frontend {
if (TL_MODE == 'FE') { if (TL_MODE == 'FE') {
global $objPage; global $objPage;
$this->import('aeo\\AeoUtil', 'AeoUtil'); $this->aeoUtil = new AeoUtil();
if ($GLOBALS['TL_CONFIG']['aeo_replace_standard_obfuscation'] === true) { if ($GLOBALS['TL_CONFIG']['aeo_replace_standard_obfuscation'] === true) {
$this->use_rot_13 = $GLOBALS['TL_CONFIG']['aeo_use_rot_13']; $this->use_rot_13 = $GLOBALS['TL_CONFIG']['aeo_use_rot_13'];
@ -103,7 +108,7 @@ class AeoFrontendUtil extends \Frontend {
$folder .= $objPage->rootLanguage.'/'; $folder .= $objPage->rootLanguage.'/';
} }
if (in_array('i18nl10n', $this->Config->getActiveModules())) { if (in_array('i18nl10n', $this->Config->getActiveModules())) {
$this->AeoUtil->fixupCurrentLanguage(); $this->aeoUtil->fixupCurrentLanguage();
if ($GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'url') { if ($GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'url') {
$folder .= $GLOBALS['TL_LANGUAGE'] . '/'; $folder .= $GLOBALS['TL_LANGUAGE'] . '/';
} }
@ -123,7 +128,7 @@ class AeoFrontendUtil extends \Frontend {
if (strlen($GLOBALS['TL_CONFIG']['urlSuffix']) > 0) { if (strlen($GLOBALS['TL_CONFIG']['urlSuffix']) > 0) {
if (in_array('i18nl10n', $this->Config->getActiveModules()) && if (in_array('i18nl10n', $this->Config->getActiveModules()) &&
$GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') { $GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') {
$this->AeoUtil->fixupCurrentLanguage(); $this->aeoUtil->fixupCurrentLanguage();
$urlSuffix .= '.'.$GLOBALS['TL_LANGUAGE']; $urlSuffix .= '.'.$GLOBALS['TL_LANGUAGE'];
} }
$urlSuffix .= $GLOBALS['TL_CONFIG']['urlSuffix']; $urlSuffix .= $GLOBALS['TL_CONFIG']['urlSuffix'];
@ -186,7 +191,7 @@ class AeoFrontendUtil extends \Frontend {
{ {
global $objPage; global $objPage;
$objPage2 = $this->getPageDetails($objPage->id); $objPage2 = $this->getPageDetails($objPage->id);
$redirectPageId = $this->AeoUtil->getRedirectPageForLanguage(deserialize($this->jump_to_no_js), $objPage2->rootLanguage); $redirectPageId = $this->aeoUtil->getRedirectPageForLanguage(deserialize($this->jump_to_no_js), $objPage2->rootLanguage);
if (TL_MODE == 'FE' && $this->replace_standard_obfuscation && $objPage2->id != $redirectPageId) { if (TL_MODE == 'FE' && $this->replace_standard_obfuscation && $objPage2->id != $redirectPageId) {
$strContent = $this->aeoReplaceInsertTags($strContent); $strContent = $this->aeoReplaceInsertTags($strContent);
@ -236,8 +241,8 @@ class AeoFrontendUtil extends \Frontend {
->execute($objPage2->layout) ->execute($objPage2->layout)
->fetchAssoc(); ->fetchAssoc();
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/zaeo/public/js/onReadyAeo.min.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitaeo/js/onReadyAeo.min.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/zaeo/public/js/aeo.min.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitaeo/js/aeo.min.js|static';
} }
/** /**
@ -491,11 +496,8 @@ class Aeo extends \System {
} }
function dropJS() { function dropJS() {
$this->import('aeo\\AeoJavaScript', 'AeoJavaScript'); $strContentJs = AeoJavaScript::getContent(str_replace("/", "\/", $this->folder), $this->rot13);
$strContentJs = $this->AeoJavaScript->getContent(str_replace("/", "\/", $this->folder), $this->rot13);
$strContentJs = "\n<script type=\"text/javascript\">\n$strContentJs\n</script>\n"; $strContentJs = "\n<script type=\"text/javascript\">\n$strContentJs\n</script>\n";
// $strContentJs .= "<script src=\"system/modules/zaeo/public/js/onReadyAeo.js\" type=\"text/javascript\"></script>";
// $strContentJs .= "<script src=\"system/modules/zaeo/public/js/aeo.js\" type=\"text/javascript\"></script>";
return $strContentJs; return $strContentJs;
} }

View File

@ -30,18 +30,22 @@
namespace cgoIT\aeo; namespace cgoIT\aeo;
use cgoIT\aeo\AeoUtil;
/** /**
* Class AeoRedirectUtil * Class AeoRedirectUtil
*/ */
class AeoRedirectUtil extends \Frontend { class AeoRedirectUtil extends \Frontend {
protected $aeoUtil;
/** /**
* Initialize the object * Initialize the object
* @param array * @param array
*/ */
public function __construct($arrAttributes=false) { public function __construct($arrAttributes=false) {
parent::__construct($arrAttributes); parent::__construct($arrAttributes);
$this->import('aeo\\AeoUtil', 'AeoUtil'); $this->aeoUtil = new AeoUtil();
} }
/** /**
@ -129,7 +133,7 @@ class AeoRedirectUtil extends \Frontend {
$strObfuscatedValues = $arrFragments[3]; $strObfuscatedValues = $arrFragments[3];
if (in_array('i18nl10n', $this->Config->getActiveModules()) && if (in_array('i18nl10n', $this->Config->getActiveModules()) &&
$GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') { $GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') {
$this->AeoUtil->fixupCurrentLanguage(); $this->aeoUtil->fixupCurrentLanguage();
$strObfuscatedValues = str_replace('.'.$GLOBALS['TL_LANGUAGE'], '', $strObfuscatedValues); $strObfuscatedValues = str_replace('.'.$GLOBALS['TL_LANGUAGE'], '', $strObfuscatedValues);
} }
$arrObfuscatedValues = explode('+', $strObfuscatedValues, 5); $arrObfuscatedValues = explode('+', $strObfuscatedValues, 5);
@ -219,7 +223,7 @@ class AeoRedirectUtil extends \Frontend {
} }
if (in_array('i18nl10n', $this->Config->getActiveModules()) && if (in_array('i18nl10n', $this->Config->getActiveModules()) &&
$GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') { $GLOBALS['TL_CONFIG']['i18nl10n_urlParam'] == 'alias') {
$this->AeoUtil->fixupCurrentLanguage(); $this->aeoUtil->fixupCurrentLanguage();
$strUrl = str_replace('.'.$GLOBALS['TL_LANGUAGE'], '', $strUrl); $strUrl = str_replace('.'.$GLOBALS['TL_LANGUAGE'], '', $strUrl);
} }
return $strUrl; return $strUrl;