Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,205 @@
<?php
namespace TYPO3\TgmSocialshareprivacy\Controller;
/***************************************************************
* Copyright notice
*
* (c) 2014 Paul Beck <pb@teamgeist-medien.de>, Teamgeist Medien GbR
*
* 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!
* Just always need this: \TYPO3\CMS\Core\Utility\DebugUtility::debug();
***************************************************************/
/**
*
*
* @package tgm_socialshareprivacy
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class SocialButtonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* Include helper class
*
* @var \TYPO3\TgmSocialshareprivacy\Helper\HelperFunctions
* @inject
*/
protected $helperClass;
/**
* Content Object UID
* @var Number
*/
protected $cObjUid;
/**
* socialButtonRepository
*
* @var \TYPO3\TgmSocialshareprivacy\Domain\Repository\SocialButtonRepository
* @inject
*/
protected $socialButtonRepository;
/**
* Main buttons to show
*/
protected $main_buttons;
/**
* Additional buttons to show
*/
protected $additional_buttons;
/**
* Initialize action
* Adding required header data and Javascript
*
* @return void
*/
public function initializeAction() {
/** Combine Typoscript and Flexform settings first */
$this->settings = $this->helperClass->getSettings();
/** Get the cObj UID */
$this->cObjUid = $this->helperClass->getContentObjectUid();
if ($this->cObjUid == '') {
$this->cObjUid = 1;
}
/** Get the selected social buttons (main and additional buttons) */
/** @var \TYPO3\TgmSocialshareprivacy\Domain\Model\SocialButton */
$this->main_buttons = $this->socialButtonRepository->findByUids($this->settings['main_buttons']);
/** @var \TYPO3\TgmSocialshareprivacy\Domain\Model\SocialButton */
$this->additional_buttons = $this->socialButtonRepository->findByUids($this->settings['additional_buttons']);
/** Include Javascript libaries jQuery / jQuery UI depending on settings */
if($this->settings['include_jquery']) {
if($this->settings['include_to_footer']) {
$jqueryFile = '/typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-1.10.2.js';
$GLOBALS['TSFE']->getPageRenderer()->addJsFooterFile ($jqueryFile, $type= 'text/javascript', $compress=FALSE, $forceOnTop=FALSE, $allWrap= '', $excludeFromConcatenation=TRUE);
}
else {
$this->response->addAdditionalHeaderData('<script src="typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-1.10.2.js" type="text/javascript"></script>');
}
}
if($this->settings['include_jqueryui']) {
if($this->settings['include_to_footer']) {
$jqueryUiFile = '/typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-ui-1.10.4.custom.min.js';
$GLOBALS['TSFE']->getPageRenderer()->addJsFooterFile ($jqueryUiFile, $type='text/javascript', $compress=FALSE, $forceOnTop=FALSE, $allWrap= '', $excludeFromConcatenation=TRUE);
}
else {
$this->response->addAdditionalHeaderData('<script src="typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-ui-1.10.4.custom.min.js" type="text/javascript"></script>');
}
}
/** Add required extension Javascript, Javascript configuration, CSS and IE7 workaround */
if($this->settings['include_to_footer']) {
/** required extension Javascript */
$socialSharePrivacyJsFile = '/typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/tgm_socialshareprivacy.js';
$GLOBALS['TSFE']->getPageRenderer()->addJsFooterFile ($socialSharePrivacyJsFile, $type= 'text/javascript', $compress=FALSE, $forceOnTop=FALSE, $allWrap= '', $excludeFromConcatenation=TRUE);
/** required CSS and IE7 workaround */
$this->response->addAdditionalHeaderData('
<link rel="stylesheet" type="text/css" href="'.$this->settings['css_path'].'" media="all">
<!--[if IE 7]>
<link rel="stylesheet" href="/typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Css/fontello-ie7.css">
<![endif]-->
');
/** javascript configuration */
$socialSharePrivacyJsConfiguration = $this->renderJavascriptConfiguration();
$GLOBALS['TSFE']->getPageRenderer()->addJsFooterInlineCode ('socialSharePrivacyButtons', $socialSharePrivacyJsConfiguration, $compress=FALSE, $forceOnTop=FALSE);
}
else {
/** required extension Javascript, CSS and IE7 workaround */
$this->response->addAdditionalHeaderData('
<script src="typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/tgm_socialshareprivacy.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="'.$this->settings['css_path'].'" media="all">
<!--[if IE 7]>
<link rel="stylesheet" href="/typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Css/fontello-ie7.css">
<![endif]-->
');
/** javascript configuration */
$this->response->addAdditionalHeaderData('<script type="text/javascript">' . $this->renderJavascriptConfiguration() . '</script>');
}
// So könnte man auch CSS Dateien mit der TypoScript Methode einbinden
/*
$cssFile = $this->settings['css_path'];
$GLOBALS['TSFE']->getPageRenderer()->addCssFile ($cssFile, $rel='stylesheet', $media= 'all', $title= '', $compress=TRUE, $forceOnTop=FALSE, $allWrap= '');
*/
}
/**
* Index Action / Default View
*
* @return void
*/
public function indexAction() {
/** Pass the buttons and cObjUid to fluid */
$this->view->assignMultiple(array(
'socialbuttons' => $this->main_buttons,
'additional_socialbuttons' => $this->additional_buttons,
'cObjUid' => $this->cObjUid
));
}
/**
* Render the Javascript standalone template for configuration in FE
*
* @return string The rendered Javascript part
*/
public function renderJavascriptConfiguration() {
/** @var \TYPO3\CMS\Fluid\View\StandaloneView $javascriptConfigView */
$javascriptConfigView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
/** Define format */
$javascriptConfigView->setFormat('html');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
/** Get configuration of the template from Typoscript */
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
/** Set template path */
$templatePathAndFilename = $templateRootPath . 'Standalone/JavascriptConfiguration.html';
$javascriptConfigView->setTemplatePathAndFilename($templatePathAndFilename);
/** Pass the buttons, settings and cObjUid to the Fluid standalone template */
$javascriptConfigView->assignMultiple(array(
'socialbuttons' => $this->main_buttons,
'additional_socialbuttons' => $this->additional_buttons,
'settings' => $this->settings,
'cObjUid' => $this->cObjUid
));
/** Render the view and return it to the initializeAction for including */
$javascriptConfigView = $javascriptConfigView->render();
return $javascriptConfigView;
}
}
?>

View File

@@ -0,0 +1,237 @@
<?php
namespace TYPO3\TgmSocialshareprivacy\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) 2014 Paul Beck <pb@teamgeist-medien.de>, Teamgeist Medien GbR
*
* 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!
***************************************************************/
/**
*
*
* @package tgm_socialshareprivacy
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class SocialButton extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* Include helper class
*
* @var \TYPO3\TgmSocialshareprivacy\Helper\HelperFunctions
* @inject
*/
protected $helperClass;
/**
* Name of the Button
*
* @var \string
* @validate NotEmpty
*/
protected $name;
/**
* Name of the Button in the frontend
*
* @var \string
* @validate NotEmpty
*/
protected $nameFe;
/**
* Description text of the button
*
* @var \string
* @validate NotEmpty
*/
protected $descriptionText;
/**
* Dummyimage of the button
*
* @var \string
* @validate NotEmpty
*/
protected $dummyimage;
/**
* Required HTM
*
* @var \string
*/
protected $htmlCode;
/**
* Required Javascript
*
* @var \string
*/
protected $jsCode;
/**
* Append or Prepend JS to Body
*
* @var \integer
*/
protected $jsIncludeMethode;
/**
* Returns the name
*
* @return \string $name
*/
public function getName() {
return $this->name;
}
/**
* Sets the name
*
* @param \string $name
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Returns the name for frontend
*
* @return \string $nameFe
*/
public function getNameFe() {
return $this->nameFe;
}
/**
* Sets the name for frontend
*
* @param \string $nameFe
* @return void
*/
public function setNameFe($nameFe) {
$this->nameFe = $nameFe;
}
/**
* Returns description text
*
* @return \string $descriptionText
*/
public function getDescriptionText() {
return $this->descriptionText;
}
/**
* Sets description text
*
* @param \string $descriptionText
* @return void
*/
public function setDescriptionText($descriptionText) {
$this->descriptionText = $descriptionText;
}
/**
* Returns the dummyimage
*
* @return \string $dummyimage
*/
public function getDummyimage() {
return $this->dummyimage;
}
/**
* Sets the dummyimage
*
* @param \string $dummyimage
* @return void
*/
public function setDummyimage($dummyimage) {
$this->dummyimage = $dummyimage;
}
/**
* Returns the htmlCode
*
* @return \string $htmlCode
*/
public function getHtmlCode() {
if(strpos($this->htmlCode, '###URL###')) {
$this->htmlCode = $this->helperClass->replaceUrlMarker($this->htmlCode);
}
return \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->htmlCode);
}
/**
* Sets the htmlCode
*
* @param \string $htmlCode
* @return void
*/
public function setHtmlCode($htmlCode) {
$this->htmlCode = $htmlCode;
}
/**
* Returns the jsCode
*
* @return \string $jsCode
*/
public function getJsCode() {
if(strpos($this->jsCode, '###URL###')) {
$this->jsCode = $this->helperClass->replaceUrlMarker($this->jsCode);
}
return \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->jsCode);
}
/**
* Sets the jsCode
*
* @param \string $jsCode
* @return void
*/
public function setJsCode($jsCode) {
$this->jsCode = $jsCode;
}
/**
* Returns the jsIncludeMethode
*
* @return \integer $jsIncludeMethode
*/
public function getJsIncludeMethode() {
return $this->jsIncludeMethode;
}
/**
* Sets the jsIncludeMethode
*
* @param \integer $jsIncludeMethode
* @return void
*/
public function setJsIncludeMethode($jsIncludeMethode) {
$this->jsIncludeMethode = $jsIncludeMethode;
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php
namespace TYPO3\TgmSocialshareprivacy\Domain\Repository;
/***************************************************************
* Copyright notice
*
* (c) 2014 Paul Beck <pb@teamgeist-medien.de>, Teamgeist Medien GbR
*
* 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!
***************************************************************/
/**
*
*
* @package tgm_socialshareprivacy
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class SocialButtonRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* Find by multiple uids using , seperated string
*
* @param string String containing uids
* @return \TYPO3\TgmSocialshareprivacy\Domain\Model\SocialButton Matching social buttons
*/
public function findByUids($uids) {
$uidArray = explode(",", $uids);
$query = $this->createQuery();
foreach ($uidArray as $key => $value) {
$constraints[] = $query->equals('uid', $value);
}
return $query->matching(
$query->logicalAnd(
$query->logicalOr(
$constraints
),
$query->equals('hidden', 0),
$query->equals('deleted', 0)
)
)->execute();
}
}
?>

View File

@@ -0,0 +1,128 @@
<?php
namespace TYPO3\TgmSocialshareprivacy\Helper;
/***************************************************************
* Copyright notice
*
* (c) 2014 Paul Beck <pb@teamgeist-medien.de>, Teamgeist Medien GbR
*
* 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!
* Just always need this: \TYPO3\CMS\Core\Utility\DebugUtility::debug();
***************************************************************/
/**
*
*
* @package tgm_socialshareprivacy
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class HelperFunctions {
/**
* Flexform / Typoscript Settings
*/
public $settings;
/**
* Configuration Manager
*/
public $configurationManager;
/**
* Inject the configuration manager
*
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
* @inject
*/
public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager) {
$this->configurationManager = $configurationManager;
$this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
$this->initializeSettings();
}
/**
* Combine settings on empty Flexform values with Typoscript values
*
* @return boolean
*/
public function initializeSettings() {
if(isset($this->settings['flexform'])) {
foreach ($this->settings['flexform'] as $key => $value) {
if (isset($this->settings[$key]) && $value != '') {
$this->settings[$key] = $value;
}
}
}
}
/**
* Returns the combined settings
*
* @return array
*/
public function getSettings() {
return $this->settings;
}
/**
* Replace ###URL### Marker in string with URL
*
* @param string $code The code containing the marker
* @return string
*/
public function replaceUrlMarker($code) {
if(empty($this->settings['share_link']) || $this->settings['share_link'] == 'current') {
$code = str_replace('###URL###', $this->getCurPageURL(), $code);
} else {
$code = str_replace('###URL###', $this->settings['share_link'], $code);
}
return $code;
}
/**
* Returns current URL
*
* @return string
*/
public function getCurPageURL() {
$pageURL = 'http';
if ($_SERVER['HTTPS'] == 'on') {$pageURL .= 's';
}
$pageURL .= '://';
if ($_SERVER['SERVER_PORT'] != '80') {
$pageURL .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
} else {
$pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
}
return $pageURL;
}
/**
* Returns the cObj UID
*
* @return number
*/
public function getContentObjectUid() {
$contentObject = $this->configurationManager->getContentObject();
return $contentObject->data['uid'];
}
}
?>