Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
3bc8c0d7
Commit
3bc8c0d7
authored
9 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Plain Diff
Merge pull request #1158 from splitbrain/local_conf_negation
Local configuration negation
parents
efed51d4
10b38f10
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/confutils.php
+44
-9
44 additions, 9 deletions
inc/confutils.php
with
44 additions
and
9 deletions
inc/confutils.php
+
44
−
9
View file @
3bc8c0d7
...
...
@@ -6,6 +6,12 @@
* @author Harry Fuecks <hfuecks@gmail.com>
*/
/*
* line prefix used to negate single value config items
* (scheme.conf & stopwords.conf), e.g.
* !gopher
*/
const
DOKU_CONF_NEGATION
=
'!'
;
/**
* Returns the (known) extension and mimetype of a given filename
...
...
@@ -49,6 +55,7 @@ function getMimeTypes() {
static
$mime
=
null
;
if
(
!
$mime
)
{
$mime
=
retrieveConfig
(
'mime'
,
'confToHash'
);
$mime
=
array_filter
(
$mime
);
}
return
$mime
;
}
...
...
@@ -62,6 +69,7 @@ function getAcronyms() {
static
$acronyms
=
null
;
if
(
!
$acronyms
)
{
$acronyms
=
retrieveConfig
(
'acronyms'
,
'confToHash'
);
$acronyms
=
array_filter
(
$acronyms
,
'strlen'
);
}
return
$acronyms
;
}
...
...
@@ -75,6 +83,7 @@ function getSmileys() {
static
$smileys
=
null
;
if
(
!
$smileys
)
{
$smileys
=
retrieveConfig
(
'smileys'
,
'confToHash'
);
$smileys
=
array_filter
(
$smileys
,
'strlen'
);
}
return
$smileys
;
}
...
...
@@ -88,6 +97,7 @@ function getEntities() {
static
$entities
=
null
;
if
(
!
$entities
)
{
$entities
=
retrieveConfig
(
'entities'
,
'confToHash'
);
$entities
=
array_filter
(
$entities
,
'strlen'
);
}
return
$entities
;
}
...
...
@@ -101,9 +111,11 @@ function getInterwiki() {
static
$wikis
=
null
;
if
(
!
$wikis
)
{
$wikis
=
retrieveConfig
(
'interwiki'
,
'confToHash'
,
array
(
true
));
$wikis
=
array_filter
(
$wikis
,
'strlen'
);
//add sepecial case 'this'
$wikis
[
'this'
]
=
DOKU_URL
.
'{NAME}'
;
}
//add sepecial case 'this'
$wikis
[
'this'
]
=
DOKU_URL
.
'{NAME}'
;
return
$wikis
;
}
...
...
@@ -114,7 +126,7 @@ function getInterwiki() {
function
getWordblocks
()
{
static
$wordblocks
=
null
;
if
(
!
$wordblocks
)
{
$wordblocks
=
retrieveConfig
(
'wordblock'
,
'file'
);
$wordblocks
=
retrieveConfig
(
'wordblock'
,
'file'
,
null
,
'array_merge_with_removal'
);
}
return
$wordblocks
;
}
...
...
@@ -127,11 +139,11 @@ function getWordblocks() {
function
getSchemes
()
{
static
$schemes
=
null
;
if
(
!
$schemes
)
{
$schemes
=
retrieveConfig
(
'scheme'
,
'file'
);
$schemes
=
retrieveConfig
(
'scheme'
,
'file'
,
null
,
'array_merge_with_removal'
);
$schemes
=
array_map
(
'trim'
,
$schemes
);
$schemes
=
preg_replace
(
'/^#.*/'
,
''
,
$schemes
);
$schemes
=
array_filter
(
$schemes
);
}
$schemes
=
array_map
(
'trim'
,
$schemes
);
$schemes
=
preg_replace
(
'/^#.*/'
,
''
,
$schemes
);
$schemes
=
array_filter
(
$schemes
);
return
$schemes
;
}
...
...
@@ -196,7 +208,7 @@ function confToHash($file,$lower=false) {
* @param array $params optional additional params to pass to the callback
* @return array configuration values
*/
function
retrieveConfig
(
$type
,
$fn
,
$params
=
null
)
{
function
retrieveConfig
(
$type
,
$fn
,
$params
=
null
,
$combine
=
'array_merge'
)
{
global
$config_cascade
;
if
(
!
is_array
(
$params
))
$params
=
array
();
...
...
@@ -208,7 +220,7 @@ function retrieveConfig($type,$fn,$params=null) {
foreach
(
$config_cascade
[
$type
][
$config_group
]
as
$file
)
{
if
(
file_exists
(
$file
))
{
$config
=
call_user_func_array
(
$fn
,
array_merge
(
array
(
$file
),
$params
));
$combined
=
array_merg
e
(
$combined
,
$config
);
$combined
=
$combin
e
(
$combined
,
$config
);
}
}
}
...
...
@@ -347,4 +359,27 @@ function conf_decodeString($str) {
return
$str
;
}
}
/**
* array combination function to remove negated values (prefixed by !)
*
* @param array $current
* @param array $new
*
* @return array the combined array, numeric keys reset
*/
function
array_merge_with_removal
(
$current
,
$new
)
{
foreach
(
$new
as
$val
)
{
if
(
substr
(
$val
,
0
,
1
)
==
DOKU_CONF_NEGATION
)
{
$idx
=
array_search
(
trim
(
substr
(
$val
,
1
)),
$current
);
if
(
$idx
!==
false
)
{
unset
(
$current
[
$idx
]);
}
}
else
{
$current
[]
=
trim
(
$val
);
}
}
return
array_slice
(
$current
,
0
);
}
//Setup VIM: ex: et ts=4 :
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment