Skip to content

Commit

Permalink
- task: raise minimun requirement to TYPO3 version 6.2
Browse files Browse the repository at this point in the history
- task: remove all checks for TYPO3 version.
  • Loading branch information
Christian Bülter committed Sep 24, 2015
1 parent f9e72d0 commit 7df0a40
Show file tree
Hide file tree
Showing 53 changed files with 393 additions and 1,631 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Version 2.0.0
IMPORTANT: This version has breaking changes: Marker based templatating has been removed completely, support for TYPO 4.5 has been dropped!
- feature: add fluid based templating.
- task: remove "wrap" option for filter rendering, this can be done in the fluid template.
- task: raise minimun requirement to TYPO3 version 6.2
- task: remove all checks for TYPO3 version.

Version 1.10.2
- bugfix: add langDisable in flexform, https://forge.typo3.org/issues/64579
Expand Down
26 changes: 3 additions & 23 deletions Classes/Backend/class.tx_kesearch_classes_flexform.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@ class tx_kesearch_classes_flexform {
var $lang;

public function init() {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$this->lang = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
} else if (TYPO3_VERSION_INTEGER >= 6002000) {
$this->lang = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('language');
} else {
$this->lang = t3lib_div::makeInstance('language');
}

if (TYPO3_VERSION_INTEGER < 6001000) {
t3lib_div::loadTCA('tx_kesearch_index');
}
$this->lang = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
}

function listAvailableOrderingsForFrontend(&$config) {
Expand All @@ -30,12 +20,7 @@ function listAvailableOrderingsForFrontend(&$config) {
$res = $GLOBALS['TYPO3_DB']->sql_query('SHOW COLUMNS FROM tx_kesearch_index');
while($col = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {

if (TYPO3_VERSION_INTEGER >= 7000000) {
$isInList = TYPO3\CMS\Core\Utility\GeneralUtility::inList($notAllowedFields, $col['Field']);
} else {
$isInList = t3lib_div::inList($notAllowedFields, $col['Field']);
}

$isInList = TYPO3\CMS\Core\Utility\GeneralUtility::inList($notAllowedFields, $col['Field']);
if(!$isInList) {
$file = $GLOBALS['TCA']['tx_kesearch_index']['columns'][$col['Field']]['label'];
$fieldLabel = $this->lang->sL($file);
Expand All @@ -58,12 +43,7 @@ function listAvailableOrderingsForAdmin(&$config) {
$res = $GLOBALS['TYPO3_DB']->sql_query('SHOW COLUMNS FROM tx_kesearch_index');
while($col = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {

if (TYPO3_VERSION_INTEGER >= 7000000) {
$isInList = TYPO3\CMS\Core\Utility\GeneralUtility::inList($notAllowedFields, $col['Field']);
} else {
$isInList = t3lib_div::inList($notAllowedFields, $col['Field']);
}

$isInList = TYPO3\CMS\Core\Utility\GeneralUtility::inList($notAllowedFields, $col['Field']);
if(!$isInList) {
$file = $GLOBALS['TCA']['tx_kesearch_index']['columns'][$col['Field']]['label'];
$fieldLabel = $this->lang->sL($file);
Expand Down
53 changes: 11 additions & 42 deletions Classes/Backend/class.user_filterlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@ function getListOfAvailableFiltersForFlexforms(&$config) {
$fields = '*';
$table = 'tx_kesearch_filters';
$where = 'pid IN('.$intString.') ';
if (TYPO3_VERSION_INTEGER > 7000000) {
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);
} else {
$where .= t3lib_befunc::BEenableFields($table,$inv=0);
$where .= t3lib_befunc::deleteClause($table,$inv=0);
}
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields,$table,$where,$groupBy='',$orderBy='',$limit='');
$anz = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
while ($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
Expand All @@ -76,11 +71,7 @@ function getListOfAvailableFiltersForTCA(&$config) {
}

// get the page TSconfig
if (TYPO3_VERSION_INTEGER > 7000000) {
$this->pageTSconfig=\TYPO3\CMS\Backend\Utility\BackendUtility::GetPagesTSconfig($currentPid);
} else {
$this->pageTSconfig=t3lib_BEfunc::GetPagesTSconfig($currentPid);
}
$this->pageTSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::GetPagesTSconfig($currentPid);
$this->modTSconfig=$this->pageTSconfig['ke_search.'];

// get filters
Expand All @@ -96,13 +87,8 @@ function getListOfAvailableFiltersForTCA(&$config) {
$where = '1=1 ';
}

if (TYPO3_VERSION_INTEGER > 7000000) {
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);
} else {
$where .= t3lib_befunc::BEenableFields($table,$inv=0);
$where .= t3lib_befunc::deleteClause($table,$inv=0);
}
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields,$table,$where,$groupBy='',$orderBy='',$limit='');
$anz = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
Expand All @@ -112,13 +98,8 @@ function getListOfAvailableFiltersForTCA(&$config) {
$fields2 = '*';
$table2 = 'tx_kesearch_filteroptions';
$where2 = 'uid in ('.$row['options'].')';
if (TYPO3_VERSION_INTEGER > 7000000) {
$where2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table2);
$where2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table2);
} else {
$where2 .= t3lib_befunc::BEenableFields($table2);
$where2 .= t3lib_befunc::deleteClause($table2);
}
$where2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table2);
$where2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table2);

$res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields2,$table2,$where2);
while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
Expand Down Expand Up @@ -148,14 +129,8 @@ function getListOfAvailableFilteroptionsForFlexforms(&$config) {
$fields = '*';
$table = 'tx_kesearch_filters';
$where = 'pid IN('.$intString.') ';

if (TYPO3_VERSION_INTEGER > 7000000) {
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);
} else {
$where .= t3lib_befunc::BEenableFields($table,$inv=0);
$where .= t3lib_befunc::deleteClause($table,$inv=0);
}
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table,$inv=0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table,$inv=0);

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields,$table,$where,$groupBy='',$orderBy='',$limit='');
while ($rowFilter=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
Expand All @@ -165,14 +140,8 @@ function getListOfAvailableFilteroptionsForFlexforms(&$config) {
$fieldsOpts = '*';
$tableOpts = 'tx_kesearch_filteroptions';
$whereOpts = 'uid in ('.$rowFilter['options'].')';

if (TYPO3_VERSION_INTEGER > 7000000) {
$whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableOpts,$inv=0);
$whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableOpts,$inv=0);
} else {
$whereOpts .= t3lib_befunc::BEenableFields($tableOpts,$inv=0);
$whereOpts .= t3lib_befunc::deleteClause($tableOpts,$inv=0);
}
$whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableOpts,$inv=0);
$whereOpts .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableOpts,$inv=0);

$resOpts = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fieldsOpts,$tableOpts,$whereOpts,$groupBy='',$orderBy='',$limit='');
while ($rowOpts=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($resOpts)) {
Expand Down
25 changes: 6 additions & 19 deletions Classes/Scheduler/class.tx_kesearch_indexertask.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,26 @@



// include indexer class and create a "baseclass" (only for backwards compatibility)
if (TYPO3_VERSION_INTEGER >= 6002000) {
require_once(TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ke_search') . 'Classes/indexer/class.tx_kesearch_indexer.php');
abstract class tx_kesearch_indexertask_baseclass extends \TYPO3\CMS\Scheduler\Task\AbstractTask { }
} else {
require_once(t3lib_extMgm::extPath('ke_search') . 'Classes/indexer/class.tx_kesearch_indexer.php');
abstract class tx_kesearch_indexertask_baseclass extends tx_scheduler_Task { }
}
// include indexer class
require_once(TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ke_search') . 'Classes/indexer/class.tx_kesearch_indexer.php');

class tx_kesearch_indexertask extends tx_kesearch_indexertask_baseclass {
class tx_kesearch_indexertask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {

public function execute() {

// get extension configuration
$this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ke_search']);

// make indexer instance
if (TYPO3_VERSION_INTEGER >= 6002000) {
$indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_indexer');
} else {
$indexer = t3lib_div::makeInstance('tx_kesearch_indexer');
}
$indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_indexer');

// process
$response = $indexer->startIndexing(true, $this->extConf, 'CLI');
$indexer->startIndexing(true, $this->extConf, 'CLI');

return true;

}

}

if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/ke_search/Classes/Scheduler/class.tx_kesearch_indexertask.php']) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/ke_search/Classes/Scheduler/class.tx_kesearch_indexertask.php']);
}
?>
}
96 changes: 18 additions & 78 deletions Classes/indexer/class.tx_kesearch_indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,9 @@ public function __construct() {
// get extension configuration array
$this->extConf = tx_kesearch_helper::getExtConf();
$this->extConfPremium = tx_kesearch_helper::getExtConfPremium();

if (TYPO3_VERSION_INTEGER >= 7000000) {
$this->registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
} else if (TYPO3_VERSION_INTEGER >= 6002000) {
$this->registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_Registry');
} else {
$this->registry = t3lib_div::makeInstance('t3lib_Registry');
}
$this->registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');

// fetch the list of the default indexers which come with ke_search
// load TCA definition first (only necessary in TYPO3 below 6.1)
if (TYPO3_VERSION_INTEGER < 6001000) {
t3lib_div::loadTCA('tx_kesearch_indexerconfig');
}
foreach ($GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['type']['config']['items'] as $indexerType) {
$this->defaultIndexerTypes[] = $indexerType[1];
}
Expand Down Expand Up @@ -127,11 +116,7 @@ function startIndexing($verbose=true, $extConf, $mode='') {
// register additional fields which should be written to DB
if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerAdditionalFields'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerAdditionalFields'] as $_classRef) {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
} else {
$_procObj = & t3lib_div::getUserObj($_classRef);
}
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
$_procObj->registerAdditionalFields($this->additionalFields);
}
}
Expand All @@ -144,18 +129,10 @@ function startIndexing($verbose=true, $extConf, $mode='') {

// run default indexers shipped with ke_search
if (in_array($this->indexerConfig['type'], $this->defaultIndexerTypes)) {
if (TYPO3_VERSION_INTEGER < 6002000) {
$path = t3lib_extMgm::extPath('ke_search') . 'Classes/indexer/types/class.tx_kesearch_indexer_types_' . $this->indexerConfig['type'] . '.php';
} else {
$path = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ke_search') . 'Classes/indexer/types/class.tx_kesearch_indexer_types_' . $this->indexerConfig['type'] . '.php';
}
$path = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('ke_search') . 'Classes/indexer/types/class.tx_kesearch_indexer_types_' . $this->indexerConfig['type'] . '.php';
if(is_file($path)) {
require_once($path);
if (TYPO3_VERSION_INTEGER >= 6002000) {
$searchObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_indexer_types_' . $this->indexerConfig['type'], $this);
} else {
$searchObj = t3lib_div::makeInstance('tx_kesearch_indexer_types_' . $this->indexerConfig['type'], $this);
}
$searchObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_indexer_types_' . $this->indexerConfig['type'], $this);
$content .= $searchObj->startIndexing();
} else {
$content = '<div class="error"> Could not find file ' . $path . '</div>' . "\n";
Expand All @@ -165,11 +142,7 @@ function startIndexing($verbose=true, $extConf, $mode='') {
// hook for custom indexer
if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customIndexer'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customIndexer'] as $_classRef) {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
} else {
$_procObj = & t3lib_div::getUserObj($_classRef);
}
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
$content .= $_procObj->customIndexer($indexerConfig, $this);
}
}
Expand Down Expand Up @@ -202,31 +175,16 @@ function startIndexing($verbose=true, $extConf, $mode='') {
// send notification in CLI mode
if ($mode == 'CLI') {
// send finishNotification
if (TYPO3_VERSION_INTEGER >= 7000000) {
$isValidEmail = TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($extConf['notificationRecipient']);
} else {
$isValidEmail = t3lib_div::validEmail($extConf['notificationRecipient']);
}
$isValidEmail = TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($extConf['notificationRecipient']);
if ($extConf['finishNotification'] && $isValidEmail) {

// send the notification message
// use swiftmailer in 4.5 and above
if (TYPO3_VERSION_INTEGER >= 4005000) {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
} else if (TYPO3_VERSION_INTEGER >= 6002000) {
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_mail_Message');
} else {
$mail = t3lib_div::makeInstance('t3lib_mail_Message');
}
$mail->setFrom(array($extConf['notificationSender']));
$mail->setTo(array($extConf['notificationRecipient']));
$mail->setSubject($extConf['notificationSubject']);
$mail->setBody($plaintextReport);
$mail->send();
} else {
mail($extConf['notificationRecipient'], $subject, $plaintextReport);
}
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom(array($extConf['notificationSender']));
$mail->setTo(array($extConf['notificationRecipient']));
$mail->setSubject($extConf['notificationSubject']);
$mail->setBody($plaintextReport);
$mail->send();
}
}

Expand Down Expand Up @@ -361,11 +319,7 @@ function cleanUpIndex() {
// hook for cleanup
if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['cleanup'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['cleanup'] as $_classRef) {
if (TYPO3_VERSION_INTEGER >= 7000000) {
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
} else {
$_procObj = & t3lib_div::getUserObj($_classRef);
}
$_procObj = & TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
$content .= $_procObj->cleanup($where, $this);
}
}
Expand Down Expand Up @@ -455,11 +409,7 @@ function storeInIndex($storagePid, $title, $type, $targetPid, $content, $tags=''
} else {
$tags = $tagChar . $indexerTag . $tagChar;
}
if (TYPO3_VERSION_INTEGER >= 7000000) {
$tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags);
} else {
$tags = t3lib_div::uniqueList($tags);
}
$tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags);
}

$table = 'tx_kesearch_index';
Expand Down Expand Up @@ -786,13 +736,8 @@ public function getTag($tagUid, $clearText=false) {
$fields = 'title, tag';
$table = 'tx_kesearch_filteroptions';
$where = 'uid = "' . intval($tagUid) . '" ';
if (TYPO3_VERSION_INTEGER >= 7000000) {
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table, 0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table, 0);
} else {
$where .= t3lib_befunc::BEenableFields($table, 0);
$where .= t3lib_befunc::deleteClause($table, 0);
}
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table, 0);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table, 0);

$row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
$fields,
Expand Down Expand Up @@ -829,13 +774,8 @@ public function getConfigurations() {
$fields = '*';
$table = 'tx_kesearch_indexerconfig';
$where = '1=1 ';
if (TYPO3_VERSION_INTEGER >= 7000000) {
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
} else {
$where .= t3lib_befunc::BEenableFields($table);
$where .= t3lib_befunc::deleteClause($table);
}
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
$where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where);
}
}
Expand Down
Loading

0 comments on commit 7df0a40

Please sign in to comment.