8e278a9ae9613c45c9ed4f4accff0a8f781871a0
[openafs-wiki.git] / TWiki / SourceCode.mdwn
1 # <a name="TWiki Source Code Packages"></a><a name=" TWiki Source Code Packages"></a> TWiki Source Code Packages
2
3 %X% This documentation is automatically generated from the `pod`, so it always matches the running code
4
5 <div>
6   <ul>
7     <li><a href="#"> </a></li>
8     <li><a href="#"> </a></li>
9     <li><a href="#"> </a></li>
10     <li><a href="#"> </a></li>
11     <li><a href="#"> </a></li>
12     <li><a href="#"> </a></li>
13     <li><a href="#"> </a></li>
14     <li><a href="#"> </a></li>
15     <li><a href="#"> </a></li>
16     <li><a href="#"> </a></li>
17     <li><a href="#"> </a></li>
18     <li><a href="#"> </a></li>
19     <li><a href="#"> </a></li>
20     <li><a href="#"> </a></li>
21     <li><a href="#"> </a></li>
22     <li><a href="#"> </a></li>
23     <li><a href="#"> </a></li>
24     <li><a href="#"> </a></li>
25     <li><a href="#TWiki::_AccessControlException"> TWiki::AccessControlException </a></li>
26     <li><a href="#TWiki::Access"> TWiki::Access </a></li>
27     <li><a href="#TWiki::_AggregateIterator"> TWiki::AggregateIterator </a></li>
28     <li><a href="#TWiki::Attach"> TWiki::Attach </a></li>
29     <li><a href="#TWiki::Attrs"> TWiki::Attrs </a></li>
30     <li><a href="#TWiki::Compatibility"> TWiki::Compatibility </a></li>
31     <li><a href="#TWiki::Configure::Load"> TWiki::Configure::Load </a></li>
32     <li><a href="#Purpose"> Purpose</a></li>
33     <li><a href="#"> </a></li>
34     <li><a href="#TWiki"> TWiki </a></li>
35     <li><a href="#Public Data members"> Public Data members</a></li>
36     <li><a href="#TWiki::Form"> TWiki::Form </a></li>
37     <li><a href="#TWiki::Form::_FieldDefinition"> TWiki::Form::FieldDefinition </a></li>
38     <li><a href="#TWiki::Form::_ListFieldDefinitio"> TWiki::Form::ListFieldDefinition </a></li>
39     <li><a href="#"> </a></li>
40     <li><a href="#TWiki::Func"> TWiki::Func </a></li>
41     <li><a href="#TWiki::_I18N"> TWiki::I18N </a></li>
42     <li><a href="#TWiki::_I18N::Extract"> TWiki::I18N::Extract </a></li>
43     <li><a href="#TWiki::If::Node"> TWiki::If::Node </a></li>
44     <li><a href="#TWiki::If::Parser"> TWiki::If::Parser </a></li>
45     <li><a href="#TWiki::Infix::Error"> TWiki::Infix::Error </a></li>
46     <li><a href="#TWiki::Infix::Node"> TWiki::Infix::Node </a></li>
47     <li><a href="#TWiki::Infix::Parser"> TWiki::Infix::Parser </a></li>
48     <li><a href="#TWiki::_LineIterator"> TWiki::LineIterator </a></li>
49     <li><a href="#TWiki::_ListIterator"> TWiki::ListIterator </a></li>
50     <li><a href="#TWiki::_LoginManager::_ApacheLog"> TWiki::LoginManager::ApacheLogin </a></li>
51     <li><a href="#TWiki::_LoginManager"> TWiki::LoginManager </a></li>
52     <li><a href="#ObjectData =twiki="> ObjectData twiki</a></li>
53     <li><a href="#TWiki::_LoginManager::_TemplateL"> TWiki::LoginManager::TemplateLogin </a></li>
54     <li><a href="#TWiki::Merge"> TWiki::Merge </a></li>
55     <li><a href="#TWiki::Meta"> TWiki::Meta </a></li>
56     <li><a href="#TWiki::Net"> TWiki::Net </a></li>
57     <li><a href="#TWiki::Net::HTTPResponse"> TWiki::Net::HTTPResponse </a></li>
58     <li><a href="#TWiki::_OopsException"> TWiki::OopsException </a></li>
59   </ul>
60 </div>
61
62 ## <> \[[CGISessionDotPm]\[]]
63
64 This package doesn't smell
65
66 ## <> \[[CGISessionDriverDBIDotPm]\[]]
67
68 This package doesn't smell
69
70 ## <> \[[CGISessionDriverDb\_fileDotPm]\[]]
71
72 This package doesn't smell
73
74 ## <> \[[CGISessionDriverDotPm]\[]]
75
76 This package doesn't smell
77
78 ## <> \[[CGISessionDriverFileDotPm]\[]]
79
80 This package doesn't smell
81
82 ## <> \[[CGISessionDriverMysqlDotPm]\[]]
83
84 This package doesn't smell
85
86 ## <> \[[CGISessionDriverPostgresqlDotPm]\[]]
87
88 This package doesn't smell
89
90 ## <> \[[CGISessionDriverSqliteDotPm]\[]]
91
92 This package doesn't smell
93
94 ## <> \[[CGISessionErrorHandlerDotPm]\[]]
95
96 This package doesn't smell
97
98 ## <> \[[CGISessionIDIncrDotPm]\[]]
99
100 This package doesn't smell
101
102 ## <> \[[CGISessionIDMd5DotPm]\[]]
103
104 This package doesn't smell
105
106 ## <> \[[CGISessionSerializeDefaultDotPm]\[]]
107
108 This package doesn't smell
109
110 ## <> \[[CGISessionSerializeFreezethawDotPm]\[]]
111
112 This package doesn't smell
113
114 ## <> \[[CGISessionSerializeJsonDotPm]\[]]
115
116 This package doesn't smell
117
118 ## <> \[[CGISessionSerializeStorableDotPm]\[]]
119
120 This package doesn't smell
121
122 ## <> \[[CGISessionSerializeYamlDotPm]\[]]
123
124 This package doesn't smell
125
126 ## <> \[[CGISessionTutorialDotPm]\[]]
127
128 This package doesn't smell
129
130 ## <> \[[MonitorDotPm]\[]]
131
132 This package doesn't smell
133
134 ## <a name="TWiki::_AccessControlException"></a> [[TWiki::AccessControlException|Main/TWikiAccessControlExceptionDotPm]]
135
136 Exception used raise an access control violation. This exception has the following fields:
137
138 - `web` - the web which was being accessed
139 - `topic` - the topic being accessed (if any)
140 - `user` - canonical username of the person doing the accessing. Use the methods of the TWiki::Users class to get more information about the user.
141 - `mode` - the access mode e.g. CHANGE, VIEW etc
142 - `reason` a text string giving the reason for the refusal.
143
144 The exception may be thrown by plugins. If a plugin throws the exception, it will normally be caught and the browser redirected to a login screen (if the user is not logged in) or reported (if they are and just don't have access).
145
146 This package doesn't smell
147
148 ## <a name="TWiki::Access"></a> [[TWiki::Access|Main/TWikiAccessDotPm]]
149
150 A singleton object of this class manages the access control database.
151
152 This package doesn't smell
153
154 ## <a name="TWiki::_AggregateIterator"></a> [[TWiki::AggregateIterator|Main/TWikiAggregateIteratorDotPm]]
155
156 combine multiple iterators
157
158 This package doesn't smell
159
160 ## <a name="TWiki::Attach"></a> [[TWiki::Attach|Main/TWikiAttachDotPm]]
161
162 A singleton object of this class is used to deal with attachments to topics.
163
164 This package doesn't smell
165
166 ## <a name="TWiki::Attrs"></a> [[TWiki::Attrs|Main/TWikiAttrsDotPm]]
167
168 Class of attribute sets, designed for parsing and storing attribute values from a TWiki tag e.g. `%TAG{"joe" fred="bad" joe="mad"}%`
169
170 An attribute set is a hash containing an entry for each parameter. The default parameter (unnamed quoted string) is named `_DEFAULT` in the hash.
171
172 Attributes declared later in the string will override those of the same name defined earlier. The one exception to this is the \_DEFAULT key, where the _first_ instance is always taken.
173
174 As well as the default TWiki syntax (parameter values double-quoted) this class also parses single-quoted values, unquoted spaceless values, spaces around the =, and commas as well as spaces separating values. The extended syntax has to be enabled by passing the `$friendly` parameter to `new`.
175
176 This package doesn't smell
177
178 ## <a name="TWiki::Compatibility"></a> [[TWiki::Compatibility|Main/TWikiCompatibilityDotPm]]
179
180 Support for compatibility with old TWiki versions. Packaged separately because 99.999999% of the time this won't be needed.
181
182 This package has smell factor of **2**
183
184 ## <a name="TWiki::Configure::Load"></a> [[TWiki::Configure::Load|Main/TWikiConfigureLoadDotPm]]
185
186 ## <a name="Purpose"></a> Purpose
187
188 This module consists of just a single subroutine `readConfig`. It allows to safely modify configuration variables _for one single run_ without affecting normal TWiki operation.
189
190 This package doesn't smell
191
192 ## <> \[[TWikiConfigureUIsEXTENDDotPm]\[]]
193
194 This package has smell factor of **1**
195
196 ## <a name="TWiki"></a> [[TWiki|Main/TWikiDotPm]]
197
198 TWiki operates by creating a singleton object (known as the Session object) that acts as a point of reference for all the different modules in the system. This package is the class for this singleton, and also contains the vast bulk of the basic constants and the per- site configuration mechanisms.
199
200 Global variables are avoided wherever possible to avoid problems with CGI accelerators such as mod\_perl.
201
202 ## <a name="Public Data members"></a> Public Data members
203
204 - `cgiQuery` Pointer to the CGI::
205 - `context` Hash of context ids
206 - moved: `loginManager` TWiki::LoginManager singleton (moved to TWiki::Users)
207 - `plugins` TWiki::Plugins singleton
208 - `prefs` TWiki::Prefs singleton
209 - `remoteUser` Login ID when using [[ApacheLogin]]. Maintained for compatibility only, do not use.
210 - `requestedWebName` Name of web found in URL path or `web` URL parameter
211 - `sandbox` TWiki::Sandbox singleton
212 - `scriptUrlPath` URL path to the current script. May be dynamically extracted from the URL path if \{GetScriptUrlFromCgi\}. Only required to support \{GetScriptUrlFromCgi\} and not consistently used. Avoid.
213 - `security` TWiki::Access singleton
214 - `SESSION_TAGS` Hash of TWiki variables whose value is specific to the current CGI request.
215 - `store` TWiki::Store singleton
216 - `topicName` Name of topic found in URL path or `topic` URL parameter
217 - `urlHost` Host part of the URL (including the protocol) determined during intialisation and defaulting to \{DefaultUrlHost\}
218 - `user` Unique user ID of logged-in user
219 - `users` TWiki::Users singleton
220 - `webName` Name of web found in URL path, or `web` URL parameter, or \{UsersWebName\}
221
222 This package has smell factor of **32**
223
224 ## <a name="TWiki::Form"></a> [[TWiki::Form|Main/TWikiFormDotPm]]
225
226 Object representing a single form definition.
227
228 Form definitions are mainly used to control rendering of a form for editing, though there is some application login there that handles transferring values between edits and saves.
229
230 A form definition consists of a TWiki::Form object, which has a list of field definitions. Each field definition is an object of a type derived from TWiki::Form::FieldDefinition. These objects are responsible for the actual syntax and semantics of the field type. Form definitions are parsed from TWiki tables, and the types are mapped by name to a class declared in TWiki::Form::\* - for example, the `text` type is mapped to `TWiki::Form::Text` and the `checkbox` type to `TWiki::Form::Checkbox`.
231
232 The `TWiki::Form::FieldDefinition` class declares default behaviours for types that accept a single value in their definitions. The `TWiki::Form::ListFieldDefinition` extends this for types that have lists of possible values.
233
234 This package has smell factor of **4**
235
236 ## <a name="TWiki::Form::_FieldDefinition"></a> [[TWiki::Form::FieldDefinition|Main/TWikiFormFieldDefinitionDotPm]]
237
238 Base class of all field definition classes.
239
240 Type-specific classes are derived from this class to define specific per-type behaviours. This class also provides default behaviours for when a specific type cannot be loaded.
241
242 This package doesn't smell
243
244 ## <a name="TWiki::Form::_ListFieldDefinitio"></a> [[TWiki::Form::ListFieldDefinition|Main/TWikiFormListFieldDefinitionDotPm]]
245
246 Form field definitions that accept lists of values in the field definition. This is different to being multi-valued, which means the field type can **store** multiple values.
247
248 This package has smell factor of **1**
249
250 ## <> \[[TWikiFormSelectDotPm]\[]]
251
252 This package doesn't smell
253
254 ## <a name="TWiki::Func"></a> [[TWiki::Func|Main/TWikiFuncDotPm]]
255
256 _Official list of stable TWiki functions for Plugin developers_
257
258 This module defines official functions that [[Plugins|SYSTEMWEB/TWikiPlugins]] can use to interact with the TWiki engine and content.
259
260 Refer to [[EmptyPlugin]] and lib/TWiki/Plugins/EmptyPlugin.pm for a template Plugin and documentation on how to write a Plugin.
261
262 Plugins should **only** use functions published in this module. If you use functions in other TWiki libraries you might create a security hole and you will probably need to change your Plugin when you upgrade TWiki.
263
264 Deprecated functions will still work in older code, though they should _not_ be called in new Plugins and should be replaced in older Plugins as soon as possible.
265
266 The version of the TWiki::Func module is defined by the VERSION number of the TWiki::Plugins module, currently 1.11. This can be shown by the `%PLUGINVERSION%` TWiki variable, and accessed in code using `$TWiki::Plugins::VERSION`. The 'Since' field in the function documentation refers to `$TWiki::Plugins::VERSION`.
267
268 Notes on use of `$TWiki::Plugins::VERSION` (from 1.2 forwards):
269
270 - If the **major** version (e.g. `1.`) is the same then any plugin coded to use any **earlier** revision of the `1.` API will still work. No function has been removed from the interface, nor has any API published in that version changed in such a way as to **require** plugins to be recoded.
271 - If the **minor** version (e.g. 1.1) is incremented there may be changes in the API that may help improve the coding of some plugins - for example, new interfaces giving access to previously hidden core functions. In addition, **deprecation** of functions in the interface trigger a minor version increment. Note that deprecated functions are not _removed_, they are merely frozen, and plugin authors are recommended to stop using them.
272 - Any additional digits in the version number relate to minor changes, such as the addition of parameters to the existing functions, or addition of utility functions that are unlikely to require significant changes to existing plugins.
273 - `TWiki::Plugins::VERSION` also applies to the plugin handlers. The handlers are documented in the EmptyPlugin, and that module indicates what version of `TWiki::Plugins::VERSION` it relates to.
274
275 A full history of the changes to this API can be found at the end of this topic.
276
277 This package has smell factor of **1**
278
279 ## <a name="TWiki::_I18N"></a> [[TWiki::I18N|Main/TWikiI18NDotPm]]
280
281 Support for strings translation and language detection.
282
283 This package has smell factor of **2**
284
285 ## <a name="TWiki::_I18N::Extract"></a> [[TWiki::I18N::Extract|Main/TWikiI18NExtractDotPm]]
286
287 Support translatable strings extraction from TWiki topics and templates. Depends on Locale::Maketext::Extract (part of CPAN::Locale::Maketext::Lexicon).
288
289 This package has smell factor of **1**
290
291 ## <a name="TWiki::If::Node"></a> [[TWiki::If::Node|Main/TWikiIfNodeDotPm]]
292
293 Node class for the result of an If statement parse
294
295 This package doesn't smell
296
297 ## <a name="TWiki::If::Parser"></a> [[TWiki::If::Parser|Main/TWikiIfParserDotPm]]
298
299 Support for the conditions in %IF\{\} statements.
300
301 This package doesn't smell
302
303 ## <a name="TWiki::Infix::Error"></a> [[TWiki::Infix::Error|Main/TWikiInfixErrorDotPm]]
304
305 Class of errors used with TWiki::Infix::Parser
306
307 This package doesn't smell
308
309 ## <a name="TWiki::Infix::Node"></a> [[TWiki::Infix::Node|Main/TWikiInfixNodeDotPm]]
310
311 Base class for node types generated by Infix::Parser. You don't **have** to use it, but it may be useful.
312
313 This package doesn't smell
314
315 ## <a name="TWiki::Infix::Parser"></a> [[TWiki::Infix::Parser|Main/TWikiInfixParserDotPm]]
316
317 A simple stack-based parser that parses infix expressions with nonary, unary and binary operators specified using an operator table.
318
319 Escapes are supported in strings, using backslash.
320
321 This package doesn't smell
322
323 ## <a name="TWiki::_LineIterator"></a> [[TWiki::LineIterator|Main/TWikiLineIteratorDotPm]]
324
325 Iterator over the lines in a file
326
327 This package doesn't smell
328
329 ## <a name="TWiki::_ListIterator"></a> [[TWiki::ListIterator|Main/TWikiListIteratorDotPm]]
330
331 Iterator over a list
332
333 This package doesn't smell
334
335 ## <a name="TWiki::_LoginManager::_ApacheLog"></a> [[TWiki::LoginManager::ApacheLogin|Main/TWikiLoginManagerApacheLoginDotPm]]
336
337 This is login manager that you can specify in the security setup section of [configure](http://www.dementia.org/twiki/configure). It instructs TWiki to cooperate with your web server (typically Apache) to require authentication information (username &amp; password) from users. It requires that you configure your web server to demand authentication for scripts named "login" and anything ending in "auth". The latter should be symlinks to existing scripts; e.g., `viewauth -> view`, `editauth -> edit`, and so on.
338
339 See also [[TWikiUserAuthentication]].
340
341 Subclass of TWiki::LoginManager; see that class for documentation of the methods of this class.
342
343 This package has smell factor of **1**
344
345 ## <a name="TWiki::_LoginManager"></a> [[TWiki::LoginManager|Main/TWikiLoginManagerDotPm]]
346
347 The package is also a Factory for login managers and also the base class for all login managers.
348
349 On it's own, an object of this class is used when you specify 'none' in the security setup section of [configure](http://www.dementia.org/twiki/configure). When it is used, logins are not supported. If you want to authenticate users then you should consider [[TemplateLogin]] or [[ApacheLogin]], which are subclasses of this class.
350
351 If you are building a new login manager, then you should write a new subclass of this class, implementing the methods marked as **VIRTUAL**. There are already examples in the `lib/TWiki/LoginManager` directory.
352
353 The class has extensive tracing, which is enabled by $TWiki::cfg\{Trace\}\{LoginManager.pm\}. The tracing is done in such a way as to let the perl optimiser optimise out the trace function as a no-op if tracing is disabled.
354
355 Here's an overview of how it works:
356
357 Early in TWiki::new, the login manager is created. The creation of the login manager does two things:
358
359 1. If sessions are in use, it loads CGI::Session but doesn't initialise the session yet.
360 2. Creates the login manager object
361
362 Slightly later in TWiki::new, loginManager-&gt;loadSession is called.
363
364 1. Calls loginManager-&gt;getUser to get the username **before** the session is created
365   - TWiki::LoginManager::ApacheLogin looks at REMOTE\_USER (only for authenticated scripts)
366   - TWiki::LoginManager::TemplateLogin just returns undef
367 2. reads the TWIKISID cookie to get the SID (or the TWIKISID parameters in the CGI query if cookies aren't available, or [[IP2SID]] mapping if that's enabled).
368 3. Creates the CGI::Session object, and the session is thereby read.
369 4. If the username still isn't known, reads it from the cookie. Thus TWiki::LoginManager::ApacheLogin overrides the cookie using REMOTE\_USER, and TWiki::LoginManager::TemplateLogin **always** uses the session.
370
371 Later again in TWiki::new, plugins are given a chance to **override** the username found from the loginManager.
372
373 The last step in TWiki::new is to find the user, using whatever user mapping manager is in place.
374
375 ## <a name="ObjectData &lt;code&gt;twiki="></a> [[ObjectData]] =twiki
376
377 The TWiki object this login manager is attached to.
378
379 This package has smell factor of **7**
380
381 ## <a name="TWiki::_LoginManager::_TemplateL"></a> [[TWiki::LoginManager::TemplateLogin|Main/TWikiLoginManagerTemplateLoginDotPm]]
382
383 This is a login manager that you can specify in the security setup section of [configure](http://www.dementia.org/twiki/configure). It provides users with a template-based form to enter usernames and passwords, and works with the [[PasswordManager]] that you specify to verify those passwords.
384
385 Subclass of TWiki::LoginManager; see that class for documentation of the methods of this class.
386
387 This package has smell factor of **2**
388
389 ## <a name="TWiki::Merge"></a> [[TWiki::Merge|Main/TWikiMergeDotPm]]
390
391 Support for merging strings
392
393 This package has smell factor of **1**
394
395 ## <a name="TWiki::Meta"></a> [[TWiki::Meta|Main/TWikiMetaDotPm]]
396
397 All TWiki topics have **data** (text) and **meta-data** (information about the topic). Meta-data includes information such as file attachments, form fields, topic parentage etc. When TWiki loads a topic from the store, it represents the meta-data in the topic using an object of this class.
398
399 A meta-data object is a hash of different types of meta-data (keyed on the type, such as 'FIELD' and 'TOPICINFO').
400
401 Each entry in the hash is an array, where each entry in the array contains another hash of the key=value pairs, corresponding to a single meta-datum.
402
403 If there may be multiple entries of the same top-level type (i.e. for FIELD and FILEATTACHMENT) then the array has multiple entries. These types are referred to as "keyed" types. The array entries are keyed with the attribute 'name' which must be in each entry in the array.
404
405 For unkeyed types, the array has only one entry.
406
407 Pictorially,
408
409 - TOPICINFO
410   - author =&gt; '...'
411   - date =&gt; '...'
412   - ...
413 - FILEATTACHMENT
414   - [0] -&gt; \{ name =&gt; '...' ... \}
415   - [1] -&gt; \{ name =&gt; '...' ... \}
416 - FIELD
417   - [0] -&gt; \{ name =&gt; '...' ... \}
418   - [1] -&gt; \{ name =&gt; '...' ... \}
419
420 As well as the meta-data, the object also stores the web name, topic name and remaining text after meta-data extraction.
421
422 This package has smell factor of **2**
423
424 ## <a name="TWiki::Net"></a> [[TWiki::Net|Main/TWikiNetDotPm]]
425
426 Object that brokers access to network resources.
427
428 This package has smell factor of **3**
429
430 ## <a name="TWiki::Net::HTTPResponse"></a> [[TWiki::Net::HTTPResponse|Main/TWikiNetHTTPResponseDotPm]]
431
432 Fakeup of HTTP::Response for use when LWP is not available. Only implements a small subset of the HTTP::Response methods:
433
434 <table border="1" cellpadding="0" cellspacing="0">
435   <tr>
436     <td><code>code()</code></td>
437   </tr>
438   <tr>
439     <td><code>message()</code></td>
440   </tr>
441   <tr>
442     <td><code>header($field)</code></td>
443   </tr>
444   <tr>
445     <td><code>content()</code></td>
446   </tr>
447   <tr>
448     <td><code>is_error()</code></td>
449   </tr>
450   <tr>
451     <td><code>is_redirect()</code></td>
452   </tr>
453 </table>
454
455 See the documentation of HTTP::Response for information about the methods.
456
457 This package doesn't smell
458
459 ## <a name="TWiki::_OopsException"></a> [[TWiki::OopsException|Main/TWikiOopsExceptionDotPm]]
460
461 Exception used to raise a request to redirect to an Oops URL.
462
463 An [[OopsException]] thrown anywhere in the code will redirect the browser to a url based on the `oops` script. `oops` requires the name of an oops template file from the `templates` directory. This file will be expanded and the parameter values passed to the exception instantiated. The result will be shown in the browser.
464
465 Plugins may throw TWiki::OopsException. For example:
466
467     use Error;
468
469     ...
470
471     throw TWiki::OopsException( 'bathplugin',
472                                 def => 'toestuck',
473                                 web => $web,
474                                 topic => $topic,
475                                 params => [ 'bigtoe', 'hot tap' ] );
476
477     This package doesn't smell
478
479     ---++ [[TWikiPluginDotPm][]]
480
481     This package has smell factor of *2*
482
483     ---++ [[TWikiPluginsDotPm][TWiki::Plugins]]
484
485     This module defines the singleton object that handles Plugins
486     loading, initialization and execution.
487
488     This class uses Chain of Responsibility (GOF) pattern to dispatch
489     handler calls to registered plugins.
490
491     This package doesn't smell
492
493     ---++ [[TWikiPluralsDotPm][TWiki::Plurals]]
494
495     Handle conversion of plural topic names to singular form.
496
497     This package has smell factor of *3*
498
499     ---++ [[TWikiPrefsDotPm][TWiki::Prefs]]
500
501     The Prefs class is a singleton that implements management of preferences.
502     It uses a stack of TWiki::Prefs::PrefsCache objects to store the
503     preferences for global, web, user and topic contexts, and provides
504     the means to look up preferences in these.
505
506     Preferences from different places stack on top of each other, so there
507     are global preferences, then site, then web (and subweb and subsubweb),
508     then topic, included topic and so on. Each level of the stack is tagged with
509     a type identifier.
510
511     The module also maintains a separate of the preferences found in every topic
512     and web it reads. This supports the lookup of preferences for webs and topics
513     that are not on the stack, and must not be chained in (you can't allow
514     a user to override protections from their home topic!)
515
516     This package doesn't smell
517
518     ---++ [[TWikiPrefsParserDotPm][TWiki::Prefs::Parser]]
519
520     This Prefs-internal class is used to parse * Set and * Local statements
521     from arbitrary text, and extract settings from meta objects.  It is used
522     by TopicPrefs to parse preference settings from topics.
523
524     This class does no validation or duplicate-checking on the settings; it
525     simply returns the recognized settings in the order it sees them in.
526
527     This package has smell factor of *1*
528
529     ---++ [[TWikiPrefsPrefsCacheDotPm][TWiki::Prefs::PrefsCache]]
530
531     The PrefsCache package holds a cache of topics that have been read in, using
532     the TopicPrefs class.  These functions manage that cache.
533
534     We maintain 2 hashes of values:
535        * {locals} Contains all locals at this level. Locals are values that
536          only apply when the current topic is the topic where the local is
537          defined. The variable names are decorated with the locality where
538          they apply.
539        * {values} contains all sets, locals, and all values inherited from
540          the parent level
541
542     As each cache level is built, the values are copied down from the parent
543     cache level. This sounds monstrously inefficient, but in fact perl does
544     this a lot better than doing a multi-level lookup when a value is referenced.
545     This is especially important when many prefs lookups may be done in a
546     session, for example when searching.
547
548     This package doesn't smell
549
550     ---++ [[TWikiQueryHoistREsDotPm][TWiki::Query::HoistREs]]
551
552     Static functions to extract regular expressions from queries. The REs can
553     be used in caching stores that use the TWiki standard inline meta-data
554     representation to pre-filter topic lists for more efficient query matching.
555
556     See =Store/RcsFile.pm= for an example of usage.
557
558     This package doesn't smell
559
560     ---++ [[TWikiQueryNodeDotPm][TWiki::Query]]
561
562     A Query object is a representation of a query over the TWiki database.
563
564     Fields are given by name, and values by strings or numbers. Strings should always be surrounded by 'single-quotes'. Numbers can be signed integers or decimals. Single quotes in values may be escaped using backslash (\).
565
566     See TWiki.QuerySearch for details of the query language. At the time of writing
567     only a subset of the entire query language is supported, for use in searching.
568
569     A query object implements the =evaluate= method as its general
570     contract with the rest of the world. This method does a "hard work" evaluation
571     of the parser tree. Of course, smarter Store implementations should be
572     able to do it better....
573
574     This package has smell factor of *2*
575
576     ---++ [[TWikiQueryParserDotPm][TWiki::Query::Parser]]
577
578     Parser for queries
579
580     This package doesn't smell
581
582     ---++ [[TWikiRenderDotPm][TWiki::Render]]
583
584     This module provides most of the actual HTML rendering code in TWiki.
585
586     This package has smell factor of *20*
587
588     ---++ [[TWikiSandboxDotPm][TWiki::Sandbox]]
589
590     This object provides an interface to the outside world. All calls to
591     system functions, or handling of file names, should be brokered by
592     this object.
593
594     NOTE: TWiki creates a singleton sandbox that is *shared* by all TWiki
595     runs under a single mod_perl instance. If any TWiki run modifies the
596     sandbox, that modification will carry over in to subsequent runs.
597     Be very, very careful!
598
599     This package has smell factor of *4*
600
601     ---++ [[TWikiSearchDotPm][TWiki::Search]]
602
603     This module implements all the search functionality.
604
605     This package has smell factor of *15*
606
607     ---++ [[TWikiStoreDotPm][TWiki::Store]]
608
609     This module hosts the generic storage backend. This module provides
610     the interface layer between the "real" store provider - which is hidden
611     behind a handler - and the rest of the system. it is responsible for
612     checking for topic existance, access permissions, and all the other
613     general admin tasks that are common to all store implementations.
614
615     This module knows nothing about how the data is actually _stored_ -
616     that knowledge is entirely encapsulated in the handlers.
617
618     The general contract for methods in the class requires that errors
619     are signalled using exceptions. TWiki::AccessControlException is
620     used for access control exceptions, and Error::Simple for all other
621     types of error.
622
623     This package has smell factor of *14*
624
625     ---++ [[TWikiStoreQueryAlgorithmsBruteForceDotPm][TWiki::Store::QueryAlgorithms::BruteForce]]
626
627     Default brute-force query algorithm
628
629     Has some basic optimisation: it hoists regular expressions out of the
630     query to use with grep, so we can narrow down the set of topics that we
631     have to evaluate the query on.
632
633     Not sure exactly where the breakpoint is between the
634     costs of hoisting and the advantages of hoisting. Benchmarks suggest
635     that it's around 6 topics, though this may vary depending on disk
636     speed and memory size. It also depends on the complexity of the query.
637
638     This package doesn't smell
639
640     ---++ [[TWikiStoreRcsFileDotPm][TWiki::Store::RcsFile]]
641
642     This class is PACKAGE PRIVATE to Store, and should never be
643     used from anywhere else. It is the base class of implementations of stores
644     that manipulate RCS format files.
645
646     The general contract of the methods on this class and its subclasses
647     calls for errors to be signalled by Error::Simple exceptions.
648
649     Refer to Store.pm for models of usage.
650
651     This package has smell factor of *11*
652
653     ---++ [[TWikiStoreRcsLiteDotPm][TWiki::Store::RcsLite]]
654
655     This package does not publish any methods. It implements the virtual
656     methods of the [[TWikiStoreRcsFileDotPm][TWiki::Store::RcsFile]] superclass.
657
658     Simple replacement for RCS.  Doesn't support:
659        * branches
660        * locking
661     Neither of which are used (or needed) by TWiki.
662
663     This module doesn't know anything about the content of the topic
664
665     There is one of these object for each file stored under RCSLite.
666
667     This object is PACKAGE PRIVATE to Store, and should NEVER be
668     used from anywhere else.
669
670     FIXME:
671        * need to tidy up dealing with \n for differences
672        * still have difficulty on line ending at end of sequences, consequence of doing a line based diff
673
674     ---++ File format
675
676     <verbatim>
677     rcstext    ::=  admin {delta}* desc {deltatext}*
678     admin      ::=  head {num};
679                     { branch   {num}; }
680                     access {id}*;
681                     symbols {sym : num}*;
682                     locks {id : num}*;  {strict  ;}
683                     { comment  {string}; }
684                     { expand   {string}; }
685                     { newphrase }*
686     delta      ::=  num
687                     date num;
688                     author id;
689                     state {id};
690                     branches {num}*;
691                     next {num};
692                     { newphrase }*
693     desc       ::=  desc string
694     deltatext  ::=  num
695                     log string
696                     { newphrase }*
697                     text string
698     num        ::=  {digit | .}+
699     digit      ::=  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
700     id         ::=  {num} idchar {idchar | num }*
701     sym        ::=  {digit}* idchar {idchar | digit }*
702     idchar     ::=  any visible graphic character except special
703     special    ::=  $ | , | . | : | ; | @
704     string     ::=  @{any character, with @ doubled}*@
705     newphrase  ::=  id word* ;
706     word       ::=  id | num | string | :
707     </verbatim>
708     Identifiers are case sensitive. Keywords are in lower case only. The
709     sets of keywords and identifiers can overlap. In most environments RCS
710     uses the ISO 8859/1 encoding: visible graphic characters are codes
711     041-176 and 240-377, and white space characters are codes 010-015 and 040.
712
713     Dates, which appear after the date keyword, are of the form Y.mm.dd.hh.mm.ss,
714     where Y is the year, mm the month (01-12), dd the day (01-31), hh the hour
715     (00-23), mm the minute (00-59), and ss the second (00-60). Y contains just
716     the last two digits of the year for years from 1900 through 1999, and all
717     the digits of years thereafter. Dates use the Gregorian calendar; times
718     use UTC.
719
720     The newphrase productions in the grammar are reserved for future extensions
721     to the format of RCS files. No newphrase will begin with any keyword already
722     in use.
723
724     Revisions consist of a sequence of 'a' and 'd' edits that need to be
725     applied to rev N+1 to get rev N. Each edit has an offset (number of lines
726     from start) and length (number of lines). For 'a', the edit is followed by
727     length lines (the lines to be inserted in the text). For example:
728
729     d1 3     means "delete three lines starting with line 1
730     a4 2     means "insert two lines at line 4'
731     xxxxxx   is the new line 4
732     yyyyyy   is the new line 5
733
734     This package has smell factor of *2*
735
736     ---++ [[TWikiStoreRcsWrapDotPm][TWiki::Store::RcsWrap]]
737
738     This package does not publish any methods. It implements the
739     virtual methods of the [[TWikiStoreRcsFileDotPm][TWiki::Store::RcsFile]] superclass.
740
741     Wrapper around the RCS commands required by TWiki.
742     There is one of these object for each file stored under RCS.
743
744     This package has smell factor of *3*
745
746     ---++ [[TWikiStoreSearchAlgorithmsForkingDotPm][TWiki::Store::SearchAlgorithms::Forking]]
747
748     Forking implementation of the RCS cache search.
749
750     ---++ search($searchString, $topics, $options, $sDir) -> \%seen
751     Search .txt files in $dir for $searchString. See RcsFile::searchInWebContent
752     for details.
753
754     This package has smell factor of *1*
755
756     ---++ [[TWikiStoreSearchAlgorithmsPurePerlDotPm][TWiki::Store::SearchAlgorithms::PurePerl]]
757
758     Pure perl implementation of the RCS cache search.
759
760     ---++ search($searchString, $topics, $options, $sDir) -> \%seen
761     Search .txt files in $dir for $string. See RcsFile::searchInWebContent
762     for details.
763
764     This package doesn't smell
765
766     ---++ [[TWikiTemplatesDotPm][TWiki::Templates]]
767
768     Support for the TWiki template language.
769
770     This package has smell factor of *2*
771
772     ---++ [[TWikiTimeDotPm][TWiki::Time]]
773
774     Time handling functions.
775
776     This package has smell factor of *7*
777
778     ---++ [[TWikiUIChangeFormDotPm][TWiki::UI::ChangeForm]]
779
780     Service functions used by the UI packages
781
782     This package doesn't smell
783
784     ---++ [[TWikiUIDotPm][TWiki::UI]]
785
786     Service functions used by the UI packages
787
788     This package doesn't smell
789
790     ---++ [[TWikiUIEditDotPm][TWiki::UI::Edit]]
791
792     Edit command handler
793
794     This package has smell factor of *1*
795
796     ---++ [[TWikiUIManageDotPm][TWiki::UI::Manage]]
797
798     UI functions for web, topic and user management
799
800     This package has smell factor of *5*
801
802     ---++ [[TWikiUIOopsDotPm][TWiki::UI::Oops]]
803
804     UI delegate for oops function
805
806     This package doesn't smell
807
808     ---++ [[TWikiUIRDiffDotPm][TWiki::UI::RDiff]]
809
810     UI functions for diffing.
811
812     This package has smell factor of *12*
813
814     ---++ [[TWikiUIRegisterDotPm][TWiki::UI::Register]]
815
816     User registration handling.
817
818     This package has smell factor of *5*
819
820     ---++ [[TWikiUISaveDotPm][TWiki::UI::Save]]
821
822     UI delegate for save function
823
824     This package has smell factor of *1*
825
826     ---++ [[TWikiUISearchDotPm][TWiki::UI::Search]]
827
828     UI functions for searching.
829
830     This package has smell factor of *2*
831
832     ---++ [[TWikiUIStatisticsDotPm][TWiki::UI::Statistics]]
833
834     Statistics extraction and presentation
835
836     This package has smell factor of *4*
837
838     ---++ [[TWikiUIUploadDotPm][TWiki::UI::Upload]]
839
840     UI delegate for attachment management functions
841
842     This package has smell factor of *3*
843
844     ---++ [[TWikiUIViewDotPm][TWiki::UI::View]]
845
846     UI delegate for view function
847
848     This package has smell factor of *2*
849
850     ---++ [[TWikiUserMappingDotPm][TWiki::UserMapping]]
851
852     This is a virtual base class (a.k.a an interface) for all user mappers. It is
853     *not* useable as a mapping in TWiki - use the BaseUserMapping for default
854     behaviour.
855
856     User mapping is the process by which TWiki maps from a username (a login name)
857     to a display name and back. It is also where groups are maintained.
858
859     See TWiki::Users::BaseUserMapping and TWiki::Users::TWikiUserMapping for
860     the default implementations of this interface.
861
862     If you want to write a user mapper, you will need to implement the methods
863     described in this class.
864
865     User mappings work by mapping both login names and display names to a
866     _canonical user id_. This user id is composed from a prefix that defines
867     the mapper in use (something like 'BaseUserMapping_' or 'LdapUserMapping_')
868     and a unique user id that the mapper uses to identify the user.
869
870     The null prefix is reserver for the TWikiUserMapping for compatibility
871     with old TWiki releases.
872
873     __Note:__ in all the following documentation, =$user= refers to a
874     *canonical user id*.
875
876     This package has smell factor of *1*
877
878     ---++ [[TWikiUsersApacheHtpasswdUserDotPm][TWiki::Users::ApacheHtpasswdUser]]
879
880     Password manager that uses Apache::HtPasswd to manage users and passwords.
881
882     Subclass of [[TWikiUsersPasswordDotPm][ =TWiki::Users::Password= ]].
883     See documentation of that class for descriptions of the methods of this class.
884
885     Duplicates functionality of
886     [[TWikiUsersHtPasswdUserDotPm][ =TWiki::Users::HtPasswdUser=]];
887     provided mainly as an example of how to write a new password manager.
888
889     This package has smell factor of *1*
890
891     ---++ [[TWikiUsersDotPm][TWiki::Users]]
892     This package provides services for the lookup and manipulation of login and
893     wiki names of users, and their authentication.
894
895     It is a Facade that presents a common interface to the User Mapping
896     and Password modules. The rest of the core should *only* use the methods
897     of this package, and should *never* call the mapping or password managers
898     directly.
899
900     TWiki uses the concept of a _login name_ which is used to authenticate a
901     user. A login name maps to a _wiki name_ that is used to identify the user
902     for display. Each login name is unique to a single user, though several
903     login names may map to the same wiki name.
904
905     Using this module (and the associated plug-in user mapper) TWiki supports
906     the concept of _groups_. Groups are sets of login names that are treated
907     equally for the purposes of access control. Group names do not have to be
908     wiki names, though it is helpful for display if they are.
909
910     Internally in the code TWiki uses something referred to as a _canonical user
911     id_ or just _user id_. The user id is also used externally to uniquely identify
912     the user when (for example) recording topic histories. The user id is *usually*
913     just the login name, but it doesn't need to be. It just has to be a unique
914     7-bit alphanumeric and underscore string that can be mapped to/from login
915     and wiki names by the user mapper.
916
917     The canonical user id should *never* be seen by a user. On the other hand,
918     core code should never use anything *but* a canonical user id to refer
919     to a user.
920
921     *Terminology*
922        * A *login name* is the name used to log in to TWiki. Each login name is
923          assumed to be unique to a human. The Password module is responsible for
924          authenticating and manipulating login names.
925        * A *canonical user id* is an internal TWiki representation of a user. Each
926          canonical user id maps 1:1 to a login name.
927        * A *wikiname* is how a user is displayed. Many user ids may map to a
928          single wikiname. The user mapping module is responsible for mapping
929          the user id to a wikiname.
930        * A *group id* represents a group of users and other groups.
931          The user mapping module is responsible for mapping from a group id to
932          a list of canonical user ids for the users in that group.
933        * An *email* is an email address asscoiated with a *login name*. A single
934          login name may have many emails.
935
936     *NOTE:*
937        * wherever the code references $user, its a canonical_id
938        * wherever the code references $group, its a group_name
939
940     This package has smell factor of *5*
941
942     ---++ [[TWikiUsersHtPasswdUserDotPm][TWiki::Users::HtPasswdUser]]
943
944     Support for htpasswd and htdigest format password files.
945
946     Subclass of [[TWikiUsersPasswordDotPm][ =TWiki::Users::Password= ]].
947     See documentation of that class for descriptions of the methods of this class.
948
949     This package has smell factor of *3*
950
951     ---++ [[TWikiUsersPasswordDotPm][TWiki::Users::Password]]
952
953     Base class of all password handlers. Default behaviour is no passwords,
954     so anyone can be anyone they like.
955
956     The methods of this class should be overridded by subclasses that want
957     to implement other password handling methods.
958
959     This package doesn't smell
960
961      There were a total of *192* smells