/** * 差分をHTMLにして出力 * @return string */ public function render() { foreach (self::get() as $line) { // 先頭の1文字だけを抜き出す $str = Utility::htmlsc(substr($line, 1)); if ($str === '') { // 空行 $ret[] = ' '; continue; } switch (substr($line, 0, 1)) { case '+': $ret[] = '+<ins class="diff_added">' . $str . '</ins>'; break; case '-': $ret[] = '-<del class="diff_removed">' . $str . '</del>'; break; case '/': $ret[] = '/' . $str; break; default: $ret[] = ' ' . $str; break; } } return '<pre class="sh sunlight-highlight-diff">' . "\n" . join("\n", $ret) . '</pre>'; }
function plugin_region_convert() { static $first = 0; // at first call $usage = '<p class="alert alert-warning">#region usage: <code>#region(title){{ content }}</code> or <code>#region([[Pagename#hash]])</code></p>'; $title = $body = ''; $args = func_get_args(); $num = func_num_args(); $title = array_shift($args); if ($num === 1) { // BlacketNameだった場合、そのページをajaxで取得 if (preg_match('/^\\[\\[(.*)\\]\\]$/', $title, $match)) { $ret[] = '<div class="plugin-region clearfix">'; $ret[] = '<div class="plugin-region-title">' . RendererFactory::factory($title) . '</div>'; $ret[] = '<div class="plugin-region-body" data-page="' . $match[1] . '"></div>'; $ret[] = '</div>'; return join("\n", $ret); } } else { if ($num === 2) { $ret[] = '<div class="plugin-region clearfix">'; $ret[] = '<div class="plugin-region-title">' . Utility::htmlsc($title) . '</div>'; $ret[] = '<div class="plugin-region-body">' . RendererFactory::factory(array_pop($args)) . '</div>'; $ret[] = '</div>'; return join("\n", $ret); } } return $usage; }
function replace_do($search, $replace, $notimestamp) { global $cycle, $cantedit; global $_replace_msg; // パスワードが合ってたらいよいよ置換 $pages = Auth::get_existpages(); $replaced_pages = array(); foreach ($pages as $page) { $wiki = Factory::Wiki($page); if ($wiki->isEditable(false, REPLACE_IGNORE_FREEZE)) { // パスワード一致 $postdata = array(); foreach ($wiki->get() as $line) { // キーワードの置換 $postdata[] = str_replace($search, $replace, $line); } if (md5(join("\n", $postdata)) !== $wiki->digest()) { $cycle = 0; set_time_limit(30); $wiki->set($postdata, $notimestamp); $replaced_pages[] = '<li><a href="' . $wiki->uri() . '">' . Utility::htmlsc($page) . '</a></li>'; } } } $vars['cmd'] = 'read'; if (count($replaced_pages) == 0) { return array('msg' => $_replace_msg['msg_H0_no_data'], 'body' => '<p class="alert alert-danger">' . $_replace_msg['msg_no_replaced'] . '</p>'); } return array('msg' => $_replace_msg['msg_H0_replaced'], 'body' => '<p class="alert alert-success">' . $_replace_msg['msg_replaced'] . '</p>' . "\n" . '<ul>' . join("\n", $replaced_pages) . '</ul>'); }
function print_form_string($list) { global $vars; $form_string[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline">'; $form_string[] = '<fieldset>'; $form_string[] = '<legend>' . T_('Page name') . '</legend>'; if ($list['directory']) { $form_string[] = '<div class="form-group">'; $form_string[] = '<select name="directory" class="form-control">'; foreach ($list['directory'] as $dir) { $form_string[] = '<option>' . Utility::htmlsc($dir) . '/</option>'; } $form_string[] = '</select>'; $form_string[] = '</div>'; } $form_string[] = '<input type="hidden" name="cmd" value="newpage_subdir" />'; $form_string[] = isset($vars['page']) ? '<input type="hidden" name="refer" value="' . $vars['page'] . '" />' : null; $form_string[] = '<div class="form-group">'; $form_string[] = '<input type="text" name="page" size="30" value="" class="form-control" />'; $form_string[] = '</div>'; $form_string[] = '<input type="submit" class="btn btn-primary" value="' . T_('New') . '" />'; $form_string[] = '</fieldset>'; $form_string[] = '</form>'; if (isset($list['warning']) && $list['warning']) { $form_string[] = '<p>'; foreach ($list['warning'] as $warning) { $form_string[] = $warning; } $form_string[] = '</p>'; } return join("\n", $form_string); }
function plugin_newpage_convert() { global $vars, $_newpage_messages; static $id = 0; // if (PKWK_READONLY) return ''; // Show nothing if (Auth::check_role('readonly')) { return ''; } // Show nothing if (Auth::is_check_role(PKWK_CREATE_PAGE)) { return ''; } $newpage = ''; if (func_num_args()) { list($newpage) = func_get_args(); } if (!preg_match('/^' . RendererDefines::BRACKETNAME_PATTERN . '$/', $newpage)) { $newpage = ''; } $s_page = Utility::htmlsc(isset($vars['refer']) ? $vars['refer'] : ''); $s_newpage = Utility::htmlsc($newpage); ++$id; $script = get_script_uri(); $ret = <<<EOD <form action="{$script}" method="post" class="form-inline plugin-newpage-form"> \t<input type="hidden" name="cmd" value="edit" /> \t<input type="hidden" name="refer" value="{$s_page}" /> \t<div class="form-group"> \t\t<input type="text" class="form-control" name="page" id="p_newpage_{$id}" value="{$s_newpage}" size="30" placeholder="{$_newpage_messages['form_pagename']}" /> \t</div> \t<input type="submit" value="{$_newpage_messages['btn_new']}" class="btn btn-primary" /> </form> EOD; return $ret; }
function convertRef($args, $div = TRUE) { $options = Utility::htmlsc(join(',', $args)); $filename = array_shift($args); $_title = array(); $params = array('left' => 0, 'center' => 0, 'right' => 0, 'wrap' => 0, 'nowrap' => 0, 'around' => 0, 'noicon' => 0, 'nolink' => 0, 'noimg' => 0, 'zoom' => 0, '_w' => 0, '_h' => 0, '_size' => '%'); // パラメータ解析 foreach ($args as $arg) { $s_arg = strtolower($arg); if (array_key_exists($s_arg, $params)) { $params[$s_arg] = 1; } else { if (preg_match('/^([0-9]+)x([0-9]+)$/', $arg, $matches)) { $params['_w'] = $matches[1]; $params['_h'] = $matches[2]; $params['_size'] = 'px'; } else { if (preg_match('/^([0-9.]+)%$/', $arg, $matches) && $matches[1] > 0) { $params['_w'] = $matches[1]; } else { $_title[] = $arg; } } } } $align = ''; if ($params['left']) { $align = 'left'; } else { if ($params['center']) { $align = 'center'; } else { if ($params['right']) { $align = 'right'; } } } $alt = !empty($_title) ? Utility::htmlsc(join(',', $_title)) : ''; $alt = preg_replace("/^,/", '', $alt); $attribute = 'class="bg-primary" contenteditable="false"' . (UA_NAME == MSIE ? '' : ' style="cursor:default"'); $attribute .= ' _filename="' . $filename . '"'; $attribute .= ' _alt="' . $alt . '"'; $attribute .= ' _width="' . ($params['_w'] ? $params['_w'] : '') . '"'; $attribute .= ' _height="' . ($params['_h'] ? $params['_h'] : '') . '"'; $attribute .= ' _size="' . $params['_size'] . '"'; $attribute .= ' _align="' . $align . '"'; $attribute .= ' _wrap="' . $params['wrap'] . '"'; $attribute .= ' _around="' . $params['around'] . '"'; $attribute .= ' _nolink="' . $params['nolink'] . '"'; $attribute .= ' _noicon="' . $params['noicon'] . '"'; $attribute .= ' _noimg="' . $params['noimg'] . '"'; $attribute .= ' _zoom="' . $params['zoom'] . '"'; if ($div) { $tags = "<div {$attribute}>#ref({$options})</div>"; } else { $tags = "<span {$attribute}>&ref({$options});</span>"; } return $tags; }
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; }
function plugin_description_convert() { global $description; $num = func_num_args(); if ($num == 0) { return '<p class="alert alert-warning">Usage: #description(description)</p>'; } $args = func_get_args(); $description = Utility::htmlsc($args[0]); return ''; }
function plugin_unfreeze_action() { global $vars, $function_freeze, $_unfreeze_msg; $page = isset($vars['page']) ? $vars['page'] : ''; $wiki = Factory::Wiki($page); if (!$function_freeze || !$wiki->isEditable(false, true) || !$wiki->isValied($page)) { return array('msg' => $_unfreeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to unfreeze this page.</p>'); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = ''; $body = array(); if (!$wiki->isFreezed()) { // Unfreezed already $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_isunfreezed']); $body[] = '<p class="alert alert-info">' . $msg . '</p>'; } else { if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) { // BugTrack2/255 $wiki->checkReadable(); // Unfreeze $postdata = $wiki->get(); array_shift($postdata); $wiki->set($postdata); // Update if (PLUGIN_UNFREEZE_EDIT) { // BugTrack2/255 $wiki->checkEditable(true); // $vars['cmd'] = 'read'; // To show 'Freeze' link $vars['cmd'] = 'edit'; } else { $vars['cmd'] = 'read'; } $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_unfreezed']); $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p>'; $body[] = '<div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>'; Utility::redirect($wiki->uri()); exit; } else { // Show unfreeze form $msg = $_unfreeze_msg['title_unfreeze']; $body[] = $pass === NULL ? '' : '<p class="alert alert-danger">' . $_unfreeze_msg['msg_invalidpass'] . '</p>' . "\n"; $body[] = '<fieldset>'; $body[] = '<legend>' . $_unfreeze_msg['msg_unfreezing'] . '</legend>'; $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">'; $body[] = '<input type="hidden" name="cmd" value="unfreeze" />'; $body[] = '<input type="hidden" name="page" value="' . Utility::htmlsc($page) . '" />'; $body[] = '<input type="password" name="pass" size="12" class="form-control" />'; $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_unfreeze_msg['btn_unfreeze'] . '</button>'; $body[] = '</form>'; $body[] = '</fieldset>'; } } return array('msg' => $msg, 'body' => join("\n", $body)); }
public function setPattern($arr, $page) { list(, $alias, , $this->interwikiname, $this->param) = $this->splice($arr); $matches = array(); if (preg_match('/^([^#]+)(#[A-Za-z][\\w-]*)$/', $this->param, $matches)) { list(, $this->param, $this->anchor) = $matches; } $url = self::getInterWikiUrl($this->interwikiname, $this->param); if ($url === FALSE) { return $this->interwikiname . ':' . $this->param; } $this->url = Utility::htmlsc($url); return parent::setParam($page, Utility::htmlsc($this->interwikiname . ':' . $this->param), null, 'InterWikiName', empty($alias) ? $this->interwikiname . ':' . $this->param : $alias); }
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); } }
function plugin_freeze_action() { global $vars, $function_freeze, $_freeze_msg; $page = isset($vars['page']) ? $vars['page'] : null; if (is_null($page)) { return array('msg' => 'Not Found', 'body' => 'Page not found'); } $wiki = Factory::Wiki($page); if (!$function_freeze || !$wiki->isEditable(true) || !$wiki->has()) { return array('msg' => $_freeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to freeze this page.</p>'); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = ''; $body = array(); if ($wiki->isFreezed()) { // Freezed already $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_isfreezed']); $body[] = '<p class="alert alert-info">' . $msg . '</p>'; } else { if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) { // Freeze $postdata = $wiki->get(); array_unshift($postdata, "#freeze"); //凍結をページに付加 $wiki->set($postdata, true); // Update //$wiki->is_freezed(); $vars['cmd'] = 'read'; $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_freezed']); $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p><div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>'; } else { // Show a freeze form $msg = $_freeze_msg['title_freeze']; $body[] = $pass === NULL ? '' : '<p class="alert alert-warning">' . $_freeze_msg['msg_invalidpass'] . '</p>'; $body[] = '<fieldset>'; $body[] = '<legend>' . $_freeze_msg['msg_freezing'] . '</legend>'; $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">'; $body[] = '<input type="hidden" name="cmd" value="freeze" />'; $body[] = '<input type="hidden" name="page" value="' . Utility::htmlsc($page) . '" />'; $body[] = '<input type="password" name="pass" size="12" class="form-control" />'; $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_freeze_msg['btn_freeze'] . '</button>'; $body[] = '</form>'; $body[] = '</fieldset>'; } } return array('msg' => $msg, 'body' => join("\n", $body)); }
function legend_set_parm($argv) { $parm = array(); $parm['align'] = $parm['title'] = ''; foreach ($argv as $arg) { $val = explode('=', $arg); $val[1] = Utility::htmlsc(empty($val[1]) ? $val[0] : $val[1]); switch ($val[0]) { case 'r': case 'right': $parm['align'] = 'right'; break; case 'l': case 'left': $parm['align'] = 'left'; break; case 'c': case 'center': $parm['align'] = 'center'; break; /* case 't': case 'top': $parm['align'] = 'top'; break; case 'b': case 'bottom': $parm['align'] = 'bottom'; break; */ /* case 't': case 'top': $parm['align'] = 'top'; break; case 'b': case 'bottom': $parm['align'] = 'bottom'; break; */ default: $parm['title'] = $val[1]; // $parm[$val[0]] = $val[1]; } } return $parm; }
function plugin_source_action() { global $vars; //, $_source_messages; // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this'); if (Auth::check_role('safemode')) { Utility::dieMessage('PKWK_SAFE_MODE prohibits this'); } $page = isset($vars['page']) ? $vars['page'] : ''; $vars['refer'] = $page; $wiki = Factory::Wiki($page); if (!$wiki->isValied() || !$wiki->isReadable()) { return array('msg' => T_(' $1 was not found.'), 'body' => T_('cannot display the page source.')); } $source = $wiki->get(true); Auth::is_role_page($source); return array('msg' => T_('Source of $1'), 'body' => '<pre class="sh sunlight-highlight-plain">' . Utility::htmlsc($source) . '</pre>'); }
function plugin_redirect_convert() { $argv = func_get_args(); $argc = func_num_args(); $field = array('caption', 'url', 'img'); for ($i = 0; $i < $argc; $i++) { ${$field}[$i] = Utility::htmlsc($argv[$i], ENT_QUOTES); } if (empty($url)) { return 'usage: #redirect(caption, url, img)'; } if (empty($caption)) { $caption = 'no title'; } if (!empty($img)) { $caption = '<img src="' . $img . '" alt="' . $caption . '" title="' . $caption . '" />'; } return Inline::setLink($caption, $url, null, 'noreferer', true); }
function plugin_tooltip_inline($args) { $args = func_get_args(); $glossary = array_pop($args); $term = array_shift($args); if (empty($glossary)) { $glossary = Glossary::getGlossary($term); // $debug .= "B=$glossary/"; if ($glossary === FALSE) { $glossary = plugin_tooltip_get_page_title($term); if ($glossary === FALSE) { $glossary = ''; } } } $s_glossary = Utility::htmlsc($glossary); $page = Utility::stripBracket($term); $wiki = Factory::Wiki($page); if ($wiki->isValied() && $wiki->isReadable()) { return '<abbr class="glossary" title="' . $s_glossary . ' ' . $wiki->passage(false, false) . '"><a href="' . $wiki->uri() . '">' . $term . '</a></abbr>'; } return '<abbr title="' . $s_glossary . '">' . $term . '</abbr>'; }
public static function convert($line, $link = TRUE, $enc = TRUE) { if ($enc) { $line = preg_replace("/&/", "&", $line); $line = Utility::htmlsc($line); } // インライン・プラグイン $pattern = '/&(\\w+)(?:\\(((?:(?!\\)[;{]).)*)\\))?(?:\\{((?:(?R)|(?!};).)*)\\})?;/'; $line = preg_replace_callback($pattern, array(&$this, 'convert_plugin'), $line); // ルールの変換 $line = guiedit_make_line_rules($line); // 文字サイズの変換 $pattern = "/<span\\s(style=\"font-size:(\\d+)px|class=\"size([1-7])).*?>/"; $line = preg_replace_callback($pattern, array(&$this, 'convert_size'), $line); // 色の変換 $pattern = "/<sapn\\sstyle=\"color:([#0-9a-z]+)(; background-color:([#0-9a-z]+))?\">/"; $line = preg_replace_callback($pattern, array(&$this, 'convert_color'), $line); // 注釈 $line = preg_replace("/\\(\\(((?:(?R)|(?!\\)\\)).)*)\\)\\)/", "<img alt=\"Note\" title=\"\$1\" />", $line); // 参照文字 $line = preg_replace('/&(#?[a-z0-9]+);/', "&\$1;", $line); // 上付き文字 $line = preg_replace('/SUP{(.*?)}/', "<sup>\$1</sup>", $line); // 下付き文字・添え字 $line = preg_replace('/SUB{(.*?)}/', "<sub>\$1</sub>", $line); // リンク if ($link) { $pattern = "/\\(\\(((?:(?R)|(?!\\)\\)).)*)\\)\\)/"; $replace = "<img alt=\"Note\" title=\"\$1\" />"; $line = $this->make_link($line); } if (preg_match("/^<br\\s\\/>\$/", $line)) { $line .= "\n "; } return $line; }
function plugin_panel_convert() { $title = $body = ''; $type = ''; $num_of_arg = func_num_args(); $args = func_get_args(); switch ($num_of_arg) { default: return '<p class="alert alert-warning">#panel(title[,type]){{body}}</p>'; break; case 1: $body = $args[0]; break; case 2: $title = $args[0]; $body = $args[1]; break; case 3: $title = $args[0]; $type = $args[1]; $body = $args[2]; break; } if (preg_match('/^(primary|info|warning|danger)$/', $type) === 0) { $type = 'default'; } $ret[] = '<div class="panel panel-' . $type . '">'; if (!empty($title)) { $ret[] = '<div class="panel-heading">' . Utility::htmlsc($title) . '</div>'; } else { $body = str_replace(array(chr(0xd) . chr(0xa), chr(0xd), chr(0xa)), "\n", $body); } $ret[] = '<div class="panel-body">' . RendererFactory::factory($body) . '</div>'; $ret[] = '</div>'; return join("\n", $ret); }
function plugin_recent_convert() { global $vars, $date_format, $link_compact, $page_title; // , $_recent_plugin_frame; static $exec_count = 1; global $cache; if (empty($vars['page'])) { return null; } $recent_lines = PLUGIN_RECENT_DEFAULT_LINES; $args = func_get_args(); if (!empty($args)) { if (isset($args[1]) || !is_numeric($args[0])) { return PLUGIN_RECENT_USAGE . '<br />'; } $recent_lines =& $args[0]; } if ($exec_count++ > PLUGIN_RECENT_EXEC_LIMIT) { return '<div class="alert alert-warning">#recent(): You called me too much.</div>' . "\n"; } $date = ''; $items = array(); $lines = Recent::get(); if ($lines !== null) { $count = count($lines) < $recent_lines ? count($lines) : $recent_lines; $i = 0; foreach ($lines as $page => $time) { $wiki = Factory::Wiki($page); if (!$wiki->isReadable()) { continue; } //if (! $wiki->isHidden()) continue; if ($i > $count) { break; } $s_page = Utility::htmlsc($page); $_date = get_date($date_format, $time); if (!IS_MOBILE) { if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[$_date][] = ' <li>' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . $wiki->passage(false, true) : ''; $items[$_date][] = ' <li><a href="' . $wiki->uri() . '" title="' . $s_page . $passage . '">' . $s_page . '</a></li>'; } } else { if ($date !== $_date) { // New day $date = $_date; $items[] = '<li data-role="list-divider">' . $date . '</li>'; } if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[] = ' <li data-theme="e">' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . '<span class="ui-li-count">' . $wiki->passage(false, false) . '</span>' : ''; $items[] = ' <li><a href="' . $wiki->uri() . '" data-transition="slide">' . $s_page . $passage . '</a></li>'; } } $i++; } unset($lines, $i); } $_recent_title = sprintf(T_('recent(%d)'), $count); if (!IS_MOBILE) { // End of the day $ret[] = '<div class="plugin-recent">'; $ret[] = '<h5>' . $_recent_title . '</h5>'; $ret[] = '<div class="hslice" id="webslice">'; $ret[] = '<span class="entry-title" style="display:none;">' . $page_title . '</span>'; $ret[] = '<div class="entry-content">'; $ret[] = '<ul class="list-unstyled">'; foreach ($items as $date => $entries) { $ret[] = '<li><strong>' . $date . '</strong><ul>'; foreach ($entries as $entry) { $ret[] = $entry; } $ret[] = '</ul></li>'; } $ret[] = '</ul>'; $ret[] = '</div>'; $ret[] = '</div>'; $ret[] = '</div>'; return join("\n", $ret); } else { return '<ul data-role="listview" data-dividertheme="b">' . "\n" . '<li data-theme="a">' . $_recent_title . '</li>' . "\n" . join("\n", $items) . '</ul>' . "\n"; } }
function plugin_guiedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $vars; global $load_template_func, $whatsnew; global $_button; global $notimeupdate; global $js_tags, $link_tags, $js_blocks; global $guiedit_use_fck; $script = get_script_uri(); // Newly generate $digest or not if ($digest === FALSE) { $digest = md5(get_source($page, TRUE, TRUE)); } $s_id = isset($vars['id']) ? Utility::htmlsc($vars['id']) : ''; if (!$guiedit_use_fck) { $body = edit_form($page, $postdata, $digest, $b_template); $pattern = "/(<input\\s+type=\"hidden\"\\s+name=\"cmd\"\\s+value=\")edit(\"\\s*\\/?>)/"; $replace = "\$1guiedit\$2\n" . ' <input type="hidden" name="id" value="' . $s_id . '" />' . ' <input type="hidden" name="text" value="1" />'; $body = preg_replace($pattern, $replace, $body); return $body; } // require_once(GUIEDIT_CONF_PATH . 'guiedit.ini.php'); // フォームの値の設定 $s_digest = Utility::htmlsc($digest); $s_page = Utility::htmlsc($page); $s_original = Utility::htmlsc($vars['original']); $s_ticket = md5(MUTIME); if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) { // BugTrack/95 fix Problem: browser RSS request with session $_SESSION[$s_ticket] = md5(get_ticket() . $digest); $_SESSION['origin' . $s_ticket] = md5(get_ticket() . str_replace("\r", '', $s_original)); } // テンプレート $template = ''; if ($load_template_func) { global $guiedit_non_list; $pages = array(); foreach (get_existpages() as $_page) { if ($_page == $whatsnew || check_non_list($_page)) { continue; } foreach ($guiedit_non_list as $key) { $pos = strpos($_page . '/', $key . '/'); if ($pos !== FALSE && $pos == 0) { continue 2; } } $_s_page = Utility::htmlsc($_page); $pages[$_page] = ' <option value="' . $_s_page . '">' . $_s_page . '</option>'; } ksort($pages); $s_pages = join("\n", $pages); $template = <<<EOD <select name="template_page"> \t<option value="">-- {$_button['template']} --</option> {$s_pages} </select> <br /> EOD; } // チェックボックス「タイムスタンプを変更しない」 $add_notimestamp = ''; if ($notimeupdate != 0) { $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; // if ($notimeupdate == 2) { if ($notimeupdate == 2 && Auth::check_role('role_contents_admin')) { $add_notimestamp = ' ' . '<input type="password" name="pass" size="12" />' . "\n"; } $add_notimestamp = '<input type="checkbox" name="notimestamp" ' . 'id="_edit_form_notimestamp" value="true"' . $checked_time . ' />' . "\n" . ' ' . '<label for="_edit_form_notimestamp"><span class="small">' . $_button['notchangetimestamp'] . '</span></label>' . "\n" . $add_notimestamp . ' '; } // フォーム $body = <<<EOD <div id="guiedit"> \t<form id="guiedit_form" action="{$script}" method="post" style="margin-bottom:0px;"> \t{$template} \t\t<input type="hidden" name="cmd" value="guiedit" /> \t\t<input type="hidden" name="page" value="{$s_page}" /> \t\t<input type="hidden" name="digest" value="{$s_digest}" /> \t\t<input type="hidden" name="ticket" value="{$s_ticket}" /> \t\t<input type="hidden" name="id" value="{$s_id}" /> \t\t<textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> \t\t<textarea name="msg" id="editor"></textarea> \t\t<div class="pull-left"> \t\t<button type="submit" name="write" accesskey="s" class="btn btn-primary">{$_button['update']}</button> \t\t<button type="button" name="preview" accesskey="p" class="btn btn-secondary">{$_button['preview']}</button> \t\t{$add_notimestamp} \t\t</div> \t</form> \t<form action="{$script}" method="post"> \t\t<input type="hidden" name="cmd" value="guiedit" /> \t\t<input type="hidden" name="page" value="{$s_page}" /> \t\t<input type="submit" name="cancel" value="{$_button['cancel']}" class="btn btn-warning" accesskey="c" /> \t</form> </div> EOD; $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/ckeditor.js', 'defer' => 'defer'); $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/adapters/jquery.js', 'defer' => 'defer'); $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/plugin/guiedit/guiedit.js', 'defer' => 'defer'); return $body; }
function htmlsc($string = '', $flags = ENT_QUOTES, $charset = 'UTF-8') { return Utility::htmlsc($string, $flags, $charset); }
private function comment($matches) { $comments = explode("\n", $matches[0]); foreach ($comments as &$comment) { $comment = array_shift($this->comments); } $comment = join("\n", $comments); return '<span class="fa fa-comment" title="' . Utility::htmlsc($comment) . '"></span>'; }
/** * ログファイルを読む */ public function get($join = false, $legacy = false) { if (!$this->isFile()) { return false; } if (!$this->isReadable()) { Utility::dieMessage(sprintf('LogFile.php : File <var>%s</var> is not readable.', Utility::htmlsc($this->filename))); } $name = self::get_log_field($this->kind); // ファイルの読み込み $file = $this->openFile('r'); // ロック $file->flock(LOCK_SH); // 巻き戻し(要るの?) $file->rewind(); // 初期値 $result = array(); // 1行毎ファイルを読む while (!$file->eof()) { $line = $file->fgets(); $result[] = self::line2field($line, $name); } // アンロック $file->flock(LOCK_UN); // 念のためオブジェクトを開放 unset($file); rsort($result); // 逆順にソート(最新順になる) // 出力 return $result; }
function plugin_ls2_get_headings($page, &$params, $level, $include = FALSE) { static $_ls2_anchor = 0; // ページが未表示のとき $is_done = isset($params["page_{$page}"]) && $params["page_{$page}"] > 0; if (!$is_done) { $params["page_{$page}"] = ++$_ls2_anchor; } $s_page = Utility::htmlsc($page); $wiki = Factory::Wiki($page); $title = $s_page . ' ' . $wiki->passage(false, true); $href = $wiki->uri(); plugin_ls2_list_push($params, $level); $ret = $include ? '<li>include ' : '<li>'; if ($params['title'] && $is_done) { $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> '; $ret .= '<a href="#list_' . $params["page_{$page}"] . '"><sup>↑</sup></a>'; array_push($params['result'], $ret); return; } $ret .= '<a id="list_' . $params["page_{$page}"] . '" href="' . $href . '" title="' . $title . '">' . $s_page . '</a>'; array_push($params['result'], $ret); $anchor = PLUGIN_LS2_ANCHOR_ORIGIN; $matches = array(); foreach ($wiki->get() as $line) { if ($params['title'] && preg_match('/^(\\*{1,3})/', $line, $matches)) { list($heading, $id) = Rules::getHeading($line); $level = strlen($matches[1]); plugin_ls2_list_push($params, $level + strlen($level)); array_push($params['result'], '<li><a href="' . $href . '#' . $id . '">' . $heading . '</a>'); } else { if ($params['include'] && preg_match('/^#include\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { plugin_ls2_get_headings($matches[1], $params, $level + 1, TRUE); } } } }
function plugin_edit_write() { global $vars, $trackback, $_string, $_msg_edit; global $notimeupdate; $page = isset($vars['page']) ? $vars['page'] : null; $add = isset($vars['add']) ? $vars['add'] : null; $digest = isset($vars['digest']) ? $vars['digest'] : null; $partid = isset($vars['id']) ? $vars['id'] : null; $notimestamp = isset($vars['notimestamp']) && $vars['notimestamp'] !== null; if (empty($page)) { return array('mgs' => 'Error', 'body' => $_msg_edit['err_empty_page']); } $wiki = Factory::Wiki($page); // Check Validate and Ticket if ($notimestamp && !$wiki->isValied()) { return plugin_edit_honeypot(); } // Validate if (is_spampost(array('msg'))) { return plugin_edit_honeypot(); } // Paragraph edit mode if ($partid) { $source = preg_split('/([^\\n]*\\n)/', $vars['original'], -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $vars['msg'] = plugin_edit_parts($partid, $source, $vars['msg']) !== FALSE ? join('', $source) : rtrim($vars['original']) . "\n\n" . $vars['msg']; } $retvars = array(); if (isset($vars['msg']) && !empty($vars['msg'])) { // Delete "#freeze" command for form edit. $vars['msg'] = preg_replace('/^#freeze\\s*$/im', '', $vars['msg']); $msg = $vars['msg']; // Reference // Action? if ($add) { // Compat: add plugin and adding contents $postdata = isset($vars['add_top']) && $vars['add_top'] ? $msg . "\n\n" . $oldpagesrc : $oldpagesrc . "\n\n" . $msg; } else { // Edit or Remove $postdata =& $msg; } } else { // CAPTCHAが有効なときで、ページを削除しようとした時、$vars['msg']は空になる。 $wiki->set(''); $retvars['msg'] = sprintf($_msg_edit['title_deleted'], Utility::htmlsc($page)); $retvars['body'] = '<p class="alert alert-success">' . sprintf($_msg_edit['title_deleted'], Utility::htmlsc($page)) . '</p>'; return $retvars; } // $notimeupdate: Checkbox 'Do not change timestamp' // $notimestamp = isset($vars['notimestamp']) && $vars['notimestamp'] != ''; // if ($notimeupdate > 1 && $notimestamp && ! pkwk_login($vars['pass'])) { if ($notimeupdate > 1 && $notimestamp && Auth::check_role('role_contents_admin') && !pkwk_login($vars['pass'])) { // Enable only administrator & password error $retvars['body'] = '<p class="alert alert-danger">' . $_msg_edit['msg_invalidpass'] . '</p>' . "\n"; $retvars['body'] .= Utility::editForm($page, $msg, FALSE); return $retvars; } $wiki->set($postdata, $notimeupdate !== 0 && $notimestamp); if (isset($vars['refpage']) && $vars['refpage'] !== '') { $refwiki = Factory::Wiki($vars['refpage']); $url = $partid ? $refwiki->uri('read', null, rawurlencode($partid)) : $refwiki->uri(); } else { $url = $partid ? $wiki->uri('read', null, rawurlencode($partid)) : $wiki->uri(); } if (isset($vars['ajax'])) { $headers = Header::getHeaders('application/json'); Header::writeResponse($headers, 200, Json::encode(array('msg' => 'Your post has been saved.', 'posted' => true, 'taketime' => Time::getTakeTime()))); } else { Utility::redirect($url); } exit; }
function plugin_include_convert() { global $vars, $get, $post, $menubar, $sidebar; static $included = array(); static $count = 1; $_msg_include_restrict = T_('Due to the blocking, $1 cannot be include(d).'); if (func_num_args() == 0) { return '<p class="alert alert-warning">' . PLUGIN_INCLUDE_USAGE . '</p>' . "\n"; } // $menubar will already be shown via menu plugin if (!isset($included[$menubar])) { $included[$menubar] = TRUE; } // Loop yourself $root = isset($vars['page']) ? $vars['page'] : ''; $included[$root] = TRUE; // Get arguments $args = func_get_args(); // strip_bracket() is not necessary but compatible $page = isset($args[0]) ? array_shift($args) : null; $wiki = Factory::Wiki(Utility::getPageName($page, $root)); $with_title = PLUGIN_INCLUDE_WITH_TITLE; if (isset($args[0])) { switch (strtolower(array_shift($args))) { case 'title': $with_title = TRUE; break; case 'notitle': $with_title = FALSE; break; } } $s_page = Utility::htmlsc($page); $link = '<a href="' . $wiki->uri() . '">' . $s_page . '</a>'; // Read link // I'm stuffed if (isset($included[$page])) { return '<p class="alert alert-warning">#include(): Included already: ' . $link . '</p>' . "\n"; } else { if (!is_page($page)) { return '<p class="alert alert-warning">#include(): No such page: ' . $s_page . '</p>' . "\n"; } else { if ($count > PLUGIN_INCLUDE_MAX) { return '<p class="alert alert-warning">#include(): Limit exceeded: ' . $link . '</p>' . "\n"; } else { ++$count; } } } // One page, only one time, at a time $included[$page] = TRUE; // Include A page, that probably includes another pages $get['page'] = $post['page'] = $vars['page'] = $page; if ($wiki->isReadable()) { $source = $wiki->get($page); preg_replace('/^#navi/', '/\\/\\/#navi/', $source); $body = RendererFactory::factory($source); } else { $body = str_replace('$1', $page, $_msg_include_restrict); } $get['page'] = $post['page'] = $vars['page'] = $root; // Put a title-with-edit-link, before including document if ($with_title) { $link = '<a href="' . $wiki->uri('edit') . '">' . $s_page . '</a>'; if ($page == $menubar || $page == $sidebar) { $body = '<span align="center"><h5 class="side_label">' . $link . '</h5></span><small>' . $body . '</small>'; } else { $body = '<article>' . "\n" . '<h1>' . $link . '</h1>' . "\n" . $body . "\n" . '</article>' . "\n"; } } return $body; }
/** * 出力 * @param array $headers ヘッダー(別途Header::getHeaders()で指定すること) * @param int $status ステータスコード * @param string $body 内容 * @return void */ public static function writeResponse($headers, $status = Response::STATUS_CODE_200, $body = '') { global $_string; // なぜかこの行を出力しないと503エラーが起きる echo ""; // レスポンスをコンストラクト $response = new Response(); if (!empty($body)) { if ($status == Response::STATUS_CODE_200 && isset($headers['If-None-Match']) && !isset($headers['ETag'])) { // Modifiedヘッダーが出力されてない場合、出力内容からETagを生成 // 負荷対策にはならないが転送量を抑えることができる $hash = md5($body); if (preg_match('/' . $hash . '/', $headers['If-None-Match'])) { $status = Response::STATUS_CODE_304; } $headers['Etag'] = $hash; } else { if ($status == Response::STATUS_CODE_401) { // レスポンスコードが401の場合、認証画面を出力 $headers['WWW-Authenticate'] = Auth::getAuthHeader(); } } // 内容が存在する場合容量をContent-Lengthヘッダーに出力 // if (!isset($headers['Content-Length'])){ $headers['Content-Length'] = strlen($body); // } // レスポンスに内容を追加 $response->setContent($body); } // ajaxで送信した時に、net::ERR_CONTENT_LENGTH_MISMATCHエラーが発生するので、 // その場合、Content Lengthヘッダーを出力しない if (IS_AJAX) { unset($headers['Content-Length']); } // ステータスコードを出力 $response->setStatusCode($status); // ヘッダーをソート ksort($headers); // ヘッダーを指定 $response->getHeaders()->addHeaders($headers); // ヘッダー出力をチェック if (headers_sent($file, $line)) { die(sprintf('Header::writeResponse(): ' . $_string['header_sent'], Utility::htmlsc($file), $line)); exit; } // ステータスコードを出力 header($response->renderStatusLine()); // ヘッダーを出力 foreach ($response->getHeaders() as $_header) { header($_header->toString()); } if (!empty($body)) { // 内容を出力 echo $response->getBody(); } // 出力バッファをフラッシュ flush(); // 終了 exit; }
/** * 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); }
function plugin_article_convert() { global $vars, $digest; // global $_btn_article, $_btn_name, $_btn_subject; global $_article_msg; static $numbers = array(); // if (PKWK_READONLY) return ''; // Show nothing if (Auth::check_role('readonly')) { return ''; } // Show nothing if (!isset($numbers[$vars['page']])) { $numbers[$vars['page']] = 0; } $article_no = $numbers[$vars['page']]++; $s_page = Utility::htmlsc($vars['page']); $s_digest = Utility::htmlsc($digest); $name_cols = PLUGIN_ARTICLE_NAME_COLS; $subject_cols = PLUGIN_ARTICLE_SUBJECT_COLS; $article_rows = PLUGIN_ARTICLE_ROWS; $article_cols = PLUGIN_ARTICLE_COLS; $script = get_script_uri(); $string = <<<EOD <form action="{$script}" method="post" class="form-horizontal row plugin-article-form"> \t<input type="hidden" name="article_no" value="{$article_no}" /> \t<input type="hidden" name="cmd" value="article" /> \t<input type="hidden" name="digest" value="{$s_digest}" /> \t<input type="hidden" name="refer" value="{$s_page}" /> \t<div class="form-group"> \t\t<label for="_p_article_name_{$article_no}" class="col-md-2 control-label">{$_article_msg['form_name']}</label> \t\t<div class="col-md-10"> \t\t\t<input type="text" name="name" class="form-control" id="_p_article_name_{$article_no}" size="{$name_cols}" placeholder="{$_article_msg['form_name']}" /> \t\t</div> \t</div> \t<div class="form-group"> \t\t<label for="_p_article_subject_{$article_no}" class="col-md-2 control-label">{$_article_msg['form_subject']}</label> \t\t<div class="col-md-10"> \t\t\t<input type="text" name="subject" class="form-control" id="_p_article_subject_{$article_no}" size="{$subject_cols}" placeholder="{$_article_msg['form_subject']}" /> \t\t</div> \t</div> \t<div class="form-group"> \t\t<label for="_p_article_msg_{$article_no}" class="col-md-2 control-label">{$_article_msg['form_subject']}</label> \t\t<div class="col-md-10"> \t\t\t<textarea name="msg" id="_p_article_msg_{$article_no}" class="form-control" rows="{$article_rows}" cols="{$article_cols}" placeholder="{$_article_msg['form_subject']}" ></textarea> \t\t</div> \t</div> \t<div class="form-group"> \t\t<div class="col-md-offset-2 col-md-10"> \t\t\t<input type="submit" name="article" class="btn btn-primary" value="{$_article_msg['btn_submit']}" /> \t\t</div> \t</div> </form> EOD; if (IS_MOBILE) { return '<div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">' . "\n" . '<h4>' . $_article_msg['btn_article'] . '</h4>' . "\n" . $string . "\n" . '</div>'; } else { return $string; } }
/** * 編集画面を表示 * @param string $page 編集しようとしているページ名 * @param string $data 入力データー * @param boolean $show_template テンプレートを表示するか */ public static function editForm($page, $data, $show_template = TRUE) { global $vars, $session; global $_button, $_string; global $notimeupdate, $load_template_func, $load_refer_related; if (empty($page)) { return self::dieMessage('Page name was not defined.'); } $postdata = is_array($data) ? join("\n", $data) : $data; $original = isset($vars['original']) ? $vars['original'] : $postdata; // ticketは、PliginRenderer::addHiddenField()で自動挿入されるので、同じアルゴリズムでチケット名を生成 $ticket_name = md5(Utility::getTicket() . REMOTE_ADDR); // BugTrack/95 fix Problem: browser RSS request with session $session->offsetSet('origin-' . $ticket_name, md5(self::getTicket() . str_replace("\r", '', $original))); $ret[] = '<form action="' . Router::get_script_uri() . '" role="form" method="post" class="form-edit" data-collision-check-strict="true">'; $ret[] = '<input type="hidden" name="cmd" value="edit" />'; $ret[] = '<input type="hidden" name="page" value="' . self::htmlsc($page) . '" />'; $ret[] = isset($vars['id']) ? '<input type="hidden" name="id" value="' . self::htmlsc($vars['id']) . '" />' : null; if ($load_template_func && $show_template) { // ひな形を読み込む foreach (Listing::pages() as $_page) { $_w = Factory::Wiki($_page); if (!$_w->isEditable() || $_w->isHidden()) { continue; } $_s_page = self::htmlsc($_page); $_pages[$_page] = '<option value="' . $_s_page . '">' . $_s_page . '</option>' . "\n"; } // ナチュラルソート ksort($_pages, SORT_NATURAL); $ret[] = '<div class="form-inline">'; $ret[] = '<div class="form-group">'; $ret[] = '<select class="form-control" name="template_page" class="template">'; $ret[] = '<option value="" disabled="disabled" selected="selected">-- ' . $_button['template'] . ' --</option>'; $ret[] = join("\n", $_pages); $ret[] = '</select>'; $ret[] = '</div>'; $ret[] = '<button type="submit" class="btn btn-secondary" name="template" accesskey="l">' . $_button['load'] . '</button>'; $ret[] = '</div>'; unset($_s_page, $_w, $_pages); } // 編集フォーム $ret[] = '<textarea name="msg" id="msg" rows="15" class="form-control">' . self::htmlsc(($load_refer_related && isset($vars['refer']) && !empty($vars['refer']) ? '[[' . self::stripBracket($vars['refer']) . ']]' . "\n\n" : '') . $postdata) . '</textarea>'; $ret[] = '<div class="form-inline">'; if (IS_MOBILE) { // モバイル用 $ret[] = '<input type="submit" id="btn_submit" name="write" value="' . $_button['update'] . '" data-icon="check" data-inline="true" data-theme="b" />'; $ret[] = '<input type="submit" id="btn_preview" name="preview" value="' . $_button['preview'] . '" accesskey="p" data-icon="gear" data-inline="true" data-theme="e" />'; $ret[] = '<input type="submit" id="btn_cancel" name="cancel" value="' . $_button['cancel'] . '" accesskey="c" data-icon="delete" data-inline="true" />'; $ret[] = $notimeupdate === 2 && Auth::check_role('role_contents_admin') ? '<div data-role="fieldcontain">' : null; if ($notimeupdate !== 0 && Factory::Wiki($page)->isValied()) { // タイムスタンプを更新しないのチェックボックス $ret[] = '<input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true" ' . (isset($vars['notimestamp']) ? ' checked="checked"' : null) . ' />'; $ret[] = '<label for="_edit_form_notimestamp" data-inline="true">' . $_button['notchangetimestamp'] . '</label>'; } // 管理人のパス入力 $ret[] = $notimeupdate == 2 && Auth::check_role('role_contents_admin') ? '<input type="password" name="pass" size="12" data-inline="true" />' . "\n" . '</div>' : null; $ret[] = isset($vars['add']) ? '<input type="checkbox" name="add_top" value="true"' . (isset($vars['add']) ? ' checked="checked"' : '') . ' /><label for="add_top">' . $_button['addtop'] . '</label>' : null; } else { // 通常用 $ret[] = '<button type="submit" class="btn btn-primary" name="write" accesskey="s"><span class="fa fa-check"></span>' . $_button['update'] . '</button>'; $ret[] = isset($vars['add']) ? '<input type="checkbox" name="add_top" value="true"' . (isset($vars['add']) ? ' checked="checked"' : '') . ' /><label for="add_top">' . $_button['addtop'] . '</label>' : null; $ret[] = '<button type="submit" class="btn btn-secondary" name="preview" accesskey="p"><span class="fa fa-eye"></span>' . $_button['preview'] . '</button>'; if ($notimeupdate !== 0 && Factory::Wiki($page)->isValied()) { // タイムスタンプを更新しないのチェックボックス $ret[] = '<div class="checkbox">'; $ret[] = '<input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true"' . (isset($vars['notimestamp']) ? ' checked="checked"' : null) . ' />'; $ret[] = '<label for="_edit_form_notimestamp">' . $_button['notchangetimestamp'] . '</label>'; $ret[] = '</div>'; // $ret[] = '<div class="checkbox">'; // $ret[] = '<input type="checkbox" name="ping" id="_edit_form_ping" value="true"' . (isset($vars['ping']) ? ' checked="checked"' : null) . ' />'; // $ret[] = '<label for="_edit_form_ping">' . $_button['send_ping'] . '</label>'; // $ret[] = '</div>'; // $ret[] = '<div class="checkbox">'; // $ret[] = '<input type="checkbox" name="tweet" id="_edit_form_tweet" value="true"' . (isset($vars['tweet']) ? ' checked="checked"' : null) . ' />'; // $ret[] = '<label for="_edit_form_tweet"><span class="fa fa-twitter"></span></label>'; // $ret[] = '</div>'; // $ret[] = '<div class="checkbox">'; // $ret[] = '<input type="checkbox" name="ping" id="_edit_form_fb" value="true"' . (isset($vars['facebook']) ? ' checked="checked"' : null) . ' />'; // $ret[] = '<label for="_edit_form_tweet"><span class="fa fa-facebook"></span></label>'; // $ret[] = '</div>'; } // 管理人のパス入力 if ($notimeupdate === 2 && Auth::check_role('role_contents_admin')) { $ret[] = '<div class="form-group">'; $ret[] = '<div class="input-group">'; $ret[] = '<span class="input-group-addon"><span class="fa fa-key"></span></span>'; $ret[] = '<input type="password" name="pass" class="form-control" size="12" placeholder="Password" />'; $ret[] = '</div>'; $ret[] = '</div>'; } $ret[] = '<button type="submit" class="btn btn-warning" name="cancel" accesskey="c"><span class="fa fa-ban"></span>' . $_button['cancel'] . '</button>'; } $ret[] = '</div>'; $ret[] = '</form>'; if (isset($vars['help'])) { // テキストの整形ルールを表示 $rule_wiki = Factory::Wiki(self::RULE_PAGENAME); $ret[] = '<hr />'; $ret[] = $rule_wiki->has() ? $rule_wiki->render() : '<p class="alert alert-warning">Sorry, page \'' . Utility::htmlsc(self::RULE_PAGENAME) . '\' unavailable.</p>'; } else { $ret[] = '<ul><li><a href="' . Factory::Wiki($page)->uri('edit', array('help' => 'true')) . '" id="FormatRule">' . $_string['help'] . '</a></li></ul>'; } return join("\n", $ret); }