-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
executable file
·334 lines (285 loc) · 13.7 KB
/
README.txt
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
This extension can be thought of as a central library for extbase extenions and provides the following:
-------------------------------------------------------------------------------------------------------
Alternative API-Classes:
------------------------
Tx_CabagExtbase_Persistence_Repository
Make your repositories extend from this class to add setQuerySettings() and getQuerySettings() functions.
Using setQuerySettings() you can set the query settings on a per repository basis.
!! This may slow down your queries because for each new query the caller object has to be retrieved !!
Tx_CabagExtbase_MVC_Controller_ActionController
Use this ActionController which enables mapping from different get/post vars to each other
Typoscript Example:
settings {
GPMapping {
mainSearchWord {
from = tx_idcsupport_supportsearchmain|sword
to = tx_idcsupport_supportsearch|sword
}
searchWord {
from = tx_idcsupport_supportsearch|sword
to = tx_idcsupport_supportsearchmain|sword
}
}
}
Tx_CabagExtBase_Persistence_Storage_CabagTypo3DbBackend
This Db Backend allows you to sort over multiples fields when using concat. The syntax has to be like "concat(field1,field2,field3) as fieldxy. To use this, modify config.extbase like this:
config.tx_extbase {
objects {
Tx_Extbase_Persistence_Storage_BackendInterface {
className = Tx_CabagExtbase_Persistence_Storage_CabagTypo3DbBackend
}
}
}
Tx_CabagExtbase_Controller_BaseController
This alternative to Tx_Extbase_MVC_Controller_ActionController adds some extra functions to a controller.
Currently these are:
->translate($key, $arguments = null)
Automatically adds the extension key to the localization request.
->ensureLogin($loginPage, $logout = false)
Makes sure that the user is logged in, if $logout is set, the user will be logged out first.
->callActionMethod()
Allows an alternate action to be called when an exception is thrown inside the action.
The action is defined by the typoscript key plugin.tx_myext.settings.exceptionAction.
This action must return any content to be displayed directly.
By default this feature is off.
- plugin.tx_myext.settings.exceptionAction = 1
-> errorAction() is called
- plugin.tx_myext.settings.exceptionAction = error
-> errorAction() is called
- plugin.tx_myext.settings.exceptionAction = errorAction
-> errorAction() is called
- plugin.tx_myext.settings.exceptionAction = myFancyErrorHandler
-> myFancyErrorHandlerAction() is called
Also allows to add the exceptions the flash messages.
- plugin.tx_myext.settings.addExceptionToFlashMessage
-> adds the Exception message as a flash message.
- plugin.tx_myext.settings.addStackTraceToFlashMessage
-> adds the stack trace as a flash message (only thought to be used during development).
When an exception is caught this way, it will be written into $this->lastException.
Extbase domain model and repository:
------------------------------------
- static_country table
- Tx_CabagExtbase_Domain_Model_StaticCountry
- Tx_CabagExtbase_Domain_Repository_StaticCountryRepository
!! You must include the extension TypoScript in order for this to work !!
ViewHelpers:
------------
- Tx_CabagExtbase_ViewHelpers_CdataViewHelper
Renders a <![CDATA[...]]> around the content, as cdata tags are removed by the fluid engine.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:cdata>This will be a HTML-comment and wrapped with a CDATA tag.</c:cdata>
- Tx_CabagExtbase_ViewHelpers_RawViewHelper
Renders the content of the 'raw' attribute without letting fluid apply htmlspecialchars.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:raw raw="{someVariableThatContainsHTMLTags}" />
{c:raw(raw: someVariableThatContainsHTMLTags)}
- Tx_CabagExtbase_ViewHelpers_IfErrorViewHelper
Renders the content if a form error occurred for the given property.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:ifError for="myObject.myProperty">
<div class="errorMessage">This is an error message!</div>
</c:ifError>
- Tx_CabagExtbase_ViewHelpers_JsonViewHelper
Renders the content into a json array.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:json value="{some: 'array'}" />
- Tx_CabagExtbase_ViewHelpers_IfContainsViewHelper
Renders content if value (or one value in array) is found in another value (string,array,object)
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:ifContains value="objectOrArrayOrString" in="objectOrArrayOrString">
<div class="doSomething">Do something if found.</div>
</c:ifContains>
- Tx_CabagExtbase_ViewHelpers_StrftimeViewHelper
Renders a DateTime object (or constructor) using strftime formatting.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:strftime date="@1234567890" format="%d.%m.%Y" />
- Tx_CabagExtbase_ViewHelpers_ObjectAccessorViewHelper
Allows to execute a string path on a given object.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:objectAccessor subject="{someModelObject}" path="field.subfield.someTextField" />
c:objectAccessor(subject: someModelObject, path: 'field.subfield.someTextField')
-> this returns the same as {someModelObject.field.subfield.someTextField}, but the path can be retrieved from a dynamic variable
- Tx_CabagExtbase_ViewHelpers_Date2CalViewHelper
Renders a date2cal javascript date picker.
<c:date2Cal id="wishedEndDateTime" prefix="tx_jamesservices" name="tx_jamesservices_pi1[newOrder][singleorders][{service.uid}][wishedEndDateTime]" />
- Tx_CabagExtbase_ViewHelpers_ImplodeViewHelper
Implodes a given array.
<c:implode value="{0: 'some', 1: 'text'}" glue=", " /> -> some, text
<c:implode value="{0: 'b', 1: 'c', 2: 'a'}" glue="|" sort="1" /> -> a|b|c
<c:implode value="{3: 'b', 1: 'c', 0: 'a'}" glue=":" sort="numeric" reverse="1" sortByKeys="1" /> -> b:c:a
- Tx_CabagExtbase_ViewHelpers_PregReplaceViewHelper
Replaces text in the content with a regex.
<c:pregReplace from="/<[^>]*>([^<]*)<\/[^>]>/" to="$1">...</c:pregReplace>
- Tx_CabagExtbase_ViewHelpers_EscapeViewHelper
Allows certain html entities to pass through. To use it instead of the default escape viewhelper from the intercepter (for text nodes for example), add the following to the typoscript:
config.tx_extbase {
objects {
Tx_Fluid_ViewHelpers_EscapeViewHelper {
className = Tx_CabagExtbase_ViewHelpers_EscapeViewHelper
}
}
}
- Tx_CabagExtbase_ViewHelpers_FormViewHelper
Adds several options to the default form viewhelper
<c:form method="GET"... dontRenderHmac="1" dontRenderReferrer="1" dontRenderTrusted="1" ...></c:form>
<c:form method="POST"... renderArgumentsAsHidden="1"...></c:form>
- dontRenderReferrer: If set supresses rendering of the referrer information
- dontRenderHmac: If set supresses rendering of the hmac information
- dontRenderTrusted: If set supresses rendering of the __trustedProperties information
- renderArgumentsAsHidden takes the GET parameters of the action and renders them as hidden fields at the top of the form
- Tx_CabagExtbase_ViewHelpers_DebugViewHelper
Does and works the same as <f:debug>{bla}</f:debug> but instead also works the same in a backend module.
- Tx_CabagExtbase_ViewHelpers_SelectViewHelper
Adds several options to the default select viewhelper
<c:select property="topic" options="{topics}" optionLabelField="title" emptyOption="{f:translate(key: 'form.topics.empty')}" emptyOptionValue="0" />
- Tx_CabagExtbase_ViewHelpers_TypoLinkViewHelper
Renders a link from a standard typolink-field. Works for internal, external, mailto and file links.
{namespace c=Tx_CabagExtbase_ViewHelpers}
<c:TypoLink link="{linkfield}">...</c:TypoLink>
Validators:
-----------
- Tx_CabagExtbase_Validator_TwiceValidator
Allows to make sure two properties are equal.
/**
* The E-Mail adress.
*
* @var string
* @validate NotEmpty
* @validate EmailAddress
* @validate Tx_CabagExtbase_Validator_TwiceValidator(key="email")
*/
protected $email;
/**
* The E-Mail adress again.
*
* @var string
* @validate NotEmpty
* @validate EmailAddress
* @validate Tx_CabagExtbase_Validator_TwiceValidator(key="email")
*/
protected $emailAgain;
- Tx_CabagExtbase_Validator_BoundNotEmptyValidator
Allows to make sure at least X of many fields is not empty.
/**
* Phone 1
*
* @var string
* @validate Tx_CabagExtbase_Validator_BoundNotEmptyValidator(key="email", total="2", minimum="1")
*/
protected $phone1;
/**
* Phone 2
*
* @var string
* @validate Tx_CabagExtbase_Validator_BoundNotEmptyValidator(key="email", total="2", minimum="1")
*/
protected $phone2;
Utility:
--------
- Tx_CabagExtbase_Utility_File
Simplifies file upload with extbase.
$file = t3lib_div::makeInstance('Tx_CabagExtbase_Utility_File', 'uploads/tx_myext/');
$uploadedFile = $file->moveUploadedFile($_FILES['tx_myext_pi1'], array('theObject', 'theSubObject', 'theFileProperty'), '(xls)|(xlsx)');
- Tx_CabagExtbase_Utility_Mail
Allows to generate mails directly with a fluid template.
As of version 0.4.9 the controller context is optional and null can be passed instead.
$customerMail = t3lib_div::makeInstance(
'Tx_CabagExtbase_Utility_Mail',
$this->controllerContext,
t3lib_div::getFileAbsFileName($this->settings['customerMailTemplate']),
$this->settings
);
$customerMail->assign('someVariable', $someVariable);
$customerMail->sendPlainTextMail(
$user->getEmail(),
$this->translate('mail.customer.subject'),
$this->settings['fromMail'],
$this->translate('mail.fromName')
);
# instead like this a HTML-Mail is sent:
$customerMail->sendMail(
$user->getEmail(),
$this->translate('mail.customer.subject'),
$this->settings['fromMail'],
$this->translate('mail.fromName'),
true
);
# if the following is called first, the swiftmailer engine is used instead to send the mail
# it must be called before the ->sendMail() call obviously
$customerMail->setUseSwiftmailer(true);
# to add attachements you can use the following
# this only works when using html mail and/or swiftmailer engine
$customerMail->addAttachment('uploads/tx_cabagextbase/someFile.pdf');
- Tx_CabagExtbase_Utility_Logging
Allows to employ complex logging structures with multiple outputs at the same time.
The severity corresponds to the HTTP return codes:
100 -> additional information (debug)
200 -> success message
300 -> warnings/important messages
400 -> errors
500 -> serious stuff went wrong!
The following the default options and a few example output's.
The first constructor parameter is the default tag and the second is the minimum severity for an automatic write.
$logging = $this->objectManager->create('Tx_CabagExtbase_Utility_Logging', 'tx_myextension', 400);
// alternate non extbase:
$logging = t3lib_div::makeInstance('Tx_CabagExtbase_Utility_Logging', 'tx_myextension', 400);
$logging->addOutput('myExtFile', 'file', array(
'file' => 'fileadmin/log/%Y%m%d-my.log', // strftime enabled, relative to PATH_site or /absolute/path/bla.log
'severity' => 200 // minimum severity to be written
));
$logging->addOutput('myExtMail', 'mail', array(
'emails' => '[email protected],[email protected]', // comma separated list of emails
'subject' => '[STAGING] LOG', // the subject for the mail
'from' => '[email protected]', // the mail to send from
'fromName' => 'Staging Log', // the name to send from (optional)
'plain' => true, // send as plain text mail
'template' => 'EXT:my_ext/Resources/Private/Mail/Logging.html', // template file (optional)
'severity' => 400 // just send errors
));
$logging->addOutput('devlog');
$logging->addOutput('flash', array(
'flashMessageContainer' => $this->flashMessageContainer,
'severity' => 200
));
$logging->log('Starting log run');
$logging->log('An error occured!', Tx_CabagExtbase_Utility_Logging::ERROR, array(
'some' => 'additional',
'data' => 'provided'
), 'tx_otherextension');
$logging->write(); // may not do anything at all, if no entries are currently available (e.g. if an autowrite occured)
- Tx_CabagExtbase_Utility_AbstractWizicon
Allows easy creation of wizicons for plugins. You must create a class that extends it and add it to ext_tables:
// add wizicons
if (TYPO3_MODE=='BE') {
$TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']['tx_MyExt_Utility_Wizicon_Plugins'] = t3lib_extMgm::extPath($_EXTKEY).'Classes/Utility/Wizicon/Plugins.php';
}
By default, the class resolves (overwrite the respective functions to change them):
- Translations from Resources/Private/Language/locallang_db.xml
- The plugin title from the key plugin.myplugin
- The plugin description from the key plugin.myplugin.description
- The icon from Resources/Public/Icons/Wizicon_myplugin.gif
The class must look something like the following.
class tx_MyExt_Utility_Wizicon_Plugins extends tx_CabagExtbase_Utility_AbstractWizicon {
/**
* Must return the extension key that the wizicons will be generated for.
*/
function getExtensionKey() {
return 'my_ext';
}
/**
* Adds the plugin wizard icon
*
* @param array Input array with wizard items for plugins
* @return array Modified input array, having the additional items.
*/
public function proc($wizardItems) {
$wizardItems['plugins_tx_myext_' . $plugin] = $this->getWizard('myplugin');
return $wizardItems;
}
}
- Tx_CabagExtbase_Utility_FixFormToken
Creates backend module links that are sendable via mail or other channels.
For that it removes the moduleToken (which contains information about the current session) and creates a session independant token.
$fixFormUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_CabagExtbase_Utility_FixFormToken');
$independantLink = $fixFormUtility->fixLink($moduleLink);
$relativeIndependantLink = $fixFormUtility->fixLink($moduleLink, false);