if (isset($params['action']) && $params['action'] == 'view') {
$target = ' target="_blank"';
}
- return '<a href="' . htmlentities($link) . $target . '"' . $popup . $class . '>' . $text . '</a>';
+ return '<a href="' . htmlentities($link) .'"' . $target . $popup . $class . '>' . $text . '</a>';
}
/** Format tree images links
$p = $banana->spool->overview[$p]->parent;
}
foreach (array_reverse($par_ok) as $p) {
- $rsl .= makeHREF(Array('group' => $banana->spool->group), $ndx) . ' ';
+ $rsl .= makeHREF(Array('group' => $banana->spool->group,
+ 'artid' => $p),
+ $ndx) . ' ';
$ndx++;
}
return $rsl;
$res .= sprintf($fmt, $ndx, min($ndx+$banana->tmax-1,sizeof($banana->spool->overview)));
}
}
+ if (!is_null($action)) {
+ if ($action == 'new') {
+ $res .= ' > Nouveau Message';
+ }
+ }
} else {
- $res .= ' > Message';
+ if (!is_null($action)) {
+ $res .= ' > ' . makeHREF(Array('group' => $group,
+ 'artid' => $artid),
+ 'Message')
+ . ' > ';
+ if ($action == 'new') {
+ $res .= 'RĂ©pondre';
+ } elseif ($action == 'cancel') {
+ $res .= 'Annuler';
+ }
+ } else {
+ $res .= ' > Message';
+ }
}
}
return $res.'</div>';
* FORMATTING STUFF : BODY
*/
-function autoformat($text)
+function autoformat($text, $part = false)
{
global $banana;
$length = $banana->wrap;
-
- $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$length, all=>1 };'";
+ $all = null;
+ if (!$part) {
+ $all = ', all=1';
+ }
+
+ $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$length$all };'";
exec($cmd, $result, $ret);
if ($ret != 0) {
$result = split("\n", $text);
$format = false;
foreach ($splits as $line) {
if ($_force || strlen($line) > $max) {
- if (preg_match("!^(.*)($url)(.*)!i", $line, $matches) && strlen($matches[2]) > $length && strlen($matches) < 900) {
+ if (preg_match("!^(.*)($url)(.*)!i", $line, $matches)
+ && strlen($matches[2]) > $length && strlen($matches) < 900) {
if (strlen($matches[1]) != 0) {
array_push($next, rtrim($matches[1]));
if (strlen($matches[1]) > $max) {
}
}
} else {
- $format = true;
- array_push($next, $line);
+ if (strlen($line) > 2 * $max) {
+ $next = array_merge($next, autoformat($line, true));
+ } else {
+ $format = true;
+ array_push($next, $line);
+ }
}
} else {
array_push($next, $line);
function formatbody($_text, $format='plain', $flowed=false)
{
if ($format == 'html') {
- $res = '<br/>'.html_entity_decode(to_entities(removeEvilTags($_text))).'<br/>';
+ $res = html_entity_decode(to_entities(removeEvilTags($_text)));
} else if ($format == 'richtext') {
- $res = '<br/>'.html_entity_decode(to_entities(richtextToHtml($_text))).'<br/>';
+ $res = html_entity_decode(to_entities(richtextToHtml($_text)));
} else {
- $res = "\n\n" . to_entities(wrap($_text, "", $flowed))."\n\n";
+ $res = to_entities(wrap($_text, "", $flowed));
$res = formatPlainText($res);
}
$res = preg_replace("@<br[^>]*>\n?-- ?\n?(<p[^>]*>)@", "<br/>-- <br/>\\2", $res);
$res = preg_replace("@(<pre[^>]*>)\n?-- ?\n@", "<br/>-- <br/>\\1", $res);
$parts = preg_split("@(:?<p[^>]*>\n?-- ?\n?</p>|<br[^>]*>\n?-- ?\n?<br[^>]*>)@", $res);
+ $sign = '<hr style="width: 100%; margin: 1em 0em; " />';
} else {
while (preg_match("@(^|<pre>|\n)>@i", $res)) {
$res = preg_replace("@(^|<pre>|\n)((>[^\n]*\n)+)@ie",
}
$res = preg_replace("@<pre>-- ?\n@", "<pre>\n-- \n", $res);
$parts = preg_split("/\n-- ?\n/", $res);
+ $sign = '</pre><hr style="width: 100%; margin: 1em 0em; " /><pre>';
}
- if (count($parts) > 1) {
- $sign = array_pop($parts);
- if ($format == 'html') {
- $res = join('<br/>-- <br/>', $parts);
- $sign = '<hr style="width: 100%; margin: 1em 0em; " />'.$sign.'<br/>';
- } else {
- $res = join('\n-- \n', $parts);
- $sign = '</pre><hr style="width: 100%; margin: 1em 0em; " /><pre>'.$sign;
- }
- return $res.$sign;
- } else {
- return $res;
- }
+ return join($sign, $parts);
}
// vim:set et sw=4 sts=4 ts=4