OSDN Git Service

Import current code.
[osdn-codes/wiki-parser.git] / sfjp / wiki / plugin / footnote.php
1 <?php
2 namespace sfjp\Wiki\Plugin;
3 use sfjp\Wiki\Exception\Plugin_Error;
4 class FootNoteProc {
5         public $count = 0;
6         public $message = '';
7         public $formatter;
8
9         public function process() {
10                 $fmt = $this->formatter;
11                 $ret = '';
12                 if ($this->count == 1) {
13                         $ret .= $fmt->raw_node('<hr><ol id="footnote" class="footnote">');
14                 }
15                 $ret .= $fmt->raw_node("<li id=\"_fn_note-{$this->count}\">"
16                                        . "<a class=\"footnote-revref footnote-counter\" href=\"#_fn_ref-{$this->count}\">*{$this->count}</a>"
17                                        . "{$this->message}</li>");
18                 if (FootNote::$counter - 1 == $this->count) {
19                         $ret .= $fmt->raw_node('</ol>');
20                 }
21                 return $ret;
22         }
23 }
24
25 class FootNote extends Base {
26   static public $counter = 1;
27   public $is_vary = false;
28   public function process($args) {
29     $oneline_trac = new \sfjp\Wiki\Processor\Trac_oneline();
30     $oneline_trac->enable_plugin = false;
31
32     $proc = new FootNoteProc();
33     $proc->count     = self::$counter++;
34     $proc->formatter = $this->getFormatter();
35     $proc->message   = $oneline_trac->process($args[0])->getFormattedText();
36
37     $this->processor->addPostProc($proc);
38
39     return $this->getFormatter()->raw_node(
40       "<span id=\"_fn_ref-{$proc->count}\" class=\"footnote-ref\">"
41       . "<a href=\"#_fn_note-{$proc->count}\">*{$proc->count}</a></span>");
42   }
43 }