aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_content.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-15 23:23:44 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-15 23:23:44 +0200
commitd1f96aa03601536c6e191328183ac2dd0068aed7 (patch)
treee0a45c989dbd165a364e24874f6402979a0f47e1 /phpBB/includes/functions_content.php
parentc63b5275d858a3ec11674d20d1d2479e5c7477b5 (diff)
parent675cef9c2e9ea571606415fb3228b5f2c73769d9 (diff)
downloadforums-d1f96aa03601536c6e191328183ac2dd0068aed7.tar
forums-d1f96aa03601536c6e191328183ac2dd0068aed7.tar.gz
forums-d1f96aa03601536c6e191328183ac2dd0068aed7.tar.bz2
forums-d1f96aa03601536c6e191328183ac2dd0068aed7.tar.xz
forums-d1f96aa03601536c6e191328183ac2dd0068aed7.zip
Merge branch 'develop-olympus' into develop-ascraeus
* develop-olympus: [ticket/10423] Replace foreach with function in viewtopic.php [ticket/10423] Remove unnecessary include in test [ticket/10423] Match multiple wildcards [ticket/10423] Move code into a function and add tests for it [ticket/10423] Remove * from search or highlight string
Diffstat (limited to 'phpBB/includes/functions_content.php')
-rw-r--r--phpBB/includes/functions_content.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index dd9201165b..b1f69c5756 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -20,6 +20,7 @@ if (!defined('IN_PHPBB'))
* make_jumpbox()
* bump_topic_allowed()
* get_context()
+* phpbb_clean_search_string()
* decode_message()
* strip_bbcode()
* generate_text_for_display()
@@ -360,6 +361,23 @@ function get_context($text, $words, $length = 400)
}
/**
+* Cleans a search string by removing single wildcards from it and replacing multiple spaces with a single one.
+*
+* @param string $search_string The full search string which should be cleaned.
+*
+* @return string The cleaned search string without any wildcards and multiple spaces.
+*/
+function phpbb_clean_search_string($search_string)
+{
+ // This regular expressions matches every single wildcard.
+ // That means one after a whitespace or the beginning of the string or one before a whitespace or the end of the string.
+ $search_string = preg_replace('#(?<=^|\s)\*+(?=\s|$)#', '', $search_string);
+ $search_string = trim($search_string);
+ $search_string = preg_replace(array('#\s+#u', '#\*+#u'), array(' ', '*'), $search_string);
+ return $search_string;
+}
+
+/**
* Decode text whereby text is coming from the db and expected to be pre-parsed content
* We are placing this outside of the message parser because we are often in need of it...
*/