summaryrefslogtreecommitdiff
path: root/src/build_post.php
blob: 6d95be1d69150b895bd642335f83185b33105c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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; 
}

?>