forked from leftypol/leftypol
Merge pull request 'Hande crossboard invalid links with strikethrough' (#119) from cross-strikethrough into config
Reviewed-on: leftypol/leftypol#119
This commit is contained in:
commit
55508e6210
1 changed files with 20 additions and 32 deletions
|
|
@ -2228,20 +2228,15 @@ function markup(&$body, $track_cites = false) {
|
|||
$clauses = array_unique($clauses);
|
||||
|
||||
if ($board['uri'] != $_board) {
|
||||
if (!openBoard($_board)){
|
||||
if (in_array($_board,array_keys($config['boards_alias']))){
|
||||
$_board = $config['boards_alias'][$_board];
|
||||
if (openBoard($_board)){
|
||||
|
||||
}
|
||||
else {
|
||||
if (!openBoard($_board)) {
|
||||
if (\in_array($_board, \array_keys($config['boards_alias']))) {
|
||||
$_board = $config['boards_alias'][$_board];
|
||||
if (!openBoard($_board)) {
|
||||
continue; // Unknown board
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
continue; // Unknown board
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2282,38 +2277,31 @@ function markup(&$body, $track_cites = false) {
|
|||
if ($cite) {
|
||||
if (isset($cited_posts[$_board][$cite])) {
|
||||
$link = $cited_posts[$_board][$cite];
|
||||
if (isset($original_board)){
|
||||
$replacement = '<a ' .
|
||||
$replacement_board = $original_board ?? $_board;
|
||||
|
||||
$replacement = '<a ' .
|
||||
($_board == $board['uri'] ?
|
||||
'onclick="highlightReply(\''.$cite.'\', event);" '
|
||||
: '') . 'href="' . $link . '">' .
|
||||
'>>>/' . $original_board . '/' . $cite .
|
||||
'>>>/' . $replacement_board . '/' . $cite .
|
||||
'</a>';
|
||||
|
||||
if ($track_cites && $config['track_cites']) {
|
||||
$tracked_cites[] = [ $_board, $cite ];
|
||||
}
|
||||
else {
|
||||
$replacement = '<a ' .
|
||||
($_board == $board['uri'] ?
|
||||
'onclick="highlightReply(\''.$cite.'\', event);" '
|
||||
: '') . 'href="' . $link . '">' .
|
||||
'>>>/' . $_board . '/' . $cite .
|
||||
'</a>';
|
||||
|
||||
}
|
||||
|
||||
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
|
||||
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
|
||||
|
||||
if ($track_cites && $config['track_cites'])
|
||||
$tracked_cites[] = array($_board, $cite);
|
||||
} else {
|
||||
$replacement = "<s>>>>/$_board/$cite</s>";
|
||||
}
|
||||
} elseif(isset($crossboard_indexes[$_board])) {
|
||||
} elseif (isset($crossboard_indexes[$_board])) {
|
||||
$replacement = '<a href="' . $crossboard_indexes[$_board] . '">' .
|
||||
'>>>/' . $_board . '/' .
|
||||
'</a>';
|
||||
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
|
||||
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
|
||||
} else {
|
||||
$replacement = "<s>>>>/$_board/$cite</s>";
|
||||
}
|
||||
|
||||
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
|
||||
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue