Example

https://bitlabo-the-final.com/pukiwiki/?plugin=dayslater

Source

<?php
function plugin_dayslater_action()
{
    global $post;
    date_default_timezone_set('Asia/Tokyo');

    $from_date = isset($post['from_date']) ? $post['from_date'] : '';
    if ($from_date == '') {
        return array(
            'msg' =>'Days Later',
            'body'=>plugin_dayslater_show_form('', '2019-06-02', 100));
    } else {
        if (!strptime($from_date, '%Y-%m-%d')) {
            $message = '日付が正しくありません。';
            return array(
                'msg' =>'Days Later',
                'body'=>plugin_dayslater_show_form($message));
        }
        $time_stamp_from = strtotime($from_date);
        $days = isset($post['days']) ? intval($post['days']) : 0;
        $time_stamp_to = $time_stamp_from + $days * (60 * 60 * 24);
        $to_date = date('Y-m-d', $time_stamp_to);
        $message = $from_date . ' の ' . number_format($days) . ' 日後は ' . $to_date . ' です。';
        return array(
            'msg' =>'Days Later',
            'body'=>plugin_dayslater_show_form($message, $from_date, $days));
    }
}

function plugin_dayslater_show_form($message = '', $from_date = '', $days = 0)
{
    $self = get_base_uri();
    $form .= <<<EOD
<div>$message</div>
<br />
<form action="$self" method="post">
 <div>
  <input type="hidden" name="plugin" value="dayslater" />

  <label for="from_date">いつから? (YYYY-mm-dd)</label>
  <input type="text" name="from_date"  id="from_date" size="10" value="$from_date" /><br />

  <label for="days">日後?</label>
  <input type="text" name="days"  id="days" size="10" value="$days" /><br />

  <br />
  <input type="submit" value="Compute" /><br />
 </div>
</form>
EOD;
    return $form;
}

Today : 1 / Yesterday : 0 / Total : 149

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-04-11 (木) 19:49:12