, 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']; } } ?>