function banana_quote($line, $level, $mark = '>')
{
$lines = explode("\n", $line);
+ $quote = str_repeat($mark, $level);
foreach ($lines as &$line) {
- if ($level > 0 && substr($line, 0, strlen($mark)) != $mark) {
- $line = ' ' . $line;
- }
- for ($i = 0 ; $i < $level ; $i++) {
- $line = $mark . $line;
- }
+ $line = $quote . $line;
}
return implode("\n", $lines);
}
$line = banana_removeQuotes($line, $level);
while (banana_isFlowed($line)) {
$lvl = 0;
- if (is_null($nl = array_shift($lines))) {
+ if (empty($lines)) {
break;
}
+ $nl = $lines[0];
$nl = banana_removeQuotes($nl, $lvl);
- $line .= $nl;
+ if ($lvl == $level) {
+ $line .= $nl;
+ array_shift($lines);
+ } else {
+ break;
+ }
}
$text .= banana_quote($line, $level) . "\n";
}
while (!is_null($line = array_shift($lines))) {
$lvl = 0;
$line = banana_removeQuotes($line, $lvl, $strict);
- if($lvl != $level && !empty($buffer)) {
- $text .= banana_wordwrap(implode("\n", $buffer), $level + $base_level) . "\n";
+ if($lvl != $level) {
+ if (!empty($buffer)) {
+ $text .= banana_wordwrap(implode("\n", $buffer), $level + $base_level) . "\n";
+ $buffer = array();
+ }
$level = $lvl;
- $buffer = array();
}
$buffer[] = $line;
}
$this->pages[$name] = array('text' => $text, 'template' => $template);
return true;
}
-
- /** Generate XHTML code
+
+ /** Preparte the page generation
+ * @return template to use
*/
- public function run()
+ protected function prepare()
{
$this->registerPage('subscribe', _b_('Abonnements'), null);
$this->registerPage('forums', _b_('Les forums'), null);
unset($this->actions[$key]);
}
}
+
+ return 'banana-base.tpl';
+ }
+
+ /** Generate XHTML code
+ */
+ public function run()
+ {
+ $tpl = $this->prepare();
+
$this->assign('group', Banana::$group);
$this->assign('artid', Banana::$artid);
$this->assign('part', Banana::$part);
$this->assign('spool', Banana::$spool);
$this->assign('protocole', Banana::$protocole);
+ $this->register_function('url', array($this, 'makeUrl'));
+ $this->register_function('link', array($this, 'makeLink'));
+ $this->register_function('imglink', array($this, 'makeImgLink'));
+ $this->register_function('img', array($this, 'makeImg'));
+
$this->assign('errors', $this->error);
$this->assign('page', $this->page);
$this->assign('pages', $this->pages);
$this->assign('actions', $this->actions);
- $this->register_function('url', array($this, 'makeUrl'));
- $this->register_function('link', array($this, 'makeLink'));
- $this->register_function('imglink', array($this, 'makeImgLink'));
- $this->register_function('img', array($this, 'makeImg'));
if (!Banana::$debug_smarty) {
$error_level = error_reporting(0);
}
- $text = $this->fetch('banana-base.tpl');
+ $text = $this->fetch($tpl);
$text = banana_utf8entities($text);
if (!Banana::$debug_smarty) {
error_reporting($error_level);