function parseUserSignatures(&$parser, &$text, &$strip_state) { while (preg_match('/\^\^\^(.+?)\^\^\^/', $text, $matches)) { $userid = getUserIDFromUserText($matches[1]); if ($userid != 0) { // successfully found the user based on first word $u = newFromId($userid); $text = str_replace("^^^$matches[1]^^^", "[[:user:"******"|" . $u->getRealName() . "]]", $text); } else { $text = str_replace("^^^$matches[1]^^^", "'''{". wfMsg('usercontactlink-baduser') ."}'''", $text); } } return true; }
function todoSavePreparser($q) { // update the text of the todo so that it has a propper full name in it. // this way, the <dpl> search will work better $newpagetext = ''; $sections = preg_split('/({{.*?}})/', $q->textbox1, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); foreach($sections as $section) { if (preg_match("/ ^{{ # we found a template \s* # that may begin with spaces ( # capture the template name in $1 (todo) # template may be a TODO | # or (action item) # template may be an ACTION ITEM ) \s* # the template name may have trailing spaces \| # the pipe to indicate template parameter #1 (task description) ( # capture the template parameter in $4; this string is comprized of [^|]*? # a possible sequence of non pipe characters (\[\[.*\|?.*\]\])? # a possible wiki syntax link [^|]* # a possible sequence on non pipe characters ) \| # the pipe for the template parameter #3 (task assignees) ([,.\s\w\d]*) # any combination of 'chars' repeated any number of times, captured in $6 ( # following by an optional grouping captured in $7 \| # which is the template parameter #4 (project associated with task) \s*project\s*=\s* # which begins with project= (with possible spaces) [,.\s\w\d]*? # any combination of 'chars' repeated any number of times )? }}$ # which ends the template /ix", $section, $matches)) { $newpagetext .= '{{' . "$matches[1]|$matches[4]|"; $first = true; $userlist = preg_split('/\s*,\s*/', $matches[6], -1, PREG_SPLIT_NO_EMPTY); foreach ( $userlist as $user ) { if (!$first) { $newpagetext .= ', '; } else { $first = false; } $userid = getUserIDFromUserText($user); if ($userid != 0) { // successfully found the user $u = User::newFromId($userid); $username = $u->getName(); $fullname = $u->getRealName(); if ($fullname == '') $newpagetext .= $username; else $newpagetext .= $fullname; } else { // fall through to worst case scenario $newpagetext .= $user; } } if (isset($matches[7])) $newpagetext .= "$matches[7]"; $newpagetext .= '}}'; } else { $newpagetext .= $section; } } $q->textbox1 = $newpagetext; return true; }