Merge pull request #737 from chrizzor/dev-extbase-fluid-queries

Move db queries from controller to repository

Merge with some errors, which will be fixed later.
This commit is contained in:
Alexander Bigga 2021-11-22 21:13:47 +01:00 committed by GitHub
commit 855208a953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 1548 additions and 1363 deletions

View File

@ -12,12 +12,15 @@
namespace Kitodo\Dlf\Common;
use Kitodo\Dlf\Domain\Repository\DocumentRepository;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use Ubl\Iiif\Presentation\Common\Model\Resources\IiifResourceInterface;
use Ubl\Iiif\Tools\IiifHelper;
@ -418,13 +421,51 @@ abstract class Document
* @static
*
* @param mixed $uid: The unique identifier of the document to parse, the URL of XML file or the IRI of the IIIF resource
* @param int $pid: If > 0, then only document with this PID gets loaded
* @param array $settings
* @param bool $forceReload: Force reloading the document instead of returning the cached instance
*
* @return \Kitodo\Dlf\Common\Document Instance of this class, either MetsDocument or IiifManifest
*/
public static function &getInstance($uid, $pid = 0, $forceReload = false)
public static function &getInstance($uid, $settings = [], $forceReload = false)
{
/** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$frameworkConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
// override storagePid if given
if ($settings['storagePid']) {
$frameworkConfiguration['persistence']['storagePid'] = $settings['storagePid'];
}
/**
* Set table mapping if missing.
*
* This should be evaluated with TYPO3 10 again. In TYPO3 9.5 the mapping set via TypoScript is not always present.
* This could be omitted if we rename all tables to the Extbase naming schema.
* */
if (empty($frameworkConfiguration['persistence']['classes'])) {
$frameworkConfiguration['persistence']['classes'] = [
'Kitodo\Dlf\Domain\Model\Document' => [
'mapping' => [
'tableName' => 'tx_dlf_documents'
]
],
'Kitodo\Dlf\Domain\Model\Collection' => [
'mapping' => [
'tableName' => 'tx_dlf_collections'
]
]
];
}
// set modified configuration
$configurationManager->setConfiguration($frameworkConfiguration);
/** Fill documentRepository */
$documentRepository = $objectManager->get(DocumentRepository::class);
// Sanitize input.
$pid = max(intval($pid), 0);
if (!$forceReload) {
@ -469,39 +510,12 @@ abstract class Document
$iiif = null;
// Try to get document format from database
if (MathUtility::canBeInterpretedAsInteger($uid)) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$queryBuilder
->select(
'tx_dlf_documents.location AS location',
'tx_dlf_documents.document_format AS document_format'
)
->from('tx_dlf_documents');
// Get UID of document with given record identifier.
if ($pid) {
$queryBuilder
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.uid', intval($uid)),
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($pid)),
Helper::whereExpression('tx_dlf_documents')
);
} else {
$queryBuilder
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.uid', intval($uid)),
Helper::whereExpression('tx_dlf_documents')
);
$document = $documentRepository->findOneByIdAndSettings($uid, $settings);
if ($document !== null) {
$documentFormat = $document->getDocumentFormat();
}
$result = $queryBuilder
->setMaxResults(1)
->execute();
if ($resArray = $result->fetch()) {
$documentFormat = $resArray['document_format'];
}
} else {
// Get document format from content of remote document
// Cast to string for safety reasons.

View File

@ -477,13 +477,15 @@ class Solr implements LoggerAwareInterface
$cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr');
$resultSet = [];
if (($entry = $cache->get($cacheIdentifier)) === false) {
$selectQuery = $this->service->createSelect(array_merge($this->params, $parameters));
$selectQuery = $this->service->createSelect($parameters);
$result = $this->service->select($selectQuery);
foreach ($result as $doc) {
$resultSet[] = $doc;
}
// Save value in cache.
$cache->set($cacheIdentifier, $resultSet);
if ($resultSet) {
$cache->set($cacheIdentifier, $resultSet);
}
} else {
// Return cache hit.
$resultSet = $entry;

View File

@ -13,6 +13,7 @@ namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Domain\Repository\DocumentRepository;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
@ -28,6 +29,19 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
public $prefixId = 'tx_dlf';
/**
* @var DocumentRepository
*/
protected $documentRepository;
/**
* @param DocumentRepository $documentRepository
*/
public function injectDocumentRepository(DocumentRepository $documentRepository)
{
$this->documentRepository = $documentRepository;
}
/**
* @var
*/
@ -46,19 +60,16 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*
* @access protected
*
* @param array $requestData: The request data
*
* @return void
*/
protected function loadDocument($requestData)
{
// Check for required variable.
if (
!empty($requestData['id'])
&& !empty($this->settings['pages'])
) {
// Should we exclude documents from other pages than $this->settings['pages']?
$pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0);
if (!empty($requestData['id'])) {
// Get instance of \Kitodo\Dlf\Common\Document.
$this->doc = Document::getInstance($requestData['id'], $pid);
$this->doc = Document::getInstance($requestData['id'], $this->settings);
if (!$this->doc->ready) {
// Destroy the incomplete object.
$this->doc = null;

View File

@ -14,6 +14,8 @@ namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Domain\Model\ActionLog;
use Kitodo\Dlf\Domain\Repository\ActionLogRepository;
use Kitodo\Dlf\Domain\Repository\MailRepository;
use Kitodo\Dlf\Domain\Repository\BasketRepository;
use Kitodo\Dlf\Domain\Repository\PrinterRepository;
@ -24,22 +26,11 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
class BasketController extends AbstractController
{
/**
* @var BasketRepository
*/
protected $basketRepository;
/**
* @var MailRepository
*/
protected $mailRepository;
/**
* @var PrinterRepository
*/
protected $printerRepository;
/**
* @param BasketRepository $basketRepository
*/
@ -48,6 +39,11 @@ class BasketController extends AbstractController
$this->basketRepository = $basketRepository;
}
/**
* @var MailRepository
*/
protected $mailRepository;
/**
* @param MailRepository $mailRepository
*/
@ -56,6 +52,11 @@ class BasketController extends AbstractController
$this->mailRepository = $mailRepository;
}
/**
* @var PrinterRepository
*/
protected $printerRepository;
/**
* @param PrinterRepository $printerRepository
*/
@ -64,6 +65,19 @@ class BasketController extends AbstractController
$this->printerRepository = $printerRepository;
}
/**
* @var ActionLogRepository
*/
protected $actionLogRepository;
/**
* @param ActionLogRepository $actionLogRepository
*/
public function injectActionLogRepository(ActionLogRepository $actionLogRepository)
{
$this->actionLogRepository = $actionLogRepository;
}
/**
* Different actions which depends on the choosen action (form)
*
@ -170,7 +184,7 @@ class BasketController extends AbstractController
$this->view->assign('mailSelect', $mailSelect);
}
$allPrinter = $this->printerRepository->findAllWithPid($this->settings['pages']);
$allPrinter = $this->printerRepository->findAll();
$printSelect = [];
if ($allPrinter->count() > 0) {
@ -556,31 +570,25 @@ class BasketController extends AbstractController
->setTo([$mailObject->getMail() => $mailObject->getName()])
->setBody($mailBody, 'text/html')
->send();
// protocol
$insertArray = [
'pid' => $this->settings['pages'],
'file_name' => $pdfUrl,
'count_pages' => $numberOfPages,
'crdate' => time(),
];
// create entry for action log
$newActionLog = $this->objectManager->get(ActionLog::class);
$newActionLog->setFileName($pdfUrl);
$newActionLog->setCountPages($numberOfPages);
$newActionLog->setLabel('Mail: ' . $mailObject->getMail());
if ($GLOBALS["TSFE"]->loginUser) {
// internal user
$insertArray['user_id'] = $GLOBALS["TSFE"]->fe_user->user['uid'];
$insertArray['name'] = $GLOBALS["TSFE"]->fe_user->user['username'];
$insertArray['label'] = 'Mail: ' . $mailObject->getMail();
$newActionLog->setUserId($GLOBALS["TSFE"]->fe_user->user['uid']);
$newActionLog->setName($GLOBALS["TSFE"]->fe_user->user['username']);
} else {
// external user
$insertArray['user_id'] = 0;
$insertArray['name'] = 'n/a';
$insertArray['label'] = 'Mail: ' . $mailObject->getMail();
$newActionLog->setUserId(0);
$newActionLog->setName('n/a');
}
// add action to protocol
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_dlf_actionlog')
->insert(
'tx_dlf_actionlog',
$insertArray
);
$this->actionLogRepository->add($newActionLog);
$this->redirect('main');
}
@ -650,5 +658,4 @@ class BasketController extends AbstractController
$this->redirectToUri($pdfUrl);
}
}

View File

@ -12,8 +12,7 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Database\Connection;
use Kitodo\Dlf\Domain\Model\Document;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@ -87,10 +86,10 @@ class CalendarController extends AbstractController
unset($requestData['__referrer'], $requestData['__trustedProperties']);
// access arguments passed by the mainAction()
$mainrquestData = $this->request->getArguments();
$mainrequestData = $this->request->getArguments();
// merge both arguments together --> passing id by GET parameter tx_dlf[id] should win
$requestData = array_merge($requestData, $mainrquestData);
$requestData = array_merge($requestData, $mainrequestData);
// Load current document.
$this->loadDocument($requestData);
@ -99,46 +98,29 @@ class CalendarController extends AbstractController
return;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
// Get all children of year anchor.
$result = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.title AS title',
'tx_dlf_documents.year AS year',
'tx_dlf_documents.mets_label AS label',
'tx_dlf_documents.mets_orderlabel AS orderlabel'
)
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.structure', Helper::getUidFromIndexName('issue', 'tx_dlf_structures', $this->doc->cPid)),
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)),
Helper::whereExpression('tx_dlf_documents')
)
->orderBy('tx_dlf_documents.mets_orderlabel')
->execute();
$documents = $this->documentRepository->getChildrenOfYearAnchor($this->doc->uid, 'issue');
$issues = [];
// Process results.
while ($resArray = $result->fetch()) {
/** @var Document $document */
foreach ($documents as $document) {
// Set title for display in calendar view.
if (!empty($resArray['title'])) {
$title = $resArray['title'];
if (!empty($document->getTitle())) {
$title = $document->getTitle();
} else {
$title = !empty($resArray['label']) ? $resArray['label'] : $resArray['orderlabel'];
$title = !empty($document->getMetsLabel()) ? $document->getMetsLabel() : $document->getMetsOrderlabel();
if (strtotime($title) !== false) {
$title = strftime('%x', strtotime($title));
}
}
$issues[] = [
'uid' => $resArray['uid'],
'uid' => $document->getUid(),
'title' => $title,
'year' => $resArray['year']
'year' => $document->getYear()
];
}
// We need an array of issues with year => month => day number as key.
$calendarIssuesByYear = [];
foreach ($issues as $issue) {
@ -211,10 +193,10 @@ class CalendarController extends AbstractController
unset($requestData['__referrer'], $requestData['__trustedProperties']);
// access arguments passed by the mainAction()
$mainrquestData = $this->request->getArguments();
$mainrequestData = $this->request->getArguments();
// merge both arguments together --> passing id by GET parameter tx_dlf[id] should win
$requestData = array_merge($requestData, $mainrquestData);
$requestData = array_merge($requestData, $mainrequestData);
// Load current document.
$this->loadDocument($requestData);
@ -223,34 +205,19 @@ class CalendarController extends AbstractController
return;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
// Get all children of anchor. This should be the year anchor documents
$result = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.title AS title',
'tx_dlf_documents.mets_label AS label',
'tx_dlf_documents.mets_orderlabel AS orderlabel'
)
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.structure', Helper::getUidFromIndexName('year', 'tx_dlf_structures', $this->doc->cPid)),
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)),
Helper::whereExpression('tx_dlf_documents')
)
->orderBy('tx_dlf_documents.mets_orderlabel')
->execute();
$documents = $this->documentRepository->getChildrenOfYearAnchor($this->doc->uid, 'year');
$years = [];
// Process results.
while ($resArray = $result->fetch()) {
/** @var Document $document */
foreach ($documents as $document) {
$years[] = [
'title' => !empty($resArray['label']) ? $resArray['label'] : (!empty($resArray['orderlabel']) ? $resArray['orderlabel'] : $resArray['title']),
'uid' => $resArray['uid']
'title' => !empty($document->getMetsLabel()) ? $document->getMetsLabel() : (!empty($document->getMetsOrderlabel()) ? $document->getMetsOrderlabel() : $document->getTitle()),
'uid' => $document->getUid()
];
}
$yearArray = [];
if (count($years) > 0) {
foreach ($years as $year) {

View File

@ -14,10 +14,12 @@ namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\DocumentList;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\Solr;
use TYPO3\CMS\Core\Database\ConnectionPool;
use Kitodo\Dlf\Domain\Model\Document;
use Kitodo\Dlf\Domain\Model\Collection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
class CollectionController extends AbstractController
{
@ -29,6 +31,19 @@ class CollectionController extends AbstractController
*/
protected $hookObjects = [];
/**
* @var CollectionRepository
*/
protected $collectionRepository;
/**
* @param CollectionRepository $collectionRepository
*/
public function injectCollectionRepository(CollectionRepository $collectionRepository)
{
$this->collectionRepository = $collectionRepository;
}
/**
* The main method of the plugin
*
@ -50,7 +65,7 @@ class CollectionController extends AbstractController
// TODO: $this->hookObjects = Helper::getHookObjects($this->scriptRelPath);
if ($collection) {
$this->showSingleCollection($collection);
$this->showSingleCollection($this->collectionRepository->findByUid($collection[0]));
} else {
$this->showCollectionList();
}
@ -64,135 +79,64 @@ class CollectionController extends AbstractController
*/
protected function showCollectionList()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
$selectedCollections = $queryBuilder->expr()->neq('tx_dlf_collections.uid', 0);
$orderBy = 'tx_dlf_collections.label';
$showUserDefinedColls = '';
// Handle collections set by configuration.
if ($this->settings['collections']) {
if (
count(explode(',', $this->settings['collections'])) == 1
&& empty($this->settings['dont_show_single'])
) {
$this->showSingleCollection(intval(trim($this->settings['collections'], ' ,')));
}
$selectedCollections = $queryBuilder->expr()->in('tx_dlf_collections.uid', implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])));
}
// Should user-defined collections be shown?
if (empty($this->settings['show_userdefined'])) {
$showUserDefinedColls = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
} elseif ($this->settings['show_userdefined'] > 0) {
if (!empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
$showUserDefinedColls = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', intval($GLOBALS['TSFE']->fe_user->user['uid']));
} else {
$showUserDefinedColls = $queryBuilder->expr()->neq('tx_dlf_collections.fe_cruser_id', 0);
}
}
// Get collections.
$queryBuilder
->select(
'tx_dlf_collections.uid AS uid', // required by getRecordOverlay()
'tx_dlf_collections.pid AS pid', // required by getRecordOverlay()
'tx_dlf_collections.sys_language_uid AS sys_language_uid', // required by getRecordOverlay()
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.index_search as index_query',
'tx_dlf_collections.label AS label',
'tx_dlf_collections.thumbnail AS thumbnail',
'tx_dlf_collections.description AS description',
'tx_dlf_collections.priority AS priority'
)
->from('tx_dlf_collections')
->where(
$selectedCollections,
$showUserDefinedColls,
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->in('tx_dlf_collections.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_collections.sys_language_uid', $GLOBALS['TSFE']->sys_language_uid)
),
$queryBuilder->expr()->eq('tx_dlf_collections.l18n_parent', 0)
)
)
->orderBy($orderBy);
$result = $queryBuilder->execute();
$count = $queryBuilder->count('uid')->execute()->fetchColumn(0);
if ($count == 1 && empty($this->settings['dont_show_single'])) {
$resArray = $result->fetch();
$this->showSingleCollection(intval($resArray['uid']));
}
$solr = Solr::getInstance($this->settings['solrcore']);
if (!$solr->ready) {
$this->logger->error('Apache Solr not available');
//return $content;
return;
}
// We only care about the UID and partOf in the results and want them sorted
$params['fields'] = 'uid,partof';
$params['sort'] = ['uid' => 'asc'];
$collections = [];
// Get language overlay if on alterative website language.
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);
while ($collectionData = $result->fetch()) {
if ($collectionData['sys_language_uid'] != $GLOBALS['TSFE']->sys_language_content) {
$collections[$collectionData['uid']] = $pageRepository->getRecordOverlay('tx_dlf_collections', $collectionData, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
// keep the index_name of the default language
$collections[$collectionData['uid']]['index_name'] = $collectionData['index_name'];
} else {
$collections[$collectionData['uid']] = $collectionData;
}
}
// Sort collections according to flexform configuration
if ($this->settings['collections']) {
$sortedCollections = [];
foreach (GeneralUtility::intExplode(',', $this->settings['collections']) as $uid) {
$sortedCollections[$uid] = $collections[$uid];
$sortedCollections[$uid] = $this->collectionRepository->findByUid($uid);
}
$collections = $sortedCollections;
}
if (count($collections) == 1 && empty($this->settings['dont_show_single'])) {
$this->showSingleCollection(array_pop($collections));
}
$processedCollections = [];
// Process results.
foreach ($collections as $collection) {
$solr_query = '';
if ($collection['index_query'] != '') {
$solr_query .= '(' . $collection['index_query'] . ')';
if ($collection->getIndexSearch() != '') {
$solr_query .= '(' . $collection->getIndexSearch() . ')';
} else {
$solr_query .= 'collection:("' . $collection['index_name'] . '")';
$solr_query .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")';
}
$partOfNothing = $solr->search_raw($solr_query . ' AND partof:0 AND toplevel:true', $params);
$partOfSomething = $solr->search_raw($solr_query . ' AND NOT partof:0 AND toplevel:true', $params);
// Titles are all documents that are "root" elements i.e. partof == 0
$collection['titles'] = [];
$collectionInfo['titles'] = [];
foreach ($partOfNothing as $doc) {
$collection['titles'][$doc->uid] = $doc->uid;
$collectionInfo['titles'][$doc->uid] = $doc->uid;
}
// Volumes are documents that are both
// a) "leaf" elements i.e. partof != 0
// b) "root" elements that are not referenced by other documents ("root" elements that have no descendants)
$collection['volumes'] = $collection['titles'];
$collectionInfo['volumes'] = $collectionInfo['titles'];
foreach ($partOfSomething as $doc) {
$collection['volumes'][$doc->uid] = $doc->uid;
$collectionInfo['volumes'][$doc->uid] = $doc->uid;
// If a document is referenced via partof, its not a volume anymore.
unset($collection['volumes'][$doc->partof]);
unset($collectionInfo['volumes'][$doc->partof]);
}
// Generate random but unique array key taking priority into account.
do {
$_key = ($collection['priority'] * 1000) + mt_rand(0, 1000);
$_key = ($collectionInfo['priority'] * 1000) + mt_rand(0, 1000);
} while (!empty($processedCollections[$_key]));
$collection['countTitles'] = count($collection['titles']);
$collection['countVolumes'] = count($collection['volumes']);
$processedCollections[$_key] = $collection;
$processedCollections[$_key]['collection'] = $collection;
$processedCollections[$_key]['info'] = $collectionInfo;
}
// Randomize sorting?
@ -216,72 +160,21 @@ class CollectionController extends AbstractController
*
* @access protected
*
* @param int $id: The collection's UID
* @param \Kitodo\Dlf\Domain\Model\Collection The collection object
*
* @return void
*/
protected function showSingleCollection($id)
protected function showSingleCollection(\Kitodo\Dlf\Domain\Model\Collection $collection)
{
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_dlf_collections');
// access storagePid from TypoScript
$pageSettings = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$this->settings['pages'] = $pageSettings["plugin."]["tx_dlf."]["persistence."]["storagePid"];
$additionalWhere = '';
// Should user-defined collections be shown?
if (empty($this->settings['show_userdefined'])) {
$additionalWhere = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
} elseif ($this->settings['show_userdefined'] > 0) {
$additionalWhere = $queryBuilder->expr()->neq('tx_dlf_collections.fe_cruser_id', 0);
}
// Get collection information from DB
$collection = $queryBuilder
->select(
'tx_dlf_collections.uid AS uid', // required by getRecordOverlay()
'tx_dlf_collections.pid AS pid', // required by getRecordOverlay()
'tx_dlf_collections.sys_language_uid AS sys_language_uid', // required by getRecordOverlay()
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.index_search as index_search',
'tx_dlf_collections.label AS label',
'tx_dlf_collections.description AS description',
'tx_dlf_collections.thumbnail AS thumbnail',
'tx_dlf_collections.fe_cruser_id'
)
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections.uid', intval($id)),
$additionalWhere,
$queryBuilder->expr()->andX(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->in('tx_dlf_collections.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_collections.sys_language_uid', $GLOBALS['TSFE']->sys_language_uid)
),
$queryBuilder->expr()->eq('tx_dlf_collections.l18n_parent', 0)
),
Helper::whereExpression('tx_dlf_collections')
)
->setMaxResults(1)
->execute();
// Get language overlay if on alterative website language.
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);
if ($resArray = $collection->fetch()) {
if ($resArray['sys_language_uid'] != $GLOBALS['TSFE']->sys_language_content) {
$collectionData = $pageRepository->getRecordOverlay('tx_dlf_collections', $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
// keep the index_name of the default language
$collectionData['index_name'] = $resArray['index_name'];
} else {
$collectionData = $resArray;
}
} else {
$this->logger->warning('No collection with UID ' . $id . ' found.');
return;
}
// Fetch corresponding document UIDs from Solr.
if ($collectionData['index_search'] != '') {
$solr_query = '(' . $collectionData['index_search'] . ')';
if ($collection->getIndexSearch() != '') {
$solr_query = '(' . $collection->getIndexSearch() . ')';
} else {
$solr_query = 'collection:("' . $collectionData['index_name'] . '") AND toplevel:true';
$solr_query = 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '") AND toplevel:true';
}
$solr = Solr::getInstance($this->settings['solrcore']);
if (!$solr->ready) {
@ -299,47 +192,35 @@ class CollectionController extends AbstractController
}
}
$documentSet = array_unique($documentSet);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_dlf_documents');
// Fetch document info for UIDs in $documentSet from DB
$documents = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.metadata_sorting AS metadata_sorting',
'tx_dlf_documents.volume_sorting AS volume_sorting',
'tx_dlf_documents.partof AS partof'
)
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->in('tx_dlf_documents.uid', $documentSet),
Helper::whereExpression('tx_dlf_documents')
)
->execute();
$this->settings['documentSets'] = implode(',', $documentSet);
$documents = $this->documentRepository->findDocumentsBySettings($this->settings);
$toplevel = [];
$subparts = [];
$listMetadata = [];
// Process results.
while ($resArray = $documents->fetch()) {
/** @var Document $document */
foreach ($documents as $document) {
if (empty($listMetadata)) {
$listMetadata = [
'label' => htmlspecialchars($collectionData['label']),
'description' => $collectionData['description'],
'thumbnail' => htmlspecialchars($collectionData['thumbnail']),
'label' => htmlspecialchars($collection->getLabel()),
'description' => $collection->getDescription(),
'thumbnail' => htmlspecialchars($collection->getThumbnail()),
'options' => [
'source' => 'collection',
'select' => $id,
'userid' => $collectionData['userid'],
'params' => ['filterquery' => [['query' => 'collection_faceting:("' . $collectionData['index_name'] . '")']]],
'userid' => $collection->getFeCruserId(),
'params' => ['filterquery' => [['query' => 'collection_faceting:("' . $collection->getIndexName() . '")']]],
'core' => '',
'pid' => $this->settings['pages'],
'order' => 'title',
'order.asc' => true
]
];
}
// Prepare document's metadata for sorting.
$sorting = unserialize($resArray['metadata_sorting']);
$sorting = unserialize($document->getMetadataSorting());
if (!empty($sorting['type']) && MathUtility::canBeInterpretedAsInteger($sorting['type'])) {
$sorting['type'] = Helper::getIndexNameFromUid($sorting['type'], 'tx_dlf_structures', $this->settings['pages']);
}
@ -350,23 +231,24 @@ class CollectionController extends AbstractController
$sorting['collection'] = Helper::getIndexNameFromUid($sorting['collection'], 'tx_dlf_collections', $this->settings['pages']);
}
// Split toplevel documents from volumes.
if ($resArray['partof'] == 0) {
$toplevel[$resArray['uid']] = [
'u' => $resArray['uid'],
if ($document->getPartof() == 0) {
$toplevel[$document->getUid()] = [
'u' => $document->getUid(),
'h' => '',
's' => $sorting,
'p' => []
];
} else {
// volume_sorting should be always set - but it's not a required field. We append the uid to the array key to make it always unique.
$subparts[$resArray['partof']][$resArray['volume_sorting'] . str_pad($resArray['uid'], 9, '0', STR_PAD_LEFT)] = [
'u' => $resArray['uid'],
$subparts[$document->getPartof()][$document->getVolumeSorting() . str_pad($document->getUid(), 9, '0', STR_PAD_LEFT)] = [
'u' => $document->getUid(),
'h' => '',
's' => $sorting,
'p' => []
];
}
}
// Add volumes to the corresponding toplevel documents.
foreach ($subparts as $partof => $parts) {
ksort($parts);

View File

@ -12,10 +12,8 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Domain\Repository\LibraryRepository;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class FeedsController extends AbstractController
@ -71,94 +69,45 @@ class FeedsController extends AbstractController
|| empty($requestData['collection'])
|| GeneralUtility::inList($this->settings['collections'], $requestData['collection'])
) {
$additionalWhere = '';
// Check for pre-selected collections.
if (!empty($requestData['collection'])) {
$additionalWhere = 'tx_dlf_collections.uid=' . intval($requestData['collection']);
} elseif (!empty($this->settings['collections'])) {
$additionalWhere = 'tx_dlf_collections.uid IN (' . implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])) . ')';
}
// get documents
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$documents = $this->documentRepository->findAllByCollectionsLimited(GeneralUtility::intExplode(',', $requestData['collection'], true), $this->settings['limit']);
$result = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.partof AS partof',
'tx_dlf_documents.title AS title',
'tx_dlf_documents.volume AS volume',
'tx_dlf_documents.author AS author',
'tx_dlf_documents.record_id AS record_id',
'tx_dlf_documents.tstamp AS tstamp',
'tx_dlf_documents.crdate AS crdate'
)
->from('tx_dlf_documents')
->join(
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_documents_collections_mm',
$queryBuilder->expr()->eq('tx_dlf_documents.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_local'))
)
->join(
'tx_dlf_documents_collections_mm',
'tx_dlf_collections',
'tx_dlf_collections',
$queryBuilder->expr()->eq('tx_dlf_collections.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_foreign'))
)
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_documents_collections_mm.ident', $queryBuilder->createNamedParameter('docs_colls')),
$queryBuilder->expr()->eq('tx_dlf_collections.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])),
$additionalWhere
)
->groupBy('tx_dlf_documents.uid')
->orderBy('tx_dlf_documents.tstamp', 'DESC')
->setMaxResults((int) $this->settings['limit'])
->execute();
$rows = $result->fetchAll();
foreach ($rows as $resArray) {
foreach ($documents as $document) {
$title = '';
// Get title of superior document.
if ((empty($resArray['title']) || !empty($this->settings['prependSuperiorTitle']))
&& !empty($resArray['partof'])
if ((empty($document->getTitle()) || !empty($this->settings['prependSuperiorTitle']))
&& !empty($document->getPartof())
) {
$superiorTitle = Document::getTitle($resArray['partof'], true);
$superiorTitle = Document::getTitle($document->getPartof(), true);
if (!empty($superiorTitle)) {
$title .= '[' . $superiorTitle . ']';
}
}
// Get title of document.
if (!empty($resArray['title'])) {
$title .= ' ' . $resArray['title'];
if (!empty($document->getTitle())) {
$title .= ' ' . $document->getTitle();
}
// Set default title if empty.
if (empty($title)) {
$title = LocalizationUtility::translate('noTitle', 'dlf');
}
// Append volume information.
if (!empty($resArray['volume'])) {
$title .= ', ' . LocalizationUtility::translate('volume', 'dlf') . ' ' . $resArray['volume'];
if (!empty($document->getVolume())) {
$title .= ', ' . LocalizationUtility::translate('volume', 'dlf') . ' ' . $document->getVolume();
}
// Is this document new or updated?
if ($resArray['crdate'] == $resArray['tstamp']) {
if ($document->getCrdate() == $document->getTstamp()) {
$title = LocalizationUtility::translate('plugins.feeds.new', 'dlf') . ' ' . trim($title);
} else {
$title = LocalizationUtility::translate('plugins.feeds.update', 'dlf') . ' ' . trim($title);
}
$resArray['title'] = $title;
$documents[] = $resArray;
$document->setTitle($title);
}
}
$this->view->assign('documents', $documents);
$this->view->assign('feedMeta', $feedMeta);
}
}

View File

@ -11,15 +11,16 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Domain\Model\Metadata;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\DocumentList;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\Solr;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use Kitodo\Dlf\Domain\Repository\MetadataRepository;
/**
* Plugin 'List View' for the 'dlf' extension
@ -72,6 +73,19 @@ class ListViewController extends AbstractController
*/
protected $metadataList = [];
/**
* @var MetadataRepository
*/
protected $metadataRepository;
/**
* @param MetadataRepository $metadataRepository
*/
public function injectMetadataRepository(MetadataRepository $metadataRepository)
{
$this->metadataRepository = $metadataRepository;
}
/**
* Renders one entry of the list
*
@ -284,37 +298,18 @@ class ListViewController extends AbstractController
*/
protected function loadConfig()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_metadata');
$metadataResult = $this->metadataRepository->findBySettings(['is_listed' => 1, 'is_sortable' => 1]);
$result = $queryBuilder
->select(
'tx_dlf_metadata.index_name AS index_name',
'tx_dlf_metadata.wrap AS wrap',
'tx_dlf_metadata.is_listed AS is_listed',
'tx_dlf_metadata.is_sortable AS is_sortable'
)
->from('tx_dlf_metadata')
->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('tx_dlf_metadata.is_listed', 1),
$queryBuilder->expr()->eq('tx_dlf_metadata.is_sortable', 1)
),
$queryBuilder->expr()->eq('tx_dlf_metadata.pid', intval($this->settings['pages'])),
Helper::whereExpression('tx_dlf_metadata')
)
->orderBy('tx_dlf_metadata.sorting')
->execute();
while ($resArray = $result->fetch()) {
if ($resArray['is_listed']) {
$this->metadata[$resArray['index_name']] = [
'wrap' => $resArray['wrap'],
'label' => Helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->settings['pages'])
/** @var Metadata $metadata */
foreach ($metadataResult as $metadata) {
if ($metadata->getIsListed()) {
$this->metadata[$metadata->getIndexName()] = [
'wrap' => $metadata->getWrap(),
'label' => Helper::translate($metadata->getIndexName(), 'tx_dlf_metadata', $this->settings['pages'])
];
}
if ($resArray['is_sortable']) {
$this->sortables[$resArray['index_name']] = Helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->settings['pages']);
if ($metadata->getIsSortable()) {
$this->sortables[$metadata->getIndexName()] = Helper::translate($metadata->getIndexName(), 'tx_dlf_metadata', $this->settings['pages']);
}
}
}

View File

@ -14,16 +14,37 @@ namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\IiifManifest;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use Kitodo\Dlf\Domain\Model\Collection;
use Kitodo\Dlf\Domain\Model\Metadata;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use Ubl\Iiif\Context\IRI;
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
use Kitodo\Dlf\Domain\Repository\MetadataRepository;
class MetadataController extends AbstractController
{
public $prefixId = 'tx_dlf';
protected $metadataRepository;
protected $collectionRepository;
/**
* @param CollectionRepository $collectionRepository
*/
public function injectCollectionRepository(CollectionRepository $collectionRepository)
{
$this->collectionRepository = $collectionRepository;
}
/**
* @param MetadataRepository $metadataRepository
*/
public function injectMetadataRepository(MetadataRepository $metadataRepository)
{
$this->metadataRepository = $metadataRepository;
}
/**
* @return string|void
*/
@ -202,55 +223,30 @@ class MetadataController extends AbstractController
}
}
} else {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_metadata');
$result = $queryBuilder
->select(
'tx_dlf_metadata.index_name AS index_name',
'tx_dlf_metadata.is_listed AS is_listed',
'tx_dlf_metadata.wrap AS wrap',
'tx_dlf_metadata.sys_language_uid AS sys_language_uid'
)
->from('tx_dlf_metadata')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->in('tx_dlf_metadata.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_metadata.sys_language_uid', $GLOBALS['TSFE']->sys_language_uid)
),
$queryBuilder->expr()->eq('tx_dlf_metadata.l18n_parent', 0)
),
$queryBuilder->expr()->eq('tx_dlf_metadata.pid', intval($this->settings['pages']))
)
->orderBy('tx_dlf_metadata.sorting')
->execute();
while ($resArray = $result->fetch()) {
if (is_array($resArray) && $resArray['sys_language_uid'] != $GLOBALS['TSFE']->sys_language_content && $GLOBALS['TSFE']->sys_language_contentOL) {
$resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_dlf_metadata', $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
}
if ($resArray) {
if ($this->settings['showFull'] || $resArray['is_listed']) {
$metaList[$resArray['index_name']] = [
'wrap' => $resArray['wrap'],
'label' => Helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->settings['pages'])
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
$currentLanguageUid = $context->getPropertyFromAspect('language', 'id');
$metadataResult = $this->metadataRepository->findAll();
/** @var Metadata $metadata */
foreach ($metadataResult as $metadata) {
if ($metadata) {
if ($this->settings['showFull'] || $metadata->getIsListed()) {
$metaList[$metadata->getIndexName()] = [
'wrap' => $metadata->getWrap(),
'label' => Helper::translate($metadata->getIndexName(), 'tx_dlf_metadata', $this->settings['pages'])
];
}
}
}
// Get list of collections to show.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
$collList = [];
$result = $queryBuilder
->select('tx_dlf_collections.index_name AS index_name')
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages']))
)
->execute();
while ($resArray = $result->fetch()) {
$collList[] = $resArray['index_name'];
$collections = $this->collectionRepository->getCollectionForMetadata($this->settings['pages']);
/** @var Collection $collection */
foreach ($collections as $collection) {
$collList[] = $collection->getIndexName();
}
// Parse the metadata arrays.
foreach ($metadataArray as $metadata) {
$markerArray['METADATA'] = '';

View File

@ -14,10 +14,11 @@ namespace Kitodo\Dlf\Controller;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Kitodo\Dlf\Common\DocumentList;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\Solr;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use Kitodo\Dlf\Domain\Model\Token;
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
use Kitodo\Dlf\Domain\Repository\LibraryRepository;
use Kitodo\Dlf\Domain\Repository\TokenRepository;
/**
* Controller for the plugin 'OAI-PMH Interface' for the 'dlf' extension
@ -29,6 +30,45 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
*/
class OaiPmhController extends AbstractController
{
/**
* @var TokenRepository
*/
protected $tokenRepository;
/**
* @param TokenRepository $tokenRepository
*/
public function injectTokenRepository(TokenRepository $tokenRepository)
{
$this->tokenRepository = $tokenRepository;
}
/**
* @var CollectionRepository
*/
protected $collectionRepository;
/**
* @param CollectionRepository $collectionRepository
*/
public function injectCollectionRepository(CollectionRepository $collectionRepository)
{
$this->collectionRepository = $collectionRepository;
}
/**
* @var LibraryRepository
*/
protected $libraryRepository;
/**
* @param LibraryRepository $libraryRepository
*/
public function injectLibraryRepository(LibraryRepository $libraryRepository)
{
$this->libraryRepository = $libraryRepository;
}
/**
* Initializes the current action
*
@ -91,21 +131,7 @@ class OaiPmhController extends AbstractController
protected function deleteExpiredTokens()
{
// Delete expired resumption tokens.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_dlf_tokens');
$result = $queryBuilder
->delete('tx_dlf_tokens')
->where(
$queryBuilder->expr()->eq('tx_dlf_tokens.ident', $queryBuilder->createNamedParameter('oai')),
$queryBuilder->expr()->lt('tx_dlf_tokens.tstamp',
$queryBuilder->createNamedParameter((int) ($GLOBALS['EXEC_TIME'] - $this->settings['expired'])))
)
->execute();
if ($result === -1) {
// Deletion failed.
$this->logger->warning('Could not delete expired resumption tokens');
}
$this->tokenRepository->deleteExpiredTokens($this->settings['expired']);
}
/**
@ -176,21 +202,11 @@ class OaiPmhController extends AbstractController
$record[] = ['dc:format' => $record['application/mets+xml']];
$record[] = ['dc:type' => $record['Text']];
if (!empty($record['partof'])) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$result = $queryBuilder
->select('tx_dlf_documents.record_id')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.uid', intval($metadata['partof'])),
Helper::whereExpression('tx_dlf_documents')
)
->setMaxResults(1)
->execute();
$document = $this->documentRepository->findOneByPartof($metadata['partof']);
if ($partof = $result->fetch()) {
$metadata[] = ['dc:relation' => $partof['record_id']];
if ($document) {
$metadata[] = ['dc:relation' => $document->getRecordId()];
}
}
if (!empty($record['license'])) {
@ -296,24 +312,13 @@ class OaiPmhController extends AbstractController
*/
protected function resume(): ?DocumentList
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_tokens');
$token = $this->tokenRepository->findOneByToken($this->parameters['resumptionToken']);
// Get resumption token.
$result = $queryBuilder
->select('tx_dlf_tokens.options AS options')
->from('tx_dlf_tokens')
->where(
$queryBuilder->expr()->eq('tx_dlf_tokens.ident', $queryBuilder->createNamedParameter('oai')),
$queryBuilder->expr()->eq('tx_dlf_tokens.token',
$queryBuilder->expr()->literal($this->parameters['resumptionToken'])
)
)
->setMaxResults(1)
->execute();
if ($resArray = $result->fetch()) {
return unserialize($resArray['options']);
if ($token) {
$options = $token->getOptions();
}
if ($options instanceof DocumentList) {
return $options;
} else {
// No resumption token found or resumption token expired.
$this->error = 'badResumptionToken';
@ -334,73 +339,44 @@ class OaiPmhController extends AbstractController
$this->error = 'badArgument';
return;
}
if (!array_key_exists($this->parameters['metadataPrefix'], $this->formats)) {
$this->error = 'cannotDisseminateFormat';
return;
}
$where = '';
if (!$this->settings['show_userdefined']) {
$where .= 'AND tx_dlf_collections.fe_cruser_id=0 ';
}
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_dlf_documents');
$document = $this->documentRepository->getOaiRecord($this->settings, $this->parameters);
$sql = 'SELECT `tx_dlf_documents`.*, GROUP_CONCAT(DISTINCT `tx_dlf_collections`.`oai_name` ORDER BY `tx_dlf_collections`.`oai_name` SEPARATOR " ") AS `collections` ' .
'FROM `tx_dlf_documents` ' .
'INNER JOIN `tx_dlf_relations` ON `tx_dlf_relations`.`uid_local` = `tx_dlf_documents`.`uid` ' .
'INNER JOIN `tx_dlf_collections` ON `tx_dlf_collections`.`uid` = `tx_dlf_relations`.`uid_foreign` ' .
'WHERE `tx_dlf_documents`.`record_id` = ? ' .
'AND `tx_dlf_documents`.`pid` = ? ' .
'AND `tx_dlf_collections`.`pid` = ? ' .
'AND `tx_dlf_relations`.`ident`="docs_colls" ' .
$where .
'AND ' . Helper::whereExpression('tx_dlf_collections');
$values = [
$this->parameters['identifier'],
$this->settings['pages'],
$this->settings['pages']
];
$types = [
Connection::PARAM_STR,
Connection::PARAM_INT,
Connection::PARAM_INT
];
// Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query
$statement = $connection->executeQuery($sql, $values, $types);
$resArray = $statement->fetch();
if (!$resArray['uid']) {
if (!$document['uid']) {
$this->error = 'idDoesNotExist';
return;
}
// Check for required fields.
foreach ($this->formats[$this->parameters['metadataPrefix']]['requiredFields'] as $required) {
if (empty($resArray[$required])) {
if (empty($document[$required])) {
$this->error = 'cannotDisseminateFormat';
return;
}
}
// we need the collections as array later
$resArray['collections'] = explode(' ', $resArray['collections']);
$document['collections'] = explode(' ', $document['collections']);
// Add metadata
switch ($this->parameters['metadataPrefix']) {
case 'oai_dc':
$resArray['metadata'] = $this->getDcData($resArray);
$document['metadata'] = $this->getDcData($document);
break;
case 'epicur':
$resArray['metadata'] = $resArray;
$document['metadata'] = $document;
break;
case 'mets':
$resArray['metadata'] = $this->getMetsData($resArray);
$document['metadata'] = $this->getMetsData($document);
break;
}
$this->view->assign('record', $resArray);
$this->view->assign('record', $document);
}
/**
@ -412,56 +388,40 @@ class OaiPmhController extends AbstractController
*/
protected function verbIdentify()
{
// Get repository name and administrative contact.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_libraries');
$library = $this->libraryRepository->findByUid($this->settings['library']);
$result = $queryBuilder
->select(
'tx_dlf_libraries.oai_label AS oai_label',
'tx_dlf_libraries.contact AS contact'
)
->from('tx_dlf_libraries')
->where(
$queryBuilder->expr()->eq('tx_dlf_libraries.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_libraries.uid', intval($this->settings['library']))
)
->setMaxResults(1)
->execute();
$oaiIdentifyInfo = [];
$oaiIdentifyInfo = $result->fetch();
if (!$oaiIdentifyInfo) {
$this->logger->notice('Incomplete plugin configuration');
}
$oaiIdentifyInfo['oai_label'] = $library->getOaiLabel();
// Use default values for an installation with incomplete plugin configuration.
if (empty($oaiIdentifyInfo['oai_label'])) {
$oaiIdentifyInfo['oai_label'] = 'Kitodo.Presentation OAI-PMH Interface (default configuration)';
$this->logger->notice('Incomplete plugin configuration (oai_label is missing)');
}
$oaiIdentifyInfo['contact'] = $library->getContact();
if (empty($oaiIdentifyInfo['contact'])) {
$oaiIdentifyInfo['contact'] = 'unknown@example.org';
$this->logger->notice('Incomplete plugin configuration (contact is missing)');
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$document = $this->documentRepository->findOldestDocument();
$result = $queryBuilder
->select('tx_dlf_documents.tstamp AS tstamp')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages']))
)
->orderBy('tx_dlf_documents.tstamp')
->setMaxResults(1)
->execute();
if ($resArray = $result->fetch()) {
$oaiIdentifyInfo['earliestDatestamp'] = gmdate('Y-m-d\TH:i:s\Z', $resArray['tstamp']);
if ($document) {
$oaiIdentifyInfo['earliestDatestamp'] = gmdate('Y-m-d\TH:i:s\Z', $document->getTstamp()->getTimestamp());
} else {
$this->logger->notice('No records found with PID ' . $this->settings['pages']);
// access storagePid from TypoScript
$pageSettings = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$storagePid = $pageSettings["plugin."]["tx_dlf."]["persistence."]["storagePid"];
if ($storagePid > 0) {
$this->logger->notice('No records found with PID ' . $storagePid);
} else {
$this->logger->notice('No records found');
}
}
$this->view->assign('oaiIdentifyInfo', $oaiIdentifyInfo);
}
@ -533,23 +493,7 @@ class OaiPmhController extends AbstractController
$resArray = [];
// check for the optional "identifier" parameter
if (isset($this->parameters['identifier'])) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
// Check given identifier.
$result = $queryBuilder
->select('tx_dlf_documents.*')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_documents.record_id',
$queryBuilder->expr()->literal($this->parameters['identifier']))
)
->orderBy('tx_dlf_documents.tstamp')
->setMaxResults(1)
->execute();
$resArray = $result->fetch();
$resArray = $this->documentRepository->findOneByRecordId($this->parameters['identifier']);
}
$resultSet = [];
@ -557,7 +501,8 @@ class OaiPmhController extends AbstractController
if (!empty($resArray)) {
// check, if all required fields are available for a given identifier
foreach ($details['requiredFields'] as $required) {
if (empty($resArray[$required])) {
$methodName = 'get' . GeneralUtility::underscoredToUpperCamelCase($required);
if (empty($resArray->$methodName())) {
// Skip metadata formats whose requirements are not met.
continue 2;
}
@ -634,43 +579,12 @@ class OaiPmhController extends AbstractController
*/
protected function verbListSets()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
// It is required to set a oai_name inside the collection record to be shown in oai-pmh plugin.
$this->settings['hideEmptyOaiNames'] = true;
// Check for invalid arguments.
if (count($this->parameters) > 1) {
if (!empty($this->parameters['resumptionToken'])) {
$this->error = 'badResumptionToken';
return;
} else {
$this->error = 'badArgument';
return;
}
}
$where = '';
if (!$this->settings['show_userdefined']) {
$where = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
}
$oaiSets = $this->collectionRepository->findCollectionsBySettings($this->settings);
$result = $queryBuilder
->select(
'tx_dlf_collections.oai_name AS oai_name',
'tx_dlf_collections.label AS label'
)
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->in('tx_dlf_collections.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->neq('tx_dlf_collections.oai_name', $queryBuilder->createNamedParameter('')),
$where,
Helper::whereExpression('tx_dlf_collections')
)
->orderBy('tx_dlf_collections.oai_name')
->execute();
$allResults = $result->fetchAll();
$this->view->assign('oaiSets', $allResults);
$this->view->assign('oaiSets', $oaiSets);
}
/**
@ -682,34 +596,13 @@ class OaiPmhController extends AbstractController
*/
protected function fetchDocumentUIDs()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
$solr_query = '';
$where = '';
if (!$this->settings['show_userdefined']) {
$where = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
}
// Check "set" for valid value.
if (!empty($this->parameters['set'])) {
// For SOLR we need the index_name of the collection,
// For DB Query we need the UID of the collection
$result = $queryBuilder
->select(
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.uid AS uid',
'tx_dlf_collections.index_search as index_query'
)
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections.oai_name',
$queryBuilder->expr()->literal($this->parameters['set'])),
$where,
Helper::whereExpression('tx_dlf_collections')
)
->setMaxResults(1)
->execute();
$result = $this->collectionRepository->getIndexNameForSolr($this->settings, $this->parameters['set']);
if ($resArray = $result->fetch()) {
if ($resArray['index_query'] != "") {
@ -819,35 +712,7 @@ class OaiPmhController extends AbstractController
}
$verb = $this->parameters['verb'];
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_dlf_documents');
$sql = 'SELECT `tx_dlf_documents`.*, GROUP_CONCAT(DISTINCT `tx_dlf_collections`.`oai_name` ORDER BY `tx_dlf_collections`.`oai_name` SEPARATOR " ") AS `collections` ' .
'FROM `tx_dlf_documents` ' .
'INNER JOIN `tx_dlf_relations` ON `tx_dlf_relations`.`uid_local` = `tx_dlf_documents`.`uid` ' .
'INNER JOIN `tx_dlf_collections` ON `tx_dlf_collections`.`uid` = `tx_dlf_relations`.`uid_foreign` ' .
'WHERE `tx_dlf_documents`.`uid` IN ( ? ) ' .
'AND `tx_dlf_documents`.`pid` = ? ' .
'AND `tx_dlf_collections`.`pid` = ? ' .
'AND `tx_dlf_relations`.`ident`="docs_colls" ' .
'AND ' . Helper::whereExpression('tx_dlf_collections') . ' ' .
'GROUP BY `tx_dlf_documents`.`uid` ' .
'LIMIT ?';
$values = [
$documentsToProcess,
$this->settings['pages'],
$this->settings['pages'],
$this->settings['limit']
];
$types = [
Connection::PARAM_INT_ARRAY,
Connection::PARAM_INT,
Connection::PARAM_INT,
Connection::PARAM_INT
];
// Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query
$documents = $connection->executeQuery($sql, $values, $types);
$documents = $this->documentRepository->getOaiDocumentList($this->settings, $documentsToProcess);
$records = [];
while ($resArray = $documents->fetch()) {
@ -894,26 +759,15 @@ class OaiPmhController extends AbstractController
protected function generateResumptionTokenForDocumentListSet(DocumentList $documentListSet)
{
if ($documentListSet->count() !== 0) {
$token = uniqid('', false);
$resumptionToken = uniqid('', false);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_dlf_tokens');
$affectedRows = $queryBuilder
->insert('tx_dlf_tokens')
->values([
'tstamp' => $GLOBALS['EXEC_TIME'],
'token' => $token,
'options' => serialize($documentListSet),
'ident' => 'oai',
])
->execute();
// create new token
$newToken = $this->objectManager->get(Token::class);
$newToken->setToken($resumptionToken);
$newToken->setOptions($documentListSet);
if ($affectedRows === 1) {
$resumptionToken = $token;
} else {
$this->logger->error('Could not create resumption token');
$this->error = 'badResumptionToken';
return;
}
// add to tokenRepository
$this->tokenRepository->add($newToken);
} else {
// Result set complete. We don't need a token.
$resumptionToken = '';

View File

@ -60,6 +60,8 @@ class PageViewController extends AbstractController
*/
public function mainAction()
{
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$requestData = GeneralUtility::_GPmerged('tx_dlf');
unset($requestData['__referrer'], $requestData['__trustedProperties']);

View File

@ -16,17 +16,30 @@ use Kitodo\Dlf\Common\DocumentList;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\Indexer;
use Kitodo\Dlf\Common\Solr;
use Kitodo\Dlf\Domain\Model\Collection;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Kitodo\Dlf\Domain\Repository\CollectionRepository;
class SearchController extends AbstractController
{
public $prefixId = 'tx_dlf';
public $extKey = 'dlf';
/**
* @var CollectionRepository
*/
protected $collectionRepository;
/**
* @param CollectionRepository $collectionRepository
*/
public function injectCollectionRepository(CollectionRepository $collectionRepository)
{
$this->collectionRepository = $collectionRepository;
}
/**
* Search action
*/
@ -420,56 +433,47 @@ class SearchController extends AbstractController
$facetCollections = preg_replace('/[^0-9,]/', '', $this->settings['facetCollections']);
if (!empty($facetCollections)) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
$collections = $this->collectionRepository->findCollectionsBySettings(['collections' => $facetCollections]);
$result = $queryBuilder
->select('tx_dlf_collections.index_name AS index_name')
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->in(
'tx_dlf_collections.uid',
$queryBuilder->createNamedParameter(GeneralUtility::intExplode(',', $facetCollections), Connection::PARAM_INT_ARRAY)
)
)
->execute();
while ($collection = $result->fetch()) {
$facetCollectionArray[] = $collection['index_name'];
/** @var Collection $collection */
foreach ($collections as $collection) {
$facetCollectionArray[] = $collection->getIndexName();
}
}
// Process results.
foreach ($facet as $field => $values) {
$entryArray = [];
$entryArray['title'] = htmlspecialchars($facets[$field]);
$entryArray['count'] = 0;
$entryArray['_OVERRIDE_HREF'] = '';
$entryArray['doNotLinkIt'] = 1;
$entryArray['ITEM_STATE'] = 'NO';
// Count number of facet values.
$i = 0;
foreach ($values as $value => $count) {
if ($count > 0) {
// check if facet collection configuration exists
if (!empty($this->settings['facetCollections'])) {
if ($field == "collection_faceting" && !in_array($value, $facetCollectionArray)) {
continue;
if ($facet) {
foreach ($facet as $field => $values) {
$entryArray = [];
$entryArray['title'] = htmlspecialchars($facets[$field]);
$entryArray['count'] = 0;
$entryArray['_OVERRIDE_HREF'] = '';
$entryArray['doNotLinkIt'] = 1;
$entryArray['ITEM_STATE'] = 'NO';
// Count number of facet values.
$i = 0;
foreach ($values as $value => $count) {
if ($count > 0) {
// check if facet collection configuration exists
if (!empty($this->settings['facetCollections'])) {
if ($field == "collection_faceting" && !in_array($value, $facetCollectionArray)) {
continue;
}
}
}
$entryArray['count']++;
if ($entryArray['ITEM_STATE'] == 'NO') {
$entryArray['ITEM_STATE'] = 'IFSUB';
}
$entryArray['_SUB_MENU'][] = $this->getFacetsMenuEntry($field, $value, $count, $search, $entryArray['ITEM_STATE']);
if (++$i == $this->settings['limit']) {
$entryArray['count']++;
if ($entryArray['ITEM_STATE'] == 'NO') {
$entryArray['ITEM_STATE'] = 'IFSUB';
}
$entryArray['_SUB_MENU'][] = $this->getFacetsMenuEntry($field, $value, $count, $search, $entryArray['ITEM_STATE']);
if (++$i == $this->settings['limit']) {
break;
}
} else {
break;
}
} else {
break;
}
$menuArray[] = $entryArray;
}
$menuArray[] = $entryArray;
}
return $menuArray;
}

View File

@ -11,10 +11,6 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
@ -27,7 +23,6 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
*/
class StatisticsController extends AbstractController
{
/**
* The main method of the plugin
*
@ -35,138 +30,8 @@ class StatisticsController extends AbstractController
*/
public function mainAction()
{
// Quit without doing anything if required configuration variables are not set.
if (empty($this->settings['pages'])) {
$this->logger->warning('Incomplete plugin configuration');
}
// Check for selected collections.
if ($this->settings['collections']) {
// Include only selected collections.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$countTitles = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->innerJoin(
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_relations_joins',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_local',
'tx_dlf_documents.uid'
)
)
->innerJoin(
'tx_dlf_relations_joins',
'tx_dlf_collections',
'tx_dlf_collections_join',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_foreign',
'tx_dlf_collections_join.uid'
)
)
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_documents.partof', 0),
$queryBuilder->expr()->in('tx_dlf_collections_join.uid',
$queryBuilder->createNamedParameter(GeneralUtility::intExplode(',',
$this->settings['collections']), Connection::PARAM_INT_ARRAY)),
$queryBuilder->expr()->eq('tx_dlf_relations_joins.ident',
$queryBuilder->createNamedParameter('docs_colls'))
)
->execute()
->fetchColumn(0);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQuery = $subQueryBuilder
->select('tx_dlf_documents.partof')
->from('tx_dlf_documents')
->where(
$subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0)
)
->groupBy('tx_dlf_documents.partof')
->getSQL();
$countVolumes = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->innerJoin(
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_relations_joins',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_local',
'tx_dlf_documents.uid'
)
)
->innerJoin(
'tx_dlf_relations_joins',
'tx_dlf_collections',
'tx_dlf_collections_join',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_foreign',
'tx_dlf_collections_join.uid'
)
)
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery),
$queryBuilder->expr()->in('tx_dlf_collections_join.uid',
$queryBuilder->createNamedParameter(GeneralUtility::intExplode(',',
$this->settings['collections']), Connection::PARAM_INT_ARRAY)),
$queryBuilder->expr()->eq('tx_dlf_relations_joins.ident',
$queryBuilder->createNamedParameter('docs_colls'))
)
->execute()
->fetchColumn(0);
} else {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
// Include all collections.
$countTitles = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_documents.partof', 0),
Helper::whereExpression('tx_dlf_documents')
)
->execute()
->fetchColumn(0);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQuery = $subQueryBuilder
->select('tx_dlf_documents.partof')
->from('tx_dlf_documents')
->where(
$subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0)
)
->groupBy('tx_dlf_documents.partof')
->getSQL();
$countVolumes = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])),
$queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery)
)
->execute()
->fetchColumn(0);
}
$countTitles = $this->documentRepository->countAllTitles($this->settings);
$countVolumes = $this->documentRepository->countAllVolumes($this->settings);
// Set replacements.
$args['###TITLES###'] = $countTitles . ' ' . htmlspecialchars(

View File

@ -11,11 +11,9 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
/**
* Controller for plugin 'Table Of Contents' for the 'dlf' extension
@ -226,41 +224,7 @@ class TableOfContentsController extends AbstractController
$menuArray[] = $this->getMenuEntry($entry, false);
}
// Build table of contents from database.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$excludeOtherWhere = '';
if ($this->settings['excludeOther']) {
$excludeOtherWhere = 'tx_dlf_documents.pid=' . intval($this->settings['pages']);
}
// Check if there are any metadata to suggest.
$result = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.title AS title',
'tx_dlf_documents.volume AS volume',
'tx_dlf_documents.mets_label AS mets_label',
'tx_dlf_documents.mets_orderlabel AS mets_orderlabel',
'tx_dlf_structures_join.index_name AS type'
)
->innerJoin(
'tx_dlf_documents',
'tx_dlf_structures',
'tx_dlf_structures_join',
$queryBuilder->expr()->eq(
'tx_dlf_structures_join.uid',
'tx_dlf_documents.structure'
)
)
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)),
$queryBuilder->expr()->eq('tx_dlf_structures_join.pid', intval($this->doc->pid)),
$excludeOtherWhere
)
->addOrderBy('tx_dlf_documents.volume_sorting')
->addOrderBy('tx_dlf_documents.mets_orderlabel')
->execute();
$result = $this->documentRepository->getTableOfContentsFromDb($this->doc->uid, $this->doc->pid, $this->settings);
$allResults = $result->fetchAll();

View File

@ -14,10 +14,15 @@ namespace Kitodo\Dlf\Domain\Model;
class Collection extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
{
/**
* @var int
*/
protected $feCruserId;
/**
* @var string
*/
protected $fe_group;
protected $feGroup;
/**
* @var string
@ -69,20 +74,36 @@ class Collection extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
*/
protected $status;
/**
* @return int
*/
public function getFeCruserId(): int
{
return $this->feCruserId;
}
/**
* @param string $feCruserId
*/
public function setFeCruserId(string $feCruserId): void
{
$this->feCruserId = $feCruserId;
}
/**
* @return string
*/
public function getFeGroup(): string
{
return $this->fe_group;
return $this->feGroup;
}
/**
* @param string $fe_group
* @param string $feGroup
*/
public function setFeGroup(string $fe_group): void
public function setFeGroup(string $feGroup): void
{
$this->fe_group = $fe_group;
$this->feGroup = $feGroup;
}
/**

View File

@ -14,6 +14,16 @@ namespace Kitodo\Dlf\Domain\Model;
class Document extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
{
/**
* @var \DateTime
*/
protected $crdate;
/**
* @var \DateTime
*/
protected $tstamp;
/**
* @var string
*/
@ -553,16 +563,19 @@ class Document extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
$this->rightsInfo = $rightsInfo;
}
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
* Returns the collections
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> $collections
*/
public function getCollections(): ?\TYPO3\CMS\Extbase\Persistence\ObjectStorage
public function getCollections()
{
return $this->collections;
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $collections
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\Collection> $collections
*/
public function setCollections(?\TYPO3\CMS\Extbase\Persistence\ObjectStorage $collections): void
{
@ -665,4 +678,44 @@ class Document extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
$this->documentFormat = $documentFormat;
}
/**
* Returns the timestamp
*
* @return \DateTime
*/
public function getTstamp(): \DateTime
{
return $this->tstamp;
}
/**
* Sets the timestamp
*
* @param \DateTime $tstamp
*/
public function setTstamp($tstamp): void
{
$this->tstamp = $tstamp;
}
/**
* Returns the creation date
*
* @return \DateTime
*/
public function getCrdate(): \DateTime
{
return $this->crdate;
}
/**
* Sets the creation date
*
* @param \DateTime $crdate
*/
public function setCrdate($crdate): void
{
$this->crdate = $crdate;
}
}

View File

@ -89,6 +89,11 @@ class Metadata extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
*/
protected $status;
/**
* @var int
*/
protected $sysLanguageUid;
/**
* @return int
*/
@ -329,4 +334,20 @@ class Metadata extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
$this->status = $status;
}
/**
* @return int
*/
public function getSysLanguageUid(): int
{
return $this->sysLanguageUid;
}
/**
* @param int $sysLanguageUid
*/
public function setSysLanguageUid(int $sysLanguageUid): void
{
$this->sysLanguageUid = $sysLanguageUid;
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Domain\Model;
class Token extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
{
/**
* @var string
*/
protected $token;
/**
* @var string
*/
protected $options;
/**
* @var string
*/
protected $ident;
/**
* @return string
*/
public function getToken(): string
{
return $this->token;
}
/**
* @param string $token
*/
public function setToken(string $token): void
{
$this->token = $token;
}
/**
* @return \Kitodo\Dlf\Common\DocumentList
*/
public function getOptions(): \Kitodo\Dlf\Common\DocumentList
{
return unserialize($this->options);
}
/**
* @param \Kitodo\Dlf\Common\DocumentList $options
*/
public function setOptions(\Kitodo\Dlf\Common\DocumentList $options): void
{
$this->options = serialize($options);
}
/**
* @return string
*/
public function getIdent(): string
{
return $this->ident;
}
/**
* @param string $ident
*/
public function setIdent(string $ident): void
{
$this->ident = $ident;
}
}

View File

@ -10,9 +10,9 @@
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Domain\Model;
namespace Kitodo\Dlf\Domain\Repository;
class ActionlogRepository extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
class ActionLogRepository extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
{
}
}

View File

@ -12,6 +12,11 @@
namespace Kitodo\Dlf\Domain\Repository;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
class CollectionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
@ -31,10 +36,191 @@ class CollectionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
$query->matching($query->equals('fe_cruser_id', $showUserDefined));
$query->setOrderings([
'label' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
'label' => QueryInterface::ORDER_ASCENDING
]);
}
public function getCollections($settings, $uid, $sysLangUid) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
}
$selectedCollections = $queryBuilder->expr()->neq('tx_dlf_collections.uid', 0);
$orderBy = 'tx_dlf_collections.label';
$showUserDefinedColls = '';
// Handle collections set by configuration.
if ($settings['collections']) {
$selectedCollections = $queryBuilder->expr()->in('tx_dlf_collections.uid', implode(',', GeneralUtility::intExplode(',', $settings['collections'])));
}
// Should user-defined collections be shown?
if (empty($settings['show_userdefined'])) {
$showUserDefinedColls = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
} elseif ($settings['show_userdefined'] > 0) {
if (!empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
$showUserDefinedColls = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', intval($uid));
} else {
$showUserDefinedColls = $queryBuilder->expr()->neq('tx_dlf_collections.fe_cruser_id', 0);
}
}
// Get collections.
$queryBuilder
->select(
'tx_dlf_collections.uid AS uid', // required by getRecordOverlay()
'tx_dlf_collections.pid AS pid', // required by getRecordOverlay()
'tx_dlf_collections.sys_language_uid AS sys_language_uid', // required by getRecordOverlay()
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.index_search as index_query',
'tx_dlf_collections.label AS label',
'tx_dlf_collections.thumbnail AS thumbnail',
'tx_dlf_collections.description AS description',
'tx_dlf_collections.priority AS priority'
)
->from('tx_dlf_collections')
->where(
$selectedCollections,
$showUserDefinedColls,
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($settings['pages'])),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->in('tx_dlf_collections.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_collections.sys_language_uid', $sysLangUid)
),
$queryBuilder->expr()->eq('tx_dlf_collections.l18n_parent', 0)
)
)
->orderBy($orderBy);
$result = $queryBuilder->execute();
$count = $queryBuilder->count('uid')->execute()->fetchColumn(0);
return ['result' => $result, 'count' => $count];
}
public function getSingleCollection($settings, $id, $sysLangUid) {
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_dlf_collections');
$additionalWhere = '';
// Should user-defined collections be shown?
if (empty($settings['show_userdefined'])) {
$additionalWhere = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
} elseif ($settings['show_userdefined'] > 0) {
$additionalWhere = $queryBuilder->expr()->neq('tx_dlf_collections.fe_cruser_id', 0);
}
// Get collection information from DB
$collection = $queryBuilder
->select(
'tx_dlf_collections.uid AS uid', // required by getRecordOverlay()
'tx_dlf_collections.pid AS pid', // required by getRecordOverlay()
'tx_dlf_collections.sys_language_uid AS sys_language_uid', // required by getRecordOverlay()
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.index_search as index_search',
'tx_dlf_collections.label AS label',
'tx_dlf_collections.description AS description',
'tx_dlf_collections.thumbnail AS thumbnail',
'tx_dlf_collections.fe_cruser_id'
)
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections.uid', intval($id)),
$additionalWhere,
$queryBuilder->expr()->andX(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->in('tx_dlf_collections.sys_language_uid', [-1, 0]),
$queryBuilder->expr()->eq('tx_dlf_collections.sys_language_uid', $sysLangUid)
),
$queryBuilder->expr()->eq('tx_dlf_collections.l18n_parent', 0)
),
Helper::whereExpression('tx_dlf_collections')
)
->setMaxResults(1)
->execute();
return $collection;
}
public function getCollectionForMetadata($pages) {
// Get list of collections to show.
$query = $this->createQuery();
$query->matching($query->equals('pid', $pages));
return $query->execute();
}
/**
* Finds all collection for the given settings
*
* @param array $settings
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findCollectionsBySettings($settings = [])
{
$query = $this->createQuery();
$constraints = [];
if ($settings['collections']) {
$constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['collections']));
}
// do not find user created collections (used by oai-pmh plugin)
if (!$settings['show_userdefined']) {
$constraints[] = $query->equals('fe_cruser_id', 0);
}
// do not find collections without oai_name set (used by oai-pmh plugin)
if ($settings['hideEmptyOaiNames']) {
$constraints[] = $query->logicalNot($query->equals('oai_name', ''));
}
if (count($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}
// order by oai_name
$query->setOrderings(
array('oai_name' => QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
public function getIndexNameForSolr($settings, $set) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_collections');
$where = '';
if (!$settings['show_userdefined']) {
$where = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
}
// For SOLR we need the index_name of the collection,
// For DB Query we need the UID of the collection
$result = $queryBuilder
->select(
'tx_dlf_collections.index_name AS index_name',
'tx_dlf_collections.uid AS uid',
'tx_dlf_collections.index_search as index_query'
)
->from('tx_dlf_collections')
->where(
$queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections.oai_name',
$queryBuilder->expr()->literal($set)),
$where,
Helper::whereExpression('tx_dlf_collections')
)
->setMaxResults(1)
->execute();
return $result;
}
}

View File

@ -12,9 +12,23 @@
namespace Kitodo\Dlf\Domain\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
class DocumentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* Array of all document structures
*
* @var array
*/
protected $documentStructures;
public function findByUidAndPartOf($uid, $partOf)
{
$query = $this->createQuery();
@ -25,11 +39,33 @@ class DocumentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
return $query->execute();
}
public function getChildrenOfYear($structure, $partOf)
/**
* Find the oldest document
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findOldestDocument()
{
$query = $this->createQuery();
$query->matching($query->equals('structure', $structure));
$query->setOrderings(['tstamp' => QueryInterface::ORDER_ASCENDING]);
$query->setLimit(1);
return $query->execute()->getFirst();
}
/**
* @param int $partOf
* @param string $structure
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function getChildrenOfYearAnchor($partOf, $structure)
{
$this->documentStructures = $this->getDocumentStructures();
$query = $this->createQuery();
$query->matching($query->equals('structure', $this->documentStructures[$structure]));
$query->matching($query->equals('partof', $partOf));
$query->setOrderings([
@ -38,4 +74,397 @@ class DocumentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
return $query->execute();
}
}
/**
* Finds all documents for the given settings
*
* @param int $uid
* @param array $settings
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findOneByIdAndSettings($uid, $settings = [])
{
$settings['documentSets'] = $uid;
return $this->findDocumentsBySettings($settings)->getFirst();
}
/**
* Finds all documents for the given settings
*
* @param array $settings
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findDocumentsBySettings($settings = [])
{
$query = $this->createQuery();
$constraints = [];
if ($settings['documentSets']) {
$constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['documentSets']));
}
if (isset($settings['excludeOther']) && (int) $settings['excludeOther'] === 0) {
$query->getQuerySettings()->setRespectStoragePage(false);
}
if (count($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}
return $query->execute();
}
/**
* Finds all documents for the given collections
*
* @param array $collections separated by comma
* @param int $limit
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findAllByCollectionsLimited($collections, $limit = 50)
{
$query = $this->createQuery();
// order by start_date -> start_time...
$query->setOrderings(
['tstamp' => QueryInterface::ORDER_DESCENDING]
);
$constraints = [];
if ($collections) {
$constraints[] = $query->in('collections.uid', $collections);
}
if (count($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}
$query->setLimit((int) $limit);
return $query->execute();
}
/**
* Find all the titles
*
* documents with partof == 0
*
* @param array $settings
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findAllTitles($settings = [])
{
$query = $this->createQuery();
$constraints = [];
$constraints[] = $query->equals('partof', 0);
if ($settings['collections']) {
$constraints[] = $query->in('collections.uid', GeneralUtility::intExplode(',', $settings['collections']));
}
if (count($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}
return $query->execute();
}
/**
* Count the titles
*
* documents with partof == 0
*
* @param array $settings
*
* @return int
*/
public function countAllTitles($settings = [])
{
return $this->findAllTitles($settings)->count();
}
/**
* Count the volumes
*
* documents with partof != 0
*
* @param array $settings
*
* @return int
*/
public function countAllVolumes($settings = [])
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQuery = $subQueryBuilder
->select('tx_dlf_documents.partof')
->from('tx_dlf_documents')
->where(
$subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0)
)
->groupBy('tx_dlf_documents.partof')
->getSQL();
$countVolumes = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($settings['pages'])),
$queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery)
)
->execute()
->fetchColumn(0);
return $countVolumes;
}
public function getStatisticsForSelectedCollection($settings)
{
// Include only selected collections.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$countTitles = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->innerJoin(
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_relations_joins',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_local',
'tx_dlf_documents.uid'
)
)
->innerJoin(
'tx_dlf_relations_joins',
'tx_dlf_collections',
'tx_dlf_collections_join',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_foreign',
'tx_dlf_collections_join.uid'
)
)
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_documents.partof', 0),
$queryBuilder->expr()->in('tx_dlf_collections_join.uid',
$queryBuilder->createNamedParameter(GeneralUtility::intExplode(',',
$settings['collections']), Connection::PARAM_INT_ARRAY)),
$queryBuilder->expr()->eq('tx_dlf_relations_joins.ident',
$queryBuilder->createNamedParameter('docs_colls'))
)
->execute()
->fetchColumn(0);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$subQuery = $subQueryBuilder
->select('tx_dlf_documents.partof')
->from('tx_dlf_documents')
->where(
$subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0)
)
->groupBy('tx_dlf_documents.partof')
->getSQL();
$countVolumes = $queryBuilder
->count('tx_dlf_documents.uid')
->from('tx_dlf_documents')
->innerJoin(
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_relations_joins',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_local',
'tx_dlf_documents.uid'
)
)
->innerJoin(
'tx_dlf_relations_joins',
'tx_dlf_collections',
'tx_dlf_collections_join',
$queryBuilder->expr()->eq(
'tx_dlf_relations_joins.uid_foreign',
'tx_dlf_collections_join.uid'
)
)
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($settings['pages'])),
$queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($settings['pages'])),
$queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery),
$queryBuilder->expr()->in('tx_dlf_collections_join.uid',
$queryBuilder->createNamedParameter(GeneralUtility::intExplode(',',
$settings['collections']), Connection::PARAM_INT_ARRAY)),
$queryBuilder->expr()->eq('tx_dlf_relations_joins.ident',
$queryBuilder->createNamedParameter('docs_colls'))
)
->execute()
->fetchColumn(0);
return ['titles' => $countTitles, 'volumes' => $countVolumes];
}
public function getTableOfContentsFromDb($uid, $pid, $settings)
{
// Build table of contents from database.
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
$excludeOtherWhere = '';
if ($settings['excludeOther']) {
$excludeOtherWhere = 'tx_dlf_documents.pid=' . intval($settings['pages']);
}
// Check if there are any metadata to suggest.
$result = $queryBuilder
->select(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents.title AS title',
'tx_dlf_documents.volume AS volume',
'tx_dlf_documents.mets_label AS mets_label',
'tx_dlf_documents.mets_orderlabel AS mets_orderlabel',
'tx_dlf_structures_join.index_name AS type'
)
->innerJoin(
'tx_dlf_documents',
'tx_dlf_structures',
'tx_dlf_structures_join',
$queryBuilder->expr()->eq(
'tx_dlf_structures_join.uid',
'tx_dlf_documents.structure'
)
)
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($uid)),
$queryBuilder->expr()->eq('tx_dlf_structures_join.pid', intval($pid)),
$excludeOtherWhere
)
->addOrderBy('tx_dlf_documents.volume_sorting')
->addOrderBy('tx_dlf_documents.mets_orderlabel')
->execute();
return $result;
}
/**
* Find one document by given settings and identifier
*
* @param array $settings
* @param array $parameters
*
* @return array The found document object
*/
public function getOaiRecord($settings, $parameters)
{
$where = '';
if (!$settings['show_userdefined']) {
$where .= 'AND tx_dlf_collections.fe_cruser_id=0 ';
}
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_dlf_documents');
$sql = 'SELECT `tx_dlf_documents`.*, GROUP_CONCAT(DISTINCT `tx_dlf_collections`.`oai_name` ORDER BY `tx_dlf_collections`.`oai_name` SEPARATOR " ") AS `collections` ' .
'FROM `tx_dlf_documents` ' .
'INNER JOIN `tx_dlf_relations` ON `tx_dlf_relations`.`uid_local` = `tx_dlf_documents`.`uid` ' .
'INNER JOIN `tx_dlf_collections` ON `tx_dlf_collections`.`uid` = `tx_dlf_relations`.`uid_foreign` ' .
'WHERE `tx_dlf_documents`.`record_id` = ? ' .
'AND `tx_dlf_relations`.`ident`="docs_colls" ' .
$where;
$values = [
$parameters['identifier']
];
$types = [
Connection::PARAM_STR
];
// Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query
$statement = $connection->executeQuery($sql, $values, $types);
return $statement->fetch();
}
/**
* Finds all documents for the given settings
*
* @param array $settings
* @param array $documentsToProcess
*
* @return array The found document objects
*/
public function getOaiDocumentList($settings, $documentsToProcess)
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_dlf_documents');
$sql = 'SELECT `tx_dlf_documents`.*, GROUP_CONCAT(DISTINCT `tx_dlf_collections`.`oai_name` ORDER BY `tx_dlf_collections`.`oai_name` SEPARATOR " ") AS `collections` ' .
'FROM `tx_dlf_documents` ' .
'INNER JOIN `tx_dlf_relations` ON `tx_dlf_relations`.`uid_local` = `tx_dlf_documents`.`uid` ' .
'INNER JOIN `tx_dlf_collections` ON `tx_dlf_collections`.`uid` = `tx_dlf_relations`.`uid_foreign` ' .
'WHERE `tx_dlf_documents`.`uid` IN ( ? ) ' .
'AND `tx_dlf_relations`.`ident`="docs_colls" ' .
'AND ' . Helper::whereExpression('tx_dlf_collections') . ' ' .
'GROUP BY `tx_dlf_documents`.`uid` ';
$values = [
$documentsToProcess,
];
$types = [
Connection::PARAM_INT_ARRAY,
];
// Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query
$documents = $connection->executeQuery($sql, $values, $types);
return $documents;
}
/**
* Get all document structures as array
*
* @return array
*/
private function getDocumentStructures()
{
// make lookup-table of structures uid -> indexName
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_dlf_structures');
// Fetch document info for UIDs in $documentSet from DB
$kitodoStructures = $queryBuilder
->select(
'tx_dlf_structures.uid AS uid',
'tx_dlf_structures.index_name AS indexName'
)
->from('tx_dlf_structures')
->execute();
$allStructures = $kitodoStructures->fetchAll();
// make lookup-table uid -> indexName
$allStructures = array_column($allStructures, 'indexName', 'uid');
return $allStructures;
}
}

View File

@ -12,6 +12,9 @@
namespace Kitodo\Dlf\Domain\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
class LibraryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{

View File

@ -12,7 +12,45 @@
namespace Kitodo\Dlf\Domain\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
class MetadataRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* Finds all collection for the given settings
*
* @param array $settings
*
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findBySettings($settings = [])
{
$query = $this->createQuery();
}
$constraints = [];
if ($settings['is_listed']) {
$constraints[] = $query->equals('is_listed', 1);
}
if ($settings['is_sortable']) {
$constraints[] = $query->equals('is_sortable', 1);
}
if (count($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}
// order by oai_name
$query->setOrderings(
array('sorting' => QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
}

View File

@ -15,12 +15,4 @@ namespace Kitodo\Dlf\Domain\Repository;
class PrinterRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
public function findAllWithPid($pid)
{
$querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
$querySettings->setStoragePageIds(array($pid));
$this->setDefaultQuerySettings($querySettings);
return $this->findAll();
}
}
}

View File

@ -0,0 +1,46 @@
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Domain\Repository;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class TokenRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* Delete all expired token
*
* @param int $expireTime
*
* @return void
*/
public function deleteExpiredTokens($expireTime)
{
$query = $this->createQuery();
$constraints = [];
$constraints[] = $query->lessThan('tstamp', (int) (time() - $expireTime));
if (count($constraints)) {
$query->matching($query->logicalAnd($constraints));
}
$tokensToBeRemoved = $query->execute();
foreach($tokensToBeRemoved as $token) {
$this->remove($token);
}
}
}

View File

@ -81,7 +81,7 @@ class DocumentTypeFunctionProvider implements ExpressionFunctionProviderInterfac
}
// Load document with current plugin parameters.
$doc = $this->loadDocument($queryParams[$this->prefixId]);
$doc = $this->loadDocument($queryParams[$this->prefixId], $cPid);
if ($doc === null) {
return $type;
}
@ -110,15 +110,16 @@ class DocumentTypeFunctionProvider implements ExpressionFunctionProviderInterfac
* @access protected
*
* @param array $piVars The current plugin variables containing a document identifier
* @param int $pid: Storage Pid
*
* @return \Kitodo\Dlf\Common\Document Instance of the current document
*/
protected function loadDocument(array $piVars)
protected function loadDocument(array $piVars, int $pid)
{
// Check for required variable.
if (!empty($piVars['id'])) {
// Get instance of document.
$doc = Document::getInstance($piVars['id']);
$doc = Document::getInstance($piVars['id'], ['storagePid' => $pid]);
if ($doc->ready) {
return $doc;
} else {

View File

@ -20,26 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.excludeOther>
<TCEforms>
<exclude>1</exclude>
@ -61,21 +41,6 @@
</config>
</TCEforms>
</settings.elementId>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,20 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</settings.pages>
<settings.pregeneration>
<TCEforms>
<exclude>1</exclude>
@ -128,21 +114,6 @@
</config>
</TCEforms>
</settings.targetBasket>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,26 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.targetPid>
<TCEforms>
<exclude>1</exclude>
@ -90,21 +70,6 @@
</config>
</TCEforms>
</settings.showEmptyMonths>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,36 +20,17 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.collections>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.collection.flexform.collections</label>
<config>
<type>select</type>
<items type="array"/>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->collectionList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_collections</foreign_table>
<foreign_table_where>AND tx_dlf_collections.hidden = 0 AND tx_dlf_collections.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_collections.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
@ -60,13 +41,15 @@
</settings.collections>
<settings.solrcore>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.solrcore</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->solrList</itemsProcFunc>
<renderType>selectSingle</renderType>
<foreign_table>tx_dlf_solrcores</foreign_table>
<foreign_table_where>ORDER BY
tx_dlf_solrcores.label ASC
</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
@ -153,21 +136,6 @@
</config>
</TCEforms>
</settings.targetFeed>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,36 +20,17 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.collections>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.collections</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->collectionList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_collections</foreign_table>
<foreign_table_where>AND tx_dlf_collections.hidden = 0 AND tx_dlf_collections.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_collections.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
@ -70,13 +51,15 @@
</settings.excludeOther>
<settings.library>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.library</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->libraryList</itemsProcFunc>
<renderType>selectSingle</renderType>
<foreign_table>tx_dlf_libraries</foreign_table>
<foreign_table_where>AND tx_dlf_libraries.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_libraries.label ASC
</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>

View File

@ -20,26 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.features>
<TCEforms>
<exclude>1</exclude>

View File

@ -20,38 +20,17 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<onChange>reload</onChange>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.library>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.library</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->libraryList</itemsProcFunc>
<foreign_table>tx_dlf_libraries</foreign_table>
<foreign_table_where>AND tx_dlf_libraries.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_libraries.label ASC
</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
@ -92,13 +71,13 @@
</settings.show_userdefined>
<settings.solrcore>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.solrcore</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->solrList</itemsProcFunc>
<renderType>selectSingle</renderType>
<foreign_table>tx_dlf_solrcores</foreign_table>
<foreign_table_where>ORDER BY tx_dlf_solrcores.label ASC</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
@ -107,7 +86,6 @@
</settings.solrcore>
<settings.solr_limit>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.oaipmh.flexform.solr_limit</label>
<config>

View File

@ -20,26 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.paginate.itemsPerPage>
<TCEforms>
<exclude>1</exclude>
@ -85,21 +65,6 @@
</config>
</TCEforms>
</settings.targetPid>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,28 +20,6 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<onChange>reload</onChange>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.fulltext>
<TCEforms>
<exclude>1</exclude>
@ -65,13 +43,13 @@
</settings.fulltext>
<settings.solrcore>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.solrcore</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->solrList</itemsProcFunc>
<renderType>selectSingle</renderType>
<foreign_table>tx_dlf_solrcores</foreign_table>
<foreign_table_where>ORDER BY tx_dlf_solrcores.label ASC</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
@ -80,7 +58,6 @@
</settings.solrcore>
<settings.extendedSlotCount>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.extSearch.slotCount</label>
<config>
@ -96,13 +73,16 @@
</settings.extendedSlotCount>
<settings.extendedFields>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.extSearch.fields</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->extendedSearchList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_metadata</foreign_table>
<foreign_table_where>AND tx_dlf_metadata.hidden = 0 AND tx_dlf_metadata.sys_language_uid IN (-1,0)
AND tx_dlf_metadata.index_indexed=1 = 1
ORDER BY tx_dlf_metadata.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>10</maxitems>
@ -143,13 +123,15 @@
</settings.searchIn>
<settings.collections>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.collections</label>
<config>
<type>select</type>
<items type="array"/>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->collectionList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_collections</foreign_table>
<foreign_table_where>AND tx_dlf_collections.hidden = 0 AND tx_dlf_collections.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_collections.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
@ -160,13 +142,16 @@
</settings.collections>
<settings.facets>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.facets</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->facetsList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_metadata</foreign_table>
<foreign_table_where>AND tx_dlf_metadata.hidden = 0 AND tx_dlf_metadata.sys_language_uid IN (-1,0)
AND tx_dlf_metadata.is_facet = 1
ORDER BY tx_dlf_metadata.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
@ -177,13 +162,15 @@
</settings.facets>
<settings.facetCollections>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.facets.collections</label>
<config>
<type>select</type>
<items type="array"/>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->collectionList</itemsProcFunc>
<renderType>selectMultipleSideBySide</renderType>
<foreign_table>tx_dlf_collections</foreign_table>
<foreign_table_where>AND tx_dlf_collections.hidden = 0 AND tx_dlf_collections.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_collections.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
@ -194,7 +181,6 @@
</settings.facetCollections>
<settings.limitFacets>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.search.flexform.facets.limit</label>
<config>
@ -306,21 +292,6 @@
</config>
</TCEforms>
</settings.targetPidPageView>
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</settings.templateFile>
</el>
</ROOT>
</sDEF>

View File

@ -20,36 +20,16 @@
</TCEforms>
<type>array</type>
<el>
<settings.pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.pages>
<settings.collections>
<TCEforms>
<displayCond>FIELD:settings.pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.collections</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->collectionList</itemsProcFunc>
<foreign_table>tx_dlf_collections</foreign_table>
<foreign_table_where>AND tx_dlf_collections.hidden = 0 AND tx_dlf_collections.sys_language_uid IN (-1,0)
ORDER BY tx_dlf_collections.label ASC
</foreign_table_where>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>

View File

@ -46,6 +46,7 @@
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.toolbox.flexform.tools</label>
<config>
<type>select</type>
<renderType>selectMultipleSideBySide</renderType>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->toolList</itemsProcFunc>
<size>5</size>
@ -62,8 +63,9 @@
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.solrcore</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>Kitodo\Dlf\Hooks\ItemsProcFunc->solrList</itemsProcFunc>
<renderType>selectSingle</renderType>
<foreign_table>tx_dlf_solrcores</foreign_table>
<foreign_table_where>ORDER BY tx_dlf_solrcores.label ASC</foreign_table_where>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>

View File

@ -40,15 +40,31 @@ return [
'columns' => [
'hidden' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'config' => [
'type' => 'check',
'default' => 0,
],
],
'tstamp' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.timestamp',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
]
],
'crdate' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.creationDate',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
]
],
'starttime' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
@ -59,7 +75,7 @@ return [
],
'endtime' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
@ -70,14 +86,14 @@ return [
],
'fe_group' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.fe_group',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.fe_group',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'items' => [
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hide_at_login', '-1'],
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.any_login', '-2'],
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.usergroups', '--div--'],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hide_at_login', '-1'],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.any_login', '-2'],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.usergroups', '--div--'],
],
'foreign_table' => 'fe_groups',
'size' => 5,

View File

@ -0,0 +1,57 @@
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
return [
'ctrl' => [
'title' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_tokens',
'label' => 'token',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'default_sortby' => 'ORDER BY token',
'iconfile' => 'EXT:dlf/Resources/Public/Icons/txdlfsolrcores.png',
'rootLevel' => -1,
'searchFields' => 'token',
],
'feInterface' => [
'fe_admin_fieldList' => '',
],
'interface' => [
'showRecordFieldList' => 'token,options',
],
'columns' => [
'token' => [
'label' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_tokens.label',
'config' => [
'type' => 'input',
'size' => 30,
'max' => 255,
'eval' => 'required,trim',
'default' => '',
],
],
'options' => [
'label' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_tokens.index_name',
'config' => [
'type' => 'input',
'eval' => 'alphanum,nospace',
'default' => '',
],
],
],
'types' => [
'0' => ['showitem' => '--div--;LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_tokens.tab1,token,options'],
],
'palettes' => [
'1' => ['showitem' => ''],
],
];

View File

@ -0,0 +1,6 @@
plugin.tx_dlf {
persistence {
# cat=plugin.tx_dlf/100/a; type=int+; label=Default storage PID
storagePid =
}
}

View File

@ -1,82 +1,7 @@
# Model database table mapping
plugin.tx_dlf {
persistence {
#storagePid = {$plugin.tx_dlf.persistence.storagePid}
#storagePid = 2
classes {
Kitodo\Dlf\Domain\Model\ActionLog {
mapping {
tableName = tx_dlf_actionlog
recordType = \Kitodo\Dlf\Domain\Model\ActionLog
}
}
Kitodo\Dlf\Domain\Model\Basket {
mapping {
tableName = tx_dlf_basket
recordType = \Kitodo\Dlf\Domain\Model\Basket
}
}
Kitodo\Dlf\Domain\Model\Collection {
mapping {
tableName = tx_dlf_collections
recordType = \Kitodo\Dlf\Domain\Model\Collection
}
}
Kitodo\Dlf\Domain\Model\Document {
mapping {
tableName = tx_dlf_documents
recordType = \Kitodo\Dlf\Domain\Model\Document
}
}
Kitodo\Dlf\Domain\Model\Format {
mapping {
tableName = tx_dlf_formats
recordType = \Kitodo\Dlf\Domain\Model\Format
}
}
Kitodo\Dlf\Domain\Model\Library {
mapping {
tableName = tx_dlf_libraries
recordType = \Kitodo\Dlf\Domain\Model\Library
}
}
Kitodo\Dlf\Domain\Model\Mail {
mapping {
tableName = tx_dlf_mail
recordType = \Kitodo\Dlf\Domain\Model\Mail
}
}
Kitodo\Dlf\Domain\Model\Metadata {
mapping {
tableName = tx_dlf_metadata
recordType = \Kitodo\Dlf\Domain\Model\Metadata
}
}
Kitodo\Dlf\Domain\Model\MetadataFormat {
mapping {
tableName = tx_dlf_metadataformat
recordType = \Kitodo\Dlf\Domain\Model\MetadataFormat
}
}
Kitodo\Dlf\Domain\Model\Printer {
mapping {
tableName = tx_dlf_printer
recordType = \Kitodo\Dlf\Domain\Model\Printer
}
}
Kitodo\Dlf\Domain\Model\SolrCore {
mapping {
tableName = tx_dlf_solrcores
recordType = \Kitodo\Dlf\Domain\Model\SolrCore
}
}
Kitodo\Dlf\Domain\Model\Structure {
mapping {
tableName = tx_dlf_structures
recordType = \Kitodo\Dlf\Domain\Model\Structure
}
}
}
storagePid = {$plugin.tx_dlf.persistence.storagePid}
}
}

View File

@ -13,40 +13,40 @@
<div class="tx-dlf-collection">
<ul class="tx-dlf-collection-list">
<f:for each="{collections}" as="collection">
<f:for each="{collections}" as="item">
<li>
<h2>
<f:link.action action="main"
arguments="{collection : collection.uid}"
arguments="{collection : item.collection.uid}"
pageUid="{currentPageUid}">
{collection.label}
{item.collection.label}
</f:link.action>
<f:if condition="{settings.targetFeed}">
<span>
<f:link.page
pageUid="{settings.targetFeed}"
additionalParams="{'tx_dlf_feeds[collection]':collection.uid}"
additionalParams="{'tx_dlf_feeds[collection]': item.collection.uid}"
target="_blank">
<f:image src="EXT:dlf/Resources/Public/Icons/txdlffeeds.png"
title="{f:translate(key:'collection.feed.title')}"
alt="{f:translate(key:'collection.feed.alt')}" />
title="{f:translate(key:' item.collection.feed.title')}"
alt="{f:translate(key:' item.collection.feed.alt')}" />
</f:link.page>
</span>
</f:if>
</h2>
<div class="tx-dlf-collection-thumbnail">
<f:if condition="{collection.thumbnail}">
<f:image src="{collection.thumbnail}" alt="{f:translate(key: 'thumbnail')} {collection.label}" title="{collection.label}" maxWidth="250" />
<f:if condition="{item.collection.thumbnail}">
<f:image src="{item.collection.thumbnail}" alt="{f:translate(key: 'thumbnail')} {item.collection.label}" title="{item.collection.label}" maxWidth="250" />
</f:if>
</div>
<f:format.html>{collection.description}</f:format.html>
<f:format.html>{item.collection.description}</f:format.html>
<p class="tx-dlf-collection-counts">
({collection.countTitles}
<f:translate key="{f:if(condition:'{collection.countTitles} > 1', then: 'titles', else: 'title')}" />
({item.info.titles -> f:count()}
<f:translate key="{f:if(condition:'{item.info.titles -> f:count()} > 1', then: 'titles', else: 'title')}" />
/
{collection.countVolumes}
<f:translate key="{f:if(condition:'{collection.countTitles} > 1', then: 'volumes', else: 'volume')}" />)
{item.info.volumes -> f:count()}
<f:translate key="{f:if(condition:'{item.info.volumes -> f:count()} > 1', then: 'volumes', else: 'volume')}" />)
</p>
</li>
</f:for>

View File

@ -22,7 +22,7 @@
<author>{document.author}</author>
</f:if>
<pubDate><f:format.date format="r">{document.crdate}</f:format.date></pubDate>
<guid>{document.record_id}</guid>
<guid>{document.recordId}</guid>
</item>
</f:for>
</channel>

View File

@ -85,7 +85,7 @@
<ListSets>
<f:for each="{oaiSets}" as="set">
<set>
<setSpec>{set.oai_name}</setSpec>
<setSpec>{set.oaiName}</setSpec>
<setName>{set.label}</setName>
</set>
</f:for>

View File

@ -37,8 +37,7 @@
"typo3/cms-tstemplate": "^9.5",
"caseyamcl/phpoaipmh": "^3.0",
"ubl/php-iiif-prezi-reader": "0.3.0",
"solarium/solarium": "^4.2|^5.2",
"fluidtypo3/vhs": "6.0.5"
"solarium/solarium": "^4.2|^5.2"
},
"replace": {
"typo3-ter/dlf": "self.version"

View File

@ -18,8 +18,7 @@ $EM_CONF[$_EXTKEY] = [
'constraints' => [
'depends' => [
'php' => '7.3.0-7.4.99',
'typo3' => '9.5.0-9.5.99',
'vhs' => '6.0.5'
'typo3' => '9.5.0-9.5.99'
],
'conflicts' => [],
'suggests' => []

View File

@ -248,12 +248,14 @@ CREATE TABLE tx_dlf_libraries (
--
CREATE TABLE tx_dlf_tokens (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
token varchar(255) DEFAULT '' NOT NULL,
options mediumtext NOT NULL,
ident varchar(30) DEFAULT '' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid),
KEY token (token)
);

71
ext_typoscript_setup.txt Normal file
View File

@ -0,0 +1,71 @@
config.tx_extbase {
persistence {
classes {
Kitodo\Dlf\Domain\Model\ActionLog {
mapping {
tableName = tx_dlf_actionlog
}
}
Kitodo\Dlf\Domain\Model\Basket {
mapping {
tableName = tx_dlf_basket
}
}
Kitodo\Dlf\Domain\Model\Collection {
mapping {
tableName = tx_dlf_collections
}
}
Kitodo\Dlf\Domain\Model\Document {
mapping {
tableName = tx_dlf_documents
}
}
Kitodo\Dlf\Domain\Model\Format {
mapping {
tableName = tx_dlf_formats
}
}
Kitodo\Dlf\Domain\Model\Library {
mapping {
tableName = tx_dlf_libraries
}
}
Kitodo\Dlf\Domain\Model\Mail {
mapping {
tableName = tx_dlf_mail
}
}
Kitodo\Dlf\Domain\Model\Metadata {
mapping {
tableName = tx_dlf_metadata
}
}
Kitodo\Dlf\Domain\Model\MetadataFormat {
mapping {
tableName = tx_dlf_metadataformat
}
}
Kitodo\Dlf\Domain\Model\Printer {
mapping {
tableName = tx_dlf_printer
}
}
Kitodo\Dlf\Domain\Model\SolrCore {
mapping {
tableName = tx_dlf_solrcores
}
}
Kitodo\Dlf\Domain\Model\Structure {
mapping {
tableName = tx_dlf_structures
}
}
Kitodo\Dlf\Domain\Model\Token {
mapping {
tableName = tx_dlf_tokens
}
}
}
}
}