summaryrefslogtreecommitdiff
path: root/src/build_post.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/build_post.php')
-rw-r--r--src/build_post.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/build_post.php b/src/build_post.php
new file mode 100644
index 0000000..6d95be1
--- /dev/null
+++ b/src/build_post.php
@@ -0,0 +1,29 @@
+<?php
+
+function build_tag_pattern($tag) {
+ return '/' . preg_quote($tag, '/') . '\\s*/';
+}
+
+function build_post_subject($listtag, $forumtag, $subject) {
+ // strip the '[list]' and '[forum]' tags
+ $tagpat = '/(' . preg_quote($listtag, '/') .
+ '|' . preg_quote($forumtag, '/') . ')\\s*/';
+ $subject = preg_replace($tagpat, '', $subject);
+
+ // strip leading sequences of Re-equivalents
+ if (preg_match(
+ '/^((RE|AW|SV|VS)(\\[\\d+\\])?:\\s*)+/i',
+ $subject, $m, PREG_OFFSET_CAPTURE
+ )) {
+ $subject = substr($subject, $m[0][1]);
+ }
+
+ // ensure nonempty subject
+ if (trim($subject) == '') {
+ $subject = '(no subject)';
+ }
+
+ return $subject;
+}
+
+?>