Skip to content

Commit

Permalink
Item14225: More preferences reorganizing
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Nov 19, 2016
1 parent 7addae0 commit 3a79774
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
13 changes: 8 additions & 5 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,24 @@ sub init {
if $Foswiki::cfg{Plugins}{TwistyPlugin}{Enabled};
}

# init NAMEFILTER
# init NAMEFILTER - Keep for backwards compatibiltiy
unless ( Foswiki::Func::getPreferencesValue('NAMEFILTER') ) {
Foswiki::Func::setPreferencesValue( 'NAMEFILTER',
$Foswiki::cfg{NameFilter} );
}

# init ATTACHMENTNAMEFILTER
# init ATTACHMENTNAMEFILTER - Keep for backwards compatibiltiy
unless ( Foswiki::Func::getPreferencesValue('ATTACHMENTNAMEFILTER') ) {
Foswiki::Func::setPreferencesValue( 'ATTACHMENTNAMEFILTER',
$Foswiki::cfg{AttachmentNameFilter} );
}

# init URLHOST - Keep for backwards compatibiltiy
unless ( Foswiki::Func::getPreferencesValue('URLHOST') ) {
Foswiki::Func::setPreferencesValue( 'URLHOST',
Foswiki::Func::getUrlHost() );
}

# add exported preferences to head
my %prefs = ();
foreach my $pref ( split( /\s*,\s*/, $prefs ) ) {
Expand All @@ -100,9 +106,6 @@ sub init {
%{ $prefs{"SCRIPTURLPATHS"} } = %{ $Foswiki::cfg{ScriptUrlPaths} };
}

$prefs{"URLHOST"} =
Foswiki::Func::getUrlHost(); #URLHOST is not a default variable.

my $text =
"<script class='\$zone \$id foswikiPreferences' type='text/json'>"
. JSON::to_json( \%prefs, { pretty => 1, allow_nonref => 1 } )
Expand Down
5 changes: 0 additions & 5 deletions core/data/System/DefaultPreferences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,6 @@ Note, this feature also must be enabled on the UserRegistration page by adding
* Set ALLOWTOPICCHANGE = %USERSWEB%.AdminGroup
* Set ALLOWTOPICRENAME = %USERSWEB%.AdminGroup

---++ Accessible configuration items
Note that any configuration variable accessed via QUERY must be included in the
definition of {AccessibleCFG} in =configure= (expert setting)
* Set NAMEFILTER = %QUERY{"{NameFilter}"}%

---++ Creating New Preference Settings

You can introduce new [[PreferenceSettings][preference settings]] and use them in your topics and templates. There is no need to change the Foswiki engine (Perl scripts).
Expand Down
13 changes: 8 additions & 5 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,12 @@ BEGIN {
ADDTOHEAD => undef,

# deprecated, use ADDTOZONE instead
ADDTOZONE => undef,
ALLVARIABLES => sub { $_[0]->{prefs}->stringify() },
ATTACHURL => undef,
ATTACHURLPATH => undef,
DATE => sub {
ADDTOZONE => undef,
ALLVARIABLES => sub { $_[0]->{prefs}->stringify() },
ATTACHMENTNAMEFILTER => $Foswiki::cfg{AttachmentNameFilter},
ATTACHURL => undef,
ATTACHURLPATH => undef,
DATE => sub {
Foswiki::Time::formatTime(
time(),
$Foswiki::cfg{DefaultDateFormat},
Expand Down Expand Up @@ -270,6 +271,7 @@ BEGIN {
MAKETEXT => undef,
META => undef, # deprecated
METASEARCH => undef, # deprecated
NAMEFILTER => $Foswiki::cfg{NameFilter},
NONCE => undef,
PENDINGREGISTRATIONS => undef,
PERLDEPENDENCYREPORT => undef,
Expand Down Expand Up @@ -336,6 +338,7 @@ BEGIN {
'TMPL:P' => sub { $_[0]->templates->tmplP( $_[1] ) },
TOPICLIST => undef,
URLENCODE => undef,
URLHOST => sub { $_[0]->{urlHost} },
URLPARAM => undef,
USERINFO => undef,
USERNAME => undef,
Expand Down

0 comments on commit 3a79774

Please sign in to comment.