<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>{if $cmd=='data_add_input'}データ新規投稿{elseif $cmd=='data_edit_input'}データ編集{/if}|{$config.page_title|escape}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{$config.root_uri}/bootstrap/bootswatch/{$appearance.bootswatch_name}/bootstrap.min.css" media="screen">
    <link rel="stylesheet" href="{$config.root_uri}/css/parts.css">
    <link rel="stylesheet" href="{$config.root_uri}/css/flatmemo.css">
    <link rel="stylesheet" href="{$config.root_uri}/font-awesome/css/font-awesome.min.css">

    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="{$config.root_uri}/bootstrap/bootstrap.min.js"></script>
    <script src="{$config.root_uri}/bootstrap/bootswatch.js"></script>

    <script src="{$config.root_uri}/js/flatmemo.js"></script>

    <script src="{$config.root_uri}/js/uploadify/swfobject.js"></script>
    <script src="{$config.root_uri}/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>

    <!--[if lt IE 9]>
      <script src="./bootstrap/html5shiv.js"></script>
      <script src="./bootstrap/respond.min.js"></script>
    <![endif]-->

<script type="text/javascript" src="{$config.root_uri}/js/autoresize.jquery.js"></script>
{literal}
<script type="text/javascript">
$(document).ready(function(){
	$('textarea#text_name').autoResize();
	change_tag_list();
	document.FM.title_name.focus();
});
</script>
{/literal}

{literal}
<script type="text/javascript">
function change_tag_list(){
	$('#this_category_tag').hide();
	$('#all_tag').hide();
	if( $('#tagselector').val()==1 ){ $('#this_category_tag').show(); }
	else{ $('#all_tag').show(); }
}
function ct(tag_name){
	//alert(tag_name);
	v = $('#tag_name').val();
	if (v.indexOf(tag_name,0) != -1){
		v2 = v.replace(tag_name+'　','');
		v2 = v2.replace('　　','　');
		$('#tag_name').val(v2);
	}
	else{ $('#tag_name').val(v+tag_name+'　'); }

}

function add_file_upload_attach_link( file_path, file_name ){
	//alert(file_path + '  :  ' + file_name);
	
	if ( file_name.match(/\.(gif|jpg|jpeg|png|bmp)$/) ){
		$('#file_upload_attach_link').append('<input type="text" value="<img src=\'' + file_path + '\' width=\'450\' />" style="width:450px;"/>');
	}
}
var bt_name;
$(document).ready(function() {
  $('#file_upload').uploadify({
{/literal}
    'uploader'        : '{$config.root_uri}/js/uploadify/uploadify.swf',
    'script'          : '{$config.root_uri}/js/uploadify/uploadify.php?rnd_key={$rnd_key}',
    'cancelImg'       : '{$config.root_uri}/js/uploadify/cancel.png',
    'folder'          : './data/tmp',
    'auto'            : true ,
	'removeCompleted' : false ,
    'multi'           : true ,
{literal}	
	'onOpen'          : function(event,ID,fileObj) {
		$('#form_submit').attr("disabled", true);
		bt_name = $('#form_submit').val();
		$('#form_submit').attr("value", bt_name+' ( 添付ファイルupload中 )');
	} ,

onComplete: function(event, queueID, fileObj, reposnse, data) {
		add_file_upload_attach_link( fileObj.filePath, fileObj.name )
} ,


	'onAllComplete'   : function(event,data) {
		$('#form_submit').attr("disabled", false);
		$('#form_submit').attr("value", bt_name);
		if ( $('#auto_submit_flag').attr('checked') ){
			document.FM.submit();
		}
	} ,
	'onCancel'        : function(event,ID,fileObj,data) {
		if (data.fileCount==0){
			$('#form_submit').attr("disabled", false);
			$('#form_submit').attr("value", bt_name);
		}
	} ,
	'onError'        : function(event, ID, fileObj, errorObj) {
		alert(errorObj.type+"::"+errorObj.info);
	}
{/literal}
{literal}
  });
});
</script>
{/literal}

</head>
<body>

{include file="inc/header.html"}

<form name="FM" method="post" enctype="multipart/form-data" action="{$_program_uri}" onsubmit="accessing(); return notrepeat();" >
{$hidden}

<div class="container">

<div class="pull-left mr10">
<div class="fm_icon2">
<a href="{$config.memo_uri}/category/{$category_id}"><p style="background-image: url({$config.icon_uri}/{if $icon_file_name}{$icon_file_name}{else}noicon.jpg{/if})"></p></a>
</div>
</div>

      <div class="page-header">
        <h1>{if $cmd=='data_add_input'}データ新規投稿{elseif $cmd=='data_edit_input'}データ編集{/if} <small>{if $cmd=='data_add_input'}データの新規投稿{elseif $cmd=='data_edit_input'}データの編集{/if}を行います</small></h1>
      </div>

        <div class="row mb30">
        <div class="col-xs-12">
        <div class="pull-left"><a href="#" onclick="history.back(); return false;"><i class="fa fa-arrow-left"></i> 戻る</a>　　</div>
        <div class="pull-right"><a href="{$config.admin_uri}?cmd=category_edit_input" ><i class="fa fa-file-text"></i> カテゴリの編集</a>　　
        <a href="{$_program_name}?cmd=category_turn_input"><i class="fa fa-list"></i> カテゴリの順番変更</a>　　
        <a href="{$_program_uri}?cmd=tag_edit_input" ><i class="fa fa-file-text"></i> タグの編集</a>
        </div>
        </div> <!-- /.col-xs-12 -->
        </div>
        <hr />          


        <div class="row">






<div class="col-xs-12 mb25">


<p>
{$hidden_attach}
</p>

<div class="row">
<div class="col-sm-2">タイトル</div>
<div class="col-sm-10"><input name="title_name" type="text" id="title_name"  class="form-control" /></div>
</div>

<div class="row mt5">
<div class="col-sm-2">テキスト</div>
<div class="col-sm-10"><textarea name="text_name" cols="70" rows="12"  class="form-control" id="text_name"></textarea></div>
</div>

<div class="row">
<div class="col-sm-2">オプション</div>
<div class="col-sm-10">
記法<br>
<input type="radio" name="kihou_flag" value="autolink" id="autolink_flag" {if $autolink_flag=='on'}checked{/if} /> <label for="autolink_flag">標準記法を使う ( <span style="color:#999999;font-size:smaller;">URLやメールアドレスに自動でリンクを付加します</span> )</label><br />
<input type="radio" name="kihou_flag" value="hatena" id="hatena_flag" {if $hatena_flag=='on'}checked{/if}  /> <label for="hatena_flag">はてな記法を使う</label> ( <a href="http://goo.gl/XSRb" target="_blank">はてな記法一覧</a> )<br />
<input type="radio" name="kihou_flag" value="markdown" id="markdown_flag" {if $markdown_flag=='on'}checked{/if} /> <label for="markdown_flag">Markdown記法を使う</label> ( <a href="http://daringfireball.net/projects/markdown/dingus" target="_blank">Markdown記法+記法テスト</a> )<br />
<hr class="mt1 mb5">
<label><input type="checkbox" name="movetop_flag" value="on" id="movetop_flag" {$movetop_flag_check} /> この記事をカテゴリの先頭に移動させる</label><br />
<label><input type="checkbox" name="draft_flag" value="on" id="draft_flag" {$draft_flag_check} /> ドラフト（下書き）として一般公開しない</label>
</div>
</div>

<div class="row mt5 mb5">
<div class="col-sm-2">カテゴリ</div>
<div class="col-sm-10">
<select name="category_id" class="form-control">
{ foreach from=$category_master_loop key="k" item="v" name="loopname"}
<option value="{$v.category_id}">{$v.category_name|escape}</option>
{ /foreach }
</select>
</div>
</div>

<div class="row mt10">
<div class="col-sm-2">タグ</div>
<div class="col-sm-10">
<input name="tag_name" class="form-control" type="text" id="tag_name" style="width:400px;" value="{ foreach from=$tag_id_loop key="tk" item="tv" }{$tv|tag_name:$tag_master_loop}　{/foreach}" />
<small>（タグは全角または半角スペースで区切って下さい）</small>

<div class="taglist1">
<select id="tagselector" class="form-control" onchange="change_tag_list()" name="" ><!-- changetag(); -->
<option value="1" selected>このカテゴリ内</option>
<option value="2">全てのタグ</option>
</select>
</div>
<div class="taglist2" id="taglistinsert">
<p id="all_tag">
{ foreach from=$tag_master_loop key="k" item="v" name="loopname"}
<a href="javascript:ct('{$v.tag_name|escape}');">{$v.tag_name|escape}</a> | 
{ /foreach }
</p>
<p id="this_category_tag">
{ foreach from=$this_category_tag_loop key="k" item="v" name="loopname"}
<a href="javascript:ct('{$v.tag_name|escape}');">{$v.tag_name|escape}</a> | 
{ /foreach }
</p>
</div>


</div>
<br style="clear:both;" />
</div>


<div class="row">
<div class="col-sm-2">添付file</div>
<div class="col-sm-10">
<!-- file upload -->
<input class="form-control" id="file_upload" name="file_upload" type="file" />
<label><input name="auto_submit_flag" id="auto_submit_flag" type="checkbox" value="1" /> 添付fileアップロード完了後にこの記事を自動送信する</label>

<div id="file_upload_attach_link">
</div>
<!-- /file upload -->



<br>
{ foreach from=$attach_en_loop key="ak" item="av" name="loopname"}
{ math equation=a-1 a=$smarty.foreach.loopname.iteration assign=i }
<p class="article-attach-left article-attach-height2">添付ファイル{$smarty.foreach.loopname.iteration}<br />　</p> 
<p class="article-attach-right article-attach-height2"><a href="{$config.data_file_uri}/{$av}" target="_blank">{$attach_jp_loop.$i}</a><span class="article-attach-filesize">( {$attach_en_loop.$i} / {"`$config.data_file_dir`/`$av`"|fsize} )</span><br /> 
<label class="attach_label"><input name="attach_edit_flag{$smarty.foreach.loopname.iteration}" type="radio" value="notedit" checked />変更しない</label>　
<label class="attach_label" style="color:red;"><input name="attach_edit_flag{$smarty.foreach.loopname.iteration}" type="radio" value="delete" />削除する</label> 
<input type="hidden" name="attach_en{$smarty.foreach.loopname.iteration}" value="{$attach_en_loop.$i}" /> 
<input type="hidden" name="attach_jp{$smarty.foreach.loopname.iteration}" value="{$attach_jp_loop.$i}" /> 
<span class="article-attach-link">貼りつけリンク
{ if $av|ext_preg:'/.mp4$/i' }<input type="text" value='<video preload="none" controls src="{$config.data_file_uri}/{$av}" >' style="width:450px;"/>
{ elseif $av|ext_preg:'/(gif|jpg|jpeg|png|bmp)/i' }<input type="text" value='<a href="{$config.data_file_uri}/{$av}" target="_blank"><img src="{$config.data_file_uri}/{$av}" class="ci" /></a>' style="width:450px;"/>
{ /if }
</span>
</p>
{ /foreach }

</div>

</div>

<div class="row mt10">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<input id="form_submit" class="btn btn-primary" type="submit" value="送信" accesskey="s" />　<input type="reset" class="btn btn-default" />
<p id="accessing" class="fm_accessing" style="display:none;"><i class="fa fa-refresh fa-spin"></i> now accessing...</p>
</div>
</div>


</div> <!-- /.col-xs-12 -->





          
        </div><!-- /.row -->

</div><!-- /.container -->

{include file="inc/footer.html"}

</form>
</body>
</html>