function plugin_aname_inline() { $convert = FALSE; if (func_num_args() < 2) { return plugin_aname_usage($convert); } $args = func_get_args(); // ONE or more $body = Utility::stripHtmlTags(array_pop($args), FALSE); // Strip anchor tags only array_push($args, $body); return plugin_aname_tag($args, $convert); }
function plugin__get_inline() { switch (func_num_args()) { case 2: list($msg) = func_get_args(); return Utility::stripHtmlTags($msg); case 3: list($name, $msg) = func_get_args(); return i18n_gettext($name, $msg); case 4: list($name, $lang, $msg) = func_get_args(); return i18n_setlocale($name, $lang, $msg); } return ''; }
function strip_htmltag($str, $all = TRUE) { return Utility::stripHtmlTags($str, $all); }
public function parse($lines) { $this->last =& $this; $matches = array(); while (!empty($lines)) { $line = array_shift($lines); // Escape comments if (substr($line, 0, 2) === '//') { if ($this->is_guiedit) { $this->comments[] = substr($line, 2); $line = '___COMMENT___'; } else { continue; } } // Extend TITLE by miko if (preg_match('/^(TITLE):(.*)$/', $line, $matches)) { global $newtitle; static $newbase; if (!isset($newbase)) { $newbase = trim(Utility::stripHtmlTags(RendererFactory::factory($matches[2]))); // For BugTrack/132. $newtitle = Utility::htmlsc($newbase); } continue; } if (preg_match('/^(LEFT|CENTER|RIGHT|JUSTIFY):(.*)$/', $line, $matches)) { // <div style="text-align:..."> $align = new Align(strtolower($matches[1])); $this->last = $this->last->add($align); if (empty($matches[2])) { continue; } $line = $matches[2]; } $line = rtrim($line, "\t\r\n\v"); // スペース以外の空白文字をトリム // Empty if (empty($line)) { $this->last =& $this; continue; } // Horizontal Rule if (substr($line, 0, 4) == '----') { $hrule = new HRule($this, $line); $this->insert($hrule); continue; } // Multiline-enabled block plugin #plugin{{ ... }} if (preg_match('/^#[^{]+(\\{\\{+)\\s*$/', $line, $matches)) { $len = strlen($matches[1]); $line .= self::MULTILINE_DELIMITER; while (!empty($lines)) { $next_line = preg_replace('/[' . self::MULTILINE_DELIMITER . '\\n]*$/', '', array_shift($lines)); if (preg_match('/\\}{' . $len . '}/', $next_line)) { $line .= $next_line; break; } else { $line .= $next_line .= self::MULTILINE_DELIMITER; } } } // The first character $head = $line[0]; // Heading if ($head === '*') { $heading = new Heading($this, $line); $this->insert($heading); continue; } // Pre if ($head === ' ' || $head === "\t") { $pre = new Pre($this, $line); $this->last = $this->last->add($pre); continue; } // CPre (Plus!) if (substr($line, 0, 2) === '# ' or substr($line, 0, 2) == "#\t") { $sharppre = new SharpPre($this, $line); $this->last = $this->last->add($sharppr); continue; } // Line Break if (substr($line, -1) === '~') { $line = substr($line, 0, -1) . "\r"; } // Other Character if (gettype($this->last) === 'object') { switch ($head) { case '-': $content = new UList($this, $line); break; case '+': $content = new OList($this, $line); break; case '>': case '<': $content = new Blockquote($this, $line); break; // ここからはファクトリークラスを通す // ここからはファクトリークラスを通す case ':': $content = ElementFactory::factory('DList', $this, $line); break; case '|': $content = ElementFactory::factory('Table', $this, $line); break; case ',': $content = ElementFactory::factory('YTable', $this, $line); break; case '#': if ($this->is_guiedit) { $content = ElementFactory::factory('PluginDummy', $this, $line); } else { $content = ElementFactory::factory('Plugin', $this, $line); } break; default: $content = ElementFactory::factory('InlineElement', null, $line); break; } // MathJax Expression if (PluginRenderer::hasPlugin('mathjax')) { $end_mark = ''; // 開始行によって終了行を判定する if (substr($line, 0, 2) === '\\[') { $end_mark = '\\]'; } else { if (substr($line, 0, 6) === '\\begin') { $end_mark = '\\end'; } } if ($end_mark) { while (!empty($lines)) { if (strpos($line, $end_mark) !== false) { break; } $next_line = preg_replace("/[\r\n]*\$/", '', array_shift($lines)); $line .= "\n" . ' ' . $next_line; } $mathjax = new BlockPlugin(array(null, 'mathjax', $line)); $this->last = $this->last->add($mathjax); continue; } } // Default $this->last = $this->last->add($content); unset($content); continue; } } }
/** * 見出しからIDを取得 * @param string $str 入力文字列 * @param boolean $strip 見出し編集用のアンカーを削除する * @return string */ public static function getHeading($str, $strip = TRUE) { // Cut fixed-heading anchors $id = $heading = ''; $matches = array(); if (preg_match(self::HEADING_ID_PATTERN, $str, $matches)) { // 先頭が*から始まってて、なおかつ[#...]が存在する $level = substr_count($matches[1], '*'); $heading = trim($matches[2]); $id = isset($matches[3]) ? $matches[3] : null; } else { $heading = preg_replace('/^\\*{0,3}/', '', $str); $level = 0; } // Cut footnotes and tags if ($strip === TRUE) { $heading = Utility::stripHtmlTags(InlineFactory::factory(preg_replace('/' . RendererDefines::NOTE_PATTERN . '/x', '', $heading))); } return array($heading, $id, $level); }
function plugin_edit_inline() { static $usage = '<span style="alert alert-warning">&edit(pagename,anchor);</span>'; global $vars, $fixed_heading_edited; $page = isset($vars['page']) ? $vars['page'] : null; // Arguments $args = func_get_args(); if (!empty($args[0])) { $page = $args[0]; } if (empty($page)) { return ''; } $wiki = Factory::Wiki($page); if (!$fixed_heading_edited || $wiki->isFreezed() || Auth::check_role('readonly')) { return ''; } // {label}. Strip anchor tags only $s_label = Utility::stripHtmlTags(array_pop($args), FALSE); $s_label_edit = empty($s_label) ? RendererDefines::PARTIAL_EDIT_LINK_ICON : $s_label; list($page, $id) = array_pad($args, 2, ''); if (!is_page($page)) { $page = $vars['page']; } $tag_edit = '<a class="anchor_super" id="edit_' . $id . '" href="' . $wiki->uri('edit', array('id' => $id)) . '" rel="nofollow">' . $s_label_edit . '</a>'; return $tag_edit; }
/** * ページのタイトルを取得 * @return string */ public function title() { $lines = self::get(); while (!empty($lines)) { $line = array_shift($lines); if (preg_match('/^(TITLE):(.*)$/', $line, $matches)) { return trim(Utility::stripHtmlTags(RendererFactory::factory($matches[2]))); } } return $this->page; }