124 lines
5.8 KiB
PHP
124 lines
5.8 KiB
PHP
<?php
|
|
/***************************************************************
|
|
* Copyright notice
|
|
*
|
|
* (c) 2014 Paul Beck <pb@teamgeist-medien.de>
|
|
* 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 2 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!
|
|
***************************************************************/
|
|
|
|
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
/**
|
|
* Update class for the extension manager.
|
|
*
|
|
* @package TYPO3
|
|
* @subpackage TgmSocialshareprivacy
|
|
*/
|
|
class ext_update {
|
|
|
|
/**
|
|
* @var \TYPO3\CMS\Core\Database\DatabaseConnection
|
|
*/
|
|
protected $databaseConnection;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
$this->databaseConnection = $GLOBALS['TYPO3_DB'];
|
|
}
|
|
|
|
/**
|
|
* Main update function called by the extension manager.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function main() {
|
|
return $this->importSocialbuttons();
|
|
//return $this->render();
|
|
}
|
|
|
|
/**
|
|
* Show update mesage
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function access() {
|
|
return TRUE;
|
|
}
|
|
|
|
/**
|
|
* Import default social buttons
|
|
* @return void
|
|
*/
|
|
protected function importSocialbuttons() {
|
|
$countButtons = $this->databaseConnection->exec_SELECTcountRows('*', 'tx_tgmsocialshareprivacy_domain_model_socialbutton', 'hidden=0 AND deleted=0');
|
|
if(!$countButtons) {
|
|
$insert = array(
|
|
'0' => array(
|
|
'pid' => '0',
|
|
'name' => 'Facebook',
|
|
'dummyimage' => 'fb_button.png',
|
|
'html_code' => '<div class="fb-share-button" data-type="button"></div>',
|
|
'js_code' => '<div id="fb-root"></div><script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_EN/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script>',
|
|
'name_fe' => 'Facebook',
|
|
'description_text' => 'This button is saving your privacy from social networks until you turn it on.',
|
|
),
|
|
'1' => array(
|
|
'pid' => '0',
|
|
'name' => 'Google Plus',
|
|
'dummyimage' => 'gplus_button.png',
|
|
'html_code' => '<div class="g-plusone" data-size="medium" data-annotation="none"></div>',
|
|
'js_code' => '<script type="text/javascript">window.___gcfg = {lang: \'de\'}; (function() {var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true; po.src = \'https://apis.google.com/js/platform.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);})();</script>',
|
|
'name_fe' => 'Google+',
|
|
'description_text' => 'This button is saving your privacy from social networks until you turn it on.',
|
|
),
|
|
'2' => array(
|
|
'pid' => '0',
|
|
'name' => 'Twitter',
|
|
'dummyimage' => 'twitter_button.png',
|
|
'html_code' => '<a href="https://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>',
|
|
'js_code' => '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>',
|
|
'name_fe' => 'Twitter',
|
|
'description_text' => 'This button is saving your privacy from social networks until you turn it on.',
|
|
),
|
|
'3' => array(
|
|
'pid' => '0',
|
|
'name' => 'XING',
|
|
'dummyimage' => 'xing_button.png',
|
|
'html_code' => '<div data-type="XING/Share" data-counter="no_count"></div>',
|
|
'js_code' => '<script>;(function (d, s) {var x = d.createElement(s),s = d.getElementsByTagName(s)[0];x.src = "https://www.xing-share.com/js/external/share.js"; s.parentNode.insertBefore(x, s);})(document, "script");</script>',
|
|
'name_fe' => 'XING',
|
|
'description_text' => 'This button is saving your privacy from social networks until you turn it on.',
|
|
),
|
|
);
|
|
foreach($insert as $insertButton) {
|
|
$this->databaseConnection->exec_INSERTquery('tx_tgmsocialshareprivacy_domain_model_socialbutton', $insertButton);
|
|
}
|
|
/** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
|
|
$flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage','Import successful, please check PID0.','',FlashMessage::OK);
|
|
} else {
|
|
/** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
|
|
$flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage','Cannot import social buttons due to existing buttons. Delete all existing buttons before importing','',FlashMessage::ERROR);
|
|
}
|
|
return $flashMessage->render();
|
|
}
|
|
}
|