135 lines
3.1 KiB
Plaintext
135 lines
3.1 KiB
Plaintext
|
head 1.3;
|
||
|
access;
|
||
|
symbols;
|
||
|
locks; strict;
|
||
|
comment @# @;
|
||
|
|
||
|
|
||
|
1.3
|
||
|
date 2007.01.16.04.12.01; author TWikiContributor; state Exp;
|
||
|
branches;
|
||
|
next 1.2;
|
||
|
|
||
|
1.2
|
||
|
date 2006.10.25.00.21.58; author TWikiContributor; state Exp;
|
||
|
branches;
|
||
|
next 1.1;
|
||
|
|
||
|
1.1
|
||
|
date 2006.02.01.12.01.25; author TWikiContributor; state Exp;
|
||
|
branches;
|
||
|
next ;
|
||
|
|
||
|
|
||
|
desc
|
||
|
@new-topic
|
||
|
@
|
||
|
|
||
|
|
||
|
1.3
|
||
|
log
|
||
|
@buildrelease
|
||
|
@
|
||
|
text
|
||
|
@---+ Package =TWiki::Prefs::PrefsCache=
|
||
|
|
||
|
The PrefsCache package holds a cache of topics that have been read in, using
|
||
|
the TopicPrefs class. These functions manage that cache.
|
||
|
|
||
|
We maintain 2 hashes of values:
|
||
|
* {locals} Contains all locals at this level. Locals are values that
|
||
|
only apply when the current topic is the topic where the local is
|
||
|
defined. The variable names are decorated with the locality where
|
||
|
they apply.
|
||
|
* {values} contains all sets, locals, and all values inherited from
|
||
|
the parent level
|
||
|
|
||
|
As each cache level is built, the values are copied down from the parent
|
||
|
cache level. This sounds monstrously inefficient, but in fact perl does
|
||
|
this a lot better than doing a multi-level lookup when a value is referenced.
|
||
|
This is especially important when many prefs lookups may be done in a
|
||
|
session, for example when searching.
|
||
|
|
||
|
|
||
|
%TOC%
|
||
|
|
||
|
---++ ClassMethod *new* <tt>($prefs,$parent,$type,$web,$topic,$prefix)</tt>
|
||
|
|
||
|
Creates a new Prefs object.
|
||
|
* =$prefs= - controlling TWiki::Prefs object
|
||
|
* =$parent= - the PrefsCache object to use to initialise values from
|
||
|
* =$type= - Type of prefs object to create, see notes.
|
||
|
* =$web= - web containing topic to load from (required is =$topic= is set)
|
||
|
* =$topic= - topic to load from
|
||
|
* =$prefix= - key prefix for all preferences (used for plugins)
|
||
|
If the specified topic is not found, returns an empty object.
|
||
|
|
||
|
|
||
|
|
||
|
---++ ObjectMethod *finalise* <tt>($parent)</tt>
|
||
|
|
||
|
Finalise preferences in this cache, by freezing any preferences
|
||
|
listed in FINALPREFERENCES at their current value.
|
||
|
* $parent = object that supports getPreferenceValue
|
||
|
|
||
|
|
||
|
|
||
|
---++ ObjectMethod *loadPrefsFromTopic* <tt>($web,$topic,$keyPrefix)</tt>
|
||
|
|
||
|
Loads preferences from a topic. All settings loaded are prefixed
|
||
|
with the key prefix (default '').
|
||
|
|
||
|
|
||
|
|
||
|
---++ ObjectMethod *loadPrefsFromText* <tt>($text,$meta,$web,$topic)</tt>
|
||
|
|
||
|
Loads preferences from text and optional metadata. All settings loaded
|
||
|
are prefixed with the key prefix (default ''). If =$meta= is defined,
|
||
|
then metadata will be taken from that object. Otherwise, =$text= will
|
||
|
be parsed to extract meta-data.
|
||
|
|
||
|
|
||
|
|
||
|
---++ ObjectMethod *insert* <tt>($type,$key,$val)</tt>
|
||
|
|
||
|
Adds a key-value pair of the given type to the object. Type is Set or Local.
|
||
|
Callback used for the Prefs::Parser object, or can be used to add
|
||
|
arbitrary new entries to a prefs cache.
|
||
|
|
||
|
Note that attempts to redefine final preferences will be ignored.
|
||
|
|
||
|
|
||
|
|
||
|
---++ ObjectMethod *stringify* <tt>($html,\%shown) -> $text</tt>
|
||
|
|
||
|
Generate an (HTML if $html) representation of the content of this cache.
|
||
|
|
||
|
|
||
|
@
|
||
|
|
||
|
|
||
|
1.2
|
||
|
log
|
||
|
@buildrelease
|
||
|
@
|
||
|
text
|
||
|
@d37 1
|
||
|
d61 1
|
||
|
d71 1
|
||
|
@
|
||
|
|
||
|
|
||
|
1.1
|
||
|
log
|
||
|
@buildrelease
|
||
|
@
|
||
|
text
|
||
|
@d50 1
|
||
|
a50 1
|
||
|
---++ ObjectMethod *loadPrefsFromText* <tt>($text,$web,$topic)</tt>
|
||
|
d52 4
|
||
|
a55 2
|
||
|
Loads preferences from a topic. All settings loaded are prefixed
|
||
|
with the key prefix (default '').
|
||
|
@
|