Example #1
0
 function toString()
 {
     $styles = array();
     switch ($this->name) {
         case 'br':
             return '<p><br class="block" /></p>';
         case 'hr':
             return '<hr class="short_line" />';
         case 'ref':
             $param = $this->param != '' ? csv_explode(',', $this->param) : array();
             return guiedit_convert_ref($param);
         case 'clear':
             $styles[] = 'clear:both;';
     }
     if ($this->text) {
         $this->text = str_replace(' ', '&nbsp;', _htmlspecialchars($this->text));
         $this->text = preg_replace("/\r/", "<br />", $this->text);
     }
     $this->param = _htmlspecialchars($this->param);
     $inner = "#{$this->name}" . ($this->param ? "({$this->param})" : '') . $this->text;
     if (MSIE) {
         $styles[] = 'cursor:default;';
     }
     $style = '';
     if ($styles) {
         $style = ' style="' . join('', $styles) . '"';
     }
     //$inner = '<pre>'. $inner . '</pre>';
     global $xpwiki;
     $attr = $xpwiki->func->exist_plugin_convert($this->name) ? ' class="plugin" contenteditable="true"' : '';
     return $this->wrap($inner, 'div', $attr . $style);
 }
Example #2
0
 /**
  * インラインプラグイン処理メソッド
  */
 static function convert_plugin($matches)
 {
     $aryargs = !empty($matches[2]) ? explode(',', $matches[2]) : array();
     $name = strtolower($matches[1]);
     $body = empty($matches[3]) ? '' : $matches[3];
     //	プラグインが存在しない場合はそのまま返す。
     // if (!file_exists(PLUGIN_DIR . $name . '.inc.php')) {
     if (!PluginRenderer::hasPlugin($name)) {
         return $matches[0];
     }
     switch ($name) {
         case 'aname':
             return '<a name="' . $aryargs[0] . '">' . $body . '</a>';
         case 'br':
             return '<br />';
         case 'color':
             $color = $aryargs[0];
             $bgcolor = $aryargs[1];
             if ($body == '') {
                 return '';
             }
             if ($color != '' && !preg_match('/^(#[0-9a-f]+|[\\w-]+)$/i', $color)) {
                 return $body;
             }
             if ($bgcolor != '' && !preg_match('/^(#[0-9a-f]+|[\\w-]+)$/i', $bgcolor)) {
                 return $body;
             }
             if ($color != '') {
                 $color = 'color:' . $color;
             }
             if ($bgcolor != '') {
                 $bgcolor = ($color ? '; ' : '') . 'background-color:' . $bgcolor;
             }
             return '<span style="' . $color . $bgcolor . '">' . $this->convert($body, TRUE, FALSE) . '</span>';
         case 'sup':
         case 'sub':
             return '<' . $name . '>' . $body . '</' . $name . '>';
         case 'size':
             $size = $aryargs[0];
             if ($size == '' || $body == '') {
                 return '';
             }
             if (!preg_match('/^\\d+$/', $size)) {
                 return $body;
             }
             return '<span style="font-size:' . $size . 'px;line-height:130%">' . $this->convert($body, TRUE, FALSE) . "</span>";
         case 'ref':
             return guiedit_convert_ref($aryargs, FALSE);
     }
     if ($body) {
         $pattern = array("%%", "''", "[[", "]]", "{", "|", "}");
         $replace = array("&#037;&#037;", "&#039;&#039;", "&#091;&#091;", "&#093;&#093;", "&#123;", "&#124;", "&#125;");
         $body = str_replace($pattern, $replace, $body);
     }
     $inner = '&' . $matches[1] . ($matches[2] ? '(' . $matches[2] . ')' : '') . ($body ? '{' . $body . '}' : '') . ';';
     $style = UA_NAME == MSIE ? '' : ' style="cursor:default"';
     return '<span class="plugin text-primary" contenteditable="false"' . $style . '>' . $inner . '</span>';
 }
Example #3
0
 function toString()
 {
     switch ($this->name) {
         case 'br':
             return "<br />\n&nbsp;";
         case 'hr':
             return '<hr class="short_line" />';
         case 'pagebreak':
             return '<div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>';
         case 'ref':
             $param = $this->param != '' ? explode(',', $this->param) : array();
             return guiedit_convert_ref($param);
     }
     if ($this->text) {
         $this->text = preg_replace("/\r/", "<br />", $this->text);
     }
     $inner = "#{$this->name}" . ($this->param ? "({$this->param})" : '') . $this->text;
     $style = UA_NAME == MSIE ? '' : ' style="cursor:default"';
     return $this->wrap($inner, 'div', ' class="plugin" contenteditable="false"' . $style);
 }