* 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' => '
', 'js_code' => '', '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' => '', 'js_code' => '', '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' => 'Tweet', 'js_code' => '', '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' => '', 'js_code' => '', '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(); } }