Commit ef535ece authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen Committed by Thomas Löffler

[WIP] [TASK] Add solr index for ext:ter

parent d1e7b1e7
......@@ -18,7 +18,8 @@ return [
'rsaauth' => 'a:1:{s:18:"temporaryDirectory";s:0:"";}',
'saltedpasswords' => 'a:2:{s:3:"BE.";a:4:{s:21:"saltedPWHashingMethod";s:41:"TYPO3\\CMS\\Saltedpasswords\\Salt\\PhpassSalt";s:11:"forceSalted";i:0;s:15:"onlyAuthService";i:0;s:12:"updatePasswd";i:1;}s:3:"FE.";a:5:{s:7:"enabled";i:1;s:21:"saltedPWHashingMethod";s:41:"TYPO3\\CMS\\Saltedpasswords\\Salt\\PhpassSalt";s:11:"forceSalted";i:0;s:15:"onlyAuthService";i:0;s:12:"updatePasswd";i:1;}}',
'ter' => 'a:1:{s:13:"repositoryDir";s:27:"/var/www/html/fileadmin/ter";}',
'ter_fe2' => 'a:0:{}'
'ter_fe2' => 'a:0:{}',
'ter_layout' => 'a:0:{}',
],
],
'FE' => [
......@@ -43,7 +44,6 @@ return [
'TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate' => 1,
'TYPO3\CMS\Install\Updates\Compatibility6ExtractionUpdate' => 1,
'TYPO3\CMS\Install\Updates\ContentTypesToTextMediaUpdate' => 1,
'TYPO3\CMS\Install\Updates\ExtensionManagerTables' => 1,
'TYPO3\CMS\Install\Updates\FileListIsStartModuleUpdate' => 1,
'TYPO3\CMS\Install\Updates\FilesReplacePermissionUpdate' => 1,
'TYPO3\CMS\Install\Updates\LanguageIsoCodeUpdate' => 1,
......
<?php
/***************************************************************
* Copyright notice
*
* (c) 2017 Sascha Egerer <sascha@sascha-egerer.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
class Tx_TerFe2_Solr_Indexqueue_TerIndexer extends tx_solr_indexqueue_Indexer {
/**
* @var Tx_Extbase_Object_ObjectManager
*/
protected $objectManager;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
public function __construct(array $options = array()) {
parent::__construct($options);
$this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->extensionRepository->setShowInsecure(FALSE);
}
/**
* @param tx_solr_indexqueue_Item $item
* @param int $language
* @return array
*/
public function getFullItemRecord(tx_solr_indexqueue_Item $item, $language = 0) {
$itemRecord = parent::getFullItemRecord($item, $language);
$itemRecord['minimumTYPO3Version'] = 0;
$itemRecord['maximumTYPO3Version'] = 0;
// get the uid of the extkey information of the extension
$extensionUid = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
'uid',
'tx_terfe2_domain_model_extension',
'ext_key = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($itemRecord['ext_key'], 'tx_terfe2_domain_model_extension')
);
if (isset($extensionUid['uid'])) {
/**
* @var $extension Tx_TerFe2_Domain_Model_Extension
*/
$extension = $this->extensionRepository->findByUid($extensionUid['uid']);
if ($extension instanceof Tx_TerFe2_Domain_Model_Extension) {
$itemRecord['extensionIcon'] = $this->getExtensionIcon(
$itemRecord['ext_key'],
$extension->getLastVersion()->getVersionString()
);
$typo3Dependency = $this->getDependencyVersionForPackage($extension, 'typo3');
$itemRecord['minimumTYPO3Version'] = $typo3Dependency['minimum'];
$itemRecord['maximumTYPO3Version'] = $typo3Dependency['maximum'];
$itemRecord['outdated'] = $extension->getLastVersion()->getReviewState() === -2;
}
}
return $itemRecord;
}
/**
* get the minimum dependency of an extension for a given $relationName (extension, php version, TYPO3 version...)
*
* @param Tx_TerFe2_Domain_Model_Extension $extension
* @param string $relationName The dependency to get the version from (e.g. "typo3" to get the minimum typo3 version)
* @return string
*/
protected function getDependencyVersionForPackage(Tx_TerFe2_Domain_Model_Extension $extension, $relationName) {
$versions = array(
'minimum' => 0,
'maximum' => 0
);
foreach ($extension->getLastVersion()->getSoftwareRelations() as $relation) {
if ($relation->getRelationType() === 'depends' && $relation->getRelationKey() === $relationName) {
$versions = array(
'minimum' => $relation->getMinimumVersion(),
'maximum' => $relation->getMaximumVersion()
);
break;
}
}
return $versions;
}
/**
* get the relative path for the extension icon
* could be png or gif
*
* @param $extensionKey
* @param $extensionVersion
* @return string
*/
protected function getExtensionIcon($extensionKey, $extensionVersion) {
// check if there is a gif or a png icon or if there is no icon
$iconFilePng = $this->generateIconFileName(
$extensionKey,
$extensionVersion,
'png'
);
$iconFileGif = $this->generateIconFileName(
$extensionKey,
$extensionVersion,
'gif'
);
$iconPath = 'fileadmin/ter/';
$icon = '';
if (file_exists(PATH_site.$iconPath.$iconFilePng)) {
$icon = Tx_TerFe2_Utility_File::getRelativeUrlFromAbsolutePath($iconPath.$iconFilePng);
} elseif(file_exists(PATH_site.$iconPath.$iconFileGif)) {
$icon = Tx_TerFe2_Utility_File::getRelativeUrlFromAbsolutePath($iconPath.$iconFileGif);
}
return $icon;
}
/**
* generate the path to an extension icon for a specific version
*
* @param $extension
* @param $version
* @param $fileType
* @return string
*/
protected function generateIconFileName($extension, $version, $fileType) {
if (empty($extension) || empty($version) || empty($fileType)) {
return '';
}
$extension = strtolower($extension);
$fileType = strtolower(trim($fileType, '. '));
return $extension[0] . '/' . $extension[1] . '/' . $extension . '_' . $version . '.' . $fileType;
}
}
\ No newline at end of file
......@@ -9,5 +9,211 @@ plugin {
templateFiles {
search = EXT:ter_layout/Resources/Private/Ext/Solr/Search.html
}
index {
queue {
ter_extension = 1
ter_extension.table = tx_terfe2_domain_model_extension
ter_extension.additionalWhereClause = last_version > 0
ter_extension.indexer = Tx_TerFe2_Solr_Indexqueue_TerIndexer
ter_extension.fields {
setRegister_ignored = LOAD_REGISTER
setRegister_ignored {
extensionVersion.cObject = SOLR_RELATION
extensionVersion.cObject {
localField = last_version
foreignLabelField = version_string
}
extensionKey.cObject = TEXT
extensionKey.cObject.field = ext_key
extensionState.cObject = SOLR_RELATION
extensionState.cObject {
localField = last_version
foreignLabelField = state
}
}
author = SOLR_CONTENT
author {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = author
}
}
author_textWstS = SOLR_CONTENT
author_textWstS {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = author
}
}
title = SOLR_CONTENT
title {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = title
}
}
sortTitle_stringS = SOLR_CONTENT
sortTitle_stringS {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = title
}
}
content = SOLR_CONTENT
content {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = description
}
}
url = TEXT
url {
typolink.parameter = {$plugin.tx_solr.ter_detailpage}
typolink.additionalParams = &tx_terfe2_pi1[controller]=Extension&tx_terfe2_pi1[action]=show&tx_terfe2_pi1[extension]={field:uid}
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
}
extensionKey_textS = ext_key
extensionKey_stringS = ext_key
extensionVersion_stringS = TEXT
extensionVersion_stringS {
value = {register:extensionVersion}
insertData = 1
}
extensionState_stringS = TEXT
extensionState_stringS {
value = n/a
override {
data = register:extensionState
if {
isInList.data = register:extensionState
value = alpha,beta,stable,test,experimental,obsolete
}
}
}
extensionLastUpload_dateS = TEXT
extensionLastUpload_dateS {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = upload_date
}
date = Y-m-d\TH:i:s\Z
}
extensionLastUpload_intS = SOLR_RELATION
extensionLastUpload_intS {
localField = last_version
foreignLabelField = upload_date
}
extensionLastUpload_tDateS = TEXT
extensionLastUpload_tDateS {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = upload_date
}
date = Y-m-d\TH:i:s\Z
}
extensionDownloads_intS = downloads
# extensionIcon is filled by the ter indexer Tx_TerFe2_Solr_Indexqueue_TerIndexer
extensionIcon_stringS = TEXT
extensionIcon_stringS.field = extensionIcon
# minimumTYPO3Version and maximumTYPO3Version is filled by the ter indexer Tx_TerFe2_Solr_Indexqueue_TerIndexer
extensionMinTYPO3Version_sIntS = minimumTYPO3Version
extensionMaxTYPO3Version_sIntS = maximumTYPO3Version
extensionHasZipFile_intS = SOLR_RELATION
extensionHasZipFile_intS {
localField = last_version
foreignLabelField = has_zip_file
}
extensionManual_intS = SOLR_RELATION
extensionManual_intS {
localField = last_version
foreignLabelField = has_manual
}
extensionDownloadT3xUrl_stringS = TEXT
extensionDownloadT3xUrl_stringS {
typolink.parameter = {$plugin.tx_solr.ter_detailpage}
typolink.additionalParams = &tx_terfe2_pi1[controller]=Extension&tx_terfe2_pi1[action]=download&tx_terfe2_pi1[extension]={field:uid}&tx_terfe2_pi1[versionString]={register:extensionVersion}&tx_terfe2_pi1[format]=t3x
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
}
extensionDownloadZipUrl_stringS = TEXT
extensionDownloadZipUrl_stringS {
typolink.parameter = {$plugin.tx_solr.ter_detailpage}
typolink.additionalParams = &tx_terfe2_pi1[controller]=Extension&tx_terfe2_pi1[action]=download&tx_terfe2_pi1[extension]={field:uid}&tx_terfe2_pi1[versionString]={register:extensionVersion}&tx_terfe2_pi1[format]=zip
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
}
extensionDocumentationLink_stringS = USER
extensionDocumentationLink_stringS {
includeLibs = EXT:t3org_base/userfunc/ter_generate_extension_doc_link.php
userFunc = user_generateExtensionDocumentationLink
# ToDo remove this parameter
urlPrefix = TEXT
urlPrefix.value =
extensionKey = TEXT
extensionKey.data = register:extensionKey
extensionVersion = TEXT
extensionVersion.data = register:extensionVersion
}
extensionReviewState_intS = SOLR_RELATION
extensionReviewState_intS {
localField = last_version
foreignLabelField = review_state
}
extensionCategory_stringS = SOLR_CONTENT
extensionCategory_stringS {
cObject = SOLR_RELATION
cObject {
localField = last_version
foreignLabelField = em_category
}
}
siteName_stringS = TEXT
siteName_stringS.value = t3o
}
}
}
}
}
\ No newline at end of file
# Detail page for TER
plugin.tx_solr.ter_detailpage = 3
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment