Ejemplo n.º 1
0
function plugin_permalink_convert()
{
    global $script, $vars;
    $qm = get_qm();
    $code = get_tiny_code($vars['page']);
    $url = $script . '?go=' . $code;
    if (func_num_args()) {
        $args = func_get_args();
        $text = $args[0];
        if ($text === 'nolabel') {
            $text = '';
        }
    } else {
        $text = $qm->m['plg_permalink']['label_surl'] . ' : ';
    }
    $temp1 = '<p style="text-align:center"><span style="color:gray">' . $text . ' <input type="text" value="%url%" readonly="readonly" onclick="this.select();" style="width:65%;color:gray" /></span></p>';
    return str_replace('%url%', $url, $temp1);
}
Ejemplo n.º 2
0
function plugin_update_tinycode_action()
{
    global $script, $vars, $defaultpage;
    global $username;
    $qm = get_qm();
    //check admin, setting
    if ($username != $_SESSION['usr'] && $vars['phase'] != 'user2' && $vars['phase'] != 'script' && $vars['phase'] != 'sssavepath') {
        return array('msg' => $qm->m['plg_update_tinycode']['title_err_auth'], 'body' => $qm->m['plg_update_tinycode']['err_auth']);
    }
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    // テンプレート指定
    $tinycode_title = $qm->m['plg_update_tinycode']['title'];
    $body_top = '
* ' . $qm->m['plg_update_tinycode']['title'] . ' 

#contents
';
    $body_page = '
** ' . $qm->m['plg_update_tinycode']['hdr_update'] . '

' . $qm->m['plg_update_tinycode']['ntc_update'] . '

- ' . $qm->m['plg_update_tinycode']['update_pagename'] . '
%update_tinycode%

%update_form%

&br;

';
    $body_list = '
** ' . $qm->m['plg_update_tinycode']['hdr_list'] . ' [#list]

' . $qm->m['plg_update_tinycode']['ntc_list'] . '

%list_form%

';
    $body_clean = '
** ' . $qm->m['plg_update_tinycode']['hdr_clean'] . ' [#clean]

' . $qm->m['plg_update_tinycode']['ntc_clean'] . '

%clean_form%
&br;

';
    $body_reset = '
** ' . $qm->m['plg_update_tinycode']['hdr_reset'] . ' [#reset]

' . $qm->m['plg_update_tinycode']['ntc_reset'] . '

%reset_form%
&br;

';
    $body_verup = '
** ' . $qm->m['plg_update_tinycode']['hdr_init'] . ' [#verup]

' . $qm->m['plg_update_tinycode']['ntc_init'] . '

%verup_form%
&br;

';
    $pagename = $vars['page'];
    $go_tinycode_top = '<p style="text-align:right"><a href="' . $script . '?cmd=update_tinycode' . '">&gt;&gt;&nbsp;' . $tinycode_title . '</a></p>';
    $msg = $body = '';
    if (empty($vars['action'])) {
        if ($pagename != '') {
            if (!is_page($pagename)) {
                $btn_name = $qm->m['plg_update_tinycode']['btn_delete'];
                $btn_action = 'clean';
                $deletestyle = ' style="color:red;"';
            } else {
                $btn_name = $qm->m['plg_update_tinycode']['btn_update'];
                $btn_action = 'update';
            }
            $_go_url = $script . '?go=' . get_tiny_code($pagename);
            $update_page = '<span' . $deletestyle . '>' . $pagename . '</span>';
            $update_tinycode = '<input type="text" value="' . $_go_url . '" readonly="readonly"  onclick="this.select();" style="width:400px;" />';
            $update_form = '
<form method="POST" action="' . $script . '">
<input type="hidden" name="plugin" value="update_tinycode" />
<input type="hidden" name="action" value="' . $btn_action . '" />
<input type="hidden" name="page" value="' . h($pagename) . '" />
<input type="submit" value="' . $btn_name . '" />
</form>
' . $go_tinycode_top;
            $body = convert_html($body_top . $body_page);
            $body = str_replace('%update_page%', $update_page, $body);
            $body = str_replace('%update_tinycode%', $update_tinycode, $body);
            $body = str_replace('%update_form%', $update_form, $body);
        } else {
            $tiny_table = get_tiny_table(false);
            $list_form = '<div style="overflow:auto;border:1px solid #dcdcdc;padding:5px 10px;margin-left:auto;margin-right:auto;text-align:justify;width:450px;height:300px">';
            if (count($tiny_table) > 0) {
                $list_form .= '<ul class="list1">';
                ksort($tiny_table);
                foreach ($tiny_table as $pname => $code) {
                    $delstyle = '';
                    if (!is_page($pname)) {
                        $delstyle = ' style="color:red;"';
                    }
                    if (!preg_match("/^:[config|RenameLog]|InterWikiName|InterWiki/", $pname)) {
                        $_go_url = $script . '?go=' . get_tiny_code($pname);
                        $list_form .= '<li style="margin-bottom:0.5em;"><a' . $delstyle . ' href="' . $script . '?cmd=update_tinycode&page=' . h($pname) . '">' . h($pname) . '</a><br /><input type="text" value="' . $_go_url . '" readonly="readonly"  onclick="this.select();" style="width:400px;" /></li>';
                    }
                }
                $list_form .= '</ul>';
            }
            $list_form .= '</div>';
            // クリーニング
            $clean_form = '
<form method="POST" action="' . $script . '">
<input type="hidden" name="plugin" value="update_tinycode" />
<input type="hidden" name="action" value="clean" />
<input type="submit" name="clean" value="' . $qm->m['plg_update_tinycode']['btn_clean'] . '" />
</form>';
            // リセット
            $reset_form = '
<form method="POST" action="' . $script . '">
 <div>
  <input type="hidden" name="plugin" value="update_tinycode" />
  <input type="hidden" name="action" value="reset" />
  <label for="_p_update_entities_adminpass">' . $qm->m['adminpass'] . '</label>
  <input type="password" name="adminpass" id="_p_update_entities_adminpass" size="20" value="" />
  <input type="submit" value="' . $qm->m['plg_update_tinycode']['btn_reset'] . '" />
 </div>
</form>
';
            $body = convert_html($body_top . $body_list . $body_clean . $body_reset);
            $body = str_replace('%list_form%', $list_form, $body);
            $body = str_replace('%clean_form%', $clean_form, $body);
            $body = str_replace('%reset_form%', $reset_form, $body);
        }
    } else {
        if ($vars['action'] == 'versionup') {
            // バージョンアップ
            $verup_form = '
<form method="POST" action="' . $script . '">
 <div>
  <input type="hidden" name="plugin" value="update_tinycode" />
  <input type="hidden" name="action" value="reset" />
  <label for="_p_update_entities_adminpass">' . $qm->m['adminpass'] . '</label>
  <input type="password" name="adminpass" id="_p_update_entities_adminpass" size="20" value="" />
  <input type="submit" value="' . $qm->m['plg_update_tinycode']['btn_init'] . '" />
 </div>
</form>
';
            $body = convert_html($body_top . $body_verup);
            $body = str_replace('%verup_form%', $verup_form, $body);
        } else {
            if ($vars['action'] == 'update') {
                plugin_update_tinycode_update($pagename);
                $msg = $tinycode_title;
                $body = $qm->m['plg_update_tinycode']['updated'] . $go_tinycode_top;
            } else {
                if ($vars['action'] == 'clean') {
                    plugin_update_tinycode_clean($pagename);
                    $msg = $tinycode_title;
                    $body = $qm->m['plg_update_tinycode']['updated'] . $go_tinycode_top;
                } else {
                    if ($vars['action'] == 'reset' && !empty($vars['adminpass']) && pkwk_login($vars['adminpass'])) {
                        plugin_update_tinycode_reset();
                        $msg = $tinycode_title;
                        $body = $qm->m['plg_update_tinycode']['updated'] . $go_tinycode_top;
                    } else {
                        $msg = $tinycode_title;
                        $body = $qm->m['plg_update_tinycode']['err_invalid_action'] . $go_tinycode_top;
                    }
                }
            }
        }
    }
    return array('msg' => $msg, 'body' => $body);
}
Ejemplo n.º 3
0
/**
 *   Social Buttons Plugin
 *   -------------------------------------------
 *   ./plugin/social_buttons.inc.php
 *
 *   Copyright (c) 2012 hokuken
 *   http://hokuken.com/
 *
 *   created  : 2012-03-12
 *   modified :
 *
 *   Description
 *
 *   Usage :
 *
 */
function plugin_social_buttons_convert()
{
    global $script, $vars;
    $qt = get_qt();
    $qt->setv('jquery_include', true);
    $args = func_get_args();
    $url = '';
    $layout = 'h1';
    //h1 | h2 | large
    $margin = '3px';
    //margin-right per button
    $h_margin = '0';
    //horizontal margin of buttons wrapper
    $text = '';
    //extra text
    $float = 'right';
    //left|right
    $service_list = array('google_plusone', 'twitter', 'facebook_like');
    $services = array();
    foreach ($args as $arg) {
        $arg = trim($arg);
        if (preg_match('/^tw(?:itter)?(?:=([^,\\)]*))?$/', $arg, $mts)) {
            $option_str = isset($mts[1]) ? $mts[1] : '';
            $services['twitter'] = plugin_social_buttons_parse_option($option_str);
        } else {
            if (preg_match('/^(?:facebook|fb)(?:=([^,\\)]*))?$/', $arg, $mts)) {
                $option_str = isset($mts[1]) ? $mts[1] : '';
                $services['facebook_like'] = plugin_social_buttons_parse_option($option_str);
            } else {
                if (preg_match('/^(?:google_plusone|gp)(?:=([^,\\)]*))?$/', $arg, $mts)) {
                    $option_str = isset($mts[1]) ? $mts[1] : '';
                    $services['google_plusone'] = plugin_social_buttons_parse_option($option_str);
                } else {
                    if (in_array($arg, array('h1', 'h2', 'large'))) {
                        $layout = $arg;
                        if ($layout === 'large') {
                            $margin = '15px';
                        }
                    } else {
                        if (is_url($arg)) {
                            $url = $arg;
                        } else {
                            if (preg_match('/^\\d+$/', $arg)) {
                                $margin = intval($arg);
                                $margin = $margin > 0 ? $margin . 'px' : 0;
                            } else {
                                if ($arg === 'right' or $arg === 'left') {
                                    $float = $arg;
                                } else {
                                    $text = $arg;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (count($services) === 0) {
        foreach (array_flip($service_list) as $service => $v) {
            $services[$service] = array();
        }
    }
    if ($float === 'right') {
        $services = array_combine(array_reverse(array_keys($services)), array_reverse(array_values($services)));
    }
    $use_fb = FALSE;
    foreach ($services as $service => $option) {
        switch ($service) {
            case 'twitter':
                switch ($layout) {
                    case 'h1':
                        $tmp = 'none';
                        break;
                    case 'h2':
                        $tmp = 'horizontal';
                        break;
                    default:
                        //large
                        $tmp = 'vertical';
                }
                $option['button'] = $tmp;
                break;
            case 'facebook_like':
                $use_fb = TRUE;
                $width = 120;
                switch ($layout) {
                    case 'h1':
                        $width = 100;
                    case 'h2':
                        $tmp = 'button_count';
                        break;
                    default:
                        //large
                        $tmp = 'box_count';
                }
                $option['show_faces'] = 'false';
                $option['layout'] = $tmp;
                $option['width'] = isset($option['width']) ? $option['width'] : $width;
                break;
            case 'google_plusone':
                $count = TRUE;
                //size
                switch ($layout) {
                    case 'h1':
                        $count = 'false';
                    case 'h2':
                        $tmp = 'medium';
                        break;
                    default:
                        //large
                        $tmp = 'tall';
                }
                $option['size'] = $tmp;
                $option['count'] = $count;
                //lang
                $option['lang'] = 'ja';
                break;
        }
        $services[$service] = $option;
    }
    $tinyurl = $fburl = $url;
    $page = $vars['page'];
    if ($url === '') {
        $fburl = $script . '?' . rawurlencode($page);
        $url = $script . '?' . rawurlencode($page);
        $tinyurl = $script . '?go=' . get_tiny_code($page);
    }
    $addscript = '
<style type="text/css">
.qhm_plugin_social_buttons {
	margin: 3px 0;
}
</style>
<script type="text/javascript" src="./js/jquery.socialbutton-1.9.1.js"></script>
<script type="text/javascript">
$(function(){
	$("div.qhm_plugin_social_button").each(function(){
		var $$ = $(this), service = $$.attr("data-sb-service"), option = {}, attrs = this.attributes;
		var cnt = 0, attr, opt_name;

		while (1)
		{
			attr = attrs.item(cnt);
			cnt++;
			if (attr == null) break;
			if (attr.name == "data-sb-service") continue;

			if (/^data-sb-(.+)$/.test(attr.name))
			{
				opt_name = attr.name.match(/^data-sb-(.+)$/)[1];
				option[opt_name] = /^false$/.test(attr.value) ? false: attr.value;
			}
		}

		$$.socialbutton(service, option);
	});
});
</script>
';
    $body = '
<div class="qhm_plugin_social_buttons">
';
    foreach ($services as $service => $option) {
        $option_attr = '';
        foreach ($option as $key => $val) {
            $option_attr .= ' data-sb-' . $key . '="' . h($val) . '"';
        }
        switch ($service) {
            case 'twitter':
                $service_url = $tinyurl;
                break;
            case 'facebook_like':
                $service_url = $fburl;
                break;
            default:
                $service_url = $url;
        }
        $body .= '<div class="qhm_plugin_social_button" data-sb-service="' . h($service) . '" data-sb-url="' . h($service_url) . '"' . $option_attr . ' style="margin-right:' . h($margin) . ';float:' . h($float) . ';"></div>';
    }
    $body .= '
	<div style="clear:both;"></div>
</div>
';
    $editable = check_editable($page, FALSE, FALSE);
    //Facebook いいね!ボタンが表示されない問題への対処について。
    //原因は不明だが、Fbデバッガへ通すと改善する。
    //管理者にはFacebook のデバッガーへのリンクを表示する。
    if ($editable && $use_fb) {
        $debuggerlink = 'http://developers.facebook.com/tools/debug/og/object?q=' . rawurlencode($fburl);
        $body .= '
<p style="text-align:' . h($float) . ';margin-top: 0;">
<button type="button" class="" style="color:navy;cursor:pointer;border:none;background:none;" data-toggle="collapse" data-target="div.plugin_social_button_alert">
	<i class="icon icon-hand-up"></i>
	いいね!が表示されない
</button>
</p>

<div class="collapse out plugin_social_button_alert">
	<div class="alert alert-info">

	<p>
		以下の手順で復旧してください。
	</p>

	1. <a href="' . h($debuggerlink) . '" class="btn btn-default btn-sm">ここをクリック &gt;&gt;</a><br />
	2. Facebook のページが開いたら、そのまま閉じる。<br />
	3. このページを<a href="#" class="btn btn-default btn-sm" onclick="document.location.reload();return false;">再読み込み</a>する。<br />
	4. 完了
	</div>
</div>
';
    }
    $qt->appendv_once('plugin_social_buttons', 'beforescript', $addscript);
    return $body;
}
Ejemplo n.º 4
0
function plugin_tweet_inline()
{
    global $script, $vars;
    $page = $vars['page'];
    $args = func_get_args();
    $label = array_shift($args);
    $status = array_shift($args);
    $label = $label ? trim($label) : PLUGIN_TWEET_DEFAULT_LABEL;
    $status = $status ? trim($status) : PLUGIN_TWEET_DEFAULT_STATUS;
    if (preg_match('/^ICON:([mslt])([abc])([ops])?:(.*)$/', $label, $ms)) {
        $isize = $ms[1];
        $icolor = $ms[2];
        $disp = $ms[3];
        $label = $ms[4] ? $ms[4] : PLUGIN_TWEET_DEFAULT_LABEL;
        $icon = '';
        $ic_w = $ic_h = 16;
        switch ($isize) {
            case 's':
                $icon .= 't_small';
                $ic_w = $ic_h = 22;
                break;
            case 'l':
                $icon .= 't_logo';
                $ic_w = $ic_h = 36;
                break;
            case 't':
                $icon .= 'twitter';
                $ic_w = 61;
                $ic_h = 23;
                break;
            default:
                $icon .= 't_mini';
        }
        $icon .= '-';
        if (in_array($icolor, array('a', 'b', 'c'))) {
            $icon .= $icolor;
        } else {
            $icon .= 'a';
        }
        $icon .= '.png';
        $icon = '<img src="http://twitter-badges.s3.amazonaws.com/' . $icon . '" width="' . $ic_w . '" height="' . $ic_h . '" />';
        switch ($disp) {
            case 'p':
                //前置
                $icon .= $label;
                break;
            case 's':
                //後置
                $icon = $label . $icon;
                break;
            default:
        }
    }
    $option = array('username' => '', 'title' => get_page_title($page), 'url' => $script . '?go=' . get_tiny_code($page));
    foreach ($args as $arg) {
        if (strpos($arg, '=')) {
            list($key, $val) = explode('=', $arg, 2);
            $option[$key] = $val;
        } else {
            if (trim($arg)) {
                $option['username'] = $arg;
                break;
            }
        }
    }
    $srcs = array_keys($option);
    $rpls = array();
    foreach ($srcs as $i => $key) {
        $srcs[$i] = '%' . $key . '%';
        $rpls[$i] = $option[$key];
    }
    $status = str_replace($srcs, $rpls, $status);
    $twurl = 'http://twitter.com/?status=';
    $twurl .= rawurlencode($status);
    $ret = '<a href="' . $twurl . '" title="' . $label . '" target="_black">' . (isset($icon) ? $icon : $label) . '</a>';
    return $ret;
}
Ejemplo n.º 5
0
function plugin_tw_button_body($args)
{
    global $script, $vars;
    $page = $vars['page'];
    $r_page = rawurlencode($page);
    $qm = get_qm();
    $qt = get_qt();
    //data-count
    $count_styles = array('vertical', 'horizontal', 'none');
    //data-text
    //data-url
    //data-lang
    $langs = array('Japanese' => 'ja', 'Dutch' => 'nl', 'English' => '', 'French' => 'fr', 'German' => 'de', 'Indnesian' => 'id', 'Italian' => 'it', 'Korean' => 'ko', 'Portuguese' => 'pt', 'Russian' => 'ru', 'Spanish' => 'es', 'Turkish' => 'tr');
    //data-via
    //data-related
    $qt->appendv_once('plugin_tw_button', 'lastscript', '<script type="text/javascript" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>');
    //attr を構築
    $init_url = FALSE;
    $attrs = array('data-count' => 'horizontal', 'data-lang' => 'ja');
    foreach ($args as $i => $arg) {
        // data-text モード
        if (isset($attrs['data-text'])) {
            $attrs['data-text'] .= ',' . $arg;
            continue;
        }
        $or_arg = $arg;
        $arg = trim($arg);
        // url
        if (!$init_url && is_url($arg)) {
            $attrs['data-url'] = $arg;
            $init_url = TRUE;
        } else {
            if (strpos($arg, 'style=') === 0) {
                list($key, $val) = explode('=', $arg, 2);
                switch ($val) {
                    case 'v':
                    case 'vertical':
                        $attrs['data-count'] = 'vertical';
                        break;
                    case 'h':
                    case 'horizontal':
                        $attrs['data-count'] = 'horizontal';
                        break;
                    case 'n':
                    case 'none':
                    default:
                        $attrs['data-count'] = 'none';
                }
            } else {
                if (strpos($arg, 'lang=') === 0) {
                    list($key, $val) = explode('=', $arg, 2);
                    $attrs['data-lang'] = trim($val);
                    if ($val == 'en') {
                        unset($attrs['data-lang']);
                    }
                } else {
                    if (strpos($arg, 'user='******'via=') === 0) {
                        list($key, $val) = explode('=', $arg, 2);
                        $attrs['data-via'] = trim($val);
                    } else {
                        if (strpos($arg, 'related=') === 0) {
                            list($key, $val) = explode('=', $arg, 2);
                            $attrs['data-related'] = $val;
                        } else {
                            if (strpos($arg, 'rel_desc=') === 0) {
                                list($key, $val) = explode('=', $arg, 2);
                                $attrs['data-related-2'] = $val;
                            } else {
                                $attrs['data-text'] = $or_arg;
                            }
                        }
                    }
                }
            }
        }
    }
    //URLをセット
    //※日本語ページ名だと二重でURLエンコードされるため、data-url は必ずセットする
    //※index.php?URLENCODE(ページ名) というURLが安全じゃないとエラーが出るので短縮URLを採用
    if ($init_url === FALSE) {
        $attrs['data-url'] = $script . '?go=' . get_tiny_code($page);
    }
    if (isset($attrs['data-related']) && isset($attrs['data-related-2'])) {
        $attrs['data-related'] = $attrs['data-related'] . ':' . $attrs['data-related-2'];
    } else {
        if (isset($attrs['data-related-2']) && !isset($attrs['data-related'])) {
            unset($attrs['data-related-2']);
        }
    }
    $attr_str = '';
    foreach ($attrs as $key => $val) {
        $val = h($val);
        $attr_str .= ' ' . $key . '="' . $val . '"';
    }
    $html = sprintf(PLUGIN_TW_bUTTON_FMT, $attr_str);
    return $html;
}
Ejemplo n.º 6
0
$qt->setv('ownertel', $ownertel);
$qt->getv('beforescript') ? '' : $qt->setv('beforescript', '');
$qt->getv('main_visual') ? '' : $qt->setv('main_visual', '');
$qt->getv('lastscript') ? '' : $qt->setv('lastscript', '');
$qt->setv('_page', $_page);
$qt->setv('_script', $script);
$qt->setv('auth_link', $qhm_adminmenu <= 1 ? '<a href="' . h($script . '?cmd=qhmauth') . '" class="qhm-auth-link">QHM</a>' : '');
//head
$qt->setv('headcopy_is_empty', trim($headcopy) === '');
if (!$qt->getv('headcopy_is_empty')) {
    $qt->setv('head_copy_tag', '<div id="headcopy" class="qhm-head-copy">
<h1>' . $headcopy . '</h1>
</div><!-- END: id:headcopy -->
');
}
$_go_url = $script . '?go=' . get_tiny_code($_page);
$qt->setv('go_url', $_go_url);
$_qhm_rawurl = $script . '?' . rawurlencode($_page);
//---- Prohibit direct access
if (!defined('UI_LANG')) {
    die('UI_LANG is not set');
}
if (!isset($_LANG)) {
    die('$_LANG is not set');
}
if (!defined('PKWK_READONLY')) {
    die('PKWK_READONLY is not set');
}
$link =& $_LINK;
$image =& $_IMAGE['skin'];
$rw = !PKWK_READONLY;