This repository has been archived by the owner on Jun 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ext_localconf.php
140 lines (105 loc) · 5.29 KB
/
ext_localconf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
if (!defined ("TYPO3_MODE")) die ("Access denied.");
// Determine, which x-class for t3lib_DB should be used for this T3 version.
$xClassFromEmSettings = __getXClassFromEmSettings();
if ($xClassFromEmSettings && __isT3LibDbXClassingActivated()) {
$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_db.php'] = $xClassFromEmSettings;
} else {
__includeXClassForCurrentT3Version();
}
// Hook to be called BEFORE TYPO3 starts site rendering (first possible hook to take)
if (!is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] = array();
}
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'][] = 'EXT:sandstormmedia_plumber/Classes/Hooks/Hook.php:Tx_SandstormmediaPlumber_Hooks_Hook->preprocessRequest';
// Hooks for the t3lib_db calls (check whether x-classing is activated)
if (__isT3LibDbXClassingActivated()) {
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_db.php']['queryProcessors'])) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_db.php']['queryProcessors'] = array();
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_db.php']['queryProcessors'][] = 'EXT:sandstormmedia_plumber/Classes/Hooks/Hook.php:Tx_SandstormmediaPlumber_Hooks_Hook';
}
// Hook to be called AFTER TYPO3 finished site rendering (last possible hook to take)
if (!is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'])) {
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'] = array();
}
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'][] = 'EXT:sandstormmedia_plumber/Classes/Hooks/Hook.php:Tx_SandstormmediaPlumber_Hooks_Hook->endOfRequest';
/**************************************************************************************************************
*
* Helper methods
*
**************************************************************************************************************/
/**
* Returns the current T3 version, as we have to include different xclasses depending on version
* $t3version is a three part version number, eg '4.12.3' -> 4012003
*
* @return int
* @throws Exception if TYPO3 version is below 4.5 (we do not support version prior to 4.5)
*/
function __getT3Version() {
if (function_exists('t3lib_utility_VersionNumber::convertVersionNumberToInteger')) {
$t3version = t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version);
} else {
$t3version = t3lib_div::int_from_ver(TYPO3_version);
}
if ($t3version < 4005000) { // We do not support T3 version < 4.5
throw new Exception('This extension can not be used with a version prior to 4.5 of TYPO3!', 1364212859);
}
return $t3version;
}
/**
* Returns xclass given in EM configuration of this extension
*
* @return null|string
*/
function __getXClassFromEmSettings() {
$plumberEmSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sandstormmedia_plumber']);
if (!empty($plumberEmSettings['t3libDbXclass'])) {
list($extension, $fileName) = explode('::', $plumberEmSettings['t3libDbXclass']);
if (!empty($extension) && !empty($fileName)) {
return t3lib_extMgm::extPath($extension) . $fileName;
}
}
// No xclass configured --> NULL
return NULL;
}
/**
* Returns TRUE, if x-classing for t3lib_DB is activated
*
* @return bool
*/
function __isT3LibDbXClassingActivated() {
$plumberEmSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sandstormmedia_plumber']);
if (!empty($plumberEmSettings['t3libDbXclassingActivated'])) {
if ($plumberEmSettings['t3libDbXclassingActivated']) {
return TRUE;
}
}
return FALSE;
}
/**
* Includes proper xclass for extending t3lib_DB
*/
function __includeXClassForCurrentT3Version() {
$t3version = __getT3Version();
if ($t3version < 4006000) { // Version < 4.6
$xclass = t3lib_extMgm::extPath('sandstormmedia_plumber') . 'Classes/Xclass/ux_t3lib_DB_4.5.php';
// Inclusion of required interfaces (those are not available in v 4.5)
require_once( t3lib_extMgm::extPath('sandstormmedia_plumber') . 'Classes/Hooks/v4.5Compatibility/interface.t3lib_db_postprocessqueryhook.php');
require_once( t3lib_extMgm::extPath('sandstormmedia_plumber') . 'Classes/Hooks/v4.5Compatibility/interface.t3lib_db_preprocessqueryhook.php');
} elseif ($t3version < 4007000) { // Version < 4.7
$xclass = t3lib_extMgm::extPath('sandstormmedia_plumber') . 'Classes/Xclass/ux_t3lib_DB_4.6.php';
// Inclusion of required interfaces (we probably have no auto-loading)
require_once(PATH_site . 't3lib/interfaces/interface.t3lib_db_postprocessqueryhook.php');
require_once(PATH_site . 't3lib/interfaces/interface.t3lib_db_preprocessqueryhook.php');
} else { // Version >= 4.7
$xclass = t3lib_extMgm::extPath('sandstormmedia_plumber') . 'Classes/Xclass/ux_t3lib_DB_4.7.php';
// Inclusion of required interfaces (we probably have no auto-loading)
require_once(PATH_site . 't3lib/interfaces/interface.t3lib_db_postprocessqueryhook.php');
require_once(PATH_site . 't3lib/interfaces/interface.t3lib_db_preprocessqueryhook.php');
}
// Check whether x-classing is activated
if (__isT3LibDbXClassingActivated()) {
$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_db.php'] = $xclass;
}
}