Esempio n. 1
0
    /**
     * @return string
     */
    protected function renderStorageMenu()
    {
        $currentStorage = $this->getMediaModule()->getCurrentStorage();
        /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
        $options = '';
        foreach ($this->getMediaModule()->getAllowedStorages() as $storage) {
            $selected = '';
            if ($currentStorage->getUid() == $storage->getUid()) {
                $selected = 'selected';
            }
            $options .= sprintf('<option value="%s" %s>%s %s</option>', $storage->getUid(), $selected, $storage->getName(), $storage->isOnline() ? '' : '(' . LocalizationUtility::translate('offline', 'media') . ')');
        }
        $parameters = GeneralUtility::_GET();
        $inputs = '';
        foreach ($parameters as $parameter => $value) {
            list($parameter, $value) = $this->computeParameterAndValue($parameter, $value);
            if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') {
                $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value);
            }
        }
        $template = '<form action="mod.php" id="form-menu-storage" method="get">
						%s
						<select name="%s[storage]" class="btn btn-min" id="menu-storage" onchange="$(\'#form-menu-storage\').submit()">%s</select>
					</form>';
        return sprintf($template, $inputs, $this->moduleLoader->getParameterPrefix(), $options);
    }
 /**
  * Checks if the given value is a valid recaptcha.
  *
  * @param mixed $value The value that should be validated
  * @throws InvalidVariableException
  */
 public function isValid($value)
 {
     $response = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('g-recaptcha-response');
     if ($response !== null) {
         // Only check if a response is set
         $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
         $fullTs = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
         $reCaptchaSettings = $fullTs['plugin.']['tx_sfeventmgt.']['settings.']['reCaptcha.'];
         if (isset($reCaptchaSettings) && is_array($reCaptchaSettings) && isset($reCaptchaSettings['secretKey']) && $reCaptchaSettings['secretKey']) {
             $ch = curl_init();
             $fields = ['secret' => $reCaptchaSettings['secretKey'], 'response' => $response];
             // url-ify the data for the POST
             $fieldsString = '';
             foreach ($fields as $key => $value) {
                 $fieldsString .= $key . '=' . $value . '&';
             }
             rtrim($fieldsString, '&');
             // set the url, number of POST vars, POST data
             curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
             curl_setopt($ch, CURLOPT_POST, count($fields));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
             // execute post
             $resultCH = json_decode(curl_exec($ch));
             if (!(bool) $resultCH->success) {
                 $this->addError(LocalizationUtility::translate('validation.possible_robot', 'sf_event_mgt'), 1231423345);
             }
         } else {
             throw new InvalidVariableException(LocalizationUtility::translate('error.no_secretKey', 'sf_event_mgt'), 1358349150);
         }
     }
 }
 /**
  * @return array
  */
 public function render()
 {
     $result = [];
     // Start the select with a blank element?
     if ($this->arguments['leadingBlank']) {
         $result[''] = '';
     }
     $extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
     if (!empty($this->arguments['values'])) {
         foreach ($this->arguments['values'] as $item => $count) {
             // Localise item name.
             $localisationKey = $this->arguments['localisationPrefix'] . $item;
             $localisedItem = LocalizationUtility::translate($localisationKey, $extensionName);
             if (!$localisedItem) {
                 $localisedItem = $item;
             }
             // Append count to item name?
             $result[$item] = $localisedItem . ($this->arguments['showCount'] ? ' (' . $count . ')' : '');
         }
     }
     // Sort the array?
     if ($this->arguments['sortByName']) {
         ksort($result);
     }
     // Strip sort prefixes.
     if ($this->arguments['sortPrefixSeparator']) {
         $strippedResult = [];
         foreach ($result as $key => $value) {
             $valueParts = explode($this->arguments['sortPrefixSeparator'], $value, 2);
             $strippedResult[$key] = $valueParts[count($valueParts) - 1];
         }
         $result = $strippedResult;
     }
     return $result;
 }
Esempio n. 4
0
 public function render()
 {
     $key = $this->arguments['key'];
     $id = $this->arguments['id'];
     $default = $arguments['default'];
     $htmlEscape = $arguments['htmlEscape'];
     $extensionName = $this->arguments['extensionName'];
     $arguments = $arguments['arguments'];
     // Wrapper including a compatibility layer for TYPO3 Flow Translation
     if ($id === null) {
         $id = $key;
     }
     if ((string) $id === '') {
         \AuM\Blypo\Service\ExceptionService::throwException('An argument "key" or "id" has to be provided');
     }
     $request = static::$renderingContext->getControllerContext()->getRequest();
     $extensionName = $extensionName === null ? $request->getControllerExtensionName() : $extensionName;
     $value = LocalizationUtility::translate($id, $extensionName, $arguments);
     if ($value === null) {
         $value = $default !== null ? $default : '';
         if (!empty($arguments)) {
             $value = vsprintf($value, $arguments);
         }
     } elseif ($htmlEscape) {
         $value = htmlspecialchars($value);
     }
     return $value;
 }
 /**
  * This method is used to define new fields for adding or editing a task
  * In this case, it adds an pid field
  *
  * @param array $taskInfo Reference to the array containing the info used in the add/edit form
  * @param object $task When editing, reference to the current task object. Null when adding.
  * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
  * @return array	Array containing all the information pertaining to the additional fields
  */
 public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
 {
     // Initialize extra field value
     if (empty($taskInfo['newsPids'])) {
         if ($parentObject->CMD == 'edit') {
             // In case of edit, set to internal value if no data was submitted already
             $taskInfo['newsPids'] = $task->newsPids;
         } else {
             // Otherwise set an empty value, as it will not be used anyway
             $taskInfo['newsPids'] = '';
         }
     }
     if (empty($taskInfo['ignore'])) {
         if ($parentObject->CMD == 'edit') {
             // In case of edit, set to internal value if no data was submitted already
             $taskInfo['ignore'] = $task->ignore;
         } else {
             // Otherwise set an empty value, as it will not be used anyway
             $taskInfo['ignore'] = 0;
         }
     }
     $additionalFields = array();
     // Write the code for the field
     $fieldID = 'task_newsPids';
     $fieldCode = $this->getMooxNewsFoldersSelector('tx_scheduler[newsPids]', $taskInfo['newsPids']);
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('LLL:EXT:moox_news/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxnews_tasks_setnewsaccesstask.news_pids_label', 'moox_news'), 'cshKey' => '_MOD_tools_txschedulerM1', 'cshLabel' => $fieldID);
     // Write the code for the field
     $fieldID = 'task_ignore';
     $fieldCode = '<input type="checkbox" name="tx_scheduler[ignore]" id="' . $fieldID . '" value="1" ' . ($taskInfo['ignore'] ? 'checked="checked" ' : '') . '/>';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('LLL:EXT:moox_news/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxnews_tasks_setnewsaccesstask.ignore_label', 'moox_news'), 'cshKey' => '_MOD_tools_txschedulerM1', 'cshLabel' => $fieldID);
     return $additionalFields;
 }
Esempio n. 6
0
 /**
  * Add an entry to the CacheMenuItems array
  *
  * @param array $cacheActions Array of CacheMenuItems
  * @param array $optionValues Array of AccessConfigurations-identifiers (typically  used by userTS with options.clearCache.identifier)
  */
 public function manipulateCacheActions(&$cacheActions, &$optionValues)
 {
     $title = LocalizationUtility::translate('cache_action.title', 'cs_clear_images');
     $icon = '<img ' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ExtensionManagementUtility::extRelPath('cs_clear_images') . 'Resources/Public/Images/clear_cache_icon.png', 'width="16" height="16"') . ' alt="" title="' . $title . '"/>';
     // Clearing of processed images
     $cacheActions[] = array('id' => 'tx_csclearimages', 'title' => $title, 'href' => $this->backPath . 'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() . '&cacheCmd=tx_csclearimages&ajaxCall=1' . \TYPO3\CMS\Backend\Utility\BackendUtility::getUrlToken('tceAction'), 'icon' => $icon);
 }
    /**
     * Renders a download link
     *
     * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
     * @return string the rendered a tag
     */
    public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
    {
        $installPaths = \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallPaths();
        if (empty($installPaths)) {
            return '';
        }
        $pathSelector = '<ul class="is-hidden">';
        foreach ($installPaths as $installPathType => $installPath) {
            $pathSelector .= '<li>
				<input type="radio" id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '" name="' . htmlspecialchars($this->getFieldNamePrefix('downloadPath')) . '[downloadPath]" class="downloadPath" value="' . htmlspecialchars($installPathType) . '"' . ($installPathType == 'Local' ? ' checked="checked"' : '') . '/>
				<label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label>
			</li>';
        }
        $pathSelector .= '</ul>';
        $uriBuilder = $this->controllerContext->getUriBuilder();
        $action = 'checkDependencies';
        $uriBuilder->reset();
        $uriBuilder->setFormat('json');
        $uri = $uriBuilder->uriFor($action, array('extension' => (int) $extension->getUid()), 'Download');
        $this->tag->addAttribute('data-href', $uri);
        $label = '
			<div class="btn-group">
				<button
					title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '"
					type="submit"
					class="btn btn-default"
					value="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '"
				>
					<span class="t3-icon fa fa-cloud-download"></span>
				</button>
			</div>';
        $this->tag->setContent($label . $pathSelector);
        $this->tag->addAttribute('class', 'download');
        return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>';
    }
 /**
  *
  */
 protected function initializeAction()
 {
     if (!$this->backendUserHasUserGroup($this->getRequiredUserGroup())) {
         $this->addFlashMessage(LocalizationUtility::translate('controller.be.protected_controller.no_permission', 'election'), LocalizationUtility::translate('controller.be.protected_controller.error', 'election'), AbstractMessage::ERROR);
         $this->redirect(BeDashboardController::ACTION_INDEX, BeDashboardController::CONTROLLER_NAME);
     }
 }
 /**
  * @param \S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task
  *
  * @return bool
  */
 public function run(\S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task)
 {
     $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extensionName]);
     $upperLimit = new \DateTime();
     $lowerLimit = new \DateTime();
     $daysLeft = $settings['warnXDaysBeforeExpireDate'];
     $sender = [$task->getSenderAddress()];
     $receiver = [$task->getReceiverAddress()];
     $subject = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.subject', $this->extensionName);
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     // Upper limit (expiry) = Current date + Days left
     $upperLimit->setTimestamp($upperLimit->getTimestamp() + $daysLeft * 86400);
     // Lower limit (expiry) = Current date + Days left - Scheduler frequency
     $lowerLimit->setTimestamp($lowerLimit->getTimestamp() + $daysLeft * 86400 - $task->getExecution()->getInterval());
     $where = "date_of_expiry > '{$lowerLimit->format('Y-m-d h:i:s')}' AND date_of_expiry < '{$upperLimit->format('Y-m-d h:i:s')}'";
     if ($this->databaseConnection->exec_SELECTcountRows('*', 'tx_projectregistration_domain_model_project', $where)) {
         $expiredProjects = $this->databaseConnection->exec_SELECTgetRows('project.*, registrant.name as registrant_name, registrant.company as registrant_company', 'tx_projectregistration_domain_model_project as project join tx_projectregistration_domain_model_person as registrant on project.registrant=registrant.uid', $where);
         $list = [];
         /** @var array $expiredProject */
         foreach ($expiredProjects as $expiredProject) {
             $list[] = "#{$expiredProject['uid']} - '{$expiredProject['title']}' by {$expiredProject['registrant_name']} ({$expiredProject['registrant_company']})";
         }
         $mailContent = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.message', $this->extensionName, [$daysLeft, '<li>' . implode('</li><li>', $list) . '</li>']);
         /** @var \TYPO3\CMS\Core\Mail\MailMessage $mail */
         $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
         $mail->setContentType('text/html');
         /**
          * Email to sender
          */
         $mail->setFrom($sender)->setTo($receiver)->setPriority(1)->setSubject($subject)->setBody($mailContent)->send();
     }
     return true;
 }
Esempio n. 10
0
 public function render()
 {
     $class = 'control-group';
     if ($this->arguments['llLabel']) {
         $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($this->arguments['llLabel'], 'typo3_forum');
     } else {
         $label = $this->arguments['label'];
     }
     if ($this->arguments['error']) {
         $results = $this->controllerContext->getRequest()->getOriginalRequestMappingResults()->getSubResults();
         $propertyPath = explode('.', $this->arguments['error']);
         foreach ($propertyPath as $currentPropertyName) {
             $errors = $this->getErrorsForProperty($currentPropertyName, $results);
         }
         if (count($errors) > 0) {
             $class .= ' error';
             $errorContent = '';
             foreach ($errors as $error) {
                 $errorText = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($this->arguments['errorLLPrefix'] . '_' . $error->getCode(), 'typo3_forum');
                 if (!$errorText) {
                     $errorText = 'TRANSLATE: ' . $this->arguments['errorLLPrefix'] . '_' . $error->getCode();
                 }
                 $errorContent .= '<p class="help-block">' . $errorText . '</p>';
             }
         }
     } else {
         $errorText = '';
     }
     $label = '<label>' . $label . '</label>';
     $content = '<div>' . $this->renderChildren() . $errorContent . '</div>';
     $this->tag->addAttribute('class', $class);
     $this->tag->setContent($label . $content);
     return $this->tag->render();
 }
 /**
  */
 protected function errorAction()
 {
     $results = new \stdClass();
     $results->hasErrors = false;
     $errorResults = $this->arguments->getValidationResults();
     $results->errors = new \stdClass();
     $results->errors->byProperty = array();
     foreach ($errorResults->getFlattenedErrors() as $property => $error) {
         $errorDetails = $errorResults->forProperty($property)->getErrors();
         foreach ($errorDetails as $error) {
             $results->hasErrors = true;
             $errorObj = new \stdClass();
             $errorObj->code = $error->getCode();
             $errorObj->property = $property;
             $key = 'form-frontendUserController-' . $errorObj->property . '-' . $errorObj->code;
             $translatedMessage = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'cicregister');
             if ($translatedMessage) {
                 $errorObj->message = $translatedMessage;
             } else {
                 $errorObj->message = $error->getMessage();
             }
             $results->errors->byProperty[str_replace('.', '-', $property)][] = $errorObj;
         }
     }
     $this->view->assign('results', json_encode($results));
 }
 /**
  * Check the word that was entered against the hashed value
  * Returns TRUE, if the given property ($word) matches the session captcha value.
  *
  * @param string $word: the word that was entered and should be validated
  * @return boolean TRUE, if the word entered matches the hash value, FALSE if an error occured
  */
 public function isValid($word)
 {
     $isValid = FALSE;
     // Overwrite $word if options contains a value
     if ($this->options['word']) {
         $word = $this->options['word'];
     }
     // Get session data
     /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var \SJBR\SrFreecap\Domain\Repository\WordRepository $wordRepository */
     $wordRepository = $objectManager->get('SJBR\\SrFreecap\\Domain\\Repository\\WordRepository');
     $wordObject = $wordRepository->getWord();
     $wordHash = $wordObject->getWordHash();
     // Check the word hash against the stored hash value
     if (!empty($wordHash) && !empty($word)) {
         if ($wordObject->getHashFunction() == 'md5') {
             // All freeCap words are lowercase.
             // font #4 looks uppercase, but trust me, it's not...
             if (md5(strtolower(utf8_decode($word))) == $wordHash) {
                 // Reset freeCap session vars
                 // Cannot stress enough how important it is to do this
                 // Defeats re-use of known image with spoofed session id
                 $wordRepository->cleanUpWord();
                 $isValid = TRUE;
             }
         }
     }
     if (!$isValid) {
         $this->addError(LocalizationUtility::translate('tx_pwcomments.validation_error.captcha', 'PwComments'), 9221561048.0);
     }
     return $isValid;
 }
Esempio n. 13
0
 /**
  * Implementing CompilableInterface suppresses object instantiation of this view helper
  *
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  * @return string
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     // The two main icon classes are static during one call. They trigger relatively expensive
     // calculation with a signal and object creation and thus make sense to have them cached.
     if (!static::$grantedCssClasses) {
         static::$grantedCssClasses = IconUtility::getSpriteIconClasses('status-status-permission-granted');
     }
     if (!static::$deniedCssClasses) {
         static::$deniedCssClasses = IconUtility::getSpriteIconClasses('status-status-permission-denied');
     }
     $masks = array(1, 16, 2, 4, 8);
     if (empty(static::$permissionLabels)) {
         foreach ($masks as $mask) {
             static::$permissionLabels[$mask] = LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:' . $mask, 'be_user');
         }
     }
     $icon = '';
     foreach ($masks as $mask) {
         if ($arguments['permission'] & $mask) {
             $icon .= '<span' . ' title="' . static::$permissionLabels[$mask] . '"' . ' class="' . static::$grantedCssClasses . ' change-permission text-success"' . ' data-page="' . $arguments['pageId'] . '"' . ' data-permissions="' . $arguments['permission'] . '"' . ' data-mode="delete"' . ' data-who="' . $arguments['scope'] . '"' . ' data-bits="' . $mask . '"' . ' style="cursor:pointer"' . '></span>';
         } else {
             $icon .= '<span' . ' title="' . static::$permissionLabels[$mask] . '"' . ' class="' . static::$deniedCssClasses . ' change-permission text-danger"' . ' data-page="' . $arguments['pageId'] . '"' . ' data-permissions="' . $arguments['permission'] . '"' . ' data-mode="add"' . ' data-who="' . $arguments['scope'] . '"' . ' data-bits="' . $mask . '"' . ' style="cursor:pointer"' . '></span>';
         }
     }
     return '<span id="' . $arguments['pageId'] . '_' . $arguments['scope'] . '">' . $icon . '</span>';
 }
Esempio n. 14
0
 public function render()
 {
     $decimals = isset($this->arguments['decimals']) ? $this->arguments['decimals'] : 2;
     $decSep = isset($this->arguments['decSep']) ? $this->arguments['decSep'] : false;
     $thouSep = isset($this->arguments['thouSep']) ? $this->arguments['thouSep'] : false;
     $value = $this->arguments['value'];
     if ($value === null) {
         //TODO #exception
     }
     if (empty(self::$units)) {
         self::$units = GeneralUtility::trimExplode(',', LocalizationUtility::translate('viewhelper.format.bytes.units', 'fluid'));
     }
     if (!is_integer($value) && !is_float($value)) {
         if (is_numeric($value)) {
             $value = (double) $value;
         } else {
             $value = 0;
         }
     }
     $bytes = max($value, 0);
     $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
     $pow = min($pow, count(self::$units) - 1);
     $bytes /= pow(2, 10 * $pow);
     echo sprintf('%s %s', number_format(round($bytes, 4 * $this->arguments['decimals']), $this->arguments['decimals'], $this->arguments['decimalSeparator'], $this->arguments['thousandsSeparator']), self::$units[$pow]);
 }
Esempio n. 15
0
 /**
  * Initial function to validate
  *
  * @param Comment $comment Comment model to validate
  * @return bool
  */
 public function isValid($comment)
 {
     $this->settings = $this->getExtensionSettings();
     $errorNumber = NULL;
     $errorArguments = NULL;
     if (!$this->anyPropertyIsSet($comment)) {
         $errorNumber = 1299628038;
     } elseif (!$this->mailIsValid($comment)) {
         $errorNumber = 1299628371;
     } elseif (!$this->messageIsSet($comment)) {
         $errorNumber = 1299628099;
         $errorArguments = array($this->settings['secondsBetweenTwoComments']);
     } elseif ($this->settings['useBadWordsList'] && !$this->checkTextForBadWords($comment->getMessage())) {
         $errorNumber = 1315608355;
     } elseif ($this->settings['useBadWordsListOnUsername'] && !$this->checkTextForBadWords($comment->getAuthorName())) {
         $errorNumber = 1406644911;
     } elseif ($this->settings['useBadWordsListOnMailAddress'] && !$this->checkTextForBadWords($comment->getAuthorMail())) {
         $errorNumber = 1406644912;
     } elseif (!$this->lastCommentRespectsTimer($comment)) {
         $errorNumber = 1300280476;
         $errorArguments = array($this->settings['secondsBetweenTwoComments']);
     }
     if ($errorNumber !== NULL) {
         $errorMessage = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_pwcomments.validation_error.' . $errorNumber, 'PwComments', $errorArguments);
         $this->addError($errorMessage, $errorNumber);
     }
     return $errorNumber === NULL;
 }
Esempio n. 16
0
 /**
  * @param $content string
  * @return string
  */
 public function render($content = NULL)
 {
     $alternative = $this->arguments['alternative'];
     if (NULL === $content) {
         $content = $this->renderChildren();
     }
     if (FALSE === empty($content)) {
         return $content;
     }
     if (FALSE === is_string($alternative) || 0 !== strpos($alternative, 'LLL:')) {
         return $alternative;
     }
     if (0 !== strpos($alternative, 'LLL:EXT:')) {
         // Trim off LLL: from shorthand LLL:labelname syntax so only label is passed to translate function
         $translate = substr($alternative, 4);
     }
     $arguments = $this->arguments['arguments'];
     $extensionName = $this->arguments['extensionName'];
     if (NULL === $extensionName) {
         if (TRUE === method_exists($this, 'getControllerContext')) {
             $request = $this->getControllerContext()->getRequest();
         } else {
             $request = $this->controllerContext->getRequest();
         }
         $extensionName = $request->getControllerExtensionName();
     }
     $content = LocalizationUtility::translate($translate, $extensionName, $arguments);
     if (NULL === $content) {
         $content = $alternative;
     }
     return $content;
 }
Esempio n. 17
0
 /**
  * Renders a configure extension link if the extension has configuration options
  *
  * @return string the rendered tag or child nodes content
  */
 public function render()
 {
     $extension = $this->arguments['extension'];
     $forceConfiguration = $this->arguments['forceConfiguration'];
     $showDescription = $this->arguments['showDescription'];
     $content = (string) $this->renderChildren();
     if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
         $uriBuilder = $this->controllerContext->getUriBuilder();
         $action = 'showConfigurationForm';
         $uri = $uriBuilder->reset()->uriFor($action, ['extension' => ['key' => $extension['key']]], 'Configuration');
         if ($showDescription) {
             $title = $extension['description'] . PHP_EOL . LocalizationUtility::translate('extensionList.clickToConfigure', 'extensionmanager');
         } else {
             $title = LocalizationUtility::translate('extensionList.configure', 'extensionmanager');
         }
         $this->tag->addAttribute('href', $uri);
         $this->tag->addAttribute('title', $title);
         $this->tag->setContent($content);
         $content = $this->tag->render();
     } elseif ($forceConfiguration) {
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $content = '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
     } else {
         $content = '<span title="' . htmlspecialchars($extension['description']) . '">' . $content . '</span>';
     }
     return $content;
 }
 /**
  * Main function, returning the HTML content
  *
  * @return string HTML
  */
 function main()
 {
     $content = '';
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->installTool = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
     $databaseUpdateUtility = $this->objectManager->get('SJBR\\StaticInfoTables\\Utility\\DatabaseUpdateUtility');
     // Clear the class cache
     $classCacheManager = $this->objectManager->get('SJBR\\StaticInfoTables\\Cache\\ClassCacheManager');
     $classCacheManager->reBuild();
     // Process the database updates of this base extension (we want to re-process these updates every time the update script is invoked)
     $extensionSitePath = ExtensionManagementUtility::extPath(GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName));
     $content .= '<p>' . nl2br(LocalizationUtility::translate('updateTables', $this->extensionName)) . '</p>';
     $this->importStaticSqlFile($extensionSitePath);
     // Get the extensions which want to extend static_info_tables
     $loadedExtensions = array_unique(ExtensionManagementUtility::getLoadedExtensionListArray());
     foreach ($loadedExtensions as $extensionKey) {
         $extensionInfoFile = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
         if (file_exists($extensionInfoFile)) {
             // We need to reprocess the database structure update sql statements (ext_tables)
             $this->processDatabaseUpdates($extensionKey);
             // Now we process the static data updates (ext_tables_static+adt)
             // Note: The Install Tool Utility does not handle sql update statements
             $databaseUpdateUtility->doUpdate($extensionKey);
             $content .= '<p>' . nl2br(LocalizationUtility::translate('updateLanguageLabels', $this->extensionName)) . ' ' . $extensionKey . '</p>';
         }
     }
     if (!$content) {
         // Nothing to do
         $content .= '<p>' . nl2br(LocalizationUtility::translate('nothingToDo', $this->extensionName)) . '</p>';
     }
     // Notice for old language packs
     $content .= '<p>' . nl2br(LocalizationUtility::translate('update.oldLanguagePacks', $this->extensionName)) . '</p>';
     return $content;
 }
Esempio n. 19
0
 /**
  * @param Address $address
  * @return bool
  */
 protected function isValid($address)
 {
     $result = true;
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'H2dmailsub', 'Pidmailsubscribe');
     $validationSettings = $settings['validation'];
     foreach ($validationSettings as $field => $validations) {
         $value = $address->{'get' . ucfirst($field)}();
         foreach ($validations as $validation => $validationSetting) {
             switch ($validation) {
                 case 'required':
                     if ($validationSetting === '1' && empty($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.required', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
                 case 'email':
                     if (!empty($value) && $validationSetting === '1' && !\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.email', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
             }
         }
     }
     return $result;
 }
Esempio n. 20
0
 /**
  * @param $content string
  * @return string
  */
 public function render($content = NULL)
 {
     $alternative = $this->arguments['alternative'];
     $arguments = (array) $this->arguments['arguments'];
     if (NULL === $content) {
         $content = $this->renderChildren();
     }
     if (FALSE === empty($content)) {
         return TRUE === is_array($arguments) ? vsprintf($content, $arguments) : $content;
     }
     if (FALSE === is_string($alternative) || 0 !== strpos($alternative, 'LLL:')) {
         return $alternative;
     }
     if (0 === strpos($alternative, 'LLL:EXT:')) {
         return LocalizationUtility::translate($alternative, NULL, $arguments);
     }
     $translate = substr($alternative, 4);
     $extensionName = $this->arguments['extensionName'];
     if (NULL === $extensionName) {
         $request = $this->controllerContext->getRequest();
         $extensionName = $request->getControllerExtensionName();
     }
     $content = LocalizationUtility::translate($translate, $extensionName, $arguments);
     if (NULL === $content) {
         $content = $alternative;
     }
     return $content;
 }
 /**
  * Main method
  *
  * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
  * @throws \Exception
  * @return FlashMessage
  */
 public function execute()
 {
     $this->controller->headerMessage(LocalizationUtility::translate('migrateDamMetadataCommand', 'dam_falmigration'));
     if (!$this->isTableAvailable('tx_dam')) {
         return $this->getResultMessage('damTableNotFound');
     }
     $res = $this->execSelectMigratedSysFilesQuery();
     $total = $this->database->sql_num_rows($res);
     $counter = 0;
     $this->controller->infoMessage('Found ' . $total . ' migrated sys_file records');
     $this->isInstalledFileMetadata = ExtensionManagementUtility::isLoaded('filemetadata');
     $this->isInstalledMedia = ExtensionManagementUtility::isLoaded('media');
     while ($record = $this->database->sql_fetch_assoc($res)) {
         $fileMetaData = $this->createArrayForUpdateSysFileMetadataRecord($record);
         $this->database->exec_UPDATEquery('sys_file_metadata', 'uid = ' . $record['metadata_uid'] . ' AND sys_language_uid = ' . $record['sys_language_uid'], $fileMetaData);
         // if no SQL error and still no record has been updated, then it means that
         // the record does not exist and must be created e.g. localized DAM record.
         if ($this->database->sql_error() == '' && $this->database->sql_affected_rows() == 0) {
             $this->updateArrayForInsertSysFileRecord($fileMetaData, $record);
             $this->database->exec_INSERTquery('sys_file_metadata', $fileMetaData);
         }
         $this->database->exec_UPDATEquery('sys_file', 'uid = ' . $record['file_uid'], $this->createArrayForUpdateSysFileRecord($record));
         $this->controller->message(number_format(100 * ($counter / $total), 1) . '% of ' . $total . ' id: ' . $record['file_uid']);
         $this->amountOfMigratedRecords++;
         $counter++;
     }
     $this->database->sql_free_result($res);
     return $this->getResultMessage();
 }
 /**
  * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
  * @param boolean $emulate Return to current session or logout after target session termination?
  * @return string
  */
 public function render(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser, $emulate = FALSE)
 {
     if ($backendUser->getUid() == $GLOBALS['BE_USER']->user['uid']) {
         return '';
     }
     $title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($emulate ? 'switchBackMode' : 'changeToMode', 'beuser');
     return '<a href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('SwitchUser' => $backendUser->getUid(), 'switchBackUser' => $emulate)) . '" target="_top" title="' . htmlspecialchars($title) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-backend-user-' . ($emulate ? 'emulate' : 'switch')) . '</a>';
 }
 /**
  * main render function
  *
  * @param integer $numberOfResults
  * @param integer $resultsPerPage
  * @param integer $currentPage
  * @return string the content
  */
 public function render($numberOfResults, $resultsPerPage, $currentPage = 1)
 {
     $firstResultOnPage = $currentPage * $resultsPerPage + 1;
     $lastResultOnPage = $currentPage * $resultsPerPage + $resultsPerPage;
     $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('displayResults', 'indexed_search');
     $content = sprintf($label, $firstResultOnPage, min(array($numberOfResults, $lastResultOnPage)), $numberOfResults);
     return $content;
 }
Esempio n. 24
0
 /**
  * Renders a "mass delete" menu item to be placed in the grid menu.
  *
  * @return string
  */
 public function render()
 {
     $output = '';
     if ($this->getMediaModule()->hasFolderTree()) {
         $output = sprintf('<li><a href="%s" class="clipboard-save" >%s %s</a>', $this->getSaveInClipboardUri(), $this->getIconFactory()->getIcon('actions-document-paste-after', Icon::SIZE_SMALL), LocalizationUtility::translate('clipboard.save', 'vidi'));
     }
     return $output;
 }
 /**
  * Translate a given key or use the tag body as default.
  *
  * @return string The translated key or tag body if key doesn't exist
  */
 public function render()
 {
     $value = parent::render();
     if (!isset($value)) {
         $value = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($this->arguments['key'], 'roq_newsevent', $this->arguments);
     }
     return $value;
 }
 /**
  * Translate label for module
  *
  * @param string $key
  * @param array $arguments
  * @return string
  */
 protected function translate($key, $arguments = array())
 {
     $label = null;
     if (!empty($key)) {
         $label = LocalizationUtility::translate('backendUserAccessOverview_' . $key, 'my_user_management', $arguments);
     }
     return $label ? $label : $key;
 }
Esempio n. 27
0
 /**
  * @param string $key
  * @param $labelsIn
  * @param $labelPrefix
  * @return string
  */
 protected function getLabel($key, $labelsIn, $labelPrefix)
 {
     $label = LocalizationUtility::translate($labelPrefix . $key, $labelsIn);
     if (empty($label)) {
         $label = $key;
     }
     return $label;
 }
Esempio n. 28
0
 /**
  * Translation handler.
  *
  * @param    string $index     The index to the LLL reference.
  * @param    array  $arguments Arguments passed over to vsprintf.
  * @return    string                The translated string.
  */
 public static function translate($index, $arguments = null)
 {
     $result = LocalizationUtility::translate($index, self::EXTENSION_KEY, $arguments);
     if ($result == '' && $index != '') {
         $result = $index;
     }
     return $result;
 }
Esempio n. 29
0
 /**
  * @param Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn
  * @return string
  */
 public function renderColumnLabel(Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn $headerColumn)
 {
     $label = $headerColumn->getLabel();
     $label = Tx_PtExtlist_Utility_RenderValue::stdWrapIfPlainArray($label);
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($label, 'LLL:')) {
         $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label, '');
     }
     return $label;
 }
 /**
  * Fetches the translation for a given label. If no translation is found, the label is returned unchanged.
  *
  * @param string $label The label to translate
  * @return string
  */
 protected function translateLabel($label)
 {
     if ($label === '') {
         return '';
     }
     $labelKey = $this->hasArgument('optionLabelPrefix') ? $this->arguments['optionLabelPrefix'] . $label : $label;
     $translatedLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($labelKey, $this->controllerContext->getRequest()->getControllerExtensionName());
     return $translatedLabel ? $translatedLabel : $label;
 }