none
[openafs-wiki.git] / TWiki / TWikiPrefsDotPm.mdwn
1 # <a name="Package &lt;code&gt;TWiki::Prefs="></a> Package =TWiki::Prefs
2
3 The Prefs class is a singleton that implements management of preferences. It uses a stack of TWiki::Prefs::PrefsCache objects to store the preferences for global, web, user and topic contexts, and provides the means to look up preferences in these.
4
5 Preferences from different places stack on top of each other, so there are global preferences, then site, then web (and subweb and subsubweb), then topic, included topic and so on. Each level of the stack is tagged with a type identifier.
6
7 The module also maintains a separate of the preferences found in every topic and web it reads. This supports the lookup of preferences for webs and topics that are not on the stack, and must not be chained in (you can't allow a user to override protections from their home topic!)
8
9 <div>
10   <ul>
11     <li><a href="#Package =TWiki::Prefs="> Package TWiki::Prefs</a><ul>
12         <li><a href="#ClassMethod <strong>new</strong> ($session[,$ca"> ClassMethod new <tt>($session[,$cache])</tt></a></li>
13         <li><a href="#ObjectMethod *finish*"> ObjectMethod finish <tt></tt></a></li>
14         <li><a href="#ObjectMethod <strong>pushPreferences</strong> ("> ObjectMethod pushPreferences <tt>($web,$topic,$type)</tt></a></li>
15         <li><a href="#ObjectMethod *push_WebPreference"> ObjectMethod pushWebPreferences <tt>($web)</tt></a></li>
16         <li><a href="#ObjectMethod *push_GlobalPrefere"> ObjectMethod pushGlobalPreferences <tt>()</tt></a></li>
17         <li><a href="#ObjectMethod *push_PreferencesVa"> ObjectMethod pushPreferencesValues <tt>($type,\%values)</tt></a></li>
18         <li><a href="#ObjectMethod <strong>mark</strong> ()"> ObjectMethod mark <tt>()</tt></a></li>
19         <li><a href="#ObjectMethod <strong>resetTo</strong> ($mark)"> ObjectMethod resetTo <tt>($mark)</tt></a></li>
20         <li><a href="#ObjectMethod *get_PreferencesVal"> ObjectMethod getPreferencesValue <tt>($key) -&gt; $value</tt></a></li>
21         <li><a href="#ObjectMethod <strong>isFinalised</strong> ($key"> ObjectMethod isFinalised <tt>($key)</tt></a></li>
22         <li><a href="#ObjectMethod *get_TopicPreferenc"> ObjectMethod getTopicPreferencesValue <tt>($key,$web,$topic) -&gt; $value</tt></a></li>
23         <li><a href="#get_TextPreferencesValue( $key,"> getTextPreferencesValue( $key, $text, $meta, $web, $topic ) -&gt; $value</a></li>
24         <li><a href="#ObjectMethod *get_WebPreferences"> ObjectMethod getWebPreferencesValue <tt>($key,$web) -&gt; $value</tt></a></li>
25         <li><a href="#ObjectMethod stringify() -> $tex">ObjectMethod stringify() -&gt; $text</a></li>
26       </ul>
27     </li>
28   </ul>
29 </div>
30
31 ## <a name="ClassMethod &lt;strong&gt;new&lt;/strong&gt; ($session[,$ca"></a> [[ClassMethod]] **new** `($session[,$cache])`
32
33 Creates a new Prefs object. If $cache is defined, it will be pushed onto the stack.
34
35 ## <a name="ObjectMethod &lt;strong&gt;finish*"></a><a name="ObjectMethod *finish&lt;/strong&gt; "></a> [[ObjectMethod]] **finish** ``
36
37 Complete processing after the client's HTTP request has been responded to.
38
39 1. breaking circular references to allow garbage collection in persistent environments
40
41 ## <a name="ObjectMethod &lt;strong&gt;pushPreferences&lt;/strong&gt; ("></a> [[ObjectMethod]] **pushPreferences** `($web,$topic,$type)`
42
43 - `$web` - web to read from
44 - `$topic` - topic to read
45 - `$type` - DEFAULT, SITE, USER, SESSION, WEB, TOPIC or PLUGIN
46 - `$prefix` - key prefix for all preferences (used for plugins)
47
48 Reads preferences from the given topic, and pushes them onto the preferences stack.
49
50 ## <a name="ObjectMethod &lt;strong&gt;push_WebPreference"></a> [[ObjectMethod]] \*pushWebPreferences `($web)`
51
52 Pushes web preferences. Web preferences for a particular web depend on the preferences of all containing webs.
53
54 ## <a name="ObjectMethod &lt;strong&gt;push_GlobalPrefere"></a> [[ObjectMethod]] \*pushGlobalPreferences `()`
55
56 Add global preferences to this preferences stack.
57
58 ## <a name="ObjectMethod &lt;strong&gt;push_PreferencesVa"></a> [[ObjectMethod]] \*pushPreferencesValues `($type,\%values)`
59
60 Push a new preference level using type and values given
61
62 ## <a name="ObjectMethod &lt;strong&gt;mark&lt;/strong&gt; ()"></a> [[ObjectMethod]] **mark** `()`
63
64 Return a marker representing the current top of the preferences stack. Used to remember the stack when new web and topic preferences are pushed during a topic include.
65
66 ## <a name="ObjectMethod &lt;strong&gt;resetTo&lt;/strong&gt; ($mark)"></a> [[ObjectMethod]] **resetTo** `($mark)`
67
68 Resets the preferences stack to the given mark, to recover after a topic include.
69
70 ## <a name="ObjectMethod &lt;strong&gt;get_PreferencesVal"></a> [[ObjectMethod]] \*getPreferencesValue `($key) -> $value`
71
72 - =$key - key to look up
73
74 Returns the value of the preference `$key`, or undef.
75
76 Looks up local preferences when the level topic is the same as the current web,topic in the session.
77
78 ## <a name="ObjectMethod &lt;strong&gt;isFinalised&lt;/strong&gt; ($key"></a> [[ObjectMethod]] **isFinalised** `($key)`
79
80 Return true if $key is finalised somewhere in the prefs stack
81
82 ## <a name="ObjectMethod &lt;strong&gt;get_TopicPreferenc"></a> [[ObjectMethod]] \*getTopicPreferencesValue `($key,$web,$topic) -> $value`
83
84 Recover a preferences value that is defined in a specific topic. Does not recover web, user or global settings.
85
86 Intended for use in protections mechanisms, where the order doesn't match the prefs stack.
87
88 ## <a name="get_TextPreferencesValue( $key,"></a><a name="get_TextPreferencesValue( $key, "></a> getTextPreferencesValue( $key, $text, $meta, $web, $topic ) -&gt; $value
89
90 Get a preference value from the settings in the text (and/or optional $meta). The values read are **not** cached.
91
92 ## <a name="ObjectMethod &lt;strong&gt;get_WebPreferences"></a> [[ObjectMethod]] \*getWebPreferencesValue `($key,$web) -> $value`
93
94 Recover a preferences value that is defined in the webhome topic of a specific web.. Does not recover user or global settings, but does recover settings from containing webs.
95
96 Intended for use in protections mechanisms, where the order doesn't match the prefs stack.
97
98 ## <a name="ObjectMethod stringify() - $text"></a> [[ObjectMethod]] stringify() -&gt; $text
99
100 Generate a TML-formatted version of the current preferences