function plugin_ogp_get_defdata() { global $script, $vars, $defaultpage, $page_title, $description; global $og_description, $fb_admins, $fb_app_id, $qblog_defaultpage; $qt = get_qt(); $url = $script; $page = $vars['page']; if ($defaultpage != $page) { $r_page = rawurlencode($vars['page']); $url .= '?' . $r_page; $this_page_title = $qt->getv('this_page_title'); if ($this_page_title === FALSE) { $this_page_title = $vars['page'] . ' - ' . $page_title; } } else { $this_page_title = $page_title; } $type = $page !== $qblog_defaultpage && is_qblog() ? 'article' : 'website'; $defdata = array('fb:app_id' => $fb_app_id != '' ? $fb_app_id : FALSE, 'fb:admins' => $fb_admins != '' ? $fb_admins : FALSE, 'og:locale' => 'ja_JP', 'og:type' => $type, 'og:title' => $this_page_title, 'og:url' => $url, 'og:site_name' => $page_title, 'og:description' => $og_description != '' ? $og_description : $description, 'og:image' => FALSE); return $defdata; }
function plugin_rename_phase2($err = '') { global $script, $qblog_menubar; $qm = get_qm(); $msg = plugin_rename_err($err); $page = plugin_rename_getvar('page'); $refer = plugin_rename_getvar('refer'); if ($page == '') { $page = $refer; } //ブログの場合、名称変更は非推奨 $warn = ''; if (is_qblog($refer) or $refer === $qblog_menubar) { $warn = ' <p style="color:red;font-weight:bold;">【警告】ブログ関連ページの名称変更を行うと、ブログの動作が不安定になる恐れがあります。</p> '; } $msg_related = ''; $related = plugin_rename_getrelated($refer); if (!empty($related)) { $msg_related = '<label for="_p_rename_related">' . $qm->m['plg_rename']['do_related'] . '</label>' . '<input type="checkbox" name="related" id="_p_rename_related" value="1" checked="checked" /><br />'; } $msg_rename = sprintf($qm->m['plg_rename']['rename'], make_pagelink($refer)); $s_page = htmlspecialchars($page); $s_refer = htmlspecialchars($refer); $ret = array(); $ret['msg'] = $qm->m['plg_rename']['title']; $ret['body'] = <<<EOD {$warn} {$msg} <form action="{$script}" method="post"> <div> <input type="hidden" name="plugin" value="rename" /> <input type="hidden" name="refer" value="{$s_refer}" /> {$msg_rename}<br /> <label for="_p_rename_newname">{$qm->m['plg_rename']['newname']}:</label> <input type="text" name="page" id="_p_rename_newname" size="80" value="{$s_page}" /><br /> {$msg_related} <input type="submit" value="{$qm->m['plg_rename']['btn_next']}" /><br /> </div> </form> EOD; if (!empty($related)) { $ret['body'] .= '<hr /><p>' . $qm->m['plg_rename']['related'] . '</p><ul>'; sort($related); foreach ($related as $name) { $ret['body'] .= '<li>' . make_pagelink($name) . '</li>'; } $ret['body'] .= '</ul>'; } return $ret; }
function plugin_qblog_comment_convert() { global $script, $vars, $digest, $username; global $qblog_defaultpage, $qblog_comment_check, $qblog_enable_comment; static $called = FALSE; $page = $vars['page']; if (PKWK_READONLY) { return ''; } // Show nothing if ($called) { return ''; } // Only once $called = TRUE; //QBlog ページ以外設置不可 if ($page === $qblog_defaultpage or !is_qblog()) { return ''; } if (isset($qblog_enable_comment) && !$qblog_enable_comment) { return ''; } $editable = check_editable($qblog_defaultpage, FALSE, FALSE); $qt = get_qt(); $qt->setv('jquery_include', TRUE); $qm = get_qm(); // TODO: remove // !既存のコメントを出力 $comments = array(); if (file_exists(CACHEQBLOG_DIR . encode($page) . '.qbcm.dat')) { $comments = unserialize(file_get_contents(CACHEQBLOG_DIR . encode($page) . '.qbcm.dat')); } if (count($comments) > 0) { foreach ($comments as $i => $comment) { if (!$comment['show']) { unset($comments[$i]); continue; } $cnt = $i + 1; if ($editable or $comment['accepted']) { $comment['msg'] = h($comment['msg']); //他のコメントにレスができる $comment['msg'] = preg_replace('/(>>|※)(\\d+)/', '<a href="#qbcomment_$2">$1$2</a>', $comment['msg']); $comment['msg'] = nl2br($comment['msg']); //URLをリンクに $ptns = array('/(?:https?|ftp)(?::\\/\\/[-_.!~*\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)/'); $rpls = array('<a href="$0">$0</a>'); $comment['msg'] = preg_replace($ptns, $rpls, $comment['msg']); $comments[$i]['msg'] = $comment['msg']; } } } //認証コード生成 $authcode = '' . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9); $action = $script . '?' . rawurlencode($page); $name = ''; if ($editable) { $name = $username === $_SESSION['usr'] ? '管理人' : $_SESSION['usr']; } $name = isset($vars['name']) ? $vars['name'] : $name; $title = isset($vars['title']) ? $vars['title'] : ''; $msg = isset($vars['msg']) ? $vars['msg'] : ''; // !エラー処理 $auth_err = $title_err = $name_err = FALSE; if (isset($vars['qblog_comment_auth_error'])) { $auth_err = $vars['qblog_comment_auth_error']; } if (isset($vars['qblog_comment_title_error'])) { $title_err = $vars['qblog_comment_title_error']; } if (isset($vars['qblog_comment_name_error'])) { $name_err = $vars['qblog_comment_name_error']; } ob_start(); include PLUGIN_DIR . 'qblog/comment_template.html'; $html = ob_get_clean(); return $html; }
/** * QBlog display post-head plugin * ------------------------------------------- * ./plugin/qblog_head.inc.php * * Copyright (c) 2012 hokuken * http://hokuken.com/ * * created : 12/07/30 * modified : * * Description * * Usage : * */ function plugin_qblog_head_convert() { global $vars, $script, $defaultpage; global $qblog_date_format, $qblog_page_re, $qblog_defaultpage, $qblog_close, $qblog_default_cat; if (!is_qblog()) { return ''; } $closed_msg = ''; if ($qblog_close) { if (ss_admin_check()) { $closed_msg = ' <div class="alert" style="margin-top: 15px ;margin-bottom: 15px ;"> <button class="close" data-dismiss="alert">×</button> <p> ブログは閉鎖されています。<br /> 管理者以外のアクセスはトップページへ転送されます。 </p> <p> ※ブログメニュー上のリストも管理者以外には表示されません。 </p> </div> '; } else { redirect($defaultpage); } } $qt = get_qt(); //RSSフィードを出力 if (exist_plugin('rss')) { $rssurl = $script . '?cmd=rss&qblog_rss=1'; $qt->setv_once('rss_link', $rssurl); } if (!is_bootstrap_skin()) { $include_bs = ' <link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" /> <script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>'; $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs); } //qblog.css を読み込む $head = ' <link rel="stylesheet" href="plugin/qblog/qblog.css' . '" />'; $qt->appendv_once('qblog_beforescript', 'beforescript', $head); $page = $vars['page']; // ブログトップは<head>内の調整のみ if ($page === $qblog_defaultpage) { return $closed_msg; } //日付を取得 $date = get_qblog_date($qblog_date_format, $page); $data = get_qblog_post_data($page); if ($vars['cmd'] == 'edit') { //新規ページ if (!$data) { $data['title'] = $page; $data['category'] = $qblog_default_cat; } $data['title'] = isset($vars['title']) && $vars['title'] ? $vars['title'] : $data['title']; $data['category'] = isset($vars['category']) && $vars['category'] ? $vars['category'] : $data['category']; if (isset($vars['qblog_date'])) { $date = $vars['qblog_date']; list($y, $m, $d) = array_pad(explode('-', $vars['qblog_date']), 3, ''); if (checkdate($m, $d, $y)) { $time = mktime(0, 0, 0, $m, $d, $y); $date = date($qblog_date_format, $time); } } } $category_url = $script . '?' . $qblog_defaultpage . '&mode=category&catname=' . rawurlencode($data['category']); $addpostlink_html = ''; if (ss_admin_check()) { $editpostlink = $script . '?cmd=edit&page=' . $page; $addpostlink = $script . '?cmd=qblog&mode=addpost'; $addpostlink_html = ' <a href="' . h($editpostlink) . '" class="badge badge-important" style="color:#fff"><i class="icon-white icon-edit" style="vertical-align:text-bottom"></i> この記事を編集</a> <a href="' . h($addpostlink) . '" class="badge badge-info" style="color:#fff"><i class="icon-white icon-plus" style="vertical-align:text-bottom"></i> 記事の追加</a> '; } $head = ' <style type="text/css"> #content h2.title{display:none;} </style> ' . $closed_msg . ' <div class="title"> <span class="qblog_post_date">' . h($date) . '</span> ' . $addpostlink_html . ' <a href="' . h($category_url) . '" class="qblog_category badge">カテゴリ:' . h($data['category']) . '</a> </div> <h2>' . h($data['title']) . '</h2> '; if (trim($data['image']) !== '') { if (is_file(SWFU_IMAGE_DIR . $data['image'])) { $data['image'] = SWFU_IMAGE_DIR . $data['image']; } $head .= <<<EOH EOH; } return $head; }
$qt->setv('site_navigator_is_empty', trim($site_navigator) === ''); if (!$qt->getv('SiteNavigatorInsertMark')) { $site_navigator = "\n<!-- SITENAVIGATOR CONTENTS START -->\n" . $site_navigator . "\n<!-- SITENAVIGATOR CONTENTS END -->\n"; $qt->setv('SiteNavigatorInsertMark', true); } $qt->setv('site_navigator', $site_navigator); } else { $qt->setv('site_navigator', ''); $qt->setv('site_navigator_is_empty', true); } unset($vars['page_alt']); } if (exist_plugin_convert('menu')) { global $menubar, $menubar2, $qblog_menubar; $vars['page_alt'] = $menubar; if (is_qblog()) { do_plugin_convert('menu', $qblog_menubar); } $ptn = '"' . $script . '?' . rawurlencode($vars['page']) . '"'; $ptn = '|<(h[2-4][^>]+)>(.+href="(' . $scripturi . ')".+)?</(h[2-4])>|'; $_menubody = preg_replace($ptn, '<$1 class="focus">$2</$4>', do_plugin_convert('menu')); if ($is_bootstrap_skin) { $_menubody = preg_replace('/<ul class="list1"\\s*>/', '<ul class="list1 list-group">', $_menubody); $_menubody = preg_replace('/<li>/', '<li class="list-group-item">', $_menubody); $_menuscript = ' <script type="text/javascript"> $(function(){ $(".list-group > .list-group-item").find(".list-group-item").removeClass("list-group-item"); $("#menubar .list-group .list-group-item a").each(function(){ var url = $(this).attr("href"); if (url == "' . $scripturi . '") {
function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $script, $vars, $rows, $cols, $hr, $function_freeze; global $_btn_preview, $_btn_repreview, $_btn_update, $_btn_cancel, $_msg_help; global $whatsnew, $_btn_template, $_btn_load, $load_template_func; global $notimeupdate; global $qhm_access_key; global $qblog_defaultpage, $style_name, $date_format, $qblog_default_cat; $qt = get_qt(); //accesskey setting $accesskey = array(); foreach (array('r', 'p', 's', 'c') as $v) { $accesskey[$v] = $qhm_access_key ? 'accesskey="' . $v . '"' : ''; } // Newly generate $digest or not if ($digest === FALSE) { $digest = md5(join('', get_source($page))); } $refer = $template = $headertitle = ''; // Add plugin $addtag = $add_top = ''; if (isset($vars['add'])) { global $_btn_addtop; $addtag = '<input type="hidden" name="add" value="true" />'; $add_top = isset($vars['add_top']) ? ' checked="checked"' : ''; $add_top = '<input type="checkbox" name="add_top" ' . 'id="_edit_form_add_top" value="true"' . $add_top . ' />' . "\n" . ' <label for="_edit_form_add_top" class="checkbox">' . '<span class="small">' . $_btn_addtop . '</span>' . '</label>'; } if ($load_template_func && $b_template) { $pages = array(); foreach (get_existpages() as $_page) { if ($_page == $whatsnew || check_non_list($_page)) { continue; } $s_page = htmlspecialchars($_page); $pages[$_page] = ' <option value="' . $s_page . '">' . $s_page . '</option>'; } ksort($pages); $s_pages = join("\n", $pages); $template = <<<EOD <select name="template_page"> <option value="">-- {$_btn_template} --</option> {$s_pages} </select> <input type="submit" name="template" value="{$_btn_load}" {$accesskey['r']} /> <br /> EOD; } //新規作成の場合、ページ名を大見出しとして挿入する if (isset($vars['refer']) && $vars['refer'] != '') { $headertitle = "\n\n" . '* ' . strip_bracket($page) . "\n\n"; } $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $s_digest = htmlspecialchars($digest); $s_postdata = htmlspecialchars($refer . $headertitle . $postdata); $s_original = isset($vars['original']) ? htmlspecialchars($vars['original']) : $s_postdata; $b_preview = isset($vars['preview']); // TRUE when preview $btn_preview = $b_preview ? $_btn_repreview : $_btn_preview; // Checkbox 'do not change timestamp' $add_notimestamp = ''; if ($notimeupdate != 0) { global $_btn_notchangetimestamp; $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; // Only for administrator if ($notimeupdate == 2) { $add_notimestamp = ' ' . '<input type="password" name="pass" size="12" />' . "\n"; } $add_notimestamp = '<label for="_edit_form_notimestamp" class="checkbox"><input type="checkbox" name="notimestamp" ' . 'id="_edit_form_notimestamp" value="true"' . $checked_time . ' tabindex="9" />' . "\n" . ' ' . '<span class="small">' . $_btn_notchangetimestamp . '</span></label>' . "\n" . $add_notimestamp . ' '; } $buttons_align = 'left'; $blog_cancel_button = 'right'; if (is_bootstrap_skin()) { $buttons_align = 'right'; $blog_cancel_button = 'left'; } else { //Bootstrap の読み込み $include_bs = ' <link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" /> <script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>'; $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs); } // !ブログ用編集フォーム if ($page !== $qblog_defaultpage && is_qblog()) { //メタデータを取得 $data = get_qblog_post_data($page); $data['title'] = isset($vars['title']) ? $vars['title'] : $data['title']; $data['category'] = isset($vars['category']) ? $vars['category'] : $data['category']; $data['image'] = isset($vars['image']) ? $vars['image'] : $data['image']; $date = get_qblog_date($date_format, $page); if (isset($vars['qblog_date']) && $date !== trim($vars['qblog_date'])) { $dates = array_pad(explode('-', $vars['qblog_date'], 3), 3, 0); $valid = checkdate($dates[1], $dates[2], $dates[0]); $date = $valid ? trim($vars['qblog_date']) : $date; } $category = isset($data['category']) && strlen(trim($data['category'])) > 0 ? $data['category'] : ''; $qblog_categories = array_keys(get_qblog_categories()); $qblog_cat_json = json_encode($qblog_categories); $h_qblog_cat_json = h(json_encode($qblog_categories)); $qblog_cat_list = '<ul id="qblog_categories_selector" class="qblog_categories collapse">'; foreach ($qblog_categories as $cat) { $qblog_cat_list .= '<li>' . h($cat) . '</li>'; } $qblog_cat_list .= '</ul>'; $h2title = '新規投稿'; if (is_page($page)) { $h2title = $data['title'] . 'の編集'; } $s_h2title = h($h2title); $s_blog_title = h($data['title']); $body = <<<EOD <link rel="stylesheet" href="js/datepicker/css/datepicker.css" /> <link rel="stylesheet" href="plugin/qblog/qblog.css" /> <script src="js/datepicker/js/bootstrap-datepicker.js"></script> <script tyle="text/javascript"> \$(function(){ \t\$('#qblog_datepicker').datepicker({ \t\tlanguage: "japanese" //\t\tformat: "yyyy/mm/dd" \t}); \tif (\$("input[name=category]").val().length == 0) { \t\t\$('#qblog_cat_trigger').click(); \t} \tif (\$('h2.title').length == 0) { \t\t\$("#edit_form_main").before('<h2 class="title">{$s_h2title}</h2>'); \t} \t\$('h2.title').text('{$s_h2title}'); \t\$('a.show-thumbnail').click(function(){ \t\tif (\$(this).next().is(':visible')) { \t\t\t\$(this).next().hide(); \t\t} \t\telse { \t\t\t\$(this).next().show(); \t\t} \t\treturn false; \t}); }); </script> <div class="qblog_edit_form"> <form action="{$script}" method="post" class="form-horizontal" id="edit_form_main"> {$template} {$addtag} <input type="hidden" name="cmd" value="edit" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="hidden" name="digest" value="{$s_digest}" /> <fieldset> <div class="form-group"> <label class="control-label col-sm-2">日付</label> <div class="controls col-sm-10"><input type="text" name="qblog_date" id="qblog_datepicker" tabindex="1" class="datepicker form-control" size="16" value="{$date}" data-date="{$date}" data-date-format="yyyy-mm-dd" class="form-control" /></div> </div> <div class="form-group"> <label class="control-label col-sm-2">タイトル</label> <div class="controls col-sm-10"><input type="text" name="title" value="{$s_blog_title}" tabindex="2" class="form-control" /></div> \t</div> <div class="form-group"> <label class="control-label col-sm-2">カテゴリ</label> <div class="controls col-sm-10"> <div class="input-group"> <input type="text" name="category" value="{$category}" placeholder="{$qblog_default_cat}" tabindex="3" class="form-control" data-provide="typeahead" data-source="{$h_qblog_cat_json}" autocomplete="off" /> <span class="input-group-btn"> <button type="button" id="qblog_cat_trigger" class="btn btn-default qhm-btn-default" data-toggle="collapse" data-target="#qblog_categories_selector" style="color:#333"> カテゴリ <span class="caret"></span> </button> </span> </div> {$qblog_cat_list} </div> </div> <div class="form-group"> <label class="control-label col-sm-2">記事の内容</label> <div class="controls col-sm-10"> <textarea name="msg" id="msg" tabindex="4" rows="20" class="form-control">{$s_postdata}</textarea> \t\t</div> \t</div> <div class="form-group"> <div class="controls col-sm-10 col-sm-offset-2"> \t \t\t<a class="show-thumbnail" href="#">サムネイルを指定する >></a> \t\t\t<div class="set-thumbnail"> \t\t\t\t<small>自動で本文の画像が使われます。<br />特別に指定したい場合、画像を画像名またはURLで指定してください。</small> <p style="color:#333;">画像名またはURL:<input type="text" name="image" value="{$data['image']}" tabindex="5" class="form-control" /></p> \t\t\t\t<p><small><span class="swfu"><a href="swfu/index_child.php">>>QHMのファイル管理(SWFU)を使って画像をアップする</a></span></small></p> \t\t\t</div> <!-- \t\t\t<span class="swfu"><a href="swfu/index_child.php"><i class="icon-picture"></i>SWFU</a><span> \t\t\t<p class="help-block">SWFUの画像を使う場合、画像詳細画面の<b>URL</b>をコピペしてください。</p> --> \t\t</div> \t</div> <div class="form-group"> <div class="col-sm-10 col-sm-offset-2"> <div style="float:{$buttons_align};"> <input type="submit" name="preview" value="{$btn_preview}" tabindex="6" class="qhm-btn-default"/> <input type="submit" name="write" value="{$_btn_update}" tabindex="7" class="qhm-btn-primary"/> \t\t{$add_notimestamp} {$add_top} \t\t<textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> </div> <div style="float:{$buttons_align};"> <input type="submit" name="cancel" value="{$_btn_cancel}" tabindex="8" class="btn-link"/> </div> </div> \t</div> </fieldset> </form> </div> EOD; } else { $body = <<<EOD <div class="edit_form"> <form action="{$script}" method="post" style="margin-bottom:0px;" id="edit_form_main"> {$template} {$addtag} <input type="hidden" name="cmd" value="edit" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="hidden" name="digest" value="{$s_digest}" /> <div class="form-group"> <textarea name="msg" id="msg" rows="{$rows}" cols="{$cols}" tabindex="2" class="form-control">{$s_postdata}</textarea> </div> <div style="float:{$buttons_align};"> <input type="submit" name="preview" value="{$btn_preview}" tabindex="4" class="qhm-btn-default"/> <input type="submit" name="write" value="{$_btn_update}" tabindex="5" class="qhm-btn-primary"/> {$add_top} {$add_notimestamp} </div> <textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> </form> <form action="{$script}" method="post" style="margin-top:0px;margin-left:5px;float:{$buttons_align};" id="edit_form_cancel"> <input type="hidden" name="cmd" value="edit" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="submit" name="cancel" value="{$_btn_cancel}" tabindex="6" class="btn-link"/> </form> <div style="clear:both;"></div> </div> EOD; } $addscript = <<<EOD <script data-qhm-plugin="edit"> \$(function(){ if (\$("h2.title").length == 0) { \$(".edit_form").before('<h2 class="title">{$s_page} の編集</h2>'); } \$("h2.title").css({fontSize: "14px", marginBottom: '15px'}); \$("#editboxlink").on("click", function(){ if (\$(".qblog_edit_form").length) { QHM.scroll(".qblog_edit_form", 300); } else { QHM.scroll("h2.title", 300); } \$("#msg").focus(); return false; }); if (\$("#preview_body").length) { } else { \$(".qhm-eyecatch").hide(); setTimeout(function(){ \$("html, body").animate({scrollTop: \$("h2.title").offset().top}, 300); \$("#msg").focus(); }, 25); } }); </script> EOD; $qt->appendv_once("plugin_edit_form_script", 'lastscript', $addscript); // List of attached files to the page by hokuken.com $attaches = exist_plugin_action('attach') ? attach_filelist(true) : ''; if ($attaches !== '') { $body .= <<<EOD <script type="text/javascript" src="js/yahoo.js"></script> <script type="text/javascript" src="js/event.js"></script> <script type="text/javascript" src="js/dom.js"></script> <style type="text/css"> .yui-tt { \tposition: absolute; \tpadding: 5px; \tbackground-color:#eee; \tborder:1px solid #aaa; } </style> <script type="text/javascript" src="js/container.js"></script> <script type="text/javascript"> function init() { var el = document.getElementById('attachlist'); if(el != null){ \t var list = el.getElementsByTagName('a'); \t for( var i=0; i<list.length; i++ ) { \t if( list[i].getAttribute("rel") == "attachhref" ){ \t\t\t\t\tvar el = 'tooltip'+i; \t\t\t\t\tvar url = list[i].href; \t\t\t\t\tvar title = '<img src="'+list[i].href+'">'; \t\t\t\t\tif ( list[i].title ) title += '<br>'+list[i].innerHTML; \t\t\t\t\tvar tp = new YAHOO.widget.Tooltip( el, { context:list[i], text: title, autodismissdelay: 7500 } ); \t\t\t\t} \t } } var el = document.getElementById('swfulist'); if(el != null){ \tvar list = el.getElementsByTagName('a'); \t for( var i=0; i<list.length; i++ ) { \t if( list[i].getAttribute("rel") == "attachhref" ){ \t\t\t\t\tvar el = 'tooltip'+i; \t\t\t\t\tvar url = list[i].getAttribute("url"); \t\t\t\t\tvar title = '<img src="'+url+'">'; \t\t\t\t\tif ( list[i].title ) title += '<br>'+list[i].innerHTML; \t\t\t\t\tvar tp = new YAHOO.widget.Tooltip( el, { context:list[i], text: title, autodismissdelay: 7500 } ); \t\t\t\t} \t } \t\t} } YAHOO.util.Event.addListener(window, "load", init); </script> EOD; $body .= '<br /><div id="attachlist" style="border: 2px dashed #666;padding:5px 10px;background-color:#eee">' . $attaches . '</div>'; } $qm = get_qm(); $helpstr = $qm->m['html']['view_help_message']; //list up swfu files if (has_swfu()) { require_once SWFU_TEXTSQL_PATH; $db = new CTextDB(SWFU_IMAGEDB_PATH); $imgtitle = $qm->m['html']['img_title']; $imgtitle2 = $qm->m['html']['img_title2']; $attcstr = $qm->m['html']['attach_message']; //! swfuの画像データを取得して表示をする $rs = $db->select('$page_name=="' . $page . '"', 'created desc'); if (count($rs) > 0) { $body .= '<div id="swfulist" style="border:1px #aaa dashed;margin-top:10px;padding:10px;font-size:12px">'; $body .= '<b><a href="./swfu/index_child.php?page=FrontPage&KeepThis=true&TB_iframe=true&height=450&width=650" class="thickbox">' . $attcstr . '(SWFU)</a> : </b>'; foreach ($rs as $k => $v) { $path = SWFU_IMAGE_DIR . $v['name']; $prop = SWFU_DIR . 'view.php?id=' . $v['id'] . '&page=FrontPage&KeepThis=true&TB_iframe=true&height=450&width=650'; $body .= '<span style="padding:2px;margin-right:5px">'; $atitle1 = $qm->replace("html.insert_title", $v['name']); $atitle2 = $qm->replace("html.ar_insert_title", $v['name']); if (preg_match('/\\.(png|jpeg|jpg|gif)$/i', $v['name'])) { $title = h($v['name']); $body .= '<a href="' . $prop . '" url="' . $path . '" rel="attachhref" class="thickbox" title="' . $title . '"><img src="image/file.png" width="20" height="20" alt="file" style="border-width:0" />' . $v['name'] . '</a>'; $body .= <<<EOD <a href="#" title="{$atitle1}" onclick="javascript:jQuery.clickpad.cpInsert('&show({$v['name']},,{$v['description']});'); return false;"><img src="image/ins-img.png" alt="{$imgtitle}"/></a><a href="#" title="{$atitle2}" onclick="javascript:jQuery.clickpad.cpInsert('\\n#show({$v['name']},aroundl,{$v['description']})\\n'); return false;"><img src="image/ins-img2.png" alt="{$imgtitle2}" /></a> EOD; } else { $body .= '<a href="' . $path . '"><img src="image/file.png" width="20" height="20" alt="file" style="border-width:0" />' . $v['name'] . '</a>'; $body .= <<<EOD <a href="#" title="{$v['name']}" onclick="javascript:insert('&dlbutton({$path});'); return false;"><img src="image/ins-btn.png" alt="{$imgtitle}"/></a> EOD; } $body .= '</span>'; } $body .= '</div>'; } } return $body; }
function plugin_edit_cancel() { global $vars, $layout_pages, $qblog_menubar, $qblog_defaultpage; pkwk_headers_sent(); if ($vars['page'] === $qblog_menubar) { header('Location: ' . get_script_uri() . '?' . $qblog_defaultpage); } else { if (is_qblog($vars['page']) && !is_page($vars['page'])) { header('Location: ' . get_script_uri() . '?' . $qblog_defaultpage); } else { if (array_key_exists($vars['page'], $layout_pages) or count(get_source($vars['page'])) == 0) { header('Location: ' . get_script_uri()); } else { header('Location: ' . get_script_uri() . '?' . rawurlencode($vars['page'])); } } } exit; }
/** * 記事単位のキャッシュを更新する * * boolean $force * string $page * asoc $option * * @return boolean キャッシュファイルが扱えるかどうか */ function qblog_update_post($force = FALSE, $page = NULL, $option = NULL) { global $vars; global $qblog_defaultpage, $qblog_page_prefix, $qblog_page_re, $qblog_default_cat; //ページが未指定の場合 if (is_null($page)) { $page = $vars['page']; //ページがブログでなければ何もしない if (!is_qblog()) { return FALSE; } } if ($page === $qblog_defaultpage) { return FALSE; } //wikiファイルとキャッシュファイルのmtime を比べる $wikifile = get_filename($page); $datafile = CACHEQBLOG_DIR . encode($page) . '.qbp.dat'; if (!file_exists($wikifile)) { return FALSE; } //キャッシュが古ければ更新 if ($force === FALSE && file_exists($datafile) && filemtime($wikifile) <= filemtime($datafile)) { return TRUE; } //オプションが未指定の場合 //すでにデータファイルがあればそれを読み込む if (is_null($option)) { $option = array('image' => '', 'category' => $qblog_default_cat); if (file_exists($datafile)) { $data = unserialize(file_get_contents($datafile)); $data = $data === FALSE ? array() : $data; $option = array_merge($option, $data); } } $source = get_source($page); $title = ''; //ページタイトル $header = ''; //見出し $image = isset($option['image']) && $option['image'] !== '' ? $option['image'] : ''; //画像パス $visible = TRUE; //表示 // 説明ページに表示しないプラグイン global $ignore_plugin, $strip_plugin, $strip_plugin_inline; foreach ($source as $i => $line) { if (preg_match($ignore_plugin, $line)) { // リストから省く $source = array(); break; } //タイトルのセット if (preg_match('/^TITLE:(.*)/', $line, $ms)) { $title = $ms[1]; unset($source[$i]); } else { if (preg_match('/^(?:\\*){1,3}(.*)\\[#\\w+\\]\\s?/', $line, $ms)) { if ($header === '') { $header = trim($ms[1]); } $source[$i] = trim($ms[1]); } else { if (preg_match($strip_plugin, $line)) { unset($source[$i]); } else { if (preg_match('/^#qblog/', $line)) { unset($source[$i]); } else { if ($image === '' && preg_match('/(?:^#show|&show)\\(([^,]+)(.*)\\)/', $line, $mts)) { if (strpos($mts[2], 'nolink') === FALSE) { $image = $mts[1]; } } } } } } } //閉鎖されている場合は表示フラグをオフ if (count($source) === 0) { $visible = FALSE; } //タイトルがない場合は最初の見出しを使う if ($title === '') { $title = $header; } //特定のインラインプラグインを除く $source = preg_replace($strip_plugin_inline, '', $source); //コンバートし、タグを除く $abstract = strip_tags(convert_html($source)); //指定文字数抜粋し、改行文字を除く $abst_length = 100; if (mb_strlen($abstract) > $abst_length) { $abstract = str_replace(array("\n", "\r"), '', mb_substr($abstract, 0, $abst_length - 1) . '…'); } else { $abstract = str_replace(array("\n", "\r"), '', $abstract); } $category = $option['category']; //カテゴリ //ファイルを保存 $data = compact(array('title', 'abstract', 'image', 'category', 'visible')); file_put_contents($datafile, serialize($data), LOCK_EX); return TRUE; }
function plugin_secedit_wrap(&$string, &$tag, &$param, &$id) { global $vars, $plugin; global $qblog_defaultpage; static $is_editable; $page = isset($vars['page']) ? $vars['page'] : ''; if ($page !== $qblog_defaultpage && is_qblog()) { return; } if (!isset($is_editable[$page])) { $is_editable[$page] = check_editable($page, false, false); } list($dummy, $count, $secid) = explode('_', $id); if (PKWK_READONLY || $plugin !== 'read' || !$is_editable[$page] || $count > 1 && PLUGIN_SECEDIT_PAGE === $page || !PLUGIN_SECEDIT_ENABLE_ON_KEITAI_PROFILE && UA_PROFILE === 'keitai') { return false; } $secid = '&id=' . strval($secid + 1); if ($count > 1 && preg_match('/<a[^>]+id="([A-Za-z][\\w-]*)"/', $string, $matches)) { $secid = '&anchor=' . $matches[1]; } elseif ($count > 1) { return false; } $open = '<' . $tag . $param . '>'; $close = '</' . $tag . '>'; $link = get_script_uri() . '?cmd=secedit&page=' . rawurlencode($page) . $secid; $link .= PLUGIN_SECEDIT_LEVEL ? '&level=true' : ''; return str_replace(array('$1', '$2', '$3', '$4'), array($open, $string, $link, $close), PLUGIN_SECEDIT_LINK_STYLE); }
/** * QBlog Footer Plugin * ------------------------------------------- * ./plugin/qblog_foot.inc.php * * Copyright (c) 2012 hokuken * http://hokuken.com/ * * created : 12/08/01 * modified : * */ function plugin_qblog_foot_convert() { global $vars, $script, $qblog_page_re, $qblog_defaultpage; global $qblog_include_page, $qblog_social_widget, $qblog_social_html, $qblog_social_wiki; $qt = get_qt(); $page = $vars['page']; if ($page === $qblog_defaultpage or !is_qblog()) { return ''; } $addquery = ''; $datafile = CACHEQBLOG_DIR . 'qblog_recent.dat'; if (isset($vars['mode'])) { $mode = trim($vars['mode']); if ($mode === 'category') { //カテゴリーから来た時はキャッシュ無効 $qt->enable_cache = FALSE; $cat = trim($vars['catname']); $datafile = CACHEQBLOG_DIR . encode($cat) . '.qbc.dat'; $addquery = '&mode=category&catname=' . rawurlencode($cat); } else { if ($mode === 'archives') { //月別アーカイブから来た時はキャッシュ無効 $qt->enable_cache = FALSE; $date = $vars['date']; $addquery = '&mode=archives&date=' . rawurlencode($date); } } } //前後の記事を qblog_recent.dat から持ってくる。 $fp = fopen($datafile, 'r'); $prev = $next = $most_recent = ''; $notfound = TRUE; if ($fp) { if ($mode !== 'category') { //件数の行を飛ばす fgets($fp, 64); } while (!feof($fp)) { $line = trim(fgets($fp, 64)); if ($most_recent === '') { $most_recent = $line; } if ($page === $line) { $notfound = FALSE; if (!feof($fp)) { $prev = trim(fgets($fp, 64)); } break; } $next = $line; } fclose($fp); } //新規記事追加後で、リストに自分のページ名がない場合 if ($notfound && $most_recent !== '') { $prev = $most_recent; $next = ''; } //日付アーカイブからのアクセスでは、同月のみ表示 if ($mode === 'archives') { $prev = $prev && $date == get_qblog_date('Ym', $prev) ? $prev : FALSE; $next = $next && $date == get_qblog_date('Ym', $next) ? $next : FALSE; } $prevlink = $script . '?' . rawurlencode($prev) . $addquery; $nextlink = $script . '?' . rawurlencode($next) . $addquery; $pagelink = $script . '?' . rawurlencode($page); $foot = '<ul class="pager">'; $foot .= $next ? '<li class="next"><a href="' . h($nextlink) . '">次の記事 →</a></li>' : ''; // $foot .= '<li><a href="'. h($pagelink) .'">パーマリンク</a></li>';//TODO: 自分自身へのリンクは消される $foot .= $prev ? '<li class="previous"><a href="' . h($prevlink) . '">← 前の記事</a></li>' : ''; $foot .= '</ul>'; //<link> を出力する $head = '<link rel="contents" href="' . h($script . '?' . $qblog_defaultpage) . '" />'; $head .= $prev ? '<link rel="prev" href="' . h($prevlink) . '" />' : ''; $head .= $next ? '<link rel="next" href="' . h($nextlink) . '" />' : ''; $qt->appendv_once('qblog_foot', 'beforescript', $head); // ! ソーシャルボタンなど、共通部品を出力する if ($qblog_social_widget === 'default') { $foot = convert_html("#social_buttons") . $foot; } else { if ($qblog_social_widget === 'wiki') { $foot = convert_html($qblog_social_wiki) . $foot; } else { if ($qblog_social_widget === 'html') { $foot = $qblog_social_html . $foot; } } } return $foot; }