summaryrefslogtreecommitdiff
path: root/src/build_post.php
blob: d6d23a7c3a87356f29a9aeabd228922d7d62a9e0 (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
30
31
32
<?php

function build_post_subject($listtag, $forumtag, $subject, $reply) {
  // 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 and Edit
  $re = '/^(?:(?:RE|AW|SV|VS|EDIT)(?:\\[\\d+\\])?:\\s*)+/i';
  if (preg_match($re, $subject, $m)) {
    $subject = substr($subject, strlen($m[0]));
  }

  // ensure nonempty subject
  $subject = trim($subject);
  if ($subject == '') {
    $subject = '(no subject)';
  }

  if ($reply) {
    $subject = 'Re: ' . $subject;
  }

  return $subject;
}

function strip_list_footer($message, $fpattern) {
  return preg_replace($fpattern, '', $message);
}

?>