function plugin_ganatracker2_inline() { global $accesstag_moved; global $accesstag; global $vars; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; //parameter check $args = func_get_args(); $num = func_num_args(); if ($num != 3) { return $qm->replace('fmt_err_iln', 'ganatracker2', $qm->m['plg_ganatracker2']['err_usage_iln']); } $text = strip_autolink(array_pop($args)); //テキストデータ $tname = array_pop($args); $url = array_pop($args); if (!is_url($url)) { $url = 'index.php?' . rawurlencode($url); } $acc_tag = ''; //初めて呼び出される場合、accesstag情報を表示する if (!$accesstag_moved) { $acc_tag = $accesstag; $accesstag_moved = 1; //accesstag_movedを設定 } $ret = $acc_tag . '<a href="' . $url . '" onClick="javascript:pageTracker._trackPageview(\'' . $tname . '\');">' . $text . '</a>'; $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<div style="border:2px dashed #f00;background-color:#fee;margin:1em">' . $ret . '<br />' . $qm->replace('plg_ganatracker2.ntc_admin', $tname) . '</div>'; } else { return $ret; } }
function plugin_color_inline() { global $pkwk_dtd; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // htmlsc(text) already $color = isset($args[0]) ? trim($args[0]) : ''; $bgcolor = isset($args[1]) ? trim($args[1]) : ''; if ($color == '' && $bgcolor == '' || func_num_args() > 3) { return PLUGIN_COLOR_USAGE; } if ($text == '') { if ($color != '' && $bgcolor != '') { $text = htmlsc($bgcolor); $bgcolor = ''; } else { return PLUGIN_COLOR_USAGE; } } foreach (array($color, $bgcolor) as $_color) { if ($_color != '' && !preg_match(PLUGIN_COLOR_REGEX, $_color)) { return '&color():Invalid color: ' . htmlsc($_color) . ';'; } } if ($color != '') { $color = 'color:' . $color; } if ($bgcolor != '') { $bgcolor = 'background-color:' . $bgcolor; } $delimiter = $color != '' && $bgcolor != '' ? ';' : ''; return '<span class="wikicolor" style="' . $color . $delimiter . $bgcolor . '">' . $text . '</span>'; }
function plugin_commu_logout_inline() { //キャッシュを無効に if (QHM_VERSION < 4.6) { global $enable_cache; $enable_cache = false; } else { $qt = get_qt(); $qt->enable_cache = false; } $args = func_get_args(); $text = strip_autolink(array_pop($args)); if ($text == "") { $text = 'ログアウト'; } $dirpath = ''; if ($handle = opendir('./commu')) { $dirpath = "./commu/"; closedir($handle); } else { if ($handle = opendir('../commu')) { $dirpath = "../commu/"; closedir($handle); } else { return PLUGIN_COMMU_INFO_NOCOMMU; } } return '<a href="' . $dirpath . 'user_logout.php">' . $text . '</a>'; }
function plugin_ga_link_inline() { global $accesstag_moved; global $accesstag; global $vars; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //parameter check $args = func_get_args(); $num = func_num_args(); if ($num != 2) { return $qm->replace('fmt_err_iln', 'ga_link', $qm->m['plg_ga_link']['err_usage']); } $text = strip_autolink(array_pop($args)); //テキストデータ $url = array_pop($args); if (!is_url($url)) { $url = 'index.php?' . rawurlencode($url); } $acc_tag = ''; //初めて呼び出される場合、accesstag情報を表示する if (!$accesstag_moved) { $accesstag_moved = TRUE; //accesstag_movedを設定 $editable = edit_auth($page, FALSE, FALSE); if (!$editable) { $qt->setv('toolkit_upper', $accesstag); } } //Google Analytics用のjavascriptを先に読み込んでから、関数を呼び出す $ret = '<a href="index.php?cmd=ga_link&url=' . rawurlencode($url) . '" onClick="javascript:pageTracker._link(this.href);return false;">' . $text . '</a>'; return $ret; }
function plugin_greybox_inline() { $qm = get_qm(); $addscript = ' <script type="text/javascript"> var GB_ROOT_DIR = "./plugin/greybox/"; </script> <script type="text/javascript" src="./plugin/greybox/AJS.js"></script> <script type="text/javascript" src="./plugin/greybox/AJS_fx.js"></script> <script type="text/javascript" src="./plugin/greybox/gb_scripts.js"></script> <link href="./plugin/greybox/gb_styles.css" rel="stylesheet" type="text/css" /> '; $qt = get_qt(); $qt->appendv_once('plugin_greybox', 'beforescript', $addscript); $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($url, $title, $group) = array_pad($args, 3, ''); if ($url == '' && $group == '' || $text == '' || func_num_args() > 4) { return $qm->replace('fmt_err_iln', 'greybox', $qm->m['plg_greybox']['err_usage']); } $url = htmlspecialchars($url); $title = htmlspecialchars($title); $group = htmlspecialchars($group); $title = $title == '' ? '' : ' title="' . $title . '"'; //image grey box if (preg_match("/.*(jpg|jpeg|png|gif)\$/i", $url)) { $rel = $group == '' ? ' rel="gb_image[]"' : ' rel="gb_imageset[' . $group . ']"'; } else { //web grey box $rel = $group == '' ? ' rel="gb_page_fs[]"' : 'rel="gb_pageset[' . $group . ']"'; } $ret = '<a href="' . $url . '" ' . $title . $rel . '>' . $text . '</a>'; return $ret; }
function plugin_redirect_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); //キャッシュしない $qt->enable_cache = false; $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $url = strip_autolink(array_shift($args)); $status = array_shift($args); $status_codes = array('301' => 'HTTP/1.1 301 Moved Permanently'); if (isset($status_codes[$status])) { $headers[] = $status_codes[$status]; } if ($url == '') { $url = $script . '?FrontPage'; } else { $url = is_url($url) ? $url : $script . '?' . rawurlencode($url); } $editable = ss_admin_check(); //自分自身にリダイレクトして、ループする場合は警告する if ($url === $script . '?' . rawurlencode($page)) { return $qm->m['plg_redirect']['err_self_ref']; } if ($editable) { return $qm->replace('plg_redirect.ntc_admin', $url); } else { $headers[] = 'Location: ' . $url; foreach ($headers as $header) { header($header); } exit; } }
function plugin_chpassword_inline() { global $script, $vars; global $auth_users; $qm = get_qm(); $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($dispflg) = array_pad($args, 1, 'false'); $_page = isset($vars['page']) ? $vars['page'] : ''; $url = $script . '?plugin=qhmsetting&mode=form&phase='; if ($text == '') { $text = $qm->m['plg_chpassword']['label']; } $is_login = false; if (isset($_SESSION['usr']) && array_key_exists($_SESSION['usr'], $auth_users)) { if (ss_admin_check()) { // 管理者 $url .= 'admin'; } else { $url .= 'user2'; } $is_login = true; } else { // ログイン $url = $script . '?cmd=qhmauth'; } $ret = ''; if ($dispflg == 'true' || $dispflg == 'false' && $is_login) { $ret = '<a href="' . $url . '" >' . $text . '</a>'; } return $ret; }
function plugin_redirect_iframe_convert() { global $vars, $script; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $url = strip_autolink(array_pop($args)); if ($url == '') { $url = $script . '?' . rawurlencode($page); } else { $url = is_url($url) ? $url : $script . '?' . rawurlencode($url); } $editable = ss_admin_check(); if ($editable) { return $qm->replace('plg_redirect_iframe.ntc_admin', $url); } else { return <<<EOD <span id="redirect_iframe_msg"><p style="color:gray"><a href="{$url}" target="new">{$qm->m['plg_redirect_iframe']['link']}</a></p></span> <script type="text/javascript"> <!-- if(parent != self){ parent.location.href="{$url}"; } else{ var element = document.getElementById("redirect_iframe_msg"); element.innerHTML = ""; } //--> </script> EOD; } }
function plugin_dllink_inline() { global $vars, $script; $qm = get_qm(); $page = $vars['page']; if (!(PKWK_READONLY > 0 or is_freeze($page) or plugin_dllink_is_edit_auth($page))) { return $qm->replace('fmt_err_not_editable', '&dllink', $page); } $args = func_get_args(); $args_num = count($args); if ($args_num < 1 || 5 < $args_num) { return $qm->replace('fmt_err_iln', 'dllink', $qm->m['plg_dllink']['err_usage']); } $filename = ""; $label = ""; $email = ""; $title = ""; $label = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($filename, $email, $title) = array_pad($args, 3, ''); //param check if (!is_url($filename) && !file_exists($filename)) { return $qm->replace('plg_dlbutton.err_file_notfound', ''); } $label = $label == '' ? $qm->m['plg_dllink']['label'] : $label; if ($email != '') { if (!preg_match('/^[a-zA-Z0-9_\\.\\-]+?@[A-Za-z0-9_\\.\\-]+$/', $email)) { return $qm->replace('plg_dlbutton.err_invalid_email', $email); } } $title = $title == '' ? $qm->replace('plg_dlbutton.subject') : $title; if (isset($vars['page_alt'])) { $page = $vars['page_alt']; } //url encode $title = urlencode($title); $filename = urlencode($filename); $page = urlencode($page); //ボタン作成 $md5 = md5(file_get_contents('qhm.ini.php')); if ($email == '') { $dlurl = dirname($script) . '/plugin/dlexec.php?filename=' . $filename . '&key=' . $md5; } else { $dlurl = dirname($script) . '/plugin/dlexec.php?filename=' . $filename . '&key=' . $md5 . '&email=' . $email . '&title=' . $title; } $dlurl .= '&refer=' . $page; $btn = '<a onClick=\'location.href="' . h($dlurl) . '"\' style="cursor:pointer;">' . $label . '</a>'; return $btn; }
function plugin_ruby_inline() { if (func_num_args() != 2) { return PLUGIN_RUBY_USAGE; } $args = func_get_args(); $body = trim(strip_autolink(array_pop($args))); // htmlsc() already $ruby = isset($args[0]) ? trim($args[0]) : ''; // strip_htmltag() is just for avoiding AutoLink insertion if ($ruby == '' || $body == '') { return PLUGIN_RUBY_USAGE; } return '<ruby>' . '<rb>' . $body . '</rb>' . '<rp>(</rp>' . '<rt>' . htmlsc($ruby) . '</rt>' . '<rp>)</rp>' . '</ruby>'; }
function plugin_otherwin_inline() { global $pkwk_dtd; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($url, $target) = array_pad($args, 2, ''); if ($url == '' && $target == '' || $text == '' || func_num_args() > 3) { return PLUGIN_OTHERWIN_USAGE; } $url = is_url($url) ? $url : 'index.php?' . rawurlencode($url); $target = $target == '' ? '_blank' : $target; $ret = '<a href="' . $url . '" target="' . $target . '" >' . $text . '</a>'; return $ret; }
function plugin_stationary_inline() { if (PKWK_SAFE_MODE || PKWK_READONLY) { return ''; } // See above // {bar} is always exists, and already sanitized $args = func_get_args(); $body = strip_autolink(array_pop($args)); // {bar} foreach (array_keys($args) as $key) { $args[$key] = trim($args[$key]); } $result = join(',', $args); return '&stationary(' . htmlsc($result) . '){' . $body . '};'; }
function plugin_conversion_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $num = func_num_args(); //---- キャッシュのための処理を登録 ----- if ($qt->create_cache) { $args = func_get_args(); return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args); } //------------------------------------ //check if ($num != 2 && $num != 4) { return $qm->replace('fmt_err_cvt', 'conversion', $qm->m['plg_conversion']['err_usage']); } //変数を格納 $step = strip_autolink($args[0]); $group = strip_autolink($args[1]); $pattern = isset($args[2]) ? $args[2] : ''; $name = isset($args[3]) ? $args[3] : $page; $en_group = rawurldecode($group); //edit auth check $editable = edit_auth($page, FALSE, FALSE); //編集モードの場合 if ($editable) { $msg = plugin_conversion_msg(); return <<<EOD <div style="border:1px dashed #666;background-color:#eee;margin:1em;padding:0px 1em;"> <p><strong>{$qm->m['plg_conversion']['ntc_admin']}</strong></p> <ul> <li>ページ名 : {$name}</li> <li>グループ名 : {$group}</li> <li>ステップ : {$step}</li> <li><a href="{$script}?cmd=conversion&group={$en_group}" target="new">{$qm->m['plg_conversion']['label_result']}</a></li> <li>パターン : {$pattern}</li> </ul> <p>{$msg}</p> </div> EOD; } //コンバージョン計測 return plugin_conversion_count($step, $group, $name, $pattern); }
function plugin_stationary_inline() { // if (PKWK_SAFE_MODE || PKWK_READONLY) return ''; // See above if (auth::check_role('safemode') || auth::check_role('readonly')) { return ''; } // See above // {bar} is always exists, and already sanitized $args = func_get_args(); $body = strip_autolink(array_pop($args)); // {bar} foreach (array_keys($args) as $key) { $args[$key] = trim($args[$key]); } $result = join(',', $args); return '&stationary(' . htmlspecialchars($result) . '){' . $body . '};'; }
function plugin_ganatracker_inline() { global $accesstag_moved; global $accesstag; global $vars; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; //parameter check $args = func_get_args(); $num = func_num_args(); if ($num != 3) { return $qm->replace('fmt_err_iln', 'ganatracker', $qm->m['plg_ganatracker']['err_usage_iln']); } $text = strip_autolink(array_pop($args)); //テキストデータ $tname = array_pop($args); $url = array_pop($args); if (!is_url($url)) { $url = 'index.php?' . rawurlencode($url); } $acc_tag = ''; //初めて呼び出される場合、accesstag情報を表示する if (!$accesstag_moved) { $acc_tag = $accesstag; $accesstag_moved = 1; //accesstag_movedを設定 } //Google Analytics Tracking code check ( New or Old) //新しいものは、gaJsHost変数が使われている // $version = $qm->m['plg_ganatracker']['old']; if (strstr($accesstag, "gaJsHost") == false) { //Old version $ret = $acc_tag . '<a href="' . $url . '" onClick="javascript:urchinTracker(\'' . $tname . '\');">' . $text . '</a>'; } else { //New version or none or invalid tag $version = $qm->m['plg_ganatracker']['new']; $ret = $acc_tag . '<a href="' . $url . '" onClick="javascript:pageTracker._trackPageview(\'' . $tname . '\');">' . $text . '</a>'; } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<div style="border:2px dashed #f00;background-color:#fee;margin:1em">' . $ret . "<br />" . $qm->replace('plg_ganatracker.ntc_admin', $version, $tname) . "</div>"; } else { return $ret; } }
function plugin_absplit_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //--- キャッシュを無効に --- $qt->enable_cache = false; $args = func_get_args(); $num = func_num_args(); //check if ($num != 2) { return "<p>{$qm->m['plg_absplit']['err_param_count']}</p>"; } $url = array(); $url[1] = strip_autolink(array_pop($args)); $url[0] = strip_autolink(array_pop($args)); if (!is_url($url[0])) { return "<p> " . $qm->replace('plg_absplit.err_invalid_url', $url[0]) . "</p>"; } if (!is_url($url[1])) { return "<p> " . $qm->replace('plg_absplit.err_invalid_url', $url[1]) . "</p>"; } //edit auth check $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return $qm->replace('plg_absplit.ntc_admin', $url[0], $url[1], $page); } else { //generate cookie name from $page $ckname = encode($page); if (isset($_COOKIE[$ckname])) { $target = $_COOKIE[$ckname]; header("Location: " . $url[$target]); exit; } else { $target = rand(0, 1); //set cookie for split test $result = setcookie($ckname, $target, time() + 60 * 60 * 24 * 30); header("Location: " . $url[$target]); exit; } } }
function plugin_color_inline() { global $pkwk_dtd; $qm = get_qm(); $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($color, $bgcolor) = array_pad($args, 2, ''); if ($color != '' && $bgcolor != '' && $text == '') { // Maybe the old style: '&color(foreground,text);' $text = htmlspecialchars($bgcolor); $bgcolor = ''; } if ($color == '' && $bgcolor == '' || $text == '' || func_num_args() > 3) { return $qm->m['plg_color']['err_usage']; } // Invalid color foreach (array($color, $bgcolor) as $col) { if ($col != '' && !preg_match(PLUGIN_COLOR_REGEX, $col)) { return $qm->replace('plg_color.err_invalid_color', h($col)); } } if (PLUGIN_COLOR_ALLOW_CSS === TRUE || !isset($pkwk_dtd) || $pkwk_dtd == PKWK_DTD_XHTML_1_1) { $delimiter = ''; if ($color != '' && $bgcolor != '') { $delimiter = '; '; } if ($color != '') { $color = 'color:' . $color; } if ($bgcolor != '') { $bgcolor = 'background-color:' . $bgcolor; } return '<span style="' . $color . $delimiter . $bgcolor . '">' . $text . '</span>'; } else { if ($bgcolor != '') { return $qm->m['plg_color']['err_bgcolor']; } else { return '<font color="' . $color . '">' . $text . '</font>'; } } }
function plugin_color_inline() { global $pkwk_dtd; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlsc(text) list($color, $bgcolor) = array_pad($args, 2, ''); if ($color != '' && $bgcolor != '' && $text == '') { // Maybe the old style: '&color(foreground,text);' $text = htmlsc($bgcolor); $bgcolor = ''; } if ($color == '' && $bgcolor == '' || $text == '' || func_num_args() > 3) { return PLUGIN_COLOR_USAGE; } // Invalid color foreach (array($color, $bgcolor) as $col) { if ($col != '' && !preg_match(PLUGIN_COLOR_REGEX, $col)) { return '&color():Invalid color: ' . htmlsc($col) . ';'; } } if (PLUGIN_COLOR_ALLOW_CSS === TRUE || !isset($pkwk_dtd) || $pkwk_dtd == PKWK_DTD_XHTML_1_1) { $delimiter = ''; if ($color != '' && $bgcolor != '') { $delimiter = '; '; } if ($color != '') { $color = 'color:' . $color; } if ($bgcolor != '') { $bgcolor = 'background-color:' . $bgcolor; } return '<span style="' . $color . $delimiter . $bgcolor . '">' . $text . '</span>'; } else { if ($bgcolor != '') { return '&color(): bgcolor (with CSS) not allowed;'; } return '<font color="' . $color . '">' . $text . '</font>'; } }
function plugin_lightbox2_inline() { global $vars; $qm = get_qm(); $qt = get_qt(); $qt->setv('jquery_include', true); $addscript = ' <script type="text/javascript" src="js/jquery.dimensions.min.js"></script> <script type="text/javascript" src="js/jquery.dropshadow.js"></script> <script type="text/javascript" src="' . LIGHTBOX2_LIB . '/js/jquery.lightbox.js"></script> <link href="' . LIGHTBOX2_LIB . '/css/lightbox.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(document).ready(function(){ $(".lightbox").lightbox(); }); </script> '; $qt->appendv_once('plugin_lightbox2', 'beforescript', $addscript); $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($img, $title, $group, $bg_color) = array_pad($args, 4, ''); if ($img == '' && $group == '' || $text == '' || func_num_args() > 5) { return $qm->replace('fmt_err_iln', 'lightbox2', $qm->m['plg_lightbox2']['err_usage']); } $img = htmlspecialchars($img); $title = htmlspecialchars($title); $group = htmlspecialchars($group); if ($bg_color != '') { $addstyle = '<style type="text/css">div#overlay{background-color:' . $bg_color . ';}</style>'; $qt->appendv_once('plugin_lightbox2_bgcolor', 'beforescript', $addstyle); } if ($group == '') { $group = ""; } else { $group = ' rel="' . $group . '"'; } $ret = '<a href="' . $img . '" title="' . $title . '" class="lightbox" ' . $group . '>' . $text . '</a>'; return $ret; }
function plugin_new_inline() { global $vars, $_plugin_new_elapses; $retval = ''; $args = func_get_args(); $date = strip_autolink(array_pop($args)); // {date} always exists if ($date !== '') { // Show 'New!' message by the time of the $date string if (func_num_args() > 2) { return '&new([nodate]){date};'; } $timestamp = strtotime($date); if ($timestamp === -1) { return '&new([nodate]){date}: Invalid date string;'; } $timestamp -= ZONETIME; $retval = in_array('nodate', $args) ? '' : htmlsc($date); } else { // Show 'New!' message by the timestamp of the page if (func_num_args() > 3) { return '&new(pagename[,nolink]);'; } $name = strip_bracket(!empty($args) ? array_shift($args) : $vars['page']); $page = get_fullname($name, $vars['page']); $nolink = in_array('nolink', $args); if (substr($page, -1) == '/') { // Check multiple pages started with "$page" $timestamp = 0; $regex = '/^' . preg_quote($page, '/') . '/'; foreach (preg_grep($regex, get_existpages()) as $page) { // Get the latest pagename and its timestamp $_timestamp = get_filetime($page); if ($timestamp < $_timestamp) { $timestamp = $_timestamp; $retval = $nolink ? '' : make_pagelink($page); } } if ($timestamp == 0) { return '&new(pagename/[,nolink]): No such pages;'; } } else { // Check a page if (is_page($page)) { $timestamp = get_filetime($page); $retval = $nolink ? '' : make_pagelink($page, $name); } else { return '&new(pagename[,nolink]): No such page;'; } } } // Add 'New!' string by the elapsed time $erapse = UTIME - $timestamp; foreach ($_plugin_new_elapses as $limit => $tag) { if ($erapse <= $limit) { $retval .= sprintf($tag, get_passage($timestamp)); break; } } if ($date !== '') { // Show a date string return sprintf(PLUGIN_NEW_DATE_FORMAT, $retval); } else { // Show a page name return $retval; } }
function plugin_addfavorite_inline() { global $script; $qm = get_qm(); $args = func_get_args(); $text = trim(strip_autolink(array_pop($args))); // Already htmlspecialchars(text) list($sitename, $linktype) = array_pad($args, 2, ''); if ($sitename == '') { return $qm->m['plg_addfavorite']['err_no_sitename']; } if ($text == '') { $text_ie = $qm->m['plg_addfavorite']['ie']; $text_fx = $qm->m['plg_addfavorite']['firefox']; $text_op = $qm->m['plg_addfavorite']['opera']; } else { $text_ie = $text_fx = $text_op = $text; } switch ($linktype) { case "button": $src = <<<EOD <script type="text/javascript"> <!-- if(navigator.userAgent.indexOf("MSIE") > -1){ //Internet Explorer document.write('<!-'+'-[if IE]>'); document.write('<input type="button" value="{$text_ie}"'); document.write(' onclick="window.external.AddFavorite(\\'{$script}\\',\\'{$sitename}\\')">'); document.write('<![endif]-'+'->'); } else if(navigator.userAgent.indexOf("Firefox") > -1){ //Firefox document.write('<input type="button" value="{$text_fx}"'); document.write(' onclick="window.sidebar.addPanel(\\'{$sitename}\\',\\'{$script}\\',\\'\\');">'); } else if(navigator.userAgent.indexOf("Opera") > -1){ //Opera document.write('<a href="{$script}" rel="sidebar" title="{$sitename}">{$text_op}</a>'); } else { void(0); } //--> </script> EOD; break; default: $src = <<<EOD <script type="text/javascript"> <!-- if(navigator.userAgent.indexOf("MSIE") > -1){ //Internet Explorer document.write('<!-'+'-[if IE]>'); document.write('<a href="#" onclick="javascript:window.external.addFavorite(\\'{$script}\\',\\'{$sitename}\\')">{$text_ie}</a>'); document.write('<![endif]-'+'->'); } else if(navigator.userAgent.indexOf("Firefox") > -1){ //Firefox document.write('<a href="#" onclick="javascript:window.sidebar.addPanel(\\'{$sitename}\\',\\'{$script}\\',\\'\\');">{$text_fx}</a>'); } else if(navigator.userAgent.indexOf("Opera") > -1){ //Opera document.write('<a href="#" onclick="{$script}" rel="sidebar" title="{$sitename}">{$text_op}</a>'); } else { void(0); } //--> </script> EOD; } return $src; }
function plugin_slides_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); $qt->setv('jquery_include', true); $qt->setv('jquery_cookie_include', true); static $id = 0; $id++; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($frame, $float, $play, $easing, $easing1) = array_pad($args, 5, ''); global $enable_smart_style; $frame_width = 739; $frame_height = 341; $slides_container_width = 570; $slides_container_height = 270; $container_width = 550; $container_height = 320; $slides_btn_top = 107; if ($frame == "small") { $frame_image = "frame_small.png"; $frame_width = 350; $frame_height = 252; $slides_container_width = 182; $slides_container_height = 181; $container_width = 168; $container_height = 220; $slides_btn_top = 68; } else { if ($frame == "large") { $frame_image = "frame_large.png"; $frame_width = 1067; $frame_height = 300; $slides_container_width = 900; $slides_container_height = 200; $container_width = 1067; $container_height = 250; $slides_btn_top = 76; if (is_smart_phone() && $enable_smart_style) { $frame_image = "frame_large.png"; $frame_width = 550; $frame_height = 180; $slides_container_width = 540; $slides_container_height = 120; $container_width = 550; $container_height = 180; $slides_btn_top = 30; } } else { if ($frame == "portrait") { $frame_image = "frame_portrait.png"; $frame_width = 388; $frame_height = 406; $slides_container_width = 227; $slides_container_height = 333; $container_width = 216; $container_height = 406; $slides_btn_top = 146; } else { if ($frame == "black") { $frame_image = "frame_black.png"; } else { if ($frame == "cargo") { $frame_image = "frame_cargo.png"; } else { if ($frame == "cotton") { $frame_image = "frame_cotton.png"; } else { if ($frame == "iron") { $frame_image = "frame_iron.png"; } else { if ($frame == "wood") { $frame_image = "frame_wood.png"; } else { if ($frame == "board") { $frame_image = "frame_board.png"; } else { $frame_image = "frame_default.png"; } } } } } } } } } $play = $play == '' ? 5000 : $play * 1000; $easing = $easing == '' ? "easeOutQuint" : $easing; $easing1 = $easing1 == '' ? "easeOutQuint" : $easing1; if ($float == "right") { $float = $float; $marginLeft = '40px'; $marginRight = '40px'; } else { if ($float == "left") { $float = $float; $marginLeft = '40px'; $marginRight = '40px'; } else { $float = "none"; $marginLeft = "auto"; $marginRight = "auto"; } } $addoncescript = ' <script src="js/jquery.easing.1.3.js" type="text/javascript"></script> <script src="js/slides.jquery.js" type="text/javascript"></script> '; $qt->prependv_once('plugin_slides_jquery', 'beforescript', $addoncescript); $addscript = ' <style type="text/css"> a.prev:hover,a.next:hover{ background-color:transparent!important; } .slides_container a img { display:block; margin: 0 auto; } .slides_pagination li { float:left; margin:0 1px; list-style:none; } .slides_pagination li a { display:block; width:12px; height:0; padding-top:12px; background-image:url(image/slides/pagination.png); background-position:0 0; float:left; overflow:hidden; } .slides_pagination li.current a { background-position:0 -12px; } </style> '; $qt->appendv_once('plugin_slides', 'beforescript', $addscript); $eachscript = ' <style type="text/css"> #slides_' . $id . ' .slides_container { width:' . $slides_container_width . 'px; overflow:hidden; position:relative; display:none; } #slides_' . $id . ' .slides_container a { width:' . $slides_container_width . 'px; height:' . $slides_container_height . 'px; display:block; } #container_' . $id . ' { width:' . $container_width . 'px; height: ' . $container_height . 'px; padding:10px; margin:10px auto 0; position:relative; z-index:0; float: ' . $float . '; margin-left: ' . $marginLeft . '; margin-right: ' . $marginRight . '; } #frame_' . $id . ' { position:absolute; z-index:0; width:' . $frame_width . 'px; height:' . $frame_height . 'px; top:-3px; left:-80px; max-width: none; } #slides_' . $id . ' { position:absolute; top:15px; left:4px; z-index:100; } #slides_' . $id . ' .next,#slides_' . $id . ' .prev { position:absolute; top:' . $slides_btn_top . 'px; left: -24px; width:24px; height:34px; display:block; z-index:101; } #slides_' . $id . ' .next img,#slides_' . $id . ' .prev img{ -ms-filter: "alpha( opacity=30 )"; filter: alpha( opacity=30 ); opacity: 0.3; width: 100%; } #slides_' . $id . ' .next:hover img,#slides_' . $id . ' .prev:hover img { opacity:0.8; } #slides_' . $id . ' .next { left: ' . $slides_container_width . 'px; } #wrapper ul.slides_pagination { margin:26px auto 0; width:135px; padding: 0; } </style> <script type="text/javascript"> <!-- $(function(){ $("#slides_' . $id . '").slides({ preload: true, preloadImage: "image/slides/slide_loading.gif", play: ' . $play . ', pause: 2500, hoverPause: true, slideEasing: "' . $easing . '", paginationClass : "slides_pagination" }); }); //--> </script> <script type="text/javascript"> <!-- $(function(){ $("#slides_' . $id . ' .next img,#slides_' . $id . ' .prev img").hover(function(){ $(this).fadeTo("fast",0.8); },function(){ $(this).fadeTo("fast",0.3); }); $("#slides_' . $id . ' .slides_control img").hover(function(){ $(this).fadeTo("100",0.8,"' . $easing1 . '"); },function(){ $(this).fadeTo("fast",1.0); }); }); //--> </script> '; if ($frame == "large" && is_smart_phone() && $enable_smart_style) { $eachscript .= ' <style> #main_visual #frame_' . $id . ' { left: -36px; width: 640px; height: 178px; top: 0; } #main_visual #slides_' . $id . ' { left: 14px; top: 10px; } #slides_' . $id . ' .slides_container img{ max-width: 100%; } </style> '; } $qt->appendv('beforescript', $eachscript); $text = str_replace(array("\r\n", "\r"), array("\n", "\n"), $text); $lines = explode("\n", $text); $ret = ' <div id="container_' . $id . '"> <div id="slides_' . $id . '"> <div class="slides_container">'; foreach ($lines as $line) { list($url, $link, $title, $alt) = array_pad(explode(',', $line), 4, ''); if (trim($url) == '') { continue; } $is_url = is_url($url); if (!$is_url) { $file = $url; if (!is_file($file)) { $file = SWFU_IMAGE_DIR . $file; if (!is_file($file)) { return $qm->replace('plg_show.err_notfound', h($url)); } } } else { $file = $url; } //first image をセット $qt->set_first_image($is_url ? $url : dirname($script) . '/' . $file); if (is_page($link)) { if ($vars['page'] != $link) { $link = $script . '?' . rawurlencode($link); } else { $link = '#'; } } $ret .= '<a href="' . $link . '"><img src="' . $file . '" alt="' . $alt . '" title="' . $title . '" /></a>' . "\n"; } $ret .= '</div> <a href="#" class="prev"><img src="image/slides/arrow-prev.png" width="24" height="43" alt="Arrow Prev" /></a> <a href="#" class="next"><img src="image/slides/arrow-next.png" width="24" height="43" alt="Arrow Next" /></a> </div> <img src="image/slides/' . $frame_image . '" alt="Frame" id="frame_' . $id . '" width="' . $frame_width . '" height="' . $frame_height . '" /></div>'; return $ret; }
function plugin_deco_inline() { global $pkwk_dtd; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) if (!isset($args[0])) { //引数が足りない return PLUGIN_DECO_USAGE; } //分解 $color = array(); $ccnt = 0; $size = ''; $weight = ''; $underline = ''; $italic = ''; $strong = false; foreach ($args as $v) { if (is_numeric($v)) { $size = $v . 'px'; } else { if (preg_match('/^(\\d|\\.)/', $v)) { $size = $v; } else { if (preg_match('/small|medium|large/', $v)) { $size = $v; } else { if ($v == 'bold' || $v == 'b') { $strong = true; } else { if ($v == 'underline' || $v == 'u') { $underline = 'text-decoration:underline;'; } else { if ($v == 'italic' || $v == 'i') { $italic = 'font-style:italic;'; } else { if (preg_match(PLUGIN_DECO_REGEX, $v)) { $color[$ccnt] = $v; $ccnt++; } else { if ($v == '') { $color[$ccnt] = 'inherit'; $ccnt++; } } } } } } } } } $style = 'style="'; $style .= $size == '' ? '' : 'font-size:' . $size . ';'; $style .= isset($color[0]) && $color[0] != '' ? 'color:' . $color[0] . ';' : ''; $style .= isset($color[1]) && $color[1] != '' ? 'background-color:' . $color[1] . ';' : ''; $style .= $underline . $italic; $style .= '" '; if ($strong) { $stg_s = '<strong>'; $stg_e = '</strong>'; } else { $stg_s = ''; $stg_e = ''; } return '<span ' . $style . ' class="qhm-deco">' . $stg_s . $text . $stg_e . '</span>'; }
function plugin_slideshow_convert() { global $vars; $qm = get_qm(); $qt = get_qt(); $qt->setv('jquery_include', true); $qt->setv('jquery_cookie_include', true); static $id = 0; $id++; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) list($height, $random, $interval, $margin_left, $speed) = array_pad($args, 5, ''); if ($height == '') { return "<p>{$qm->m['plg_slideshow']['err_noheight']}</p>"; } $height = is_numeric($height) ? $height : 350; $random = $random == 'true' ? $random : 'false'; $interval = $interval == '' ? 3000 : $interval * 1000; $margin_left = $margin_left == '' ? 0 : $margin_left; $speed = $speed == '' ? 1000 : $speed * 1000; $addscript = ' <script type="text/javascript"> <!-- $(function(){ $("div.plugin_slideshow").each(function(){ var $$ = $(this), option = $$.data("plugin_slideshow_option"); $$.css({ height: option.height, marginLeft: option.marginLeft }); $$.bind("slideImage", function(){ var $active = $("img.active", $$); if ( $active.length == 0 ) { $active = $("img:last-child", $$); } if (option.random) { var $sibs = $active.siblings("img"), randnum = Math.floor(Math.random() * $sibs.length), $next = $sibs.eq(randnum); } else { var $next = $active.next("img").length? $active.next("img"): $("img:first", $$); } $active.addClass("last-active"); $next .css("opacity", 0) .addClass("active") .animate({opacity: 1.0}, option.speed, function(){ $active.removeClass("active last-active"); setTimeout(function(){ $$.triggerHandler("slideImage"); }, option.interval); }); }); setTimeout(function(){ $$.triggerHandler("slideImage"); }, option.interval); }); }); //--> </script> <style type="text/css"> div.plugin_slideshow { position:relative; } div.plugin_slideshow img { position:absolute; top:0; left:0; z-index:8; opacity:0.0; } div.plugin_slideshow img.active { z-index:10; opacity:1.0; } div.plugin_slideshow img.last-active { z-index:9; } </style> '; $qt->appendv_once('plugin_slideshow', 'beforescript', $addscript); $eachscript = ' <script type="text/javascript"> <!-- $(function(){ $("#slideshow_' . $id . '").data("plugin_slideshow_option", {height:' . $height . ', random:' . $random . ', interval:' . $interval . ', marginLeft:' . $margin_left . ', speed:' . $speed . '}); }); //--> </script> '; $qt->prependv('beforescript', $eachscript); $lines = $lines = preg_split("/[\r\n(\r\n)]/", $text); $active = 'class="active"'; $ret = ' <div id="slideshow_' . $id . '" class="plugin_slideshow" >'; foreach ($lines as $line) { list($url, $alt) = array_pad(explode(',', $line), 2, ''); if ($url != '') { $ret .= '<img src="' . h($url) . '" alt="' . h($alt) . '" ' . $active . '/>' . "\n"; $active = ''; //first image をセット $qt->set_first_image(is_url($url) ? $url : dirname($script) . '/' . $url); } } $ret .= '</div>'; return $ret; }
/** * label * ------------------------------------------- * label.inc.php * * Copyright (c) 2014 hokuken * http://hokuken.com/ * * created : 14/06/09 * modified : * * Description * * * Usage : &label([type][classname]){label}; * */ function plugin_label_inline() { $args = func_get_args(); $text = strip_autolink(array_pop($args)); return plugin_label_body($args, $text); }
/** * Image Carousel * ------------------------------------------- * bs_carousel.inc.php * * Copyright (c) 2014 hokuken * http://hokuken.com/ * * created : 14/05/21 * modified : * * Description * * * Usage : * */ function plugin_bs_carousel_convert() { global $vars, $script; static $slide_num = 0; $qt = get_qt(); $args = func_get_args(); $body = strip_autolink(array_pop($args)); // Already htmlspecialchars(text) $indicator = $slide_button = TRUE; $item_height = ''; $item_class = ' fit'; $fit = TRUE; $cols = $cols_offset = NULL; //options foreach ($args as $arg) { switch ($arg) { case 'nobutton': $indicator = $slide_button = FALSE; break; case 'noindicator': $indicator = FALSE; break; case 'noslidebutton': $slide_button = FALSE; break; case 'nofit': $item_class = ''; $fit = FALSE; break; case preg_match('/^height=(.+)$/', $arg, $mts) ? true : false: $item_height = $mts[1]; break; case preg_match('/^(\\d+)(?:\\+(\\d+))?$/', $arg, $mts) ? true : false: $cols = $mts[1]; $cols_offset =& $mts[2]; break; default: } } $body = str_replace("\r", "\n", $body); $lines = explode("\n", $body); $slide_num++; $items = array(); $cnt = 0; $min_width = FALSE; foreach ($lines as $line) { $line = trim($line); if ($line == '') { continue; } $options = explode(',', $line); $to = ''; foreach ($options as $i => $opt) { $opt = trim($opt); if (preg_match('/^link_to=(.*)$/', $opt, $mts)) { $to = $mts[1]; if (!is_url($to) && is_page($to)) { $to = $script . '?' . rawurlencode($to); } break; } } if ($to) { array_splice($options, $i, 1); } $options = join(',', $options); list($filename, $title, $caption) = explode(',', $options, 3); $filepath = get_file_path($filename); $image = ''; if (file_exists($filepath)) { list($_width, $_height) = getimagesize($filepath); $min_width = $min_width !== FALSE ? min($_width, $min_width) : $_width; $image = '<img src="' . h($filepath) . '" alt="">'; $image_url = dirname($script) . '/' . $filepath; } else { $image = '<img src="' . h($filepath) . '" alt="">'; $image_url = $filepath; } // set first image $qt->set_first_image($image_url); $h = $title ? '<h3 class="no-toc">' . h($title) . '</h3>' : ''; // アイキャッチの場合は、タイトルをh1にする global $is_eyecatch; if ($is_eyecatch) { $h = $title ? '<h1 class="no-toc">' . h($title) . '</h1>' : ''; } // 画像クリックでリンク可能にする $onclick = ''; $add_style = ''; if ($to !== '') { $onclick = ' onclick="location.href = \'' . h($to) . '\'"'; $add_style = 'cursor:pointer;'; } $p = $caption ? convert_html($caption) : ''; $block = ($h or $p); $items[] = ' <div class="item' . ($cnt ? '' : ' active') . $item_class . '" style="' . ($item_height ? ' max-height:' . h($item_height) . 'px;min-height:' . h($item_height) . 'px;' : '') . $add_style . '"' . $onclick . '> ' . $image . ' <div class="' . ($block ? 'carousel-caption' : '') . '"> ' . $h . ' ' . $p . ' </div> </div> '; $cnt++; } $plural = $cnt > 1; if ($cnt > 0) { $id = 'slide_' . $slide_num; $html = ' <div id="' . $id . '" class="qhm-bs-carousel carousel slide" data-ride="carousel" style="' . ($fit === FALSE && $min_width !== FALSE ? 'max-width:' . $min_width . 'px;' : '') . '"> '; if ($plural && $indicator) { $html .= ' <ol class="carousel-indicators"> '; for ($i = 0; $i < $cnt; $i++) { $html .= ' <li data-target="#' . $id . '" data-slide-to="' . $i . '" class="' . ($i ? '' : 'active') . '"></li> '; } $html .= ' </ol>'; } $html .= ' <div class="carousel-inner"> ' . join("\n", $items) . ' </div> '; if ($plural && $slide_button) { $html .= ' <a href="#' . $id . '" class="left carousel-control" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a> <a href="#' . $id . '" class="right carousel-control" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a> '; } $html .= ' </div> '; if ($cols) { $class_attr = 'col-sm-' . $cols; if ($cols_offset) { $class_attr .= ' col-sm-offset-' . $cols_offset; } $html = '<div class="row"><div class="' . $class_attr . '">' . $html . '</div></div>' . "\n"; } // Output CSS $addstyle = ' <style> .carousel.qhm-bs-carousel .item.fit > img { width: 100%; max-width: 100%; min-width: 100%; } .carousel .carousel-control { outline-style: none; } </style> '; $qt->appendv_once('plugin_bs_carousel_css', 'beforescript', $addstyle); } return $html; }