Example #1
0
 public function setPattern($arr, $page)
 {
     global $foot_explain, $vars;
     list(, $body) = $this->splice($arr);
     // Recover of notes(miko)
     if (count($foot_explain) === 0) {
         self::$note_id = 0;
     }
     $script = !self::ALLOW_RELATIVE_FOOTNOTE_ANCHOR ? Factory::Wiki($page)->uri() : '';
     $id = ++self::$note_id;
     $note = InlineFactory::factory($body);
     $page = isset($vars['page']) ? rawurlencode($vars['page']) : null;
     // Footnote
     $foot_explain[$id] = '<li id="notefoot_' . $id . '">' . '<a href="' . $script . '#notetext_' . $id . '" class="note_super">' . RendererDefines::FOOTNOTE_ANCHOR_ICON . $id . '</a>' . $note . '</li>';
     if (!IS_MOBILE) {
         // A hyperlink, content-body to footnote
         if (!is_numeric(self::FOOTNOTE_TITLE_MAX) || self::FOOTNOTE_TITLE_MAX <= 0) {
             $title = '';
         } else {
             $title = strip_tags($note);
             $count = mb_strlen($title, SOURCE_ENCODING);
             $title = mb_substr($title, 0, self::FOOTNOTE_TITLE_MAX, SOURCE_ENCODING);
             $abbr = mb_strlen($title) < $count ? '...' : '';
             $title = ' title="' . $title . $abbr . '"';
         }
         $name = '<a id="notetext_' . $id . '" href="' . $script . '#notefoot_' . $id . '" class="note_super"' . $title . '>' . RendererDefines::FOOTNOTE_ANCHOR_ICON . $id . '</a>';
     } else {
         // モバイルは、ツールチップで代用
         $name = '<span class="note_super" aria-describedby="tooltip" data-msgtext="' . strip_tags($note) . '">' . RendererDefines::FOOTNOTE_ANCHOR_ICON . $id . '</span>';
     }
     return parent::setParam($page, $name, $body);
 }
Example #2
0
 public function __toString()
 {
     $this->aliases = self::getAutoAliasDict($this->name);
     if (empty($this->aliases)) {
         return;
     }
     $link = '[[' . $this->name . ']]';
     return InlineFactory::factory($link);
 }
Example #3
0
function plugin_read_action()
{
    global $vars, $_read_msg;
    $page = isset($vars['page']) ? Utility::stripBracket($vars['page']) : null;
    $ret = array('msg' => null, 'body' => null);
    $id = isset($vars['id']) ? $vars['id'] : null;
    if (!$page) {
        return $ret;
    }
    // 読み込むことができるページか
    $wiki = Factory::Wiki($page);
    if ($wiki->isReadable(true)) {
        return array('msg' => Utility::htmlsc($page), 'body' => $wiki->render($id));
        //return $ret;
    }
    global $referer;
    $referer = 0;
    // InterWikiNameに含まれるページか?
    // ?adv:FrontPageみたいな感じでアクセス
    if (preg_match('/^' . RendererDefines::INTERWIKINAME_PATTERN . '$/', $page, $match)) {
        $url = InterWikiName::getInterWikiUrl($match[2], $match[3]);
        if ($url == false) {
            return array('msg' => $_read_msg['title_invalied'], 'body' => sprintf($_read_msg['msg_ibvaliediw'], $match[2]));
        }
        Utility::redirect($url);
        return;
    }
    // AutoAliasに含まれるページか?
    $realpage = AutoAlias::getAutoAlias($page);
    if (count($realpage) === 1) {
        // AutoAliasの指定先のページを指定
        $a_wiki = Factory::Wiki($realpage);
        if ($a_wiki->isValied()) {
            Utility::redirect($a_wiki->link());
            return;
        } else {
            if (Utility::isUri($realpage)) {
                Utility::redirect($realpage);
                return;
            }
        }
    } else {
        if (count($realpage) >= 2) {
            $body = '<p>';
            $body .= $_read_msg['msg_invalidwn'] . '<br />';
            foreach ($realpage as $entry) {
                $link[] = '[[' . $entry . '>' . $entry . ']]&br;';
            }
            $body .= InlineFactory::Wiki(join("\n", $link));
            $body .= '</p>';
            return array('msg' => $_read_msg['title_invalied'], 'body' => $body);
        }
    }
    Utility::notfound();
    exit;
}
Example #4
0
 public function __toString()
 {
     $body = empty($this->body) ? null : InlineFactory::factory($this->body);
     $str = FALSE;
     // Try to call the plugin
     $str = PluginRenderer::executePluginInline($this->name, $this->param, $body);
     if ($str !== FALSE) {
         return $str;
         // Succeed
     } else {
         // No such plugin, or Failed
         $body = (empty($body) ? '' : '{' . $body . '}') . ';';
         return parent::setLineRules(Utility::htmlsc('&' . $this->plain) . $body);
     }
 }
Example #5
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 #6
0
 public function toString()
 {
     static $saved_glossary, $saved_autolink, $make_link;
     global $glossary, $autolink;
     // 変換されるのを防ぐため、一時的にGlossaryとAutoLinkを無効化する
     $saved_glossary = $glossary;
     $saved_autolink = $autolink;
     $glossary = FALSE;
     $autolink = FALSE;
     // 変換処理
     $ret = InlineFactory::factory($this->elements);
     // GlossaryとAutoLinkをもとに戻す
     $autolink = $saved_autolink;
     $glossary = $saved_glossary;
     return $this->wrap($ret, 'pre');
 }
Example #7
0
 /**
  * Get Vote Form HTML for convert plugin
  *
  * @static
  * @param array $votes
  * @param integer $vote_id vote form id
  * @global $vars
  * @global $vars['page']
  * @global $defaultpage
  * @global $digest
  * @var $options 'readonly'
  * @var $options 'addchoice'
  * @uses get_script_uri()
  * @return string
  */
 function get_vote_form_convert($votes, $vote_id)
 {
     // Initilization
     global $vars, $defaultpage;
     global $digest;
     $page = isset($vars['page']) ? $vars['page'] : $defaultpage;
     $script = $this->options['readonly'] ? '' : get_script_uri();
     $submit = $this->options['readonly'] ? 'hidden' : 'submit';
     $anchor = $this->get_anchor('convert', $vote_id);
     // Header
     $form[] = '<div class="table_wrapper">';
     if (!$this->options['readonly']) {
         $form[] = '<form class="vote_form" action="' . get_script_uri() . '" method="post">';
         $form[] = '<input type="hidden" name="cmd"     value="vote" />';
         $form[] = '<input type="hidden" name="pcmd"    value="convert" />';
         $form[] = '<input type="hidden" name="refer"   value="' . htmlsc($page) . '" />';
         $form[] = '<input type="hidden" name="vote_id" value="' . htmlsc($vote_id) . '" />';
         $form[] = '<input type="hidden" name="digest"  value="' . htmlsc($digest) . '" />';
     }
     $form[] = '<table class="table plugin-vote-table" summary="vote" id="' . $anchor . '" data-pagenate="false">';
     $form[] = '<thead>';
     $form[] = '<tr>';
     $form[] = '<th>' . T_('Selection') . '</th>';
     $form[] = '<th>' . T_('Points') . '</th>';
     $form[] = $this->options['readonly'] ? null : '<th>' . T_('Vote') . '</th>';
     $form[] = '</tr>';
     $form[] = '</thead>';
     // Body
     $form[] = '<tbody>';
     foreach ($votes as $choice_id => $vote) {
         list($choice, $count) = $vote;
         $form[] = '<tr>' . "\n";
         $form[] = '<td class="vote_choise_td">' . InlineFactory::factory($choice) . '</td>';
         $form[] = '<td class="vote_count_td"><var>' . Utility::htmlsc($count) . '</var></td>';
         $form[] = $this->options['readonly'] ? null : '<td class="vote_form_td"><input type="submit" class="btn btn-secondary" name="' . $this->encode_choice($choice_id) . '" value="' . T_('Vote') . '" /></td>';
         $form[] = '</tr>';
     }
     $form[] = '</tbody>';
     // add choice
     if ($this->options['addchoice'] && !$this->options['readonly']) {
         $choice_id++;
         $choice_key = $this->encode_choice($choice_id);
         $form[] = '<tfoot>';
         $form[] = '<tr>';
         $form[] = '<th colspan="2">';
         $form[] = '<input type="text" style="width:90%;" name="addchoice" value="" placeholder="' . T_('Item name') . '" class="form-control" />';
         $form[] = '</th>';
         $form[] = '<th>';
         $form[] = '<input type="' . $submit . '" class="btn btn-primary" name="' . $choice_key . '" value="' . T_('Add') . '" class="submit" />';
         $form[] = '</th>';
         $form[] = '</tr>';
         $form[] = '</tfoot>';
     }
     // Footer
     $form[] = '</table>';
     if (!$this->options['readonly']) {
         $form[] = '</form>';
     }
     $form[] = '</div>';
     return join("\n", $form);
 }
Example #8
0
function make_link($string, $page = '')
{
    return InlineFactory::factory($string, $page);
}
Example #9
0
 public function __toString()
 {
     $body = empty($this->body) ? '' : InlineFactory::factory($this->body);
     return PluginRenderer::executePluginInline($this->name, $this->param, $body);
 }
Example #10
0
 /**
  * 見出しから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);
 }
Example #11
0
 public function __construct($text)
 {
     parent::__construct();
     $this->elements[] = trim(substr($text, 0, 1) === "\n" ? $text : InlineFactory::factory($text));
 }