コード例 #1
0
 /**
  * Returns whether the field in the context is localizable or not.
  *
  * @return string
  */
 public function render()
 {
     $dataType = $this->templateVariableContainer->get('dataType');
     $fieldName = $this->templateVariableContainer->get('fieldName');
     $isLanguageApplicable = Tca::table($dataType)->hasLanguageSupport() && Tca::table($dataType)->field($fieldName)->isLocalized();
     return $isLanguageApplicable;
 }
コード例 #2
0
ファイル: MetadataRenderer.php プロジェクト: visol/media
 /**
  * Renders a configurable metadata property of a file in the Grid.
  *
  * @throws \Exception
  * @return string
  */
 public function render()
 {
     if (empty($this->gridRendererConfiguration['property'])) {
         throw new \Exception('Missing property value for Grid Renderer Metadata', 1390391042);
     }
     $file = $this->getFileConverter()->convert($this->object);
     $propertyName = $this->gridRendererConfiguration['property'];
     if ($propertyName === 'uid') {
         $metadata = $file->_getMetaData();
         $result = $metadata['uid'];
         // make an exception here to retrieve the uid of the metadata.
     } else {
         $result = $file->getProperty($propertyName);
     }
     // Avoid bad surprise, converts characters to HTML.
     $fieldType = Tca::table('sys_file_metadata')->field($propertyName)->getType();
     if ($fieldType !== FieldType::TEXTAREA) {
         $result = htmlentities($result);
     } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($result)) {
         $result = htmlentities($result);
     } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($result)) {
         $result = nl2br($result);
     }
     return $result;
 }
コード例 #3
0
 /**
  * Return the label field of the foreign table.
  *
  * @param string $fieldName
  * @return string
  */
 protected function getForeignTableLabelField($fieldName)
 {
     // Get TCA table service.
     $table = Tca::table($this->object);
     // Compute the label of the foreign table.
     $relationDataType = $table->field($fieldName)->relationDataType();
     return Tca::table($relationDataType)->getLabelField();
 }
コード例 #4
0
 /**
  * Return whether the current field name has a relation to the main content.
  *
  * @return boolean
  */
 public function render()
 {
     $fieldNameAndPath = $this->templateVariableContainer->get('columnName');
     $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
     $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
     $hasRelation = Tca::table($dataType)->field($fieldName)->hasRelation();
     return $hasRelation;
 }
コード例 #5
0
 /**
  * Check if $matches is valid. If it is not valid, throw an exception.
  *
  * @param mixed $matches
  * @return void
  */
 public function isValid($matches)
 {
     foreach ($matches as $fieldName => $value) {
         if (!Tca::table()->hasField($fieldName)) {
             $message = sprintf('Field "%s" is not allowed. Actually, it is not configured in the TCA.', $fieldName);
             $this->addError($message, 1380019718);
         }
     }
 }
コード例 #6
0
 /**
  * Returns an order object.
  *
  * @return Order
  */
 public function getOrder()
 {
     // Default ordering
     $order = Tca::table($this->dataType)->getDefaultOrderings();
     if (!empty($this->settings['sorting'])) {
         $direction = empty($this->settings['direction']) ? 'ASC' : $this->settings['direction'];
         $order = array($this->settings['sorting'] => $direction);
     }
     return GeneralUtility::makeInstance(Order::class, $order);
 }
コード例 #7
0
ファイル: ConfigurationWarning.php プロジェクト: visol/media
 /**
  * @return boolean
  */
 protected function configureStorage()
 {
     $tableName = 'sys_file_storage';
     $fields = array('maximum_dimension_original_image', 'extension_allowed_file_type_1', 'extension_allowed_file_type_2', 'extension_allowed_file_type_3', 'extension_allowed_file_type_4', 'extension_allowed_file_type_5');
     $values = array();
     foreach ($fields as $field) {
         $values[$field] = Tca::table($tableName)->field($field)->getDefaultValue();
     }
     $storage = $this->getMediaModule()->getCurrentStorage();
     $this->getDatabaseConnection()->exec_UPDATEquery($tableName, 'uid = ' . $storage->getUid(), $values);
 }
コード例 #8
0
 /**
  * Tell whether the field looks ok to be displayed within the Grid.
  *
  * @param string $fieldNameAndPath
  * @return boolean
  */
 protected function isAllowed($fieldNameAndPath)
 {
     $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
     $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
     $isAllowed = FALSE;
     if (Tca::grid()->hasRenderers($fieldNameAndPath)) {
         $isAllowed = TRUE;
     } elseif (Tca::table()->field($fieldNameAndPath)->isSystem() || Tca::table($dataType)->hasField($fieldName)) {
         $isAllowed = TRUE;
     }
     return $isAllowed;
 }
コード例 #9
0
ファイル: StandardFacet.php プロジェクト: BergischMedia/vidi
 /**
  * @return string
  */
 public function getLabel()
 {
     if ($this->label === $this->name) {
         $label = Tca::table($this->dataType)->field($this->getName())->getLabel();
     } else {
         $label = LocalizationUtility::translate($this->label, '');
         if (empty($label)) {
             $label = $this->label;
         }
     }
     return $label;
 }
コード例 #10
0
 /**
  * Render a representation of the relation on the GUI.
  *
  * @return string
  */
 public function render()
 {
     $template = '<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>';
     // Initialize url parameters array.
     $urlParameters = array($this->getModuleLoader()->getParameterPrefix() => array('controller' => 'Content', 'action' => 'edit', 'matches' => array('uid' => $this->object->getUid()), 'fieldNameAndPath' => $this->getFieldName()));
     $fieldLabel = Tca::table()->field($this->getFieldName())->getLabel();
     if ($fieldLabel) {
         $fieldLabel = str_replace(':', '', $fieldLabel);
         // sanitize label
     }
     $result = sprintf($template, $this->getModuleLoader()->getModuleUrl($urlParameters), $fieldLabel, $this->getIconFactory()->getIcon('actions-edit-add', Icon::SIZE_SMALL));
     return $result;
 }
コード例 #11
0
 /**
  * Retrieve possible suggestions for a field name
  *
  * @param string $fieldNameAndPath
  * @return array
  */
 public function getSuggestions($fieldNameAndPath)
 {
     $values = array();
     $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
     $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
     if (Tca::grid()->facet($fieldNameAndPath)->hasSuggestions()) {
         $values = Tca::grid()->facet($fieldNameAndPath)->getSuggestions();
     } else {
         if (Tca::table($dataType)->hasField($fieldName)) {
             if (Tca::table($dataType)->field($fieldName)->hasRelation()) {
                 // Fetch the adequate repository
                 $foreignTable = Tca::table($dataType)->field($fieldName)->getForeignTable();
                 $contentRepository = ContentRepositoryFactory::getInstance($foreignTable);
                 $table = Tca::table($foreignTable);
                 // Initialize the matcher object.
                 $matcher = MatcherObjectFactory::getInstance()->getMatcher(array(), $foreignTable);
                 $numberOfValues = $contentRepository->countBy($matcher);
                 if ($numberOfValues <= $this->getLimit()) {
                     $contents = $contentRepository->findBy($matcher);
                     foreach ($contents as $content) {
                         $values[] = array($content->getUid() => $content[$table->getLabelField()]);
                     }
                 }
             } elseif (!Tca::table($dataType)->field($fieldName)->isTextArea()) {
                 // We don't want suggestion if field is text area.
                 // Fetch the adequate repository
                 /** @var \Fab\Vidi\Domain\Repository\ContentRepository $contentRepository */
                 $contentRepository = ContentRepositoryFactory::getInstance($dataType);
                 // Initialize some objects related to the query
                 $matcher = MatcherObjectFactory::getInstance()->getMatcher(array(), $dataType);
                 // Count the number of objects.
                 $numberOfValues = $contentRepository->countDistinctValues($fieldName, $matcher);
                 // Only returns suggestion if there are not too many for the browser.
                 if ($numberOfValues <= $this->getLimit()) {
                     // Query the repository.
                     $contents = $contentRepository->findDistinctValues($fieldName, $matcher);
                     foreach ($contents as $content) {
                         $value = $content[$fieldName];
                         $label = $content[$fieldName];
                         if (Tca::table($dataType)->field($fieldName)->isSelect()) {
                             $label = Tca::table($dataType)->field($fieldName)->getLabelForItem($value);
                         }
                         $values[] = $label;
                     }
                 }
             }
         }
     }
     return $values;
 }
コード例 #12
0
 /**
  * Returns an order object.
  *
  * @param string $dataType
  * @return \Fab\Vidi\Persistence\Order
  */
 public function getOrder($dataType = '')
 {
     // Default ordering
     $order = Tca::table($dataType)->getDefaultOrderings();
     // Retrieve a possible id of the column from the request
     $orderings = GeneralUtility::_GP('order');
     if (is_array($orderings) && isset($orderings[0])) {
         $columnPosition = $orderings[0]['column'];
         $direction = $orderings[0]['dir'];
         if ($columnPosition > 0) {
             $field = Tca::grid()->getFieldNameByPosition($columnPosition);
             $order = array($field => strtoupper($direction));
         }
     }
     return GeneralUtility::makeInstance('Fab\\Vidi\\Persistence\\Order', $order);
 }
コード例 #13
0
 /**
  * Returns a value from the TCA Table service according to a key.
  *
  * @param string $key
  * @param string $dataType
  * @return string
  */
 public function render($key, $dataType = '')
 {
     $result = Tca::table($dataType)->getTca();
     // Explode segment and loop around.
     $keys = explode('|', $key);
     foreach ($keys as $key) {
         if (!empty($result[$key])) {
             $result = $result[$key];
         } else {
             // not found value
             $result = FALSE;
             break;
         }
     }
     return $result;
 }
コード例 #14
0
 /**
  * @param Content $object
  * @param string $propertyName
  * @return File[]
  */
 public function findReferencedBy($propertyName, Content $object)
 {
     if (!isset(self::$instances[$object->getUid()][$propertyName])) {
         // Initialize instances value
         if (!isset(self::$instances[$object->getUid()])) {
             self::$instances[$object->getUid()] = array();
         }
         $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
         $field = Tca::table($object->getDataType())->field($fieldName);
         if ($field->getForeignTable() === 'sys_file_reference') {
             $files = $this->findByFileReference($propertyName, $object);
             self::$instances[$object->getUid()][$propertyName] = $files;
         } else {
             // @todo the standard way of handling file references is by "sys_file_reference". Let see if there is other use cases...
         }
     }
     return self::$instances[$object->getUid()][$propertyName];
 }
コード例 #15
0
 /**
  * @param \Fab\Vidi\Domain\Model\Content $object
  * @param $fieldNameAndPath
  * @param array $contentData
  * @param string $savingBehavior
  * @return array
  */
 protected function appendOrRemoveRelations(Content $object, $fieldNameAndPath, array $contentData, $savingBehavior)
 {
     foreach ($contentData as $fieldName => $values) {
         $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
         if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) {
             // TRUE means CSV values must be converted to array.
             if (!is_array($values)) {
                 $values = GeneralUtility::trimExplode(',', $values);
             }
             $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName);
             foreach ($values as $value) {
                 $appendOrRemove = $savingBehavior . 'Relations';
                 $relatedValues = $this->{$appendOrRemove}($value, $relatedValues);
             }
             $contentData[$fieldName] = $relatedValues;
         }
     }
     return $contentData;
 }
コード例 #16
0
ファイル: ModuleService.php プロジェクト: BergischMedia/vidi
 /**
  * Fetch all modules displayed given a pid.
  *
  * @param int $pid
  * @return array
  */
 public function getModulesForPid($pid = NULL)
 {
     if (!isset($this->storage[$pid])) {
         $modules = array();
         foreach ($GLOBALS['TCA'] as $dataType => $configuration) {
             if (Tca::table($dataType)->isNotHidden()) {
                 $clause = 'pid = ' . $pid;
                 $clause .= BackendUtility::deleteClause($dataType);
                 $record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $dataType, $clause);
                 if (!empty($record)) {
                     $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1';
                     $title = Tca::table($dataType)->getTitle();
                     $modules[$moduleName] = $title;
                 }
             }
         }
         $this->storage[$pid] = $modules;
     }
     return $this->storage[$pid];
 }
コード例 #17
0
 /**
  * Render a representation of the relation on the GUI.
  *
  * @return string
  */
 public function render()
 {
     $numberOfObjects = count($this->object[$this->fieldName]);
     if ($numberOfObjects > 1) {
         $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:items';
         if (isset($this->gridRendererConfiguration['labelPlural'])) {
             $label = $this->gridRendererConfiguration['labelPlural'];
         }
     } else {
         $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:item';
         if (isset($this->gridRendererConfiguration['labelSingular'])) {
             $label = $this->gridRendererConfiguration['labelSingular'];
         }
     }
     $template = '<a href="%s&returnUrl=%s&search=%s&query=%s:%s">%s %s<span class="invisible" style="padding-left: 5px">%s</span></a>';
     $foreignField = Tca::table($this->object)->field($this->fieldName)->getForeignField();
     $search = json_encode(array(array($foreignField => $this->object->getUid())));
     $moduleTarget = empty($this->gridRendererConfiguration['targetModule']) ? '' : $this->gridRendererConfiguration['targetModule'];
     return sprintf($template, BackendUtility::getModuleUrl($moduleTarget), rawurlencode(BackendUtility::getModuleUrl($this->gridRendererConfiguration['sourceModule'])), rawurlencode($search), rawurlencode($foreignField), rawurlencode($this->object->getUid()), htmlspecialchars($numberOfObjects), htmlspecialchars(LocalizationUtility::translate($label, '')), $this->getIconFactory()->getIcon('extensions-vidi-go', Icon::SIZE_SMALL));
 }
コード例 #18
0
 /**
  * Do the job!
  *
  * @param array $arguments
  * @return string
  */
 public function work(array $arguments = array())
 {
     if (isset($arguments['save'])) {
         // Revert visible <-> excluded
         $excludedFields = array_diff(Tca::grid()->getAllFieldNames(), $arguments['excluded_fields'], $this->getExcludedFieldsFromTca());
         $arguments['excluded_fields'] = $excludedFields;
         $this->getModulePreferences()->save($arguments);
     }
     $templateNameAndPath = 'EXT:vidi/Resources/Private/Backend/Standalone/Tool/ModulePreferences/WorkResult.html';
     $view = $this->initializeStandaloneView($templateNameAndPath);
     $view->assign('title', Tca::table($this->getModuleLoader()->getDataType())->getTitle());
     // Fetch the menu of visible items.
     $menuVisibleItems = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS);
     $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS, $menuVisibleItems);
     // Fetch the default number of menu visible items.
     $menuDefaultVisible = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT);
     $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT, $menuDefaultVisible);
     // Get the visible columns
     $view->assign('columns', Tca::grid()->getAllFieldNames());
     return $view->render();
 }
コード例 #19
0
 /**
  * Returns a localized record according to a Content object and a language identifier.
  * Notice! This method does not overlay anything but simply returns the raw localized record.
  *
  * @param Content $object
  * @param int $language
  * @return Content
  */
 public function getLocalizedContent(Content $object, $language)
 {
     // We want to cache data per Content object. Retrieve the Object hash.
     $objectHash = spl_object_hash($object);
     // Initialize the storage
     if (empty($this->localizedRecordStorage[$objectHash])) {
         $this->localizedRecordStorage[$objectHash] = array();
     }
     if (empty($this->localizedRecordStorage[$objectHash][$language])) {
         $clause = sprintf('%s = %s AND %s = %s', Tca::table($object)->getLanguageParentField(), $object->getUid(), Tca::table($object)->getLanguageField(), $language);
         $clause .= BackendUtility::deleteClause($object->getDataType());
         $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $object->getDataType(), $clause);
         if ($localizedRecord) {
             $localizedContent = GeneralUtility::makeInstance('Fab\\Vidi\\Domain\\Model\\Content', $object->getDataType(), $localizedRecord);
             $this->localizedRecordStorage[$objectHash][$language] = $localizedContent;
         } else {
             $this->localizedRecordStorage[$objectHash][$language] = array();
             // We want an array at least, even if empty.
         }
     }
     return $this->localizedRecordStorage[$objectHash][$language];
 }
コード例 #20
0
 /**
  * Process Content with action "update".
  *
  * @param Content $content
  * @throws \Exception
  * @return bool
  */
 public function processUpdate(Content $content)
 {
     $values = array();
     // Check the field to be updated exists
     foreach ($content->toArray() as $fieldName => $value) {
         if (!Tca::table($content->getDataType())->hasField($fieldName)) {
             $message = sprintf('It looks field "%s" does not exist for data type "%s"', $fieldName, $content->getDataType());
             throw new \Exception($message, 1390668497);
         }
         // Flatten value if array given which is required for the DataHandler.
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         $values[$fieldName] = $value;
     }
     $data[$content->getDataType()][$content->getUid()] = $values;
     $dataHandler = $this->getDataHandler();
     $dataHandler->start($data, array());
     $dataHandler->process_datamap();
     $this->errorMessages = $dataHandler->errorLog;
     // Returns TRUE is log does not contain errors.
     return empty($dataHandler->errorLog);
 }
コード例 #21
0
 /**
  * Retrieve Content objects from the Clipboard then "move" them according to the target.
  *
  * @param string $target
  * @return string
  */
 public function moveClipboardAction($target)
 {
     // Retrieve matcher object from clipboard.
     $matcher = $this->getClipboardService()->getMatcher();
     // Fetch objects via the Content Service.
     $contentService = $this->getContentService()->findBy($matcher);
     // Compute the label field name of the table.
     $tableTitleField = Tca::table()->getLabelField();
     // Get result object for storing data along the processing.
     $result = $this->getJsonResult();
     $result->setNumberOfObjects($contentService->getNumberOfObjects());
     foreach ($contentService->getObjects() as $object) {
         // Store the first object, so that the "action" message can be more explicit when deleting only one record.
         if ($contentService->getNumberOfObjects() === 1) {
             $tableTitleValue = $object[$tableTitleField];
             $processedObjectData = array('uid' => $object->getUid(), 'name' => $tableTitleValue);
             $result->setProcessedObject($processedObjectData);
         }
         // Work out the object.
         ContentRepositoryFactory::getInstance()->move($object, $target);
         // Get the possible error messages and store them.
         $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages();
         $result->addErrorMessages($errorMessages);
     }
     // Flush Clipboard if told so.
     if (GeneralUtility::_GP('flushClipboard')) {
         $this->getClipboardService()->flush();
     }
     // Set the result and render the JSON view.
     $this->getJsonView()->setResult($result);
     return $this->getJsonView()->render();
 }
コード例 #22
0
 /**
  * Tell whether the operator should be equals instead of like for a search, e.g. if the value is numerical.
  *
  * @param string $fieldName
  * @param string $dataType
  * @param string $value
  * @return bool
  */
 protected function isOperatorEquals($fieldName, $dataType, $value)
 {
     return Tca::table($dataType)->field($fieldName)->hasRelation() && MathUtility::canBeInterpretedAsInteger($value) || Tca::table($dataType)->field($fieldName)->isNumerical();
 }
コード例 #23
0
 /**
  * @param Content $object
  * @return string
  */
 protected function getEditUri(Content $object)
 {
     $hiddenField = Tca::table()->getHiddenField();
     $additionalParameters = array($this->getModuleLoader()->getParameterPrefix() => ['controller' => 'Content', 'action' => 'update', 'format' => 'json', 'fieldNameAndPath' => Tca::table()->getHiddenField(), 'matches' => ['uid' => $object->getUid()], 'content' => [$hiddenField => (int) (!$this->object[$hiddenField])]]);
     return $this->getModuleLoader()->getModuleUrl($additionalParameters);
 }
コード例 #24
0
ファイル: RelationsCheck.php プロジェクト: BergischMedia/vidi
 /**
  * Check relations of current data type in the Grid.
  *
  * @return boolean
  */
 protected function isTcaValid()
 {
     $dataType = $this->getModuleLoader()->getDataType();
     $table = Tca::table($dataType);
     foreach (Tca::grid($dataType)->getFields() as $fieldName => $configuration) {
         if ($table->hasField($fieldName) && $table->field($fieldName)->hasMany()) {
             if ($table->field($fieldName)->hasRelationManyToMany()) {
                 $foreignTable = $table->field($fieldName)->getForeignTable();
                 $manyToManyTable = $table->field($fieldName)->getManyToManyTable();
                 $foreignField = $table->field($fieldName)->getForeignField();
                 if (!$foreignField) {
                     $this->invalidFields[] = $fieldName;
                 } elseif (!$foreignTable) {
                     $this->invalidFields[] = $fieldName;
                 } elseif (!$manyToManyTable) {
                     $this->invalidFields[] = $fieldName;
                 }
             }
         }
     }
     return empty($this->invalidFields);
 }
コード例 #25
0
 /**
  * Tell whether the field name contains a path, e.g. metadata.title
  * But resolves the case when the field is composite e.g "items.sys_file_metadata" and looks as field path but is not!
  * A composite field = a field for a MM relation  of type "group" where the table name is appended.
  *
  * @param string $fieldNameAndPath
  * @param string $dataType
  * @return boolean
  */
 public function containsPath($fieldNameAndPath, $dataType)
 {
     $doesContainPath = strpos($fieldNameAndPath, '.') > 0 && !Tca::table($dataType)->hasField($fieldNameAndPath);
     // -> will make sure it is not a composite field name.
     return $doesContainPath;
 }
コード例 #26
0
 /**
  * Handle the magic call by properly creating a Query object and returning its result.
  *
  * @param string $propertyName
  * @param string $value
  * @param string $flag
  * @return array
  */
 protected function processMagicCall($propertyName, $value, $flag = '')
 {
     $fieldName = Property::name($propertyName)->of($this->dataType)->toFieldName();
     /** @var $matcher Matcher */
     $matcher = GeneralUtility::makeInstance('Fab\\Vidi\\Persistence\\Matcher', array(), $this->getDataType());
     $table = Tca::table($this->dataType);
     if ($table->field($fieldName)->isGroup()) {
         $valueParts = explode('.', $value, 2);
         $fieldName = $fieldName . '.' . $valueParts[0];
         $value = $valueParts[1];
     }
     $matcher->equals($fieldName, $value);
     if ($flag == 'count') {
         $result = $this->countBy($matcher);
     } else {
         $result = $this->findBy($matcher);
     }
     return $flag == 'one' && !empty($result) ? reset($result) : $result;
 }
コード例 #27
0
ファイル: VidiDbBackend.php プロジェクト: BergischMedia/vidi
 /**
  * Returns constraint statement for backend context
  *
  * @param string $tableNameOrAlias
  * @param boolean $ignoreEnableFields A flag indicating whether the enable fields should be ignored
  * @param boolean $includeDeleted A flag indicating whether deleted records should be included
  * @return string
  */
 protected function getBackendConstraintStatement($tableNameOrAlias, $ignoreEnableFields, $includeDeleted)
 {
     $tableName = $this->resolveTableNameAlias($tableNameOrAlias);
     $statement = '';
     if (!$ignoreEnableFields) {
         $statement .= BackendUtility::BEenableFields($tableName);
     }
     // If the table is found to have "workspace" support, add the corresponding fields in the statement.
     if (Tca::table($tableName)->hasWorkspaceSupport()) {
         if ($this->getBackendUser()->workspace === 0) {
             $statement .= ' AND ' . $tableName . '.t3ver_state<=' . new VersionState(VersionState::DEFAULT_STATE);
         } else {
             // Show only records of live and of the current workspace
             // In case we are in a Versioning preview
             $statement .= ' AND (' . $tableName . '.t3ver_wsid=0 OR ' . $tableName . '.t3ver_wsid=' . (int) $this->getBackendUser()->workspace . ')';
         }
         // Check if this segment make sense here or whether it should be in the "if" part when we have workspace = 0
         $statement .= ' AND ' . $tableName . '.pid<>-1';
     }
     if (!$includeDeleted) {
         $statement .= BackendUtility::deleteClause($tableName);
     }
     return $this->replaceTableNameByAlias($tableName, $tableNameOrAlias, $statement);
 }
コード例 #28
0
 /**
  * Returns the label of a field
  *
  * @param string $dataType
  * @param string $fieldName
  * @return string
  */
 public function render($dataType, $fieldName)
 {
     return Tca::table($dataType)->field($fieldName)->getLabel();
 }
コード例 #29
0
ファイル: PidCheck.php プロジェクト: BergischMedia/vidi
 /**
  * Check if pid is 0 and given table is allowed on root level.
  *
  * @return void
  */
 protected function validateRootLevel()
 {
     if ($this->configuredPid > 0) {
         return;
     }
     $isRootLevel = (bool) Tca::table()->get('rootLevel');
     if (!$isRootLevel) {
         $this->errors[] = sprintf('You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;', $this->dataType);
     }
 }
コード例 #30
0
ファイル: NewButton.php プロジェクト: lorenzulrich/vidi
 /**
  * Return the default configured pid.
  *
  * @return int
  */
 protected function getStoragePid()
 {
     if (GeneralUtility::_GP(Parameter::PID)) {
         $pid = GeneralUtility::_GP(Parameter::PID);
     } elseif ((int) Tca::table()->get('rootLevel') === 1) {
         $pid = 0;
     } else {
         // Get configuration from User TSconfig if any
         $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType());
         $result = $this->getBackendUser()->getTSConfig($tsConfigPath);
         $pid = $result['value'];
         // Get pid from Module Loader
         if (NULL === $pid) {
             $pid = $this->getModuleLoader()->getDefaultPid();
         }
     }
     return (int) $pid;
 }