示例#1
0
文件: icon.inc.php 项目: big2men/qhm
/**
 *   Haik Icon Plugin
 *   -------------------------------------------
 *   plugin/icon.inc.php
 *
 *   Copyright (c) 2013 hokuken
 *   http://hokuken.com/
 *
 *   created  : 13/01/29
 *   modified :
 *
 *   Description
 *
 *   Usage :
 *
 */
function plugin_icon_inline()
{
    $args = func_get_args();
    $class = '';
    $icon_base = 'glyphicon';
    $icon_prefix = $icon_base . '-';
    $icon_name = $icon_options = '';
    foreach ($args as $arg) {
        if ($arg === 'glyphicon') {
            $icon_base = 'glyphicon';
            $icon_prefix = $icon_base . '-';
        }
        if ($arg === 'font-awesome' or $arg === 'fa') {
            $icon_base = 'fa';
            $icon_prefix = $icon_base . '-';
            plugin_icon_set_font_awesome();
        } else {
            if ($icon_base === 'fa' && preg_match('/^[1-5]x|lg$/', $arg)) {
                $icon_options = " {$icon_prefix}{$arg}";
            } else {
                if ($arg !== '') {
                    $icon_name = $arg;
                }
            }
        }
    }
    $icon_name = $icon_prefix . $icon_name;
    $format = '<i class="%s %s%s"></i>';
    return sprintf($format, h($icon_base), h($icon_name), $icon_options);
}
示例#2
0
/**
 *   トップに戻るリンク
 *   -------------------------------------------
 *   scrollup.inc.php
 *
 *   Copyright (c) 2014 hokuken
 *   http://hokuken.com/
 *
 *   created  : 14/08/26
 *   modified :
 *
 *   Usage :
 *     #scrollup
 *
 */
function plugin_scrollup_convert()
{
    $args = func_get_args();
    $qt = get_qt();
    $target = 'body';
    $title = 'トップ';
    if (count($args) > 0) {
        $target = h(trim($args[0]));
        if (isset($args[1])) {
            $title = h(trim($args[1]));
        }
    }
    if (exist_plugin('icon')) {
        plugin_icon_set_font_awesome();
    }
    $add_style = <<<EOD
<style data-qhm-plugin="scrollup">
.qhm-plugin-scrollup {
  color: inherit;
  bottom: 10px;
  right: 10px;
  cursor: pointer;
}
.qhm-plugin-scrollup.affix:hover {
  color: inherit;
  opacity: .8;
}
</style>
EOD;
    $qt->appendv_once('plugin_scrollup_style', 'beforescript', $add_style);
    $add_script = <<<EOD
<script data-qhm-plugin="scrollup">
\$(function() {
    \$("body").append('<a class="qhm-plugin-scrollup"></a>').find(".qhm-plugin-scrollup")
    .html('<i class="fa fa-arrow-up fa-2x"></i>')
    .attr({
      'data-target': "{$target}",
      'title': "{$title}"
    })
    .affix({
      offset: {
        top: 50
      }
    });

    \$(".qhm-plugin-scrollup").on("click", function(e){
      QHM.scroll(\$(this).data("target"));
      e.preventDefault();
      return false;
    });
});
</script>
EOD;
    $qt->appendv_once('plugin_scrollup_script', 'lastscript', $add_script);
    return;
}
示例#3
0
function plugin_search2_form($s_word = '', $type = '', $bases = array())
{
    global $script;
    $qm = get_qm();
    $qt = get_qt();
    $cols = 12;
    $offset = 0;
    $show_type_selector = false;
    $btn_type = 'default';
    $form_type = '';
    foreach ($bases as $base) {
        $base = trim($base);
        switch ($base) {
            case 'showtype':
                $show_type_selector = true;
                break;
            case preg_match('/^(\\d+)(?:\\+(\\d+))?$/', $base, $mts) ? true : false:
                $cols = $mts[1];
                $offset = isset($mts[2]) && $mts[2] ? $mts[2] : $offset;
                break;
            case 'primary':
            case 'success':
            case 'info':
            case 'warning':
            case 'danger':
            case 'default':
                $btn_type = $base;
                break;
            case 'compact':
                $form_type = $base;
                break;
        }
    }
    $width_class = 'col-sm-' . $cols;
    if ($offset) {
        $width_class .= ' col-sm-offset-' . $offset;
    }
    $and_check = $or_check = '';
    if ($type == 'OR') {
        $or_check = ' checked="checked"';
    } else {
        $and_check = ' checked="checked"';
    }
    $type_selector_html = '<input type="hidden" name="type" value="AND" />';
    if ($show_type_selector) {
        $type_selector_html = <<<EOD
<div class="form-group">
  <label class="radio-inline" style="display:inline-block;">
    <input type="radio" name="type" value="AND" {$and_check} /> {$qm->m['plg_search']['lbl_and']}
  </label>
  <label class="radio-inline" style="display:inline-block;">
    <input type="radio" name="type" value="OR"  {$or_check}  /> {$qm->m['plg_search']['lbl_or']}
  </label>
</div>
EOD;
    }
    if ($form_type === 'compact') {
        $html = '
<form action="' . $script . '" method="get" class="qhm-search2 form-inline" data-plugin="search2">
  <input type="hidden" name="cmd" value="search2" />
  <input type="hidden" name="type" value="AND" />
  <div class="form-group">
    <input type="text"  name="word" value="' . h($s_word) . '" class="form-control" placeholder="検索ワード" />
  </div>
</form>
';
    } else {
        $html = '
<form action="' . $script . '" method="get" class="qhm-search2 form-inline" data-plugin="search2">
  <input type="hidden" name="cmd" value="search2" />
  <div class="input-group ' . $width_class . '">
    <input type="text"  name="word" value="' . h($s_word) . '" class="form-control" placeholder="検索ワード" />
    <div class="input-group-btn">
      <input class="btn btn-' . $btn_type . '" type="submit" value="検索" />
    </div>
  </div>
  ' . $type_selector_html . '
</form>
';
    }
    $style = '';
    if (exist_plugin('icon')) {
        plugin_icon_set_font_awesome();
        $style = '
<style>
[data-plugin=search2] > div.input-group,
[data-plugin=search2] > div.form-group {
    position: relative;
}
[data-plugin=search2] > div.input-group:before,
[data-plugin=search2] > div.form-group:before {
    font-family: FontAwesome;
    content: "\\f002";
    position:absolute;
    top:8px;
    left:10px;
    z-index: 3;
    color: #999;
    line-height: 1.42857143;
}
[data-plugin=search2] input[type=text] {
    padding-left:30px;
}
</style>
';
    }
    $qt->appendv_once("plugin_search2_style", "beforescript", $style);
    return $html;
}
示例#4
0
文件: video.inc.php 项目: big2men/qhm
function plugin_video_body($args = array(), $body = "")
{
    static $num = 0;
    static $called_sources = array();
    $num++;
    $id = "qhm_plugin_video_{$num}";
    $qt = get_qt();
    $qt->setv("jquery_include", TRUE);
    if (exist_plugin("icon")) {
        plugin_icon_set_font_awesome();
    }
    $embed_url = $popup = FALSE;
    $sources = array();
    $poster = FALSE;
    $aspect_ratio = "16by9";
    $width = PLUGIN_VIDEO_EMBED_WIDTH;
    $height = PLUGIN_VIDEO_EMBED_HEIGHT;
    $aspect_ratio_float = 0.5625;
    $theme = FALSE;
    $youtube_thumbnail_type = FALSE;
    $rel = true;
    // 関連動画の表示(youtube)
    foreach ($args as $arg) {
        $arg = trim($arg);
        switch ($arg) {
            case "16:9":
            case "4:3":
                list($aspect_width, $aspect_height) = explode(':', $arg);
                $aspect_ratio_float = (double) $aspect_height / (double) $aspect_width;
                $aspect_ratio = str_replace(":", "by", $arg);
                break;
            case "popup":
                $popup = TRUE;
                break;
            case preg_match('*^https?://(www\\.youtube\\.com|youtu\\.be|vimeo.com)/*', $arg) ? TRUE : FALSE:
                $embed_url = $arg;
                break;
            case preg_match('/\\Aytpreview=(.+)\\z/', $arg, $mts) ? TRUE : FALSE:
                // YouTube thumbnail type
                $_types = array('thumb-default', 'thumb-1', 'thumb-2', 'thumb-3', 'default', 'medium', 'high');
                if (in_array($mts[1], $_types)) {
                    $youtube_thumbnail_type = $mts[1];
                }
                break;
            case preg_match('/^(.+\\.(png|jpeg|jpg|gif))\\z/i', $arg, $mts) ? TRUE : FALSE:
                $poster = get_file_path($mts[1]);
                break;
            case preg_match('/^(.+\\.mp4)\\z/i', $arg, $mts) ? TRUE : FALSE:
                $sources[PLUGIN_VIDEO_MIMETYPE_MP4] = get_file_path($mts[1]);
                break;
            case "ted":
            case "wmp":
                $theme = $arg;
                break;
            case "norel":
                $rel = false;
                break;
        }
    }
    $mediaelement_path = 'js/mediaelementplayer/';
    $include_mediaelement = '
<link rel="stylesheet" href="' . $mediaelement_path . 'mediaelementplayer.min.css">
<script src="' . $mediaelement_path . 'mediaelement-and-player.min.js"></script>
';
    $qt->appendv_once("include_mediaelement", "beforescript", $include_mediaelement);
    $addstyle = '
<link rel="stylesheet" href="' . $mediaelement_path . 'mejs-skins.css">
<link rel="stylesheet" href="' . PLUGIN_DIR . 'video/video.min.css">
';
    $qt->appendv_once("plugin_video_style", "beforescript", $addstyle);
    $qt->appendv_once("plugin_video_script", "beforescript", '<script src="' . PLUGIN_DIR . 'video/video.min.js"></script>');
    $popup_html = $popup_style = '';
    if ($popup) {
        if ($body == '') {
            if ($poster !== FALSE) {
                $body = '<img src="' . h($poster) . '">';
            } else {
                $body = '<i class="fa fa-play-circle-o"></i>';
            }
        }
        $popup_html = <<<EOD
<a class="qhm-plugin-video-trigger" data-toggle="modal" data-target="#{$id}_modal">{$body}</a>
EOD;
    }
    if ($embed_url !== FALSE) {
        return $popup_html . plugin_video_embed($embed_url, $id, $aspect_ratio, $body, $popup, $poster, $youtube_thumbnail_type, $rel);
    }
    if (!isset($sources[PLUGIN_VIDEO_MIMETYPE_MP4])) {
        return '<p>Usage: #video(video.mp4)</p>' . "\n";
    } else {
        if (is_url($sources[PLUGIN_VIDEO_MIMETYPE_MP4])) {
            $sources[PLUGIN_VIDEO_MIMETYPE_WEBM] = substr($sources[PLUGIN_VIDEO_MIMETYPE_MP4], 0, -3) . "webm";
        } else {
            if (file_exists($sources[PLUGIN_VIDEO_MIMETYPE_MP4])) {
                $webm_path = substr($sources[PLUGIN_VIDEO_MIMETYPE_MP4], 0, -3) . "webm";
                if (file_exists($webm_path)) {
                    $sources[PLUGIN_VIDEO_MIMETYPE_WEBM] = $webm_path;
                }
            }
        }
    }
    foreach ($sources as $mime_type => $url) {
        if (isset($called_sources[$url])) {
            $called_sources[$url] += 1;
            $sources[$mime_type] = $url . '?' . $called_sources[$url];
        } else {
            $called_sources[$url] = 1;
        }
    }
    if ($poster !== FALSE) {
        if (!is_url($poster) && !file_exists($poster)) {
            $poster = FALSE;
        }
    }
    $sources_html = '';
    foreach ($sources as $type => $source) {
        $sources_html .= <<<EOD
  <source src="{$source}" type="{$type}">
EOD;
    }
    // video tag attribute params
    $params = array('controls' => TRUE, 'preload' => $poster === FALSE ? "auto" : "none", 'poster' => $poster, 'style' => '"width:100%; height:100%;', 'width' => '100%', 'height' => '100%', 'data-aspect-ratio' => $aspect_ratio_float);
    if ($theme !== FALSE) {
        $params['class'] = "mejs-{$theme}";
    }
    if ($popup) {
        $params['data-popup'] = 'popup';
    }
    $attrs = '';
    foreach ($params as $key => $val) {
        if ($val === FALSE) {
            continue;
        }
        if ($val === TRUE) {
            $attrs[] = $key;
            continue;
        }
        $attrs[] = $key . '="' . $val . '"';
    }
    $attrs = join(' ', $attrs);
    $mp4 = $sources[PLUGIN_VIDEO_MIMETYPE_MP4];
    $not_support_html = '<p>動画を再生するには、videoタグをサポートしたブラウザが必要です。</p>';
    $poster_html = '';
    if ($poster !== FALSE) {
        $poster_html = <<<EOD
        <img src="{$poster}" width="320" height="240" title="No video playback capabilities">
EOD;
    }
    $video_html = <<<EOD
  <div class="qhm-plugin-video-video embed-responsive-item">
    <video id="{$id}_video" {$attrs}>
      {$sources_html}
      <object width="320" height="240" type="application/x-shockwave-flash" data="{$mediaelement_path}flashmediaelement.swf">
        <param name="movie" value="{$mediaelement_path}flashmediaelement.swf">
        <param name="flashvars" value="controls=true&file={$mp4}">
        {$poster_html}
      </object>
      {$not_support_html}
    </video>
  </div>
EOD;
    if ($popup) {
        $html = <<<EOD
{$popup_html}
<div id="{$id}_modal" class="qhm-plugin-video modal fade" data-type="video">
  <div class="modal-dialog modal-lg">
    <div class="embed-responsive embed-responsive-{$aspect_ratio}">
      {$video_html}
    </div>
  </div>
</div>
EOD;
    } else {
        $html = <<<EOD
<div id="{$id}" class="qhm-plugin-video embed-responsive embed-responsive-{$aspect_ratio}" {$popup_style}>
  {$video_html}
</div>
EOD;
    }
    return $html;
}
示例#5
0
function plugin_share_buttons_convert()
{
    global $script, $vars;
    global $defaultpage, $site_title, $site_title_delim;
    $qt = get_qt();
    $buttons_options = array('facebook' => array('title' => 'Facebook でシェア'), 'twitter' => array('title' => 'Twitter でシェア'), 'google_plus' => array('title' => 'Google+ でシェア'));
    if (exist_plugin('icon')) {
        plugin_icon_set_font_awesome();
    }
    $buttons = array();
    $align = 'left';
    $nav = false;
    $args = func_get_args();
    foreach ($args as $arg) {
        $arg = strtolower($arg);
        switch ($arg) {
            case 'fb':
            case 'facebook':
                $buttons['facebook'] = $buttons_options['facebook'];
                break;
            case 'tw':
            case 'twitter':
                $buttons['twitter'] = $buttons_options['twitter'];
                break;
            case 'gp':
            case 'gplus':
            case 'google-plus':
            case 'google_plus':
            case 'googleplus':
            case 'plus':
            case 'g+':
                $buttons['google_plus'] = $buttons_options['google_plus'];
                break;
            case 'left':
            case 'right':
            case 'center':
                $align = $arg;
                break;
            case 'nav':
                $nav = true;
                break;
        }
    }
    //無指定の場合、全部
    if (count($buttons) === 0) {
        $buttons = $buttons_options;
    }
    $url = $script . '?' . rawurlencode($vars['page']);
    $enc_url = rawurlencode($url);
    $page_title = get_page_title($vars['page']);
    $full_title = $vars['page'] === $defaultpage ? $page_title : $page_title . $site_title_delim . $site_title;
    $enc_full_title = rawurlencode($full_title);
    $share_buttons = array_keys($buttons);
    $navclass = $nav ? ' share_buttons_nav navbar-text' : '';
    $html = '<div class="share_buttons ' . $align . $navclass . '"><ul class="nav nav-pills">';
    foreach ($share_buttons as $btn) {
        $defname = 'PLUGIN_SHARE_BUTTONS_' . strtoupper($btn);
        $title = $buttons[$btn]['title'];
        if (defined($defname)) {
            $html .= '<li>' . sprintf(constant($defname), h($url), h($full_title), h($enc_url), h($enc_full_title), h($title)) . '</li>';
        }
    }
    $html .= '</ul></div>';
    $addstyle = '
<style>
.share_buttons {
  display: table;
}
.share_buttons.center {
  margin: 0 auto;
  text-align: center;
}
.share_buttons.right {
  float: right;
  margin-right: 10px;
}
.share_buttons.share_buttons_nav ul.nav {
  margin: 0px;
}
.share_buttons.share_buttons_nav ul.nav > li > a {
  padding: 0 3px;
}
.share_buttons ul.nav > li {
  margin: 0px;
}
.share_buttons ul.nav > li > a {
  display: block;
  margin: 0;
  font-size: inherit;
  color: #999;
  padding: 0 3px;
}
.share_buttons ul.nav > li > a:hover {
  background-color: transparent;
}
.share_buttons ul.nav > li > a i.orgm-icon-facebook-2:before {
  background-color: white;
  border-radius: 7px;
  max-height: 24px;
}
.share_buttons ul.nav > li > a i.orgm-icon-twitter-2:before {
  background-color: white;
  border-radius: 7px;
  max-height: 24px;
}
.share_buttons ul.nav > li > a i.orgm-icon-google-plus-2:before {
  background-color: white;
  border-radius: 7px;
  max-height: 24px;
}
.share_buttons ul.nav > li > a.facebook:hover > i {
  color: #3b5998;
}
.share_buttons ul.nav > li > a.twitter:hover > i {
  color: #3fbdf6;
}
.share_buttons ul.nav > li > a.google-plus:hover > i {
  color: #d34836;
}
</style>
';
    $qt->appendv_once('plugin_share_button_style', 'beforescript', $addstyle);
    //$qt->setv('share_buttons', $html);
    return $html;
}
示例#6
0
文件: audio.inc.php 项目: big2men/qhm
function plugin_audio_compact_player($id, $play_label = null, $pause_label = null)
{
    $qt = get_qt();
    if (exist_plugin('icon')) {
        plugin_icon_set_font_awesome();
        $play_label = '<i class="fa fa-play-circle"></i> ' . $play_label;
        $pause_label = '<i class="fa fa-pause"></i> ' . $pause_label;
    }
    $e_play_label = h($play_label);
    $e_pause_label = h($pause_label);
    $compact_html = <<<EOD
<a href="#{$id}" data-toggle="qhm-audio" class="qhm-plugin-audio-compact-player"
   data-play-label="{$e_play_label}" data-pause-label="{$e_pause_label}"></a>
EOD;
    $include_head = '
<script src="' . PLUGIN_DIR . 'audio/audio.min.js"></script>';
    $qt->appendv_once('plugin_audio_head', 'beforescript', $include_head);
    return $compact_html;
}