<?php
/**
 *  p2 書き込みフォーム ポップアップ (iPhone)
 * （2013/06/06 iphone/post_form_popup.inc.php から移動）
 */

/**
 * @access  public
 * @return  string  HTML
 */
function getPostFormPopupIPhoneHtml($host, $bbs, $key, $ttitle_en, $rescount)
{
    global $_conf, $STYLE; // readonly
    global $htm, $hs; // readonly
    // $htm['src_fix'], $htm['be2ch'], $htm['title_need_be'], $htm['maru_kakiko']
    // $hs['mail'], $hs['FROM']
    global $time_for_post, $res_disabled_at, $MESSAGE_hs, $wrap, $msg_cols_at, $sage_cb_ht, $on_check_sage, $mail_size_at, $name_size_at; // readonly
    // global $ptitle, $submit_value; // readonly
    global $popup, $newthread_hidden_ht, $readnew_hidden_ht; // for read
    
    $csrfid = P2Util::getCsrfId();
    
    $submit_value = '書き込む';
    
    $k_br_ht = '';
    $kakiko_on_js_ht = '';
    if (UA::isIPhoneGroup() || UA::isPC()) {
        // 2013/06/13 iPhone Safari, AndroidのChromeで onKeyup を拾うのを確認した。
        $kakiko_on_js_ht = ' onFocus="adjustTextareaRows(this, 2);" onKeyup="adjustTextareaRows(this, 2);'
            . sprintf(" autoSavePostForm('%s', '%s', '%s');", $host, $bbs, $key) . '"';
    // 携帯
    } else {
        $k_br_ht = '<br>';
    }

    $subject_ht             = isset($htm['subject'])        ? $htm['subject'] : '';
    $popup_hs               = isset($popup)                 ? hs($popup) : '';
    $newthread_hidden_ht    = isset($newthread_hidden_ht)   ? $newthread_hidden_ht : '';
    $readnew_hidden_ht      = isset($readnew_hidden_ht)     ? $readnew_hidden_ht : '';

    $ttitle_en_hs = hs($ttitle_en);

    // 文字コード判定用文字列を先頭に仕込むことでmb_convert_variables()の自動判定を助ける

    // <fieldset>はorder-topが超縦長
    $post_form_htm = <<<EOP
<form class="dialog_write" id="writeForm" method="POST" action="{$_conf['post_php']}" accept-charset="{$_conf['accept_charset']}">
	<input type="hidden" name="detect_hint" value="◎◇">
	<fieldset>
	<!-- {$subject_ht} -->
	<!-- <div id="writeFormCloseBtn" style="display:none;margin:0;"><img src="iui/icon_close.png" onClick="popUpFootbarFormIPhone(0, 1)"></div> -->
		<label>Name:</label>
		<input id="FROM" name="FROM" type="text" value="{$hs['FROM']}"{$name_size_at}>
		{$htm['maru_kakiko']}
		<br>
		<label>E-Mail:</label>
		<input id="mail" name="mail" type="text" value="{$hs['mail']}"{$mail_size_at}{$on_check_sage}>
		<span>{$sage_cb_ht}</span>
		<br>
		<!--<label>Message:</label>-->
		<textarea id="MESSAGE" name="MESSAGE" rows="{$STYLE['post_msg_rows']}"{$msg_cols_at} wrap="{$wrap}"{$kakiko_on_js_ht}>{$MESSAGE_hs}</textarea>
		<br>

		<input id="submit" type="submit" name="submit" value="{$submit_value}"{$res_disabled_at}{$htm['title_need_be']} onClick="setHiddenValue(this);">
		{$htm['be2ch']}
		{$htm['src_fix']}
	</fieldset>




	<input type="hidden" name="bbs" value="{$bbs}">
	<input type="hidden" name="key" value="{$key}">
	<input type="hidden" name="time" value="{$time_for_post}">

	<input type="hidden" name="host" value="{$host}">
	<input type="hidden" name="popup" value="{$popup_hs}">
	<input type="hidden" name="rescount" value="{$rescount}">
	<input type="hidden" name="ttitle_en" value="{$ttitle_en_hs}">
	<input type="hidden" name="csrfid" value="{$csrfid}">
	{$newthread_hidden_ht}{$readnew_hidden_ht}
	{$_conf['k_input_ht']}

	<span id="status_post_form" style="font-size:10pt;"></span>\n
EOP;

    if (!UA::isK() || UA::isIPhoneGroup()) {
        $post_form_htm .= <<<EOP
<script type="text/javascript">
<!--
var messageObj = document.getElementById('MESSAGE');
if (!messageObj.value) {
	hukkatuPostFormByCookie('{$host}', '{$bbs}', '{$key}');
}
-->
</script>\n
EOP;
    }

    $post_form_htm .= "</form>\n";

    return $post_form_htm;
}

/*
 * Local Variables:
 * mode: php
 * coding: cp932
 * tab-width: 4
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */
// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:
