Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
a06967fd
Commit
a06967fd
authored
Mar 21, 2005
by
stronk7
Browse files
Added support for $CFG->filtermatchoneperpage, allowing a phrase
to be linked only once in the entire page.
parent
a0d2e272
Changes
2
Hide whitespace changes
Inline
Side-by-side
config-dist.php
View file @
a06967fd
...
...
@@ -210,6 +210,10 @@ $CFG->admin = 'admin';
// Enabling this will make most text-based filters only match the first time
// a phrase occurs in a given text. Otherwise all are matched.
// $CFG->filtermatchonepertext = true;
//
// Enabling this will make most text-based filters only match the first time
// a phrase occurs in a given page. Otherwise all are matched.
// $CFG->filtermatchoneperpage = true;
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
...
...
lib/filterlib.php
View file @
a06967fd
...
...
@@ -129,6 +129,13 @@ function filter_phrases ($text, $link_array, $ignoretagsopen=NULL, $ignoretagscl
/// Quote any regular expression characters and the delimiter
$linkobject
->
phrase
=
preg_quote
(
$linkobject
->
phrase
,
'/'
);
/// If $CFG->filtermatchoneperpage, avoid previously (request) linked phrases
if
(
!
empty
(
$CFG
->
filtermatchoneperpage
))
{
if
(
!
empty
(
$_REQUEST
[
'LINKEDPHRASES'
])
&&
in_array
(
$linkobject
->
phrase
,
$_REQUEST
[
'LINKEDPHRASES'
]))
{
continue
;
}
}
/// Regular expression modifiers
$modifiers
=
(
$linkobject
->
casesensitive
)
?
's'
:
'is'
;
...
...
@@ -151,14 +158,23 @@ function filter_phrases ($text, $link_array, $ignoretagsopen=NULL, $ignoretagscl
}
/// Finally we do our highlighting
if
(
!
empty
(
$CFG
->
filtermatchonepertext
))
{
$text
=
preg_replace
(
'/('
.
$linkobject
->
phrase
.
')/'
.
$modifiers
,
if
(
!
empty
(
$CFG
->
filtermatchonepertext
)
||
!
empty
(
$CFG
->
filtermatchoneperpage
)
)
{
$
result
text
=
preg_replace
(
'/('
.
$linkobject
->
phrase
.
')/'
.
$modifiers
,
$linkobject
->
hreftagbegin
.
'$1'
.
$linkobject
->
hreftagend
,
$text
,
1
);
}
else
{
$text
=
preg_replace
(
'/('
.
$linkobject
->
phrase
.
')/'
.
$modifiers
,
$
result
text
=
preg_replace
(
'/('
.
$linkobject
->
phrase
.
')/'
.
$modifiers
,
$linkobject
->
hreftagbegin
.
'$1'
.
$linkobject
->
hreftagend
,
$text
);
}
/// If $CFG->filtermatchoneperpage, save linked phrases to request
if
(
!
empty
(
$CFG
->
filtermatchoneperpage
))
{
if
(
$resulttext
!=
$text
)
{
//Texts are different so we have linked the phrase
$_REQUEST
[
'LINKEDPHRASES'
][]
=
$linkobject
->
phrase
;
}
}
/// Set $text to $resulttext
$text
=
$resulttext
;
/// Replace the not full matches before cycling to next link object
if
(
!
empty
(
$notfullmatches
))
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment