Example #1
0
 public function __construct($id, $is_guiedit = false)
 {
     $this->id = $id;
     $this->contents = new Element();
     $this->contents_last = $this->contents;
     $this->is_guiedit = $is_guiedit;
     parent::__construct();
 }
Example #2
0
 public function __construct(&$root, $text)
 {
     global $preformat_ltrim;
     parent::__construct();
     if (substr($text, 0, 2) === '# ') {
         $text = substr($text, 1);
     }
     $this->elements[] = !$preformat_ltrim || empty($text) || substr($text, 0, 1) !== ' ' ? $text : substr($text, 1);
 }
Example #3
0
 public function __construct(&$root, $text)
 {
     parent::__construct();
     $this->text = $text;
     $this->level = min(3, strspn($text, '*'));
     list($text, $this->msg_top, $this->id) = $root->getAnchor($text, $this->level);
     $this->insert(ElementFactory::factory('InlineElement', null, $text));
     $this->level++;
     // h2,h3,h4
 }
Example #4
0
 public function __construct($text, $param = '')
 {
     parent::__construct();
     $this->param = $param;
     if (empty($text)) {
         return;
     }
     if (substr($text, 0, 1) == '~') {
         $text = ' ' . substr($text, 1);
     }
     $this->insert(ElementFactory::factory('Inline', null, $text));
 }
Example #5
0
 public function __construct($tag, $tag2, $head, $text)
 {
     parent::__construct();
     $this->tag = $tag;
     $this->tag2 = $tag2;
     $this->level = min(3, strspn($text, $head));
     $text = ltrim(substr($text, $this->level));
     $element = new ListElement($this->level, $tag2);
     parent::insert($element);
     if (!empty($text)) {
         $this->last = $this->last->insert(ElementFactory::factory('InlineElement', null, $text));
     }
 }
Example #6
0
 public function __construct($out)
 {
     parent::__construct();
     $cells = explode('|', $out[1]);
     $this->col = count($cells);
     $this->type = strtolower($out[2]);
     $this->types = array($this->type);
     $is_template = $this->type === 'c';
     $row = array();
     foreach ($cells as $cell) {
         $row[] = new TableCell($cell, $is_template);
     }
     $this->elements[] = $row;
 }
Example #7
0
 public function __construct($row = array('cell1 ', ' cell2 ', ' cell3'))
 {
     parent::__construct();
     $str = array();
     $col = count($row);
     $matches = $_value = $_align = array();
     foreach ($row as $cell) {
         if (preg_match('/^(\\s+)?(.+?)(\\s+)?$/', $cell, $matches)) {
             if ($matches[2] == '==') {
                 // Colspan
                 $_value[] = FALSE;
                 $_align[] = FALSE;
             } else {
                 $_value[] = $matches[2];
                 if (empty($matches[1])) {
                     $_align[] = '';
                     // left
                 } else {
                     if (isset($matches[3])) {
                         $_align[] = 'center';
                     } else {
                         $_align[] = 'right';
                     }
                 }
             }
         } else {
             $_value[] = $cell;
             $_align[] = '';
         }
     }
     for ($i = 0; $i < $col; $i++) {
         if ($_value[$i] === FALSE) {
             continue;
         }
         $colspan = 1;
         while (isset($_value[$i + $colspan]) && $_value[$i + $colspan] === FALSE) {
             ++$colspan;
         }
         $colspan = $colspan > 1 ? ' colspan="' . $colspan . '"' : '';
         $text = preg_match("/\\S+/", $_value[$i]) ? InlineFactory::factory($_value[$i]) : '';
         $class = empty($text) || !preg_match("/\\S+/", $text) ? 'blank-cell' : '';
         $align = $_align[$i] ? ' style="text-align:' . $_align[$i] . '"' : '';
         $str[] = '<td class="' . $class . '"' . $align . $colspan . '>' . $text . '</td>';
         unset($_value[$i], $_align[$i], $text);
     }
     $this->col = $col;
     $this->elements[] = implode('', $str);
 }
Example #8
0
 public function __construct(&$root, $text)
 {
     parent::__construct();
     $head = substr($text, 0, 1);
     $this->level = min(3, strspn($text, $head));
     $text = ltrim(substr($text, $this->level));
     if ($head === '<') {
         // Blockquote close
         $level = $this->level;
         $this->level = 0;
         $this->last = $this->end($root, $level);
         if (!empty($text)) {
             $this->last = $this->last->insert(ElementFactory::factory('InlineElement', null, $text));
         }
     } else {
         $this->insert(ElementFactory::factory('InlineElement', null, $text));
     }
 }
Example #9
0
 public function __construct($out)
 {
     parent::__construct();
     list(, $this->name, $this->param, $this->text) = array_pad($out, 4, '');
 }
Example #10
0
 public function __construct($text, $is_template = FALSE)
 {
     parent::__construct();
     $matches = array();
     // 必ず$matchesの末尾の配列にテキストの内容が入るのでarray_popの返り値を使用する方法に変更。
     // もうすこし、マシな実装方法ないかな・・・。12/05/03
     while (preg_match(self::CELL_OPTION_MATCH_PATTERN, $text, $matches)) {
         // 内容
         $text = array_pop($matches);
         // スイッチ
         if ($matches[1]) {
             // LEFT CENTER RIGHT JUSTIFY
             $this->style['text-align'] = $matches[1];
         } else {
             if ($matches[3]) {
                 // COLOR / BGCOLOR
                 $name = $matches[2] ? 'background-color' : 'color';
                 $this->style[$name] = $matches[3];
             } else {
                 if ($matches[4]) {
                     // SIZE
                     $this->style['font-size'] = $matches[4] . 'px';
                 } else {
                     if ($matches[5]) {
                         // LANG
                         $this->lang = strtolower(Utility::htmlsc($matches[5]));
                     } else {
                         if ($matches[6]) {
                             // TOP / MIDDLE / BOTTOM
                             // http://pukiwiki.sourceforge.jp/?%E8%B3%AA%E5%95%8F%E7%AE%B14%2F540
                             $this->style['vertical-align'] = $matches[6];
                         } else {
                             if ($matches[7]) {
                                 // NOWRAP
                                 // http://pukiwiki.sourceforge.jp/dev/?PukiWiki%2F1.4%2F%A4%C1%A4%E7%A4%C3%A4%C8%CA%D8%CD%F8%A4%CB%2F%C9%BD%C1%C8%A4%DF%A4%C7nowrap%A4%F2%BB%D8%C4%EA%A4%B9%A4%EB
                                 $this->style['white-space'] = 'nowrap';
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($is_template && is_numeric($text)) {
         $this->style['width'] = $text . 'px;';
     }
     if (preg_match("/\\S+/", $text) === false) {
         // セルが空だったり、空白文字しか残らない場合は、空欄のセルとする。(HTMLではタブやスペースも削除)
         $text = '';
         $this->is_blank = true;
     } else {
         if ($text === '>') {
             $this->colspan = 0;
         } else {
             if ($text === '~') {
                 $this->rowspan = 0;
             } else {
                 if (substr($text, 0, 1) === '~') {
                     $this->tag = 'th';
                     $text = substr($text, 1);
                 }
             }
         }
     }
     if (!empty($text) && $text[0] === '#') {
         // Try using Div class for this $text
         $obj = ElementFactory::factory('Div', $this, $text);
         if ($obj instanceof Paragraph) {
             $obj = $obj->elements[0];
         }
     } else {
         $obj = ElementFactory::factory('InlineElement', null, $text);
     }
     $this->insert($obj);
 }
Example #11
0
 public function __construct(&$root, $text)
 {
     global $preformat_ltrim;
     parent::__construct();
     $this->elements[] = Utility::htmlsc(!$preformat_ltrim || empty($text) || $text[0] != ' ' ? $text : substr($text, 1));
 }
Example #12
0
 public function __construct($out)
 {
     parent::__construct();
     list(, $this->name, $this->param) = array_pad($out, 3, null);
 }
Example #13
0
 public function __construct($level, $head)
 {
     parent::__construct();
     $this->level = $level;
     $this->head = $head;
 }
Example #14
0
 public function __construct($text)
 {
     parent::__construct();
     $this->elements[] = trim(substr($text, 0, 1) === "\n" ? $text : InlineFactory::factory($text));
 }
Example #15
0
 public function __construct(&$root, $text)
 {
     parent::__construct();
 }