<?php
function plugin_route_inline(){
$aryargs = func_get_args();
return '<script type="text/javascript" encoding="UTF-8" src="http://latlonglab.yahoo.co.jp/route/paste?id=' .
$aryargs[0] .
'&width=320&height=480"></script>';
}
?>
初期化 | function plugin_{プラグイン名}_init() |
ブロック型で呼び出される | function plugin_{プラグイン名}_convert() |
インライン型で呼び出される | function plugin_{プラグイン名}_inline() |
パラメータ配列 | func_get_args() |
パラメータ数 | func_num_args() |
ルートIDを引数にして、Pukiwiki に次のように記述すればよい
&route(91d77cdc5f1fb99291550adc714ee9d4);
<?php
function plugin_js_inline(){
global $vars;
$aryargs = func_get_args();
$arylength = func_num_args();
$attach_file = '/pukiwiki/index.php?plugin=attach&pcmd=open&file=' . urlencode($aryargs[0]) . '&refer=' . urlencode($vars['page']);
$size = '';
if ($arylength == 3) {
$size = ' width="' . $aryargs[1] . '" height="' . $aryargs[2] . '"';
}
return '<iframe src="' . $attach_file . '"' . $size . ' style="border:solid"></iframe>';
}
?>
ページ名は グローバル変数 $vars に 'page' をキーに格納されている
&js(sample.html,320,240);
[source] [reload] |
<?php
function plugin_youtube_inline(){
$aryargs = func_get_args();
$arylength = func_num_args();
$videoId = $aryargs[0];
$width = 512;
$height = 384;
if (func_num_args() > 2){
if ($aryargs[1] == '4:3s') {
$width = 256;
$height = 192;
} else if ($aryargs[1] == '4:3') {
$width = 512;
$height = 384;
} else if ($aryargs[1] == '16:9s') {
$width = 320;
$height = 192;
} else if ($aryargs[1] == '16:9') {
$width = 640;
$height = 384;
}
}
return '<object width="' . $width . '" height="' . $height . '">'
. '<param name="movie" value="http://www.youtube.com/v/' . $videoId . '"></param>'
. '<embed src="http://www.youtube.com/v/' . $videoId . '" '
. ' type="application/x-shockwave-flash"'
. ' wmode="transparent" width="'. $width . '" height="' . $height . '"></embed>'
. '</object>';
}
?>
<?php
function plugin_gdoc_inline(){
global $vars;
$aryargs = func_get_args();
$arylength = func_num_args();
$size = '';
if ($arylength == 5) {
$size = ' width="' . $aryargs[2] . '" height="' . $aryargs[3] . '"';
}
if ($aryargs[0] == 'spreadsheet'){
return '<iframe src="https://spreadsheets.google.com/spreadsheet/ccc?key='
. $aryargs[1]
. '&hl=ja&ui=2&rm=demo&chrome=false#gid=0" style="border:solid" ' . $size . '>'
. '</iframe>';
}
}
?>
\(\left( \begin{array}{c} x' \\ y' \\ 1 \end{array} \right) = \left( \begin{array}{ccc} m_{11} & m_{21} & d_{x} \\ m_{12} & m_{22} & d_{y} \\ 0 & 0 & 1 \end{array} \right) \left( \begin{array}{c} x \\ y \\ 1 \end{array} \right) \)
<?php
function plugin_tex_inline(){
$aryargs = func_get_args();
$tex = $aryargs[0];
$tex = str_replace(array("\r\n","\r","\n"), '', $tex);
$tex = str_replace(' $' , '$' , $tex);
$tex = str_replace(' \\', '\\', $tex);
return '<img src="http://chart.apis.google.com/chart?cht=tx&chf=bg,s,00000000&chl='
. rawurlencode($tex) . '"/>';
}
function plugin_tex_convert(){
$aryargs = func_get_args();
$tex = $aryargs[0];
$tex = str_replace(array("\r\n","\r","\n"), '', $tex);
$tex = str_replace(' $' , '$' , $tex);
$tex = str_replace(' \\', '\\', $tex);
return '<img src="http://chart.apis.google.com/chart?cht=tx&chf=bg,s,00000000&chl='
. rawurlencode($tex) . '"/>';
}
?>
#tex(){{ \left( \begin{array}{c} x' \\ y' \\ 1 \end{array} \right) = \left( \begin{array}{ccc} m_{11} & m_{21} & d_{x} \\ m_{12} & m_{22} & d_{y} \\ 0 & 0 & 1 \end{array} \right) \left( \begin{array}{c} x \\ y \\ 1 \end{array} \right) }} オイラーの公式( &tex(e^{i\theta} = \cos(\theta) + i\sin(\theta)); )は、電気工学でよく使われます
<?php
function plugin_ispent_inline(){
$args = func_get_args();
return plugin_ispent();
}
function plugin_ispent_convert(){
$args = func_get_args();
return '<br/>' . plugin_ispent() . '<br/>';
}
function plugin_ispent(){
$html = '<fieldset style="border:dotted 2px lightgray">';
$html = $html . '<legend>' . date('Y-m-d') . '</legend>';
$html = $html . plugin_ispent_make_meter(
date('Y')
, strtotime(date('Y-01-01'))
, strtotime(date('Y-01-01', strtotime(date('Y-01-01') . '+1 year')))
, 86400);
$html = $html . '<br/>' . plugin_ispent_make_meter(
date('F')
, strtotime(date('Y-m-01'))
, strtotime(date('Y-m-01', strtotime(date('Y-m-01') . '+1 month')))
, 86400);
if(strcmp(date('D'),'Mon') === 0) {
$html = $html . '<br/>' . plugin_ispent_make_meter(
'Week ' . date('W')
, strtotime('today')
, strtotime('next monday')
, 86400);
} else {
$html = $html . '<br/>' . plugin_ispent_make_meter(
'Week ' . date('W')
, strtotime('previous monday')
, strtotime('next monday')
, 86400);
}
$html = $html . '<br/>' . plugin_ispent_make_meter(
'Day ' . date('d D')
, strtotime('today')
, strtotime('tomorrow')
, 3600);
$html = $html . '</fieldset>';
return $html;
}
function plugin_ispent_make_meter($title, $start, $end, $unit) {
$all = ($end - $start) / $unit;
$spent = (time() - $start) / $unit;
$low = $all / 3.0;
$optimum = $all / 2.0;
$high = $low * 2.0;
$progress = (floor(1000.0 * $spent / $all) / 10.0) . "% ("
. (floor(10.0 * $spent) / 10.0) . '/' . floor($all) . ")";
return $title . '<br/>'
. '<meter value="' . $spent . '"'
. ' min="0" max="' . $all . '"'
. ' title="' . $progress . '" style="width:75px">' . $progress . '</meter>';
}
?>
#ispent
<?php
function plugin_jpg_inline(){
$args = func_get_args();
return jpgto($args[0]);
}
function plugin_jpg_convert(){
$args = func_get_args();
return jpgto($args[0]);
}
function jpgto($keyword){
return '<br/><img src="http://' . $keyword . '.jpg.to/" height="240" alt="' . $keyword . '">';
}
?>
#jpg(逃げて)
#graphviz{{{
digraph {
node [shape = box, fontname = "sans-serif", fontsize = 8];
"オブジェクト型"->"コンテナ型"
"オブジェクト型"->"None"
"オブジェクト型"->"数値型"
"数値型"->"bool"
"数値型"->"int"
"数値型"->"float"
"数値型"->"Complex\n(複素数)"
"コンテナ型"->"シーケンス型"
"シーケンス型"->"list"
"シーケンス型"->"tuple\n(変更不可list)"
"シーケンス型"->"文字列"
"シーケンス型"->"range"
"コンテナ型"->"集合型"
"集合型"->"set"
"集合型"->"frozenset\n(変更不可set)"
"コンテナ型"->"マップ型"
"マップ型"->"Dictionary"
"iteratable"->"list"
"iteratable"->"tuple\n(変更不可list)"
"iteratable"->"文字列"
"iteratable"->"range"
"iteratable"->"set"
"iteratable"->"frozenset\n(変更不可set)"
"iteratable"->"Dictionary"
}
}}}