Example #1
0
 /**
  * The constructor of this class
  *
  * @param string $table The table to query
  * @param array $config The configuration (TCA overlayed with TSconfig) to use for this selector
  */
 public function __construct($table, $config)
 {
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $this->queryBuilder = $this->getQueryBuilderForTable($table);
     $this->queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class))->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class, 0));
     $this->table = $table;
     $this->config = $config;
     // get a list of all the pages that should be looked on
     if (isset($config['pidList'])) {
         $allowedPages = $pageIds = GeneralUtility::trimExplode(',', $config['pidList']);
         $depth = (int) $config['pidDepth'];
         foreach ($pageIds as $pageId) {
             if ($pageId > 0) {
                 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($allowedPages, $this->getAllSubpagesOfPage($pageId, $depth));
             }
         }
         $this->allowedPages = array_unique($allowedPages);
     }
     if (isset($config['maxItemsInResultList'])) {
         $this->maxItems = $config['maxItemsInResultList'];
     }
     if ($this->table == 'pages') {
         $this->queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($GLOBALS['BE_USER']->getPagePermsClause(1)));
     }
     if (isset($config['addWhere'])) {
         $this->queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($config['addWhere']));
     }
 }
Example #2
0
 /**
  * Creates the queryBuilder object whether it is a regular select or a JOIN
  *
  * @param Qom\SourceInterface $source The source
  * @return void
  */
 protected function initializeQueryBuilder(Qom\SourceInterface $source)
 {
     if ($source instanceof Qom\SelectorInterface) {
         $className = $source->getNodeTypeName();
         $tableName = $this->dataMapper->getDataMap($className)->getTableName();
         $this->tableName = $tableName;
         $this->queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
         $this->queryBuilder->getRestrictions()->removeAll();
         $tableAlias = $this->getUniqueAlias($tableName);
         $this->queryBuilder->select($tableAlias . '.*')->from($tableName, $tableAlias);
         $this->addRecordTypeConstraint($className);
     } elseif ($source instanceof Qom\JoinInterface) {
         $leftSource = $source->getLeft();
         $leftTableName = $leftSource->getSelectorName();
         $this->queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($leftTableName);
         $leftTableAlias = $this->getUniqueAlias($leftTableName);
         $this->queryBuilder->select($leftTableAlias . '.*')->from($leftTableName, $leftTableAlias);
         $this->parseJoin($source, $leftTableAlias);
     }
 }