示例#1
0
 /**
  * Validate ordering as extbase can't handle that currently
  *
  * @param string $fieldToCheck
  * @param string $allowedSettings
  * @return boolean
  */
 public static function isValidOrdering($fieldToCheck, $allowedSettings)
 {
     $isValid = TRUE;
     if (empty($fieldToCheck)) {
         return $isValid;
     } elseif (empty($allowedSettings)) {
         return FALSE;
     }
     $fields = GeneralUtility::trimExplode(',', $fieldToCheck, TRUE);
     foreach ($fields as $field) {
         if ($isValid === TRUE) {
             $split = GeneralUtility::trimExplode(' ', $field, TRUE);
             $count = count($split);
             switch ($count) {
                 case 1:
                     if (!GeneralUtility::inList($allowedSettings, $split[0])) {
                         $isValid = FALSE;
                     }
                     break;
                 case 2:
                     if (strtolower($split[1]) !== 'desc' && strtolower($split[1]) !== 'asc' || !GeneralUtility::inList($allowedSettings, $split[0])) {
                         $isValid = FALSE;
                     }
                     break;
                 default:
                     $isValid = FALSE;
             }
         }
     }
     return $isValid;
 }
 /**
  * Initialize new row with default values from various sources
  *
  * @param array $result
  * @return array
  */
 public function addData(array $result)
 {
     $databaseRow = $result['databaseRow'];
     $newRow = $databaseRow;
     foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
         // Keep current value if it can be resolved to "the is something" directly
         if (isset($databaseRow[$fieldName])) {
             $newRow[$fieldName] = $databaseRow[$fieldName];
             continue;
         }
         // Special handling for eval null
         if (!empty($fieldConfig['config']['eval']) && GeneralUtility::inList($fieldConfig['config']['eval'], 'null')) {
             if (array_key_exists($fieldName, $databaseRow) || array_key_exists('default', $fieldConfig['config']) && $fieldConfig['config']['default'] === null) {
                 $newRow[$fieldName] = null;
             } else {
                 $newRow[$fieldName] = (string) $fieldConfig['config']['default'];
             }
         } else {
             // Fun part: This forces empty string for any field even if no default is set. Unsure if that is a good idea.
             $newRow[$fieldName] = (string) $fieldConfig['config']['default'];
         }
     }
     $result['databaseRow'] = $newRow;
     return $result;
 }
示例#3
0
 /**
  * Rebuild the class cache
  *
  * @param array $parameters
  *
  * @throws \Evoweb\Extender\Exception\FileNotFoundException
  * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
  * @return void
  */
 public function reBuild(array $parameters = array())
 {
     if (empty($parameters) || !empty($parameters['cacheCmd']) && GeneralUtility::inList('all,system', $parameters['cacheCmd']) && isset($GLOBALS['BE_USER'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] as $extensionKey => $extensionConfiguration) {
             if (!isset($extensionConfiguration['extender']) || !is_array($extensionConfiguration['extender'])) {
                 continue;
             }
             foreach ($extensionConfiguration['extender'] as $entity => $entityConfiguration) {
                 $key = 'Domain/Model/' . $entity;
                 // Get the file to extend, this needs to be loaded as first
                 $path = ExtensionManagementUtility::extPath($extensionKey) . 'Classes/' . $key . '.php';
                 if (!is_file($path)) {
                     throw new \Evoweb\Extender\Exception\FileNotFoundException('given file "' . $path . '" does not exist');
                 }
                 $code = $this->parseSingleFile($path, false);
                 // Get the files from all other extensions that are extending this domain model
                 if (is_array($entityConfiguration)) {
                     foreach ($entityConfiguration as $extendingExtension => $extendingFilepath) {
                         $path = GeneralUtility::getFileAbsFileName($extendingFilepath, false);
                         if (!is_file($path) && !is_numeric($extendingExtension)) {
                             $path = ExtensionManagementUtility::extPath($extendingExtension) . 'Classes/' . $key . '.php';
                         }
                         $code .= $this->parseSingleFile($path);
                     }
                 }
                 // Close the class definition
                 $code = $this->closeClassDefinition($code);
                 // Add the new file to the class cache
                 $cacheEntryIdentifier = GeneralUtility::underscoredToLowerCamelCase($extensionKey) . '_' . str_replace('/', '', $key);
                 $this->cacheInstance->set($cacheEntryIdentifier, $code);
             }
         }
     }
 }
 /**
  * Initialize actions. These actions are meant to be called by an logged-in FE User.
  */
 public function initializeAction()
 {
     // Perhaps it should go into a validator?
     // Check permission before executing any action.
     $allowedFrontendGroups = trim($this->settings['allowedFrontendGroups']);
     if ($allowedFrontendGroups === '*') {
         if (empty($this->getFrontendUser()->user)) {
             throw new Exception('FE User must be logged-in.', 1387696171);
         }
     } elseif (!empty($allowedFrontendGroups)) {
         $isAllowed = FALSE;
         $frontendGroups = GeneralUtility::trimExplode(',', $allowedFrontendGroups, TRUE);
         foreach ($frontendGroups as $frontendGroup) {
             if (GeneralUtility::inList($this->getFrontendUser()->user['usergroup'], $frontendGroup)) {
                 $isAllowed = TRUE;
                 break;
             }
         }
         // Throw exception if not allowed
         if (!$isAllowed) {
             throw new Exception('FE User does not have enough permission.', 1415211931);
         }
     }
     $this->emitBeforeHandleUploadSignal();
 }
 /**
  * Renders <f:then> child if BE user is allowed to edit given table, otherwise renders <f:else> child.
  *
  * @param string $table Name of the table
  * @return string the rendered string
  * @api
  */
 public function render($table)
 {
     if ($GLOBALS['BE_USER']->isAdmin() || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['BE_USER']->groupData['tables_modify'], $table)) {
         return $this->renderThenChild();
     }
     return $this->renderElseChild();
 }
 /**
  * Rendering the cObject, HMENU
  *
  * @param array $conf Array of TypoScript properties
  * @return string Output
  */
 public function render($conf = array())
 {
     $theValue = '';
     if ($this->cObj->checkIf($conf['if.'])) {
         $cls = strtolower($conf[1]);
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TSFE']->tmpl->menuclasses, $cls)) {
             if (isset($conf['excludeUidList.'])) {
                 $conf['excludeUidList'] = $this->cObj->stdWrap($conf['excludeUidList'], $conf['excludeUidList.']);
             }
             if (isset($conf['special.']['value.'])) {
                 $conf['special.']['value'] = $this->cObj->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
             }
             $GLOBALS['TSFE']->register['count_HMENU']++;
             $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
             $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
             $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
             $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
             $menu = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_' . $cls);
             $menu->parent_cObj = $this->cObj;
             $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
             $menu->makeMenu();
             $theValue .= $menu->writeMenu();
         }
         $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
         if ($wrap) {
             $theValue = $this->cObj->wrap($theValue, $wrap);
         }
         if (isset($conf['stdWrap.'])) {
             $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
         }
     }
     return $theValue;
 }
 /**
  * Handler for unknown types.
  *
  * @return array As defined in initializeResultArray() of AbstractNode
  */
 public function render()
 {
     $resultArray = $this->initializeResultArray();
     $languageService = $this->getLanguageService();
     $row = $this->data['databaseRow'];
     $parameterArray = $this->data['parameterArray'];
     // If ratios are set do not add default options
     if (isset($parameterArray['fieldConf']['config']['ratios'])) {
         unset($this->defaultConfig['ratios']);
     }
     $config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']);
     // By default we allow all image extensions that can be handled by the GFX functionality
     if ($config['allowedExtensions'] === null) {
         $config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
     }
     if ($config['readOnly']) {
         $options = array();
         $options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
         $options['renderType'] = 'none';
         return $this->nodeFactory->create($options)->render();
     }
     $file = $this->getFile($row, $config['file_field']);
     if (!$file) {
         return $resultArray;
     }
     $content = '';
     $preview = '';
     if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) {
         // Get preview
         $preview = $this->getPreview($file, $parameterArray['itemFormElValue']);
         // Check if ratio labels hold translation strings
         foreach ((array) $config['ratios'] as $ratio => $label) {
             $config['ratios'][$ratio] = $languageService->sL($label, true);
         }
         $formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
         $wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid());
         $wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard');
         $buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId);
         $button = '<button class="btn btn-default t3js-image-manipulation-trigger"';
         foreach ($buttonAttributes as $key => $value) {
             $button .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
         }
         $button .= '><span class="t3-icon fa fa-crop"></span>';
         $button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true);
         $button .= '</button>';
         $inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
         $content .= $inputField . $button;
         $content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
         $resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}');
     }
     $content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />';
     $content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'])));
     $content .= '</em></p>';
     $item = '<div class="media">';
     $item .= $preview;
     $item .= '<div class="media-body">' . $content . '</div>';
     $item .= '</div>';
     $resultArray['html'] = $item;
     return $resultArray;
 }
 /**
  * This method actually does the processing of files locally
  *
  * takes the original file (on remote storages this will be fetched from the remote server)
  * does the IM magic on the local server by creating a temporary typo3temp/ file
  * copies the typo3temp/ file to the processing folder of the target storage
  * removes the typo3temp/ file
  *
  * @param TaskInterface $task
  * @return array
  */
 public function process(TaskInterface $task)
 {
     $targetFile = $task->getTargetFile();
     // Merge custom configuration with default configuration
     $configuration = array_merge(array('width' => 64, 'height' => 64), $task->getConfiguration());
     $configuration['width'] = Utility\MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
     $configuration['height'] = Utility\MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
     $originalFileName = $targetFile->getOriginalFile()->getForLocalProcessing(FALSE);
     // Create a temporary file in typo3temp/
     if ($targetFile->getOriginalFile()->getExtension() === 'jpg') {
         $targetFileExtension = '.jpg';
     } else {
         $targetFileExtension = '.png';
     }
     // Create the thumb filename in typo3temp/preview_....jpg
     $temporaryFileName = Utility\GeneralUtility::tempnam('preview_') . $targetFileExtension;
     // Check file extension
     if ($targetFile->getOriginalFile()->getType() != Resource\File::FILETYPE_IMAGE && !Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $targetFile->getOriginalFile()->getExtension())) {
         // Create a default image
         $this->processor->getTemporaryImageWithText($temporaryFileName, 'Not imagefile!', 'No ext!', $targetFile->getOriginalFile()->getName());
     } else {
         // Create the temporary file
         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
             $parameters = '-sample ' . $configuration['width'] . 'x' . $configuration['height'] . ' ' . $this->processor->wrapFileName($originalFileName) . '[0] ' . $this->processor->wrapFileName($temporaryFileName);
             $cmd = Utility\GeneralUtility::imageMagickCommand('convert', $parameters) . ' 2>&1';
             Utility\CommandUtility::exec($cmd);
             if (!file_exists($temporaryFileName)) {
                 // Create a error gif
                 $this->processor->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', $targetFile->getOriginalFile()->getName());
             }
         }
     }
     return array('filePath' => $temporaryFileName);
 }
示例#9
0
 /**
  * Processes the items of the new content element wizard
  * and inserts necessary default values for items created within a grid
  *
  * @param array $wizardItems : The array containing the current status of the wizard item list before rendering
  * @param \TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController $parentObject : The parent object that triggered this hook
  *
  * @return void
  */
 public function manipulateWizardItems(&$wizardItems, &$parentObject)
 {
     if (!GeneralUtility::inList($GLOBALS['BE_USER']->groupData['explicit_allowdeny'], 'tt_content:CType:gridelements_pi1:DENY')) {
         $pageID = $parentObject->id;
         $this->init($pageID);
         $container = (int) GeneralUtility::_GP('tx_gridelements_container');
         $column = (int) GeneralUtility::_GP('tx_gridelements_columns');
         $allowed_GP = GeneralUtility::_GP('tx_gridelements_allowed');
         if (!empty($allowed_GP)) {
             $allowed = array_flip(explode(',', $allowed_GP));
             $allowedGridTypes_GP = GeneralUtility::_GP('tx_gridelements_allowed_grid_types');
             if (!empty($allowedGridTypes_GP)) {
                 $allowed['gridelements_pi1'] = 1;
             }
             $this->removeDisallowedWizardItems($allowed, $wizardItems);
         } else {
             $allowed = null;
         }
         if (empty($allowed) || isset($allowed['gridelements_pi1'])) {
             $allowedGridTypes = array_flip(GeneralUtility::trimExplode(',', GeneralUtility::_GP('tx_gridelements_allowed_grid_types'), true));
             $excludeLayouts = $this->getExcludeLayouts($container, $parentObject);
             $gridItems = $this->layoutSetup->getLayoutWizardItems($parentObject->colPos, $excludeLayouts, $allowedGridTypes);
             $this->addGridItemsToWizard($gridItems, $wizardItems);
         }
         $this->addGridValuesToWizardItems($wizardItems, $container, $column);
         $this->removeEmptyHeadersFromWizard($wizardItems);
     }
 }
示例#10
0
 /**
  * Renders else-child or else-argument if variable $item is in $list
  *
  * @param string $list
  * @param string $item
  * @return string
  */
 public function render($list, $item)
 {
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($list, $item) === TRUE) {
         return $this->renderThenChild();
     }
     return $this->renderElseChild();
 }
 /**
  * Renders else-child or else-argument if variable $item is in $list
  *
  * @return string
  */
 public function render()
 {
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->arguments['list'], $this->arguments['item']) === true) {
         return $this->renderThenChild();
     }
     return $this->renderElseChild();
 }
示例#12
0
 /**
  * This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
  *
  * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
  * @return bool
  */
 protected static function evaluateCondition($arguments = null)
 {
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($arguments['list'], $arguments['item']) === true) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Remove rendered field from output if it is no event
  *
  * @param string $table
  * @param string $field
  * @param array $row
  * @param string $out
  * @return void
  */
 public function getSingleField_postProcess($table, $field, $row, &$out)
 {
     if ($table === 'tx_news_domain_model_news' && $row['is_event'] == 0) {
         if (GeneralUtility::inList(self::FIELDS, $field)) {
             $out = '';
         }
     }
 }
示例#14
0
 /**
  * Check if given list contains given item. If yes, render the thenChild, otherwise
  * the elseChild
  *
  * @param string $list list of items
  * @param string $item item
  * @return string
  */
 public function render()
 {
     if (GeneralUtility::inList($this->arguments['list'], $this->arguments['item'])) {
         return true;
     } else {
         return false;
     }
 }
示例#15
0
 /**
  * Returns the field for the ORDER BY statement
  *
  * @return string
  */
 public function getOrderBy()
 {
     $orderBy = 'lastUpdated';
     if (isset($this->settings['orderBy']) && GeneralUtility::inList($this->getAllowedOrderByFields(), $this->settings['orderBy'])) {
         $orderBy = (string) $this->settings['orderBy'];
     }
     return $orderBy;
 }
示例#16
0
 /**
  * Check if given list contains given item. If yes, render the thenChild, otherwise
  * the elseChild
  *
  * @param string $list list of items
  * @param string $item item
  * @return string
  */
 public function render($list, $item)
 {
     if (GeneralUtility::inList($list, $item)) {
         return $this->renderThenChild();
     } else {
         return $this->renderElseChild();
     }
 }
示例#17
0
 /**
  * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
  *
  * @param string $string The condition to match against its criterias.
  * @return bool Whether the condition matched
  * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parse()
  */
 protected function evaluateCondition($string)
 {
     list($key, $value) = GeneralUtility::trimExplode('=', $string, false, 2);
     $result = $this->evaluateConditionCommon($key, $value);
     if (is_bool($result)) {
         return $result;
     } else {
         switch ($key) {
             case 'usergroup':
                 $groupList = $this->getGroupList();
                 $values = GeneralUtility::trimExplode(',', $value, true);
                 foreach ($values as $test) {
                     if ($test === '*' || GeneralUtility::inList($groupList, $test)) {
                         return true;
                     }
                 }
                 break;
             case 'adminUser':
                 if ($this->isUserLoggedIn()) {
                     return !((bool) $value xor $this->isAdminUser());
                 }
                 break;
             case 'treeLevel':
                 $values = GeneralUtility::trimExplode(',', $value, true);
                 $treeLevel = count($this->rootline) - 1;
                 // If a new page is being edited or saved the treeLevel is higher by one:
                 if ($this->isNewPageWithPageId($this->pageId)) {
                     $treeLevel++;
                 }
                 foreach ($values as $test) {
                     if ($test == $treeLevel) {
                         return true;
                     }
                 }
                 break;
             case 'PIDupinRootline':
             case 'PIDinRootline':
                 $values = GeneralUtility::trimExplode(',', $value, true);
                 if ($key == 'PIDinRootline' || !in_array($this->pageId, $values) || $this->isNewPageWithPageId($this->pageId)) {
                     foreach ($values as $test) {
                         foreach ($this->rootline as $rl_dat) {
                             if ($rl_dat['uid'] == $test) {
                                 return true;
                             }
                         }
                     }
                 }
                 break;
             default:
                 $conditionResult = $this->evaluateCustomDefinedCondition($string);
                 if ($conditionResult !== null) {
                     return $conditionResult;
                 }
         }
     }
     return false;
 }
示例#18
0
 /**
  * @test
  */
 public function passwordIsTurnedIntoSaltedString()
 {
     $isSet = NULL;
     $originalPassword = '******';
     $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
     $this->assertTrue($isSet);
     $this->assertNotEquals($originalPassword, $saltedPassword);
     $this->assertTrue(GeneralUtility::inList('$1$,$2$,$2a,$P$', substr($saltedPassword, 0, 3)));
 }
示例#19
0
 /**
  * Builds a complete node including children
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent
  * @param integer $level
  * @param bool $restriction
  * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode node
  */
 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent = null, $level = 0, $restriction = false)
 {
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */
     $node = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode::class);
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(false);
         $node->setExpanded(true);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false);
         if ($this->getLabelField() !== '') {
             $label = CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row);
             $node->setLabel($label);
         } else {
             $node->setLabel($basicNode->getId());
         }
         $node->setSelected(GeneralUtility::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
         $node->setLabel($node->getLabel());
     }
     $node->setId($basicNode->getId());
     // Break to force single category activation
     if ($parent != null && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) {
         return null;
     }
     $node->setSelectable(!GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon($iconFactory->getIconForRecord($this->tableName, $row, Icon::SIZE_SMALL)->render());
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(true);
         /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */
         $childNodes = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection::class);
         $foundSomeChild = false;
         foreach ($basicNode->getChildNodes() as $child) {
             // Change in custom TreeDataProvider by adding the if clause
             if ($restriction || $this->isCategoryAllowed($child)) {
                 $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, true);
                 if (!is_null($returnedChild)) {
                     $foundSomeChild = true;
                     $childNodes->append($returnedChild);
                 } else {
                     $node->setParentNode(null);
                     $node->setHasChildren(false);
                 }
             }
             // Change in custom TreeDataProvider end
         }
         if ($foundSomeChild) {
             $node->setChildNodes($childNodes);
         }
     }
     return $node;
 }
 /**
  * Overrides the icon overlay with a LDAP symbol, if needed.
  *
  * @param string $table The current database table
  * @param array $row The current record
  * @param array &$status The array of associated statuses
  * @return void
  * @see \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordOverlayToSpriteIconName()
  */
 public function overrideIconOverlay($table, array $row, array &$status)
 {
     if (GeneralUtility::inList('be_groups,be_users,fe_groups,fe_users', $table)) {
         if (!array_key_exists('tx_igldapssoauth_dn', $row)) {
             // This is the case, e.g., in Backend users module
             $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $row['uid']);
         }
         $status['is_ldap_record'] = !empty($row['tx_igldapssoauth_dn']);
     }
 }
 /**
  * Builds a complete node including children
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent
  * @param integer $level
  * @param bool $restriction
  * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode node
  */
 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent = NULL, $level = 0, $restriction = FALSE)
 {
     /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */
     $node = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\DatabaseTreeNode');
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(FALSE);
         $node->setExpanded(TRUE);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE);
         if ($this->getLabelField() !== '') {
             $label = Tx_MooxNews_Service_CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row);
             $node->setLabel($label);
         } else {
             $node->setLabel($basicNode->getId());
         }
         $node->setSelected(\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
         $node->setLabel($node->getLabel());
     }
     $node->setId($basicNode->getId());
     // Break to force single category activation
     if ($parent != NULL && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) {
         return NULL;
     }
     $node->setSelectable(!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon(\TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($this->tableName, $row));
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(TRUE);
         /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */
         $childNodes = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\SortedTreeNodeCollection');
         $foundSomeChild = FALSE;
         foreach ($basicNode->getChildNodes() as $child) {
             // Change in custom TreeDataProvider by adding the if clause
             if ($restriction || $this->isCategoryAllowed($child)) {
                 $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, TRUE);
                 if (!is_null($returnedChild)) {
                     $foundSomeChild = TRUE;
                     $childNodes->append($returnedChild);
                 } else {
                     $node->setParentNode(NULL);
                     $node->setHasChildren(FALSE);
                 }
             }
             // Change in custom TreeDataProvider end
         }
         if ($foundSomeChild) {
             $node->setChildNodes($childNodes);
         }
     }
     return $node;
 }
 /**
  * Pre-processes the tceform rendering to specify currently assigned users.
  *
  * @param string $table
  * @param string $field
  * @param array $row
  * @param array $PA
  * @return void
  */
 public function getSingleField_beforeRender($table, $field, array $row, array &$PA)
 {
     if (GeneralUtility::inList('be_groups,fe_groups', $table) && $field === 'tx_mrusrgrpmgmt_users') {
         $users = $this->getAssignedUsers($table, $row['uid']);
         $list = array();
         foreach ($users as $user) {
             $list[] = $user['uid'];
         }
         $PA['itemFormElValue'] = implode(',', $list);
     }
 }
示例#23
0
 /**
  * Check extension of given filename
  *
  * @param string $filename Filename like (upload.png)
  * @return bool If Extension is allowed
  */
 public static function checkExtension($filename)
 {
     $extensionList = 'jpg,jpeg,png,gif,bmp';
     $settings = self::getTypoScriptFrontendController()->tmpl->setup['plugin.']['tx_femanager.']['settings.'];
     if (!empty($settings['misc.']['uploadFileExtension'])) {
         $extensionList = $settings['misc.']['uploadFileExtension'];
         $extensionList = str_replace(' ', '', $extensionList);
     }
     $fileInfo = pathinfo($filename);
     return !empty($fileInfo['extension']) && GeneralUtility::inList($extensionList, strtolower($fileInfo['extension'])) && GeneralUtility::verifyFilenameAgainstDenyPattern($filename) && GeneralUtility::validPathStr($filename);
 }
 /**
  * Fetches users from a given group record.
  *
  * @param array $result
  * @return array
  */
 public function addData(array $result)
 {
     if (GeneralUtility::inList('be_groups,fe_groups', $result['tableName'])) {
         $users = $this->getAssignedUsers($result['tableName'], $result['databaseRow']['uid']);
         $result['databaseRow']['tx_mrusrgrpmgmt_users'] = [];
         foreach ($users as $user) {
             $result['databaseRow']['tx_mrusrgrpmgmt_users'][] = $user['uid'];
         }
     }
     return $result;
 }
示例#25
0
 /**
  * return true if the element is valide
  *
  * @param	string $value value to test
  * @return	bool true if the element is valide
  */
 public function isValid($value)
 {
     if (!is_array($value) && empty($value)) {
         return true;
     }
     if (is_array($value)) {
         $pathfinfo = pathinfo($value['name']);
         return GeneralUtility::inList($this->configuration['allowed'], strtolower($pathfinfo['extension']));
     }
     return false;
 }
 /**
  * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
  *
  * @param string $string The condition to match against its criterias.
  * @return boolean Whether the condition matched
  * @see t3lib_tsparser::parse()
  */
 protected function evaluateCondition($string)
 {
     list($key, $value) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('=', $string, FALSE, 2);
     $result = parent::evaluateConditionCommon($key, $value);
     if (is_bool($result)) {
         return $result;
     } else {
         switch ($key) {
             case 'usergroup':
                 $groupList = $this->getGroupList();
                 $values = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE);
                 foreach ($values as $test) {
                     if ($test == '*' || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($groupList, $test)) {
                         return TRUE;
                     }
                 }
                 break;
             case 'adminUser':
                 if ($this->isUserLoggedIn()) {
                     $result = !((bool) $value xor $this->isAdminUser());
                     return $result;
                 }
                 break;
             case 'treeLevel':
                 $values = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE);
                 $treeLevel = count($this->rootline) - 1;
                 // If a new page is being edited or saved the treeLevel is higher by one:
                 if ($this->isNewPageWithPageId($this->pageId)) {
                     $treeLevel++;
                 }
                 foreach ($values as $test) {
                     if ($test == $treeLevel) {
                         return TRUE;
                     }
                 }
                 break;
             case 'PIDupinRootline':
             case 'PIDinRootline':
                 $values = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE);
                 if ($key == 'PIDinRootline' || !in_array($this->pageId, $values) || $this->isNewPageWithPageId($this->pageId)) {
                     foreach ($values as $test) {
                         foreach ($this->rootline as $rl_dat) {
                             if ($rl_dat['uid'] == $test) {
                                 return TRUE;
                             }
                         }
                     }
                 }
                 break;
         }
     }
     return FALSE;
 }
示例#27
0
文件: Rotate.php 项目: visol/media
 /**
  * Returns the EXIF orientation of a given picture.
  *
  * @param string $filename
  * @return integer
  */
 protected function getOrientation($filename)
 {
     $extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
     $orientation = 1;
     // Fallback to "straight"
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('jpg,jpeg,tif,tiff', $extension) && function_exists('exif_read_data')) {
         $exif = exif_read_data($filename);
         if ($exif) {
             $orientation = $exif['Orientation'];
         }
     }
     return $orientation;
 }
 /**
  * Get an array with all the field to hide in tceform
  */
 public function getDiffFieldsFromTable($table, $defaultFields)
 {
     $fields = array();
     $res = $GLOBALS['TYPO3_DB']->sql_query('SHOW COLUMNS FROM ' . $table);
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
         if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList(self::excludeFields, $row[0])) {
             $label = $row[0];
             $value = $row[0];
             $fields[] = $value;
         }
     }
     return array_diff($fields, explode(',', $defaultFields));
 }
示例#29
0
 /**
  * Check if password fields are added with flexform
  *
  * @return bool
  */
 protected function passwordFieldsAdded()
 {
     $flexFormValues = GeneralUtility::xml2array($this->cObj->data['pi_flexform']);
     if (is_array($flexFormValues)) {
         $fields = $flexFormValues['data'][$this->actionName]['lDEF']['settings.' . $this->actionName . '.fields']['vDEF'];
         if (empty($fields) || GeneralUtility::inList($fields, 'password')) {
             // password fields are added to form
             return TRUE;
         }
     }
     // password fields are not added to form
     return FALSE;
 }
示例#30
0
 /**
  * Evaluates a TypoScript condition given as input,
  * eg. "[browser=net][...(other conditions)...]"
  *
  * @param string $string The condition to match against its criterias.
  * @return bool Whether the condition matched
  * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parse()
  * @throws \TYPO3\CMS\Core\Configuration\TypoScript\Exception\InvalidTypoScriptConditionException
  */
 protected function evaluateCondition($string)
 {
     list($key, $value) = GeneralUtility::trimExplode('=', $string, FALSE, 2);
     $result = $this->evaluateConditionCommon($key, $value);
     if (is_bool($result)) {
         return $result;
     } else {
         switch ($key) {
             case 'usergroup':
                 $groupList = $this->getGroupList();
                 // '0,-1' is the default usergroups when not logged in!
                 if ($groupList != '0,-1') {
                     $values = GeneralUtility::trimExplode(',', $value, TRUE);
                     foreach ($values as $test) {
                         if ($test == '*' || GeneralUtility::inList($groupList, $test)) {
                             return TRUE;
                         }
                     }
                 }
                 break;
             case 'treeLevel':
                 $values = GeneralUtility::trimExplode(',', $value, TRUE);
                 $treeLevel = count($this->rootline) - 1;
                 foreach ($values as $test) {
                     if ($test == $treeLevel) {
                         return TRUE;
                     }
                 }
                 break;
             case 'PIDupinRootline':
             case 'PIDinRootline':
                 $values = GeneralUtility::trimExplode(',', $value, TRUE);
                 if ($key == 'PIDinRootline' || !in_array($this->pageId, $values)) {
                     foreach ($values as $test) {
                         foreach ($this->rootline as $rlDat) {
                             if ($rlDat['uid'] == $test) {
                                 return TRUE;
                             }
                         }
                     }
                 }
                 break;
             default:
                 $conditionResult = $this->evaluateCustomDefinedCondition($string);
                 if ($conditionResult !== NULL) {
                     return $conditionResult;
                 }
         }
     }
     return FALSE;
 }