Esempio n. 1
0
 /**
  * Show general information and the installed modules
  *
  * @return void
  */
 public function indexAction()
 {
     $warnings = array();
     $contentWarnings = '';
     // Hook for additional warnings
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
             $hookObj = GeneralUtility::getUserObj($classRef);
             if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
                 $hookObj->displayWarningMessages_postProcess($warnings);
             }
         }
     }
     if (!empty($warnings)) {
         if (count($warnings) > 1) {
             $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
         } else {
             $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
         }
         $securityMessage = GeneralUtility::makeInstance(FlashMessage::class, $securityWarnings, $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'), FlashMessage::ERROR);
         $contentWarnings = '<div style="margin: 20px 0;">' . $securityMessage->render() . '</div>';
         unset($warnings);
     }
     $this->view->assignMultiple(array('TYPO3Version' => TYPO3_version, 'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(), 'warningMessages' => $contentWarnings, 'modules' => $this->getModulesData()));
 }
Esempio n. 2
0
 /**
  * @param ServerRequestInterface $request
  */
 protected function initVariables(ServerRequestInterface $request)
 {
     parent::initVariables($request);
     $parameters = $request->getQueryParams();
     $this->bparams = isset($parameters['bparams']) ? $parameters['bparams'] : '';
     // Process bparams
     $pArr = explode('|', $this->bparams);
     $pRteArr = explode(':', $pArr[1]);
     $this->editorNo = $pRteArr[0];
     $this->contentTypo3Language = $pRteArr[1];
     $this->RTEtsConfigParams = $pArr[2];
     if (!$this->editorNo) {
         $this->editorNo = GeneralUtility::_GP('editorNo');
         $this->contentTypo3Language = GeneralUtility::_GP('contentTypo3Language');
         $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
     }
     $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language));
     $pArr[2] = $this->RTEtsConfigParams;
     $this->bparams = implode('|', $pArr);
     $this->contentLanguageService->init($this->contentTypo3Language);
     $this->buttonConfig = isset($this->RTEProperties['default.']['buttons.']['link.']) ? $this->RTEProperties['default.']['buttons.']['link.'] : [];
     $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
     $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
     $this->thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
 }
Esempio n. 3
0
 /**
  * setter for databaseConnection object
  *
  * @param mixed $languageService
  *
  * @return void
  */
 public function setLanguageService($languageService)
 {
     $this->languageService = $languageService instanceof LanguageService ? $languageService : GeneralUtility::makeInstance(LanguageService::class);
     if ($this->getBackendUser()) {
         $this->languageService->init($this->getBackendUser()->uc['lang']);
     }
 }
Esempio n. 4
0
 /**
  * Returns some statistics and a social link to Twitter.
  *
  * @return void
  */
 protected function addStatisticsAndSocialLink()
 {
     $fileName = PATH_site . 'typo3conf/.tx_imageautoresize';
     if (!is_file($fileName)) {
         return;
     }
     $data = json_decode(file_get_contents($fileName), true);
     if (!is_array($data) || !(isset($data['images']) && isset($data['bytes']))) {
         return;
     }
     $resourcesPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey) . 'Resources/Public/';
     $pageRenderer = version_compare(TYPO3_version, '7.5.99', '>') ? $this->moduleTemplate->getPageRenderer() : $this->doc->getPageRenderer();
     $pageRenderer->addCssFile($resourcesPath . 'Css/twitter.css');
     $pageRenderer->addJsFile($resourcesPath . 'JavaScript/popup.js');
     $totalSpaceClaimed = GeneralUtility::formatSize((int) $data['bytes']);
     $messagePattern = $this->languageService->getLL('storage.claimed');
     $message = sprintf($messagePattern, $totalSpaceClaimed, (int) $data['images']);
     $flashMessage = htmlspecialchars($message);
     $twitterMessagePattern = $this->languageService->getLL('social.twitter');
     $message = sprintf($twitterMessagePattern, $totalSpaceClaimed);
     $url = 'https://typo3.org/extensions/repository/view/image_autoresize';
     $twitterLink = 'https://twitter.com/intent/tweet?text=' . urlencode($message) . '&url=' . urlencode($url);
     $twitterLink = GeneralUtility::quoteJSvalue($twitterLink);
     $flashMessage .= '
         <div class="custom-tweet-button">
             <a href="#" onclick="popitup(' . $twitterLink . ',\'twitter\')" title="' . $this->languageService->getLL('social.share', true) . '">
                 <i class="btn-icon"></i>
                 <span class="btn-text">Tweet</span>
             </a>
         </div>';
     if (version_compare(TYPO3_version, '7.0.0', '>=')) {
         $this->content .= '
             <div class="alert alert-info">
                 <div class="media">
                     <div class="media-left">
                         <span class="fa-stack fa-lg">
                             <i class="fa fa-circle fa-stack-2x"></i>
                             <i class="fa fa-info fa-stack-1x"></i>
                         </span>
                     </div>
                     <div class="media-body">
                         ' . $flashMessage . '
                     </div>
                 </div>
             </div>
         ';
     } else {
         $this->content .= '
             <div id="typo3-messages">
                 <div class="typo3-message message-information">
                     <div class="message-body">
                         ' . $flashMessage . '
                     </div>
                 </div>
             </div>
         ';
     }
 }
 /**
  * Return label
  *        if LLL parse
  *        if empty take value
  *
  * @param null|string $label
  * @param string $fallback
  * @return string
  */
 protected function getLabel($label, $fallback)
 {
     if (strpos($label, 'LLL:') === 0) {
         $label = $this->languageService->sL($label);
     }
     if (empty($label)) {
         $label = $fallback;
     }
     return $label;
 }
Esempio n. 6
0
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  */
 protected function getButtons()
 {
     $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
     // View page
     $viewButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))->setTitle($this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL));
     $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
     // Shortcut
     $shortCutButton = $buttonBar->makeShortcutButton()->setModuleName($this->moduleName)->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])->setGetVariables(['M', 'id', 'edit_record', 'pointer', 'new_unique_uid', 'search_field', 'search_levels', 'showLimit'])->setSetVariables(array_keys($this->MOD_MENU));
     $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
 }
 /**
  * Adding CM element for Delete
  *
  * @param	string	$table	Table name
  * @param	integer	$uid	UID for the current record.
  * @param	array	$elInfo	Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
  * @return	array		Item array, element in $menuItems
  * @internal
  */
 function DB_delete($table, $uid, $elInfo)
 {
     $loc = 'top.content.list_frame';
     if ($this->beUser->jsConfirmation(4)) {
         $conf = "confirm(" . GeneralUtility::quoteJSvalue(sprintf($this->LANG->sL('LLL:EXT:lang/locallang_core.php:mess.delete'), $elInfo[0]) . BackendUtility::referenceCount($table, $uid, ' (There are %s reference(s) to this record!)')) . ")";
     } else {
         $conf = '1==1';
     }
     $editOnClick = 'if(' . $loc . " && " . $conf . " ){" . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(" . $this->backRef->frameLocation($loc . '.document') . ")+'" . "&cmd[" . $table . '][' . $uid . '][DDdelete]=1&prErr=1&vC=' . $this->beUser->veriCode() . BackendUtility::getUrlToken('tceAction') . "';hideCM();}";
     return $this->backRef->linkItem($this->LANG->getLLL('delete', $this->LL), $this->backRef->excludeIcon(IconUtility::getSpriteIcon('actions-edit-delete')), $editOnClick . 'return false;');
 }
 /**
  * Remove specified directory
  *
  * @param string $extDirPath
  * @throws ExtensionManagerException
  * @return void
  */
 public function removeDirectory($extDirPath)
 {
     $extensionPathWithoutTrailingSlash = rtrim($extDirPath, DIRECTORY_SEPARATOR);
     if (is_link($extensionPathWithoutTrailingSlash)) {
         $result = unlink($extensionPathWithoutTrailingSlash);
     } else {
         $result = GeneralUtility::rmdir($extDirPath, TRUE);
     }
     if ($result === FALSE) {
         throw new ExtensionManagerException(sprintf($this->languageService->getLL('fileHandling.couldNotRemoveDirectory'), $this->getRelativePath($extDirPath)), 1337280415);
     }
 }
Esempio n. 9
0
 /**
  * Returns option array to be used in Fluid
  *
  * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list
  * @return array
  */
 public function getTableSelectOptions($excludeList = '')
 {
     $optValues = array();
     if (!GeneralUtility::inList($excludeList, '_ALL')) {
         $optValues['_ALL'] = '[' . $this->lang->getLL('ALL_tables') . ']';
     }
     foreach ($GLOBALS['TCA'] as $table => $_) {
         if ($this->getBackendUser()->check('tables_select', $table) && !GeneralUtility::inList($excludeList, $table)) {
             $optValues[$table] = $table;
         }
     }
     return $optValues;
 }
Esempio n. 10
0
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  *
  * @return array All available buttons as an assoc. array
  */
 protected function getButtons()
 {
     $buttons = array('csh' => '', 'view' => '', 'shortcut' => '');
     // CSH
     $buttons['csh'] = BackendUtility::cshItem('_MOD_web_info', '');
     // View page
     $buttons['view'] = '<a href="#" ' . 'onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" ' . 'title="' . $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
     // Shortcut
     if ($this->backendUser->mayMakeShortcut()) {
         $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->moduleName);
     }
     return $buttons;
 }
Esempio n. 11
0
 /**
  * Remove specified directory
  *
  * @param string $extDirPath
  * @throws ExtensionManagerException
  * @return void
  */
 public function removeDirectory($extDirPath)
 {
     $extDirPath = GeneralUtility::fixWindowsFilePath($extDirPath);
     $extensionPathWithoutTrailingSlash = rtrim($extDirPath, '/');
     if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !== 'WIN') {
         $result = unlink($extensionPathWithoutTrailingSlash);
     } else {
         $result = GeneralUtility::rmdir($extDirPath, true);
     }
     if ($result === false) {
         throw new ExtensionManagerException(sprintf($this->languageService->getLL('fileHandling.couldNotRemoveDirectory'), $this->getRelativePath($extDirPath)), 1337280415);
     }
 }
 /**
  * Initializes the controller before invoking an action method.
  *
  * @return void
  */
 protected function initializeAction()
 {
     $this->pageId = (int) GeneralUtility::_GP('id');
     $this->pageRenderer->addInlineLanguageLabelArray(array('title' => $this->languageService->getLL('title'), 'path' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.path'), 'table' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.table'), 'depth' => $this->languageService->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'), 'depth_0' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'), 'depth_1' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'), 'depth_2' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'), 'depth_3' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'), 'depth_4' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'), 'depth_infi' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi')));
     $this->pageRenderer->addInlineLanguageLabelFile('EXT:typo3_forum/Resources/Private/Language/locallang_mod.xml');
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->enableExtJSQuickTips();
     $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('lang') . 'res/js/be/typo3lang.js');
     $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
     $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ExtJS/');
     $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ForumIndex/');
     $this->includeCssFromPath('Resources/Public/Javascript/Backend/ExtJS/');
     $this->pageRenderer->addCssFile(ExtensionManagementUtility::extRelPath('typo3_forum') . 'Resources/Public/Stylesheets/typo3_forum-backend.css');
 }
 /**
  * Show Note if no Email or Name selected
  *
  * @param array $params Config Array
  * @return string
  */
 public function showNote($params)
 {
     $this->initialize();
     $content = '';
     if (!$this->showNoteActive($params)) {
         return $content;
     }
     if (!$this->senderEmailOrSenderNameSet($params['row']['uid'])) {
         if ($this->noteFieldDisabled($params)) {
             $content .= '<p style="opacity: 0.3; margin: 0;">';
             $content .= $this->getCheckboxHtml($params);
             $content .= '<label for="tx_powermail_domain_model_forms_note_checkbox"' . ' style="vertical-align: bottom;">';
             $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.note.4', true);
             $content .= '</label>';
             $content .= '<p style="margin: 0 0 3px 0;">';
         } else {
             $content .= '<div style="background-color: #FCF8E3; border: 1px solid #FFB019;' . ' padding: 5px 10px; color: #FFB019;">';
             $content .= '<p style="margin: 0 0 3px 0;">';
             $content .= '<strong>';
             $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.note.1', true);
             $content .= '</strong>';
             $content .= ' ';
             $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.note.2', true);
             $content .= '</p>';
             $content .= '<p style="margin: 0;">';
             $content .= $this->getCheckboxHtml($params);
             $content .= '<label for="tx_powermail_domain_model_forms_note_checkbox"' . ' style="vertical-align: bottom;">';
             $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.note.3', true);
             $content .= '</label>';
             $content .= '</p>';
             $content .= '</div>';
         }
     }
     if (!$this->hasFormUniqueFieldMarkers($params['row']['uid'])) {
         $content .= '<div style="background:#F2DEDE; border:1px solid #A94442;' . ' padding: 5px 10px; color: #A94442; margin-top: 10px">';
         $content .= '<p><strong>';
         $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.error.1', true);
         $content .= '</strong></p>';
         $content .= '<p>';
         $content .= $this->languageService->sL($this->locallangPath . 'tx_powermail_domain_model_forms.error.2', true);
         $content .= '</p>';
         $content .= '</div>';
     }
     return $content;
 }
 /**
  * return content collapse icon
  *
  * @param array $data
  * @param string $sortField
  * @param int $level
  * @param string $contentCollapseIcon
  * @param DatabaseRecordList $parentObj
  */
 public function contentCollapseIcon(&$data, $sortField, $level, &$contentCollapseIcon, $parentObj)
 {
     if ($data['_EXPAND_TABLE_'] === 'tt_content') {
         $expandTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandElement');
         $collapseTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseElement');
         $expandedGridelements = $parentObj->getExpandedGridelements();
         if ($expandedGridelements[$data['uid']]) {
             $href = htmlspecialchars($parentObj->listURL() . '&gridelementsExpand[' . (int) $data['uid'] . ']=0');
             $contentCollapseIcon = '<a
             class="btn btn-default t3js-toggle-gridelements-list open-gridelements-container" data-state="expanded" href="' . $href . '" id="t3-gridelements-' . $data['uid'] . '"
             title="' . $collapseTitle . '"
             data-toggle-title="' . $expandTitle . '">' . $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render() . $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
         } else {
             $href = htmlspecialchars($parentObj->listURL() . '&gridelementsExpand[' . (int) $data['uid'] . ']=1');
             $contentCollapseIcon = '<a
             class="btn btn-default t3js-toggle-gridelements-list" data-state="collapsed" href="' . $href . '" id="t3-gridelements-' . $data['uid'] . '"
             title="' . $expandTitle . '"
             data-toggle-title="' . $collapseTitle . '">' . $this->getIconFactory()->getIcon('actions-view-list-expand', 'small')->render() . $this->getIconFactory()->getIcon('actions-view-list-collapse', 'small')->render() . '</a>';
         }
     }
 }
Esempio n. 15
0
 /**
  * Inject alt attribute for image that don't have it yet
  */
 private function infoImageAlt()
 {
     if (!$this->content) {
         return;
     }
     $document = new \DOMDocument();
     $prefix = '<?xml encoding="UTF-8">';
     @$document->loadHTML($prefix . $this->content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     $imgs = $document->getElementsByTagName('img');
     $count = 0;
     foreach ($imgs as $img) {
         if (!$img->hasAttribute('alt')) {
             $img->setAttribute('alt', '');
             ++$count;
         }
     }
     if ($count) {
         $this->infos[] = sprintf($this->lang->getLL('validation_mail_injected_alt_attribute'), $count);
     }
     $newContent = trim(preg_replace('/^' . preg_quote($prefix) . '/', '', $document->saveHTML()));
     $this->content = $newContent;
 }
Esempio n. 16
0
 /**
  * CSV row titles
  *
  * @param array $row
  * @param array $conf
  * @param mixed $table Not used
  * @return string
  */
 public function csvRowTitles($row, $conf, $table)
 {
     $out = '';
     $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
     foreach ($row as $fieldName => $fieldValue) {
         if (GeneralUtility::inList($SET['queryFields'], $fieldName) || !$SET['queryFields'] && $fieldName != 'pid') {
             if (!$out) {
                 if ($GLOBALS['SOBE']->MOD_SETTINGS['search_result_labels']) {
                     $out = htmlspecialchars($this->languageService->sL($conf['columns'][$fieldName]['label'] ? $conf['columns'][$fieldName]['label'] : $fieldName));
                 } else {
                     $out = htmlspecialchars($this->languageService->sL($fieldName));
                 }
             } else {
                 if ($GLOBALS['SOBE']->MOD_SETTINGS['search_result_labels']) {
                     $out .= ',' . htmlspecialchars($this->languageService->sL($conf['columns'][$fieldName]['label'] ? $conf['columns'][$fieldName]['label'] : $fieldName));
                 } else {
                     $out .= ',' . htmlspecialchars($this->languageService->sL($fieldName));
                 }
             }
         }
     }
     return $out;
 }
 /**
  * Returns a selector-box with TCA tables
  *
  * @param string $prefix Form element name prefix
  * @param array $value The current values selected
  * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list
  * @return string HTML select element
  */
 public function tableSelector($prefix, $value, $excludeList = '')
 {
     $optValues = array();
     if (!GeneralUtility::inList($excludeList, '_ALL')) {
         $optValues['_ALL'] = '[' . $this->lang->getLL('ALL_tables') . ']';
     }
     foreach ($GLOBALS['TCA'] as $table => $_) {
         if ($this->getBackendUser()->check('tables_select', $table) && !GeneralUtility::inList($excludeList, $table)) {
             $optValues[$table] = $table;
         }
     }
     // make box:
     $opt = array();
     $opt[] = '<option value=""></option>';
     $sel = '';
     foreach ($optValues as $k => $v) {
         if (is_array($value)) {
             $sel = in_array($k, $value) ? ' selected="selected"' : '';
         }
         $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
     }
     return '<select name="' . $prefix . '[]" multiple="multiple" size="' . MathUtility::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
 }
Esempio n. 18
0
 /**
  * Show general information and the installed modules
  *
  * @return void
  */
 public function indexAction()
 {
     $warnings = [];
     $securityWarnings = '';
     // Hook for additional warnings
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
             $hookObj = GeneralUtility::getUserObj($classRef);
             if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
                 $hookObj->displayWarningMessages_postProcess($warnings);
             }
         }
     }
     if (!empty($warnings)) {
         if (count($warnings) > 1) {
             $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
         } else {
             $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
         }
         unset($warnings);
     }
     $this->view->assignMultiple(['TYPO3Version' => TYPO3_version, 'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(), 'warningMessages' => $securityWarnings, 'warningTitle' => $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.header'), 'modules' => $this->getModulesData()]);
 }
 /**
  * @param LanguageService $languageService
  * @param FlashMessageQueue $messageQueue
  * @param bool $isAjaxCall
  * @internal Only public to be used in tests
  * @return \Closure
  */
 public static function getMessageClosure(LanguageService $languageService, FlashMessageQueue $messageQueue, $isAjaxCall)
 {
     return function () use($languageService, $messageQueue, $isAjaxCall) {
         /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
         $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.formProtection.tokenInvalid'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, !$isAjaxCall);
         $messageQueue->enqueue($flashMessage);
     };
 }
Esempio n. 20
0
 /**
  * Get label from locallang_core.xlf:cm.*
  *
  * @param string $label The "cm."-suffix to get.
  * @return string
  */
 public function label($label)
 {
     return htmlspecialchars($this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:cm.' . $label));
 }
 /**
  * Get localized label
  *
  * @param string $key
  * @return string
  */
 protected function getLabel($key)
 {
     return $this->languageService->sL($this->locallangPath . 'flexform.main.' . $key, true);
 }
Esempio n. 22
0
 /**
  * Get label from locallang_core.xlf:cm.*
  *
  * @param string $label The "cm."-suffix to get.
  * @return string
  */
 public function label($label)
 {
     return $this->languageService->makeEntities($this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:cm.' . $label, true));
 }
Esempio n. 23
0
 /**
  * Renders the grid layout table after the HTML content for the single elements has been rendered
  *
  * @param array $layoutSetup : The setup of the layout that is selected for the grid we are going to render
  * @param array $row : The current data row for the container item
  * @param array $head : The data for the column headers of the grid we are going to render
  * @param array $gridContent : The content data of the grid we are going to render
  *
  * @return string
  */
 public function renderGridLayoutTable($layoutSetup, $row, $head, $gridContent)
 {
     $specificIds = Helper::getInstance()->getSpecificIds($row);
     $grid = '<div class="t3-gridContainer' . ($layoutSetup['frame'] ? ' t3-gridContainer-framed t3-gridContainer-' . $layoutSetup['frame'] : '') . ($layoutSetup['top_level_layout'] ? ' t3-gridTLContainer' : '') . '">';
     if ($layoutSetup['frame']) {
         $grid .= '<h4 class="t3-gridContainer-title-' . $layoutSetup['frame'] . '">' . $this->lang->sL($layoutSetup['title'], TRUE) . '</h4>';
     }
     if ($GLOBALS['BE_USER']->uc['showGridInformation'] === 1) {
         $grid .= '<span class="t3-help-link" href="#" data-title="' . htmlspecialchars($this->lang->sL($layoutSetup['title'])) . '" data-description="' . htmlspecialchars($this->lang->sL($layoutSetup['description'])) . '"><abbr class="t3-help-teaser">' . $this->lang->sL($layoutSetup['title'], TRUE) . '</abbr></span>';
     }
     $grid .= '<table border="0" cellspacing="1" cellpadding="4" width="100%" height="100%" class="t3-page-columns t3-gridTable">';
     // add colgroups
     $colCount = 0;
     $rowCount = 0;
     if (isset($layoutSetup['config'])) {
         if (isset($layoutSetup['config']['colCount'])) {
             $colCount = (int) $layoutSetup['config']['colCount'];
         }
         if (isset($layoutSetup['config']['rowCount'])) {
             $rowCount = (int) $layoutSetup['config']['rowCount'];
         }
     }
     $grid .= '<colgroup>';
     for ($i = 0; $i < $colCount; $i++) {
         $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
     }
     $grid .= '</colgroup>';
     // cycle through rows
     for ($layoutRow = 1; $layoutRow <= $rowCount; $layoutRow++) {
         $rowConfig = $layoutSetup['config']['rows.'][$layoutRow . '.'];
         if (!isset($rowConfig)) {
             continue;
         }
         $grid .= '<tr>';
         for ($col = 1; $col <= $colCount; $col++) {
             $columnConfig = $rowConfig['columns.'][$col . '.'];
             if (!isset($columnConfig)) {
                 continue;
             }
             // which column should be displayed inside this cell
             $columnKey = $columnConfig['colPos'] !== '' ? (int) $columnConfig['colPos'] : 32768;
             // allowed CTypes
             if (!empty($columnConfig['allowed'])) {
                 $allowedCTypes = array_flip(GeneralUtility::trimExplode(',', $columnConfig['allowed']));
                 if (!isset($allowedCTypes['*'])) {
                     foreach ($allowedCTypes as $ctype => &$ctypeClass) {
                         $ctypeClass = 't3-allow-' . $ctype;
                     }
                 } else {
                     unset($allowedCTypes);
                 }
             }
             if (!empty($columnConfig['allowedGridTypes'])) {
                 $allowedGridTypes = array_flip(GeneralUtility::trimExplode(',', $columnConfig['allowedGridTypes']));
                 if (!isset($allowedGridTypes['*'])) {
                     foreach ($allowedGridTypes as $gridType => &$gridTypeClass) {
                         $gridTypeClass = 't3-allow-gridtype-' . $gridType;
                     }
                     $allowedCTypes['gridelements_pi1'] = 't3-allow-gridelements_pi1';
                 } else {
                     if (isset($allowedCTypes)) {
                         $allowedCTypes['gridelements_pi1'] = 't3-allow-gridelements_pi1';
                     }
                     unset($allowedGridTypes);
                 }
             }
             // render the grid cell
             $colSpan = (int) $columnConfig['colspan'];
             $rowSpan = (int) $columnConfig['rowspan'];
             $grid .= '<td valign="top"' . (isset($columnConfig['colspan']) ? ' colspan="' . $colSpan . '"' : '') . (isset($columnConfig['rowspan']) ? ' rowspan="' . $rowSpan . '"' : '') . 'id="column-' . $specificIds['uid'] . 'x' . $columnKey . '" class="t3-gridCell t3-page-column t3-page-column-' . $columnKey . (!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '' ? ' t3-gridCell-unassigned' : '') . (isset($columnConfig['colspan']) && $columnConfig['colPos'] !== '' ? ' t3-gridCell-width' . $colSpan : '') . (isset($columnConfig['rowspan']) && $columnConfig['colPos'] !== '' ? ' t3-gridCell-height' . $rowSpan : '') . ' ' . ($layoutSetup['horizontal'] ? ' t3-gridCell-horizontal' : '') . (count($allowedCTypes) ? ' ' . join(' ', $allowedCTypes) : ' t3-allow-all') . (count($allowedGridTypes) ? ' ' . join(' ', $allowedGridTypes) : '') . '">';
             $grid .= ($GLOBALS['BE_USER']->uc['hideColumnHeaders'] ? '' : $head[$columnKey]) . $gridContent[$columnKey];
             $grid .= '</td>';
         }
         $grid .= '</tr>';
     }
     $grid .= '</table></div>';
     return $grid;
 }
 /**
  * Renders the link attributes for the selected link handler
  *
  * @return string
  */
 public function renderLinkAttributeFields()
 {
     // Processing the classes configuration
     if (!empty($this->buttonConfig['properties.']['class.']['allowedClasses'])) {
         $classesAnchorArray = GeneralUtility::trimExplode(',', $this->buttonConfig['properties.']['class.']['allowedClasses'], true);
         // Collecting allowed classes and configured default values
         $classesAnchor = ['all' => []];
         $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->currentLinkHandlerId . '.']['properties.']['title.']['readOnly'];
         if (is_array($this->RTEProperties['classesAnchor.'])) {
             foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
                 if (in_array($conf['class'], $classesAnchorArray)) {
                     $classesAnchor['all'][] = $conf['class'];
                     if ($conf['type'] === $this->displayedLinkHandlerId) {
                         $classesAnchor[$conf['type']][] = $conf['class'];
                         if ($this->buttonConfig[$conf['type'] . '.']['properties.']['class.']['default'] == $conf['class']) {
                             $this->classesAnchorDefault[$conf['type']] = $conf['class'];
                             if ($conf['titleText']) {
                                 $this->classesAnchorDefaultTitle[$conf['type']] = $this->contentLanguageService->sL(trim($conf['titleText']));
                             }
                             if (isset($conf['target'])) {
                                 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
                             }
                         }
                     }
                     if ($titleReadOnly && $conf['titleText']) {
                         $this->classesAnchorClassTitle[$conf['class']] = $this->classesAnchorDefaultTitle[$conf['type']] = $this->contentLanguageService->sL(trim($conf['titleText']));
                     }
                 }
             }
         }
         // Constructing the class selector options
         foreach ($classesAnchorArray as $class) {
             if (!in_array($class, $classesAnchor['all']) || in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$this->displayedLinkHandlerId]) && in_array($class, $classesAnchor[$this->displayedLinkHandlerId])) {
                 $selected = '';
                 if ($this->linkAttributeValues['class'] === $class || !$this->linkAttributeValues['class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) {
                     $selected = 'selected="selected"';
                 }
                 $classLabel = !empty($this->RTEProperties['classes.'][$class . '.']['name']) ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0) : $class;
                 $classStyle = !empty($this->RTEProperties['classes.'][$class . '.']['value']) ? $this->RTEProperties['classes.'][$class . '.']['value'] : '';
                 $this->classesAnchorJSOptions[$this->displayedLinkHandlerId] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
             }
         }
         if ($this->classesAnchorJSOptions[$this->displayedLinkHandlerId] && !($this->buttonConfig['properties.']['class.']['required'] || $this->buttonConfig[$this->currentLinkHandlerId . '.']['properties.']['class.']['required'])) {
             $selected = '';
             if (!$this->linkAttributeValues['class'] && !$this->classesAnchorDefault[$this->displayedLinkHandlerId]) {
                 $selected = 'selected="selected"';
             }
             $this->classesAnchorJSOptions[$this->displayedLinkHandlerId] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$this->displayedLinkHandlerId];
         }
     }
     // Default target
     $this->defaultLinkTarget = $this->classesAnchorDefault[$this->currentLinkHandlerId] && $this->classesAnchorDefaultTarget[$this->currentLinkHandlerId] ? $this->classesAnchorDefaultTarget[$this->currentLinkHandlerId] : (isset($this->buttonConfig[$this->currentLinkHandlerId . '.']['properties.']['target.']['default']) ? $this->buttonConfig[$this->currentLinkHandlerId . '.']['properties.']['target.']['default'] : (isset($this->buttonConfig['properties.']['target.']['default']) ? $this->buttonConfig['properties.']['target.']['default'] : ''));
     // Initializing additional attributes
     if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes']) {
         $addAttributes = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], true);
         foreach ($addAttributes as $attribute) {
             $this->additionalAttributes[$attribute] = isset($this->linkAttributeValues[$attribute]) ? $this->linkAttributeValues[$attribute] : '';
         }
     }
     return parent::renderLinkAttributeFields();
 }
Esempio n. 25
0
 /**
  * Get security status of loaded and installed extensions
  *
  * @return \stdClass with properties 'loaded' and 'existing' containing a TYPO3\CMS\Reports\Report\Status\Status object
  */
 protected function getSecurityStatusOfExtensions()
 {
     $extensionInformation = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
     $loadedInsecure = array();
     $existingInsecure = array();
     $loadedOutdated = array();
     $existingOutdated = array();
     foreach ($extensionInformation as $extensionKey => $information) {
         if (array_key_exists('terObject', $information) && $information['terObject'] instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
             /** @var $terObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
             $terObject = $information['terObject'];
             $insecureStatus = $terObject->getReviewState();
             if ($insecureStatus === -1) {
                 if (array_key_exists('installed', $information) && $information['installed'] === TRUE) {
                     $loadedInsecure[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion());
                 } else {
                     $existingInsecure[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion());
                 }
             } elseif ($insecureStatus === -2) {
                 if (array_key_exists('installed', $information) && $information['installed'] === TRUE) {
                     $loadedOutdated[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion());
                 } else {
                     $existingOutdated[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion());
                 }
             }
         }
     }
     $result = new \stdClass();
     if (empty($loadedInsecure)) {
         $value = $this->languageService->getLL('report.status.loadedExtensions.noInsecureExtensionLoaded.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     } else {
         $value = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.value'), count($loadedInsecure));
         $extensionList = array();
         foreach ($loadedInsecure as $insecureExtension) {
             $extensionList[] = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message.extension'), $insecureExtension['extensionKey'], $insecureExtension['version']);
         }
         $message = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message'), implode('', $extensionList));
         $severity = \TYPO3\CMS\Reports\Status::ERROR;
     }
     $result->loaded = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.loadedExtensions.title'), $value, $message, $severity);
     if (empty($existingInsecure)) {
         $value = $this->languageService->getLL('report.status.existingExtensions.noInsecureExtensionExists.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     } else {
         $value = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.value'), count($existingInsecure));
         $extensionList = array();
         foreach ($existingInsecure as $insecureExtension) {
             $extensionList[] = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message.extension'), $insecureExtension['extensionKey'], $insecureExtension['version']);
         }
         $message = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message'), implode('', $extensionList));
         $severity = \TYPO3\CMS\Reports\Status::WARNING;
     }
     $result->existing = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.existingExtensions.title'), $value, $message, $severity);
     if (empty($loadedOutdated)) {
         $value = $this->languageService->getLL('report.status.loadedOutdatedExtensions.noOutdatedExtensionLoaded.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     } else {
         $value = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.value'), count($loadedOutdated));
         $extensionList = array();
         foreach ($loadedOutdated as $outdatedExtension) {
             $extensionList[] = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message.extension'), $outdatedExtension['extensionKey'], $outdatedExtension['version']);
         }
         $message = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message'), implode('', $extensionList));
         $severity = \TYPO3\CMS\Reports\Status::WARNING;
     }
     $result->loadedoutdated = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.loadedOutdatedExtensions.title'), $value, $message, $severity);
     if (empty($existingOutdated)) {
         $value = $this->languageService->getLL('report.status.existingOutdatedExtensions.noOutdatedExtensionExists.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     } else {
         $value = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.value'), count($existingOutdated));
         $extensionList = array();
         foreach ($existingOutdated as $outdatedExtension) {
             $extensionList[] = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message.extension'), $outdatedExtension['extensionKey'], $outdatedExtension['version']);
         }
         $message = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message'), implode('', $extensionList));
         $severity = \TYPO3\CMS\Reports\Status::WARNING;
     }
     $result->existingoutdated = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.existingOutdatedExtensions.title'), $value, $message, $severity);
     return $result;
 }
Esempio n. 26
0
 /**
  * Returns the content of the newsletter with validation messages. The content
  * is also "fixed" automatically when possible.
  * @param Newsletter $newsletter
  * @param string $language language of the content of the newsletter (the 'L' parameter in TYPO3 URL)
  * @return array ('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos);
  */
 public function validate(Newsletter $newsletter, $language = null)
 {
     $this->initializeLang();
     // We need to catch the exception if domain was not found/configured properly
     try {
         $url = $newsletter->getContentUrl($language);
     } catch (Exception $e) {
         return array('content' => '', 'errors' => array($e->getMessage()), 'warnings' => array(), 'infos' => array());
     }
     $content = $this->getURL($url);
     $errors = array();
     $warnings = array();
     $infos = array(sprintf($this->lang->getLL('validation_content_url'), '<a target="_blank" href="' . $url . '">' . $url . '</a>'));
     // Content should be more that just a few characters. Apache error propably occured
     if (strlen($content) < 200) {
         $errors[] = $this->lang->getLL('validation_mail_too_short');
     }
     // Content should not contain PHP-Warnings
     if (substr($content, 0, 22) == "<br />\n<b>Warning</b>:") {
         $errors[] = $this->lang->getLL('validation_mail_contains_php_warnings');
     }
     // Content should not contain PHP-Warnings
     if (substr($content, 0, 26) == "<br />\n<b>Fatal error</b>:") {
         $errors[] = $this->lang->getLL('validation_mail_contains_php_errors');
     }
     // If the page contains a "Pages is being generared" text... this is bad too
     if (strpos($content, 'Page is being generated.') && strpos($content, 'If this message does not disappear within')) {
         $errors[] = $this->lang->getLL('validation_mail_being_generated');
     }
     // Find out the absolute domain. If specified in HTML source, use it as is.
     if (preg_match('|<base[^>]*href="([^"]*)"[^>]*/>|i', $content, $match)) {
         $absoluteDomain = $match[1];
     } else {
         $absoluteDomain = $newsletter->getBaseUrl() . '/';
     }
     // Fix relative URL to absolute URL
     $urlPatterns = array('hyperlinks' => '/<a [^>]*href="(.*)"/Ui', 'stylesheets' => '/<link [^>]*href="(.*)"/Ui', 'images' => '/ src="(.*)"/Ui', 'background images' => '/ background="(.*)"/Ui');
     foreach ($urlPatterns as $type => $urlPattern) {
         preg_match_all($urlPattern, $content, $urls);
         $replacementCount = 0;
         foreach ($urls[1] as $i => $url) {
             // If this is already an absolute link, dont replace it
             $decodedUrl = html_entity_decode($url);
             if (!Uri::isAbsolute($decodedUrl)) {
                 $replace_url = str_replace($decodedUrl, $absoluteDomain . ltrim($decodedUrl, '/'), $urls[0][$i]);
                 $content = str_replace($urls[0][$i], $replace_url, $content);
                 ++$replacementCount;
             }
         }
         if ($replacementCount) {
             $infos[] = sprintf($this->lang->getLL('validation_mail_converted_relative_url'), $type);
         }
     }
     // Find linked css and convert into a style-tag
     preg_match_all('|<link rel="stylesheet" type="text/css" href="([^"]+)"[^>]+>|Ui', $content, $urls);
     foreach ($urls[1] as $i => $url) {
         $content = str_replace($urls[0][$i], "<!-- fetched URL: {$url} -->\n<style type=\"text/css\">\n<!--\n" . $this->getURL($url) . "\n-->\n</style>", $content);
     }
     if (count($urls[1])) {
         $infos[] = $this->lang->getLL('validation_mail_contains_linked_styles');
     }
     // We cant very well have attached javascript in a newsmail ... removing
     $content = preg_replace('|<script[^>]*type="text/javascript"[^>]*>[^<]*</script>|i', '', $content, -1, $count);
     if ($count) {
         $warnings[] = $this->lang->getLL('validation_mail_contains_javascript');
     }
     // Images in CSS
     if (preg_match('|background-image: url\\([^\\)]+\\)|', $content) || preg_match('|list-style-image: url\\([^\\)]+\\)|', $content)) {
         $errors[] = $this->lang->getLL('validation_mail_contains_css_images');
     }
     // CSS-classes
     if (preg_match('|<[a-z]+ [^>]*class="[^"]+"[^>]*>|', $content)) {
         $warnings[] = $this->lang->getLL('validation_mail_contains_css_classes');
     }
     // Positioning & element sizes in CSS
     $forbiddenCssProperties = array('width' => '((min|max)+-)?width', 'height' => '((min|max)+-)?height', 'margin' => 'margin(-(bottom|left|right|top)+)?', 'padding' => 'padding(-(bottom|left|right|top)+)?', 'position' => 'position');
     $forbiddenCssPropertiesWarnings = array();
     if (preg_match_all('|<[a-z]+[^>]+style="([^"]*)"|', $content, $matches)) {
         foreach ($matches[1] as $stylepart) {
             foreach ($forbiddenCssProperties as $property => $regex) {
                 if (preg_match('/(^|[^\\w-])' . $regex . '[^\\w-]/', $stylepart)) {
                     $forbiddenCssPropertiesWarnings[$property] = $property;
                 }
             }
         }
         foreach ($forbiddenCssPropertiesWarnings as $property) {
             $warnings[] = sprintf($this->lang->getLL('validation_mail_contains_css_some_property'), $property);
         }
     }
     return array('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos);
 }
 /**
  * Get localized label from locallang_db.xlf
  *
  * @param string $key
  * @return string
  */
 protected function getLocalizedLabel($key)
 {
     return $this->languageService->sL($this->locallangPath . $key);
 }
 /**
  * Returns the translation for the given key.
  *
  * @param string $key
  * @return string
  */
 protected function translate($key)
 {
     return $this->languageService->sL('LLL:' . $this->languageFile . ':' . $key);
 }
 /**
  * Ensures credit card information is keyed in correctly.
  * <p>Checks that the length is correct, the first four digits are
  * within accepted ranges, the number passes the Mod 10 / Luhn
  * checksum algorithm and that you accept the given type of card. It
  * also determines the card's type via the number's first four digits.</p>
  * <p>The procedure has the option to check the card's expiration date.</p>
  * <p>Error messages are internationalized through use of variables
  * defined by files in the <kbd>./language</kbd> subdirectory.  These
  * files are named after their ISO 639-1 two letter language code.
  * The language used depends on the code put in the
  * <var>$Language</var> parameter.</p>
  * <p>Just to be clear, this process does not check with banks or
  * credit card companies to see if the card number given is actually
  * associated with a good account. It just checks to see if the
  * number matches the expected format.</p>
  * <p>Warning: this function uses exact number ranges as part of
  * the validation process.  These ranges are current as of
  * 30 July 2002.  If presently undefined ranges come into use
  * in the future, this program will improperly deject card numbers
  * in such ranges, rendering an error saying "First four digits
  * indicate unknown card type."  If this happens while entering a
  * card and type you KNOW are valid, please contact us so we can
  * update the ranges.</p>
  * <p>This function requires PHP to be at version 4.0 or above.</p>
  * <p>Please make a donation to support our open source development.
  * Update notifications are sent to people who make donations that exceed
  * the small registration threshold.  See the link below.</p>
  * <p>Credit Card Validation Solution is a trademark of The Analysis and
  * Solutions Company.</p>
  * <p>Several people deserve praise for the Credit Card Validation
  * Solution. I learned of the Mod 10 Algorithm in some Perl code,
  * entitled "The Validator," available on Matt's Script Archive,
  * http://www.scriptarchive.com/ccver.html.  That code was written by
  * David Paris, who based it on material Melvyn Myers reposted from an
  * unknown author.  Paris credits Aries Solis for tracking down the data
  * underlying the algorithm.  I pruned down the algorithm to it's core
  * components, making things smaller, cleaner and more flexible.  Plus,
  * I added the expiration date checking routine.  My first attemts at
  * this were in Visual Basic, on which Allen Browne and Rico Zschau
  * assisted. Neil Fraser helped a bit on the Perl version.  Steve
  * Horsley, Roedy Green and Jon Skeet provided tips on the Java Edition.</p>.
  *
  * @param string       $Number      the number of the credit card to
  *                                  validate.
  * @param string       $CheckNumber the ISO 639-1 two letter code of
  *                                  the language for error messages.
  * @param array|string $Accepted    credit card types you accept.  If
  *                                  not used in function call, all
  *                                  known cards are accepted.  Set
  *                                  it before calling the function: <br /><kbd>
  *                                  $A = array('Visa', 'JCB');
  *                                  </kbd><br />
  *                                  Known types:        <ul>
  *                                  <li> American Express    </li>
  *                                  <li> Australian BankCard </li>
  *                                  <li> Carte Blanche       </li>
  *                                  <li> Diners Club         </li>
  *                                  <li> Discover/Novus      </li>
  *                                  <li> JCB                 </li>
  *                                  <li> MasterCard          </li>
  *                                  <li> Visa                </li></ul>
  * @param string       $RequireExp  should the expiration date be
  *                                  checked?  Y or N.
  * @param int|string   $Month       the card's expiration month
  *                                  in M, 0M or MM foramt.
  * @param int|string   $Year        the card's expiration year in YYYY format.
  *
  * @return bool TRUE if everything is fine.  FALSE if problems.
  *
  * @version    $Name: rel-5-14 $
  *
  * @author     Daniel Convissor <*****@*****.**>
  * @copyright  The Analysis and Solutions Company, 2002-2006
  *
  * @link       http://www.analysisandsolutions.com/software/ccvs/ccvs.htm
  * @link       http://www.loc.gov/standards/iso639-2/langcodes.html
  * @link       http://www.analysisandsolutions.com/donate/
  *
  * @license    http://www.analysisandsolutions.com/software/license.htm Simple Public License
  */
 public function validateCreditCard($Number, $CheckNumber, $Accepted = '', $RequireExp = 'N', $Month = '', $Year = '')
 {
     $this->CCVSNumber = '';
     $this->CCVSNumberLeft = '';
     $this->CCVSNumberRight = '';
     $this->CCVSType = '';
     $this->CCVSExpiration = '';
     $this->CCVSError = '';
     // Catch malformed input.
     if (empty($Number) || !is_string($Number)) {
         $this->CCVSError = $this->language->getLL('ErrNumberString');
         return false;
     }
     // Ensure number doesn't overrun.
     $Number = substr($Number, 0, 30);
     // Remove non-numeric characters.
     $this->CCVSNumber = preg_replace('/[^0-9]/', '', $Number);
     // Set up variables.
     $this->CCVSCheckNumber = trim($CheckNumber);
     $this->CCVSNumberLeft = substr($this->CCVSNumber, 0, 4);
     $this->CCVSNumberRight = substr($this->CCVSNumber, -4);
     $NumberLength = strlen($this->CCVSNumber);
     $DoChecksum = 'Y';
     // Determine the card type and appropriate length.
     if ($this->CCVSNumberLeft >= 3000 && $this->CCVSNumberLeft <= 3059) {
         $this->CCVSType = 'Diners Club';
         $ShouldLength = 14;
     } elseif ($this->CCVSNumberLeft >= 3600 && $this->CCVSNumberLeft <= 3699) {
         $this->CCVSType = 'Diners Club';
         $ShouldLength = 14;
     } elseif ($this->CCVSNumberLeft >= 3800 && $this->CCVSNumberLeft <= 3889) {
         $this->CCVSType = 'Diners Club';
         $ShouldLength = 14;
     } elseif ($this->CCVSNumberLeft >= 3400 && $this->CCVSNumberLeft <= 3499) {
         $this->CCVSType = 'American Express';
         $ShouldLength = 15;
     } elseif ($this->CCVSNumberLeft >= 3700 && $this->CCVSNumberLeft <= 3799) {
         $this->CCVSType = 'American Express';
         $ShouldLength = 15;
     } elseif ($this->CCVSNumberLeft >= 3088 && $this->CCVSNumberLeft <= 3094) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3096 && $this->CCVSNumberLeft <= 3102) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3112 && $this->CCVSNumberLeft <= 3120) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3158 && $this->CCVSNumberLeft <= 3159) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3337 && $this->CCVSNumberLeft <= 3349) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3528 && $this->CCVSNumberLeft <= 3589) {
         $this->CCVSType = 'JCB';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft >= 3890 && $this->CCVSNumberLeft <= 3899) {
         $this->CCVSType = 'Carte Blanche';
         $ShouldLength = 14;
     } elseif ($this->CCVSNumberLeft >= 4000 && $this->CCVSNumberLeft <= 4999) {
         $this->CCVSType = 'Visa';
         if ($NumberLength > 14) {
             $ShouldLength = 16;
         } elseif ($NumberLength < 14) {
             $ShouldLength = 13;
         } else {
             $this->CCVSError = $this->language->getLL('ErrVisa14');
             return false;
         }
     } elseif ($this->CCVSNumberLeft >= 5100 && $this->CCVSNumberLeft <= 5599) {
         $this->CCVSType = 'MasterCard';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft == 5610) {
         $this->CCVSType = 'Australian BankCard';
         $ShouldLength = 16;
     } elseif ($this->CCVSNumberLeft == 6011) {
         $this->CCVSType = 'Discover/Novus';
         $ShouldLength = 16;
     } else {
         $this->CCVSError = sprintf($this->language->getLL('ErrUnknown'), $this->CCVSNumberLeft);
         return false;
     }
     // Check acceptance.
     if (!empty($Accepted)) {
         if (!is_array($Accepted)) {
             $this->CCVSError = $this->language->getLL('ErrAccepted');
             return false;
         }
         if (!in_array($this->CCVSType, $Accepted)) {
             $this->CCVSError = sprintf($this->language->getLL('ErrNoAccept'), $this->CCVSType);
             return false;
         }
     }
     /* Check CheckNumber. */
     if (!empty($this->CCVSType)) {
         switch ($this->CCVSType) {
             case 'American Express':
                 if (strlen($this->CCVSCheckNumber) != 4) {
                     $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber);
                     return false;
                 }
                 break;
             case 'MasterCard':
                 if (strlen($this->CCVSCheckNumber) != 3) {
                     $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber);
                     return false;
                 }
                 break;
             case 'Visa':
                 if (strlen($this->CCVSCheckNumber) != 3) {
                     $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber);
                     return false;
                 }
                 break;
         }
     }
     // Check length.
     if ($NumberLength != $ShouldLength) {
         $Missing = $NumberLength - $ShouldLength;
         if ($Missing < 0) {
             $this->CCVSError = sprintf($this->language->getLL('ErrShort'), abs($Missing));
         } else {
             $this->CCVSError = sprintf($this->language->getLL('ErrLong'), $Missing);
         }
         return false;
     }
     // Mod10 checksum process...
     if ($DoChecksum == 'Y') {
         $Checksum = 0;
         /*
          * Add even digits in even length strings
          * or odd digits in odd length strings.
          */
         for ($Location = 1 - $NumberLength % 2; $Location < $NumberLength; $Location += 2) {
             $Checksum += (int) substr($this->CCVSNumber, $Location, 1);
         }
         /*
          * Analyze odd digits in even length strings
          * or even digits in odd length strings.
          */
         for ($Location = $NumberLength % 2; $Location < $NumberLength; $Location += 2) {
             $Digit = (int) substr($this->CCVSNumber, $Location, 1) * 2;
             if ($Digit < 10) {
                 $Checksum += $Digit;
             } else {
                 $Checksum += $Digit - 9;
             }
         }
         // Checksums not divisible by 10 are bad.
         if ($Checksum % 10 != 0) {
             $this->CCVSError = $this->language->getLL('ErrChecksum');
             return false;
         }
     }
     // Expiration date process...
     if ($RequireExp == 'Y') {
         if (empty($Month) || !is_string($Month)) {
             $this->CCVSError = $this->language->getLL('ErrMonthString');
             return false;
         }
         if (!preg_match('/^(0?[1-9]|1[0-2])$/', $Month)) {
             $this->CCVSError = $this->language->getLL('ErrMonthFormat');
             return false;
         }
         if (empty($Year) || !is_string($Year)) {
             $this->CCVSError = $this->language->getLL('ErrYearString');
             return false;
         }
         if (!preg_match('/^[0-9]{4}$/', $Year)) {
             $this->CCVSError = $this->language->getLL('ErrYearFormat');
             return false;
         }
         if ($Year < date('Y')) {
             $this->CCVSError = $this->language->getLL('ErrExpired');
             return false;
         } elseif ($Year == date('Y')) {
             if ($Month < date('m')) {
                 $this->CCVSError = $this->language->getLL('ErrExpired');
                 return false;
             }
         }
         $this->CCVSExpiration = sprintf('%02d', $Month) . substr($Year, -2);
     }
     return true;
 }
 /**
  * Adding a new content element wizard item for powermail
  *
  * @param array $contentElementWizardItems
  * @return array
  */
 function proc($wizardItems)
 {
     $this->initialize();
     $wizardItems['plugins_tx_jsfaq_faq'] = array('icon' => ExtensionManagementUtility::extRelPath('js_faq') . 'Resources/Public/Icons/wizard_icon.png', 'title' => $this->languageService->sL($this->locallangPath . 'plugin-title', TRUE), 'description' => $this->languageService->sL($this->locallangPath . 'plugin-description', TRUE), 'params' => '&defVals[tt_content][CType]=list&defVals[tt_content][list_type]=jsfaq_faq', 'tt_content_defValues' => array('CType' => 'list'));
     return $wizardItems;
 }