Skip to content

Commit

Permalink
[TASK] fixes category menu. remove dependency for logged in backend user
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertgermann committed Jun 29, 2024
1 parent 67a022b commit 7264a93
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Classes/Tree/Categorytree.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
use RG\TtNews\Utility\IconFactory;
use TYPO3\CMS\Backend\Tree\View\AbstractTreeView;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -405,6 +409,79 @@ protected function getNewsCategoryTree($uid, $depth = 999, $blankLineCode = '')
return $c;
}

/**
* @param $parentId
*
* @return \Doctrine\DBAL\Result|mixed
*/
public function getDataInit($parentId)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DefaultRestrictionContainer::class));
$queryBuilder
->select(...$this->fieldArray)
->from($this->table)
->where(
$queryBuilder->expr()->eq(
$this->parentField,
$queryBuilder->createNamedParameter($parentId, Connection::PARAM_INT)
),
QueryHelper::stripLogicalOperatorPrefix($this->clause)
);

foreach (QueryHelper::parseOrderBy($this->orderByFields) as $orderPair) {
[$fieldName, $order] = $orderPair;
$queryBuilder->addOrderBy($fieldName, $order);
}

return $queryBuilder->executeQuery();
}

/**
* @param $res
*
* @return array|bool
*/
public function getDataNext(&$res)
{
while ($row = $res->fetchAssociative()) {
if (is_array($row)) {
break;
}
}
return $row;
}

/**
* @param $uid
*
* @return int
* @throws \Doctrine\DBAL\Exception
*/
public function getCount($uid)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DefaultRestrictionContainer::class));
$count = $queryBuilder
->count('uid')
->from($this->table)
->where(
$queryBuilder->expr()->eq(
$this->parentField,
$queryBuilder->createNamedParameter($uid, Connection::PARAM_INT)
),
QueryHelper::stripLogicalOperatorPrefix($this->clause)
)
->executeQuery()
->fetchOne();

return (int)$count;
}

/**
* @param $itemHTML
* @param $v
Expand Down

0 comments on commit 7264a93

Please sign in to comment.