Beispiel #1
0
function plugin_related_action()
{
    global $vars, $script, $defaultpage, $whatsnew;
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if ($page == $whatsnew || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    // kazuwaya
    $r_word = rawurlencode($_page);
    $s_word = htmlspecialchars($_page);
    $msg = 'Backlinks for: ' . $s_word;
    $retval = '<p><a href="' . $script . '?' . $r_word . '">' . 'Return to ' . $s_word . '</a></p>' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
    } else {
        // Show count($data)?
        ksort($data);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $r_page = rawurlencode($page);
            $s_page = htmlspecialchars($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
Beispiel #2
0
function plugin_related_action()
{
    global $vars, $script, $defaultpage, $whatsnew;
    $qm = get_qm();
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if ($page == $whatsnew || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    $r_word = rawurlencode($_page);
    $s_word = get_page_title($_page);
    $msg = $qm->replace('plg_related.title', $s_word);
    $retval = '<a href="' . $script . '?' . $r_word . '">' . $qm->replace('plg_related.link_back', $s_word) . '</a><br />' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>' . $qm->m['plg_related']['notfound'] . '</li></ul>' . "\n";
    } else {
        ksort($data);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $r_page = rawurlencode($page);
            $s_page = get_page_title($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
function plugin_related_action()
{
    global $vars, $defaultpage;
    $_page = isset($vars['page']) ? $vars['page'] : '';
    if ($_page == '') {
        $_page = $defaultpage;
    }
    // Get related from cache
    $data = links_get_related_db($_page);
    if (!empty($data)) {
        // Hide by array keys (not values)
        foreach (array_keys($data) as $page) {
            if (is_cantedit($page) || check_non_list($page)) {
                unset($data[$page]);
            }
        }
    }
    // Result
    $s_word = htmlspecialchars($_page);
    $msg = 'Backlinks for: ' . $s_word;
    $retval = '<a href="' . get_page_uri($_page) . '">' . 'Return to ' . $s_word . '</a><br />' . "\n";
    if (empty($data)) {
        $retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
    } else {
        // Show count($data)?
        ksort($data, SORT_STRING);
        $retval .= '<ul>' . "\n";
        foreach ($data as $page => $time) {
            $s_page = htmlspecialchars($page);
            $passage = get_passage($time);
            $retval .= ' <li><a href="' . get_page_uri($page) . '">' . $s_page . '</a> ' . $passage . '</li>' . "\n";
        }
        $retval .= '</ul>' . "\n";
    }
    return array('msg' => $msg, 'body' => $retval);
}
Beispiel #4
0
function links_get_related($page)
{
    global $vars, $related;
    static $links = array();
    if (isset($links[$page])) {
        return $links[$page];
    }
    // If possible, merge related pages generated by make_link()
    $links[$page] = $page == $vars['page'] ? $related : array();
    // Get repated pages from DB
    $links[$page] += links_get_related_db($vars['page']);
    return $links[$page];
}
Beispiel #5
0
function links_get_related($page)
{
	global $vars,$related;
	static $links = array();
	
	if (array_key_exists($page,$links))
	{
		return $links[$page];
	}
	
	// 可能ならmake_link()で生成した関連ページを取り込む
	$links[$page] = ($page == $vars['page']) ? $related : array();
	
	// データベースから関連ページを得る
	$links[$page] += links_get_related_db($vars['page']);
	
	return $links[$page];
}
Beispiel #6
0
function plugin_googlemaps2_output($doInit, $params)
{
    global $vars;
    $qm = get_qm();
    if (!plugin_googlemaps2_is_supported_profile()) {
        return $qm->m['plg_googlemaps2']['err_unsupport_dev'];
    }
    $defoptions = plugin_googlemaps2_get_default();
    $inoptions = array();
    $isSetZoom = false;
    foreach ($params as $param) {
        $pos = strpos($param, '=');
        if ($pos == false) {
            continue;
        }
        $index = trim(substr($param, 0, $pos));
        $value = htmlspecialchars(trim(substr($param, $pos + 1)));
        $inoptions[$index] = $value;
        if ($index == 'cx') {
            $cx = (double) $value;
        }
        //for old api
        if ($index == 'cy') {
            $cy = (double) $value;
        }
        //for old api
        if ($index == 'zoom') {
            $isSetZoom = true;
        }
        //for old api
    }
    if (array_key_exists('define', $inoptions)) {
        $vars['googlemaps2'][$inoptions['define']] = $inoptions;
        return "";
    }
    $coptions = array();
    if (array_key_exists('class', $inoptions)) {
        $class = $inoptions['class'];
        if (array_key_exists($class, $vars['googlemaps2'])) {
            $coptions = $vars['googlemaps2'][$class];
        }
    }
    $options = array_merge($defoptions, $coptions, $inoptions);
    $mapname = plugin_googlemaps2_addprefix($vars['page'], $options['mapname']);
    $key = $options['key'];
    $width = $options['width'];
    $height = $options['height'];
    $lat = (double) $options['lat'];
    $lng = (double) $options['lng'];
    $zoom = (int) $options['zoom'];
    $mapctrl = $options['mapctrl'];
    $type = $options['type'];
    $typectrl = $options['typectrl'];
    $scalectrl = $options['scalectrl'];
    $overviewctrl = $options['overviewctrl'];
    $crossctrl = $options['crossctrl'];
    $overviewwidth = $options['overviewwidth'];
    $overviewheight = $options['overviewheight'];
    $api = (int) $options['api'];
    $noiconname = $options['noiconname'];
    $togglemarker = plugin_googlemaps2_getbool($options['togglemarker']);
    $dbclickzoom = plugin_googlemaps2_getbool($options['dbclickzoom']);
    $continuouszoom = plugin_googlemaps2_getbool($options['continuouszoom']);
    $geoxml = preg_replace("/&amp;/i", '&', $options['geoxml']);
    $googlebar = plugin_googlemaps2_getbool($options['googlebar']);
    $importicon = $options['importicon'];
    $backlinkmarker = plugin_googlemaps2_getbool($options['backlinkmarker']);
    $page = $vars['page'];
    //apiのチェック
    if (!(is_numeric($api) && $api >= 0 && $api <= 2)) {
        $api = 2;
    }
    //古い1系APIとの互換性のためcx, cyが渡された場合lng, latに代入する。
    if ($api < 2) {
        if (isset($cx) && isset($cy)) {
            $lat = $cx;
            $lng = $cy;
        } else {
            $tmp = $lng;
            $lng = $lat;
            $lat = $tmp;
        }
    } else {
        if (isset($cx)) {
            $lng = $cx;
        }
        if (isset($cy)) {
            $lat = $cy;
        }
    }
    // zoomレベル
    if ($api < 2 && $isSetZoom) {
        $zoom = 17 - $zoom;
    }
    // width, heightの値チェック
    if (is_numeric($width)) {
        $width = (int) $width . "px";
    }
    if (is_numeric($height)) {
        $height = (int) $height . "px";
    }
    // Mapタイプの名前を正規化
    $type = plugin_googlemaps2_get_maptype($type);
    // 初期化処理の出力
    if ($doInit) {
        $output = plugin_googlemaps2_init_output($key, $noiconname);
    } else {
        $output = "";
    }
    $pukiwikiname = $options['mapname'];
    $output .= <<<EOD
<div id="{$mapname}" style="width: {$width}; height: {$height};"></div>

<script type="text/javascript">
//<![CDATA[
onloadfunc.push( function () {

if (typeof(googlemaps_maps['{$page}']) == 'undefined') {
\tgooglemaps_maps['{$page}'] = new Array();
\tgooglemaps_markers['{$page}'] = new Array();
\tgooglemaps_marker_mgrs['{$page}'] = new Array();
\tgooglemaps_icons['{$page}'] = new Array();
\tgooglemaps_crossctrl['{$page}'] = new Array();
}

var map = new GMap2(document.getElementById("{$mapname}"));
map.pukiwikiname = "{$pukiwikiname}";
GEvent.addListener(map, "dblclick", function() {
\t\tthis.closeInfoWindow();
});
onloadfunc2.push( function () {
\tp_googlemaps_regist_to_markermanager("{$page}", "{$mapname}", true);
});

map.setCenter(PGTool.getLatLng({$lat}, {$lng}, "{$api}"), {$zoom}, {$type});

var marker_mgr = new GMarkerManager(map);

// 現在(2.70)のMarker Managerではマーカーをhideしていても、描画更新時に
// マーカーを表示してしまうため、リフレッシュ後にフラグを確認して再び隠す。
// 一度表示されて消えるみたいな挙動になるが、他に手段が無いので仕方が無い。
GEvent.addListener(marker_mgr, "changed", function(bounds, markerCount) {
\tvar markers = googlemaps_markers["{$page}"]["{$mapname}"];
\tfor (key in markers) {
\t\tvar m = markers[key];
\t\tif (m.isVisible() == false) {
\t\t\tm.marker.hide();
\t\t}
\t}
});

EOD;
    // Show Map Control/Zoom
    switch ($mapctrl) {
        case "small":
            $output .= "map.addControl(new GSmallMapControl());\n";
            break;
        case "smallzoom":
            $output .= "map.addControl(new GSmallZoomControl());\n";
            break;
        case "none":
            break;
        case "large":
        default:
            $output .= "map.addControl(new GLargeMapControl());\n";
            break;
    }
    // Scale
    if ($scalectrl != "none") {
        $output .= "map.addControl(new GScaleControl());\n";
    }
    // Show Map Type Control and Center
    if ($typectrl != "none") {
        $output .= "map.addControl(new GMapTypeControl(true));\n";
    }
    // Double click zoom
    if ($dbclickzoom) {
        $output .= "map.enableDoubleClickZoom();\n";
    } else {
        $output .= "map.disableDoubleClickZoom();\n";
    }
    // Continuous zoom
    if ($continuouszoom) {
        $output .= "map.enableContinuousZoom();\n";
    } else {
        $output .= "map.disableContinuousZoom();\n";
    }
    // OverviewMap
    if ($overviewctrl != "none") {
        $ovw = preg_replace("/(\\d+).*/i", "\$1", $overviewwidth);
        $ovh = preg_replace("/(\\d+).*/i", "\$1", $overviewheight);
        if ($ovw == "") {
            $ovw = PLUGIN_GOOGLEMAPS2_DEF_OVERVIEWWIDTH;
        }
        if ($ovh == "") {
            $ovh = PLUGIN_GOOGLEMAPS2_DEF_OVERVIEWHEIGHT;
        }
        $output .= "var ovctrl = new GOverviewMapControl(new GSize({$ovw}, {$ovh}));\n";
        $output .= "map.addControl(ovctrl);\n";
        if ($overviewctrl == "hide") {
            $output .= "ovctrl.hide(true);\n";
        }
    }
    // Geo XML
    if ($geoxml != "") {
        $output .= "try {\n";
        $output .= "var geoxml = new GGeoXml(\"{$geoxml}\");\n";
        $output .= "map.addControl(geoxml);\n";
        $output .= "} catch (e) {}\n";
    }
    // GoogleBar
    if ($googlebar) {
        $output .= "map.enableGoogleBar();\n";
    }
    // Center Cross Custom Control
    if ($crossctrl != "none") {
        $output .= "var crossctrl = new PGCross();\n";
        $output .= "crossctrl.initialize(map);\n";
        $output .= "var pos = crossctrl.getDefaultPosition();\n";
        $output .= "pos.apply(crossctrl.container);\n";
        $output .= "var crossChangeStyleFunc = function () {\n";
        $output .= "\tswitch (map.getCurrentMapType()) {\n";
        $output .= "\t\tcase G_NORMAL_MAP:    crossctrl.changeStyle('#000000', 0.5); break;\n";
        $output .= "\t\tcase G_SATELLITE_MAP: crossctrl.changeStyle('#FFFFFF', 0.9); break;\n";
        $output .= "\t\tcase G_HYBRID_MAP:    crossctrl.changeStyle('#FFFFFF', 0.9); break;\n";
        $output .= "\t\tdefault: crossctrl.changeStyle('#000000', 0.5); break;\n";
        $output .= "\t}\n";
        $output .= "}\n";
        $output .= "GEvent.addListener(map, 'maptypechanged', crossChangeStyleFunc);\n";
        $output .= "crossChangeStyleFunc();\n";
        $output .= "googlemaps_crossctrl['{$page}']['{$mapname}'] = crossctrl;\n";
    }
    // マーカーの表示非表示チェックボックス
    if ($togglemarker) {
        $output .= "onloadfunc.push( function(){p_googlemaps_togglemarker_checkbox('{$page}', '{$mapname}', '{$noiconname}');} );";
    }
    $output .= "PGTool.transparentGoogleLogo(map);\n";
    $output .= "googlemaps_maps['{$page}']['{$mapname}'] = map;\n";
    $output .= "googlemaps_markers['{$page}']['{$mapname}'] = new Array();\n";
    $output .= "googlemaps_marker_mgrs['{$page}']['{$mapname}'] = marker_mgr;\n";
    $output .= "});\n";
    $output .= "//]]>\n";
    $output .= "</script>\n";
    // 指定されたPukiwikiページからアイコンを収集する
    if ($importicon != "") {
        $lines = get_source($importicon);
        foreach ($lines as $line) {
            $ismatch = preg_match('/googlemaps2_icon\\(.*?\\)/i', $line, $matches);
            if ($ismatch) {
                $output .= convert_html("#" . $matches[0]) . "\n";
            }
        }
    }
    // このページのバックリンクからマーカーを収集する。
    if ($backlinkmarker) {
        $links = links_get_related_db($vars['page']);
        if (!empty($links)) {
            $output .= "<ul>\n";
            foreach (array_keys($links) as $page) {
                $ismatch = preg_match('/#googlemaps2_mark\\(([^, \\)]+), *([^, \\)]+)(.*?)\\)/i', get_source($page, TRUE, TRUE), $matches);
                if ($ismatch) {
                    $markersource = "&googlemaps2_mark(" . $matches[1] . "," . $matches[2] . ", title=" . $page . ", maxcontent=" . $page;
                    if ($matches[3] != "") {
                        preg_match('/caption=[^,]+/', $matches[3], $m_caption);
                        if ($m_caption) {
                            $markersource .= "," . $m_caption[0];
                        }
                        preg_match('/icon=[^,]+/', $matches[3], $m_icon);
                        if ($m_icon) {
                            $markersource .= "," . $m_icon[0];
                        }
                    }
                    $markersource .= ");";
                    $output .= "<li>" . make_link($markersource) . "</li>\n";
                }
            }
            $output .= "</ul>\n";
        }
    }
    return $output;
}