/** * action show * * @param \VID\UniversalContentLists\Domain\Model\UniversalContent $universalContent * @return void */ public function showAction(\VID\UniversalContentLists\Domain\Model\UniversalContent $universalContent) { $currentPage = 1; if ($this->request->hasArgument('currentPage')) { $currentPage = (int) $this->request->getArgument('currentPage'); } $this->view->assign('currentPage', $currentPage); $this->view->assign("sysLanguageUid", $GLOBALS['TSFE']->sys_language_uid); $this->view->assign('showImageMaxWidth', $this->settings["variables"]["showImageMaxWidth"]); $this->view->assign('biggerwidth', $this->settings["variables"]["biggerwidth"] <= $this->settings["variables"]["showImageMaxWidth"] ? $this->settings["variables"]["biggerwidth"] : $this->settings["variables"]["showImageMaxWidth"]); $this->view->assign('largewidth', $this->settings["variables"]["largewidth"] <= $this->settings["variables"]["showImageMaxWidth"] ? $this->settings["variables"]["largewidth"] : $this->settings["variables"]["showImageMaxWidth"]); $this->view->assign('mediumwidth', $this->settings["variables"]["mediumwidth"] <= $this->settings["variables"]["showImageMaxWidth"] ? $this->settings["variables"]["mediumwidth"] : $this->settings["variables"]["showImageMaxWidth"]); $this->view->assign('smallwidth', $this->settings["variables"]["smallwidth"] <= $this->settings["variables"]["showImageMaxWidth"] ? $this->settings["variables"]["smallwidth"] : $this->settings["variables"]["showImageMaxWidth"]); $this->view->assign('listImageMaxWidth', $this->settings["variables"]["listImageMaxWidth"]); $this->view->assign('showImageMaxHeight', $this->settings["variables"]["showImageMaxHeight"]); $this->view->assign('biggerheight', $this->settings["variables"]["biggerheight"] <= $this->settings["variables"]["showImageMaxHeight"] ? $this->settings["variables"]["biggerheight"] : $this->settings["variables"]["showImageMaxHeight"]); $this->view->assign('largeheight', $this->settings["variables"]["largeheight"] <= $this->settings["variables"]["showImageMaxHeight"] ? $this->settings["variables"]["largeheight"] : $this->settings["variables"]["showImageMaxHeight"]); $this->view->assign('mediumheight', $this->settings["variables"]["mediumheight"] <= $this->settings["variables"]["showImageMaxHeight"] ? $this->settings["variables"]["mediumheight"] : $this->settings["variables"]["showImageMaxHeight"]); $this->view->assign('smallheight', $this->settings["variables"]["smallheight"] <= $this->settings["variables"]["showImageMaxHeight"] ? $this->settings["variables"]["smallheight"] : $this->settings["variables"]["showImageMaxHeight"]); $this->view->assign('listImageMaxHeight', $this->settings["variables"]["listImageMaxHeight"]); $tags = $universalContent->getTags(); $tagUIDs = array(); /** * @var \VID\UniversalContentLists\Domain\Model\Tag $tag */ foreach ($tags as $tag) { $tagUIDs[] = $tag->getUid(); } if ($this->settings["getRelatedFromTags"] == "1" && count($tagUIDs) > 0) { // sortfield $validSortfields = array("sorting", "colPos", "date", "crdate", "tstamp"); $sortfield_ = $this->settings["sortfield"]; $sortfield = in_array($sortfield_, $validSortfields) ? $sortfield_ : "sorting"; // sorting $validSortings = array("ASC", "DESC"); $sorting_ = $this->settings["sorting"]; $sorting = in_array($sorting_, $validSortings) ? $sorting_ : "ASC"; #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("tagUIDs"=>$tagUIDs)); $limit = (int) $this->settings["relatedLimit"]; $universalContent->setRelations($this->universalContentRepository->getRelatedByTagList($universalContent, $tagUIDs, $limit, $sortfield, $sorting)); #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("universalContent"=>$universalContent)); } $this->view->assign('detailArticle', $universalContent); }
/** * Returns a List by Tags * * @param \VID\UniversalContentLists\Domain\Model\UniversalContent $universalContent * @param array $tagIDs * @param int $limit * @param string $sortfield * @param string $sorting * * @return QueryResultInterface|array|int */ public function getRelatedByTagList($universalContent, $tagIDs, $limit, $sortfield = "sorting", $sorting = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING) { $query = $this->createQuery(); $query->getQuerySettings()->setRespectStoragePage(FALSE); #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("getListWithQuerySettings"=>array( "forbiddenCTypes"=>$forbiddenCTypes, "pidList"=>$pidList, "categoriesIDList"=>$categoriesIDList, "ColPosIDList"=>$ColPosIDList, "limit"=>$limit, "offset"=>$offset))); $constraints = array(); foreach ($tagIDs as $tagUID) { $constraints[] = $query->contains("tags", $tagUID); } $constraints[] = $query->logicalNot($query->equals("uid", $universalContent->getUid())); $query->matching($query->logicalAnd($constraints)); $sortingArray = array($sortfield => $sorting); #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($sortingArray); $res = $query->setLimit($limit)->setOrderings($sortingArray)->execute(); /** @var Typo3DbQueryParser $queryParser */ #$queryParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbQueryParser'); #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->parseQuery($query)); return $res; }