/** * Main Function * * @param array $params * @param object $pObj * @return string */ public function getInfo($params = array(), $pObj) { // settings $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['powermail']); if ($confArr['disablePluginInformation']) { return ''; } $this->params = $params; // $returnUrl = 'alt_doc.php?edit[tt_content][' . $pa['row']['uid'] . ']=edit&returnUrl=' . GeneralUtility::_GET('returnUrl'); // $returnUrl = rawurlencode($returnUrl); $returnUrl = rawurlencode(Div::getSubFolderOfCurrentUrl() . GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT')); $editFormLink = Div::getSubFolderOfCurrentUrl() . 'typo3/alt_doc.php?edit[tx_powermail_domain_model_forms][' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form'), 'uid') . ']=edit'; $editFormLink .= '&returnUrl=' . $returnUrl; // let's go $array = array($GLOBALS['LANG']->sL($this->locallangPath . 'receiverEmail') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.email'), $GLOBALS['LANG']->sL($this->locallangPath . 'receiverName') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.name'), $GLOBALS['LANG']->sL($this->locallangPath . 'subject') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.subject'), $GLOBALS['LANG']->sL($this->locallangPath . 'form') => '<a href="' . $editFormLink . '" style="text-decoration:underline;">' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form')) . '</a>', $GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />', $GLOBALS['LANG']->sL($this->locallangPath . 'optin') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />'); if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.confirmation')) { $array[$GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />'; } if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.optin')) { $array[$GLOBALS['LANG']->sL($this->locallangPath . 'optin')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />'; } if ($this->showTable) { return $this->createOutput($array); } return ''; }
/** * Create Image File * * @param $content * @return string Image HTML Code */ protected function createImage($content) { $startimage = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl(); $startimage .= $GLOBALS['TSFE']->tmpl->getFileName($this->configuration['captcha.']['default.']['image']); // if startfile does not exist if (!is_file($startimage)) { return 'Error: No Image found on ' . $startimage; } // Backgroundimage $img = ImageCreateFromPNG($startimage); $config = array(); $config['color_rgb'] = sscanf($this->configuration['captcha.']['default.']['textColor'], '#%2x%2x%2x'); $config['color'] = ImageColorAllocate($img, $config['color_rgb'][0], $config['color_rgb'][1], $config['color_rgb'][2]); $config['font'] = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl(); $config['font'] .= $GLOBALS['TSFE']->tmpl->getFileName($this->configuration['captcha.']['default.']['font']); $config['fontsize'] = $this->configuration['captcha.']['default.']['textSize']; $config['angle'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['textAngle'], TRUE); $config['fontangle'] = mt_rand($config['angle'][0], $config['angle'][1]); $config['distance_hor'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['distanceHor'], TRUE); $config['fontdistance_hor'] = mt_rand($config['distance_hor'][0], $config['distance_hor'][1]); $config['distance_vert'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['distanceVer'], TRUE); $config['fontdistance_vert'] = mt_rand($config['distance_vert'][0], $config['distance_vert'][1]); imagettftext($img, $config['fontsize'], $config['fontangle'], $config['fontdistance_hor'], $config['fontdistance_vert'], $config['color'], $config['font'], $content); imagepng($img, GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl() . $GLOBALS['TSFE']->tmpl->getFileName($this->captchaImage)); imagedestroy($img); return $GLOBALS['TSFE']->tmpl->getFileName($this->getCaptchaImage()) . '?hash=' . time(); }
/** * Test for getSubFolderOfCurrentUrl() * * @param bool $leadingSlash will be prepended * @param bool $trailingSlash will be appended * @param string $host * @param string $url * @param string $expectedResult * @return void * @dataProvider getSubFolderOfCurrentUrlReturnsStringDataProvider * @test */ public function getSubFolderOfCurrentUrlReturnsString($leadingSlash, $trailingSlash, $host, $url, $expectedResult) { $result = \In2code\Powermail\Utility\Div::getSubFolderOfCurrentUrl($leadingSlash, $trailingSlash, $host, $url); $this->assertSame($result, $expectedResult); }