<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title><?php echo C('softname'); ?></title>
<link href="__PUBLIC__/admin/css/reset.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/zh-cn-system.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/table_form.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/common.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="__PUBLIC__/admin/js/admin_common.js"></script>
<script language="javascript" type="text/javascript" src="__PUBLIC__/admin/js/styleswitch.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common.js"></script>
<link rel="stylesheet" href="__PUBLIC__/editor/themes/default/default.css" />
<link rel="stylesheet" href="__PUBLIC__/editor/plugins/code/prettify.css" />
<script charset="utf-8" src="__PUBLIC__/editor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/editor/lang/zh-CN.js"></script>
<script charset="utf-8" src="__PUBLIC__/editor/plugins/code/prettify.js"></script>
<script>
        function get_category(id,p){
            if(id) {
                deleteDiv(p);
                $.post("<?php echo U('content/ajax_get_category');?>",{id:id,p:p},function(result){
                $("#catid").val(id);
                if(result.status=='1'){
                $("#cat"+p).after(""+ result.info +"");
                }
            });
            }
            // alert(result);
        }
        function deleteDiv(p){
            if(p == 1){
            s_p = p;
            p = parseFloat(p)+parseFloat(1);
            p1 = parseFloat(s_p)+parseFloat(2);
            var my = document.getElementById("cat"+ p +"");
            var my1 = document.getElementById("cat"+ p1 +"");
            if (my != null){
                my.parentNode.removeChild(my);
            }
            if (my1 != null){
                my1.parentNode.removeChild(my1);
            }
            }else{
            p = parseFloat(p)+parseFloat(1);
            var my = document.getElementById("cat"+ p +"");
            if (my != null)
                my.parentNode.removeChild(my);
            }
        }
    </script>
<link href="__PUBLIC__/Home/css/app.min.css" media="screen, projection" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/Assets/js/sea.js"></script>
<script type="text/javascript" src="/Assets/js/sea_config.js"></script>
<script type="text/javascript">
    function tuwen(k,c){
        $(c).hide();
        $(k).show();
        if(k == '#ui-form-flash'){
            $("#viode").css("background","url('/Public/Home/images/viode_red.png')");
            $("#article").css("background","url('/Public/Home/images/article_green.png')");
            $("#type").val('2');
        }else{
            $("#viode").css("background","url('/Public/Home/images/viode_green.png')");
            $("#article").css("background","url('/Public/Home/images/article_red.png')");
            $("#type").val('1');
        }
    }
</script>
<style>
.content-block{
    width:100%;
}
#edui1_iframeholder{height:240px !important;}
</style>
</head>
<body>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="<?php echo U('content/content_content_insert');?>" enctype="multipart/form-data" method="post" id="spec_form">
<div class="content-block clearfix">

<div class="clearfix mt-l mb-l p-xl b-w bs-l">
<!-- 返回信息 -->

<!-- 发表表单 -->
<div class="wx600 f-l">
<div class="ui-tips">
    警告：禁止泛滥发帖，禁止发布大篇幅、类似小说的帖子，违者，给予删除扣积分处罚，严重者禁止发帖！
</div>
<div class="ui-form-item">
    <input type="button" value="" id="article" style="cursor: pointer; border: 0px; width: 90px; height: 30px; margin-right: 10px; background: url('__PUBLIC__/Home/images/article_red.png');" onclick="tuwen('#ui-content','#ui-form-flash')">
    <input type="button" value="" id="viode" style="cursor: pointer; border: 0px; width: 90px; height: 30px; background: url('__PUBLIC__/Home/images/viode_green.png');" onclick="tuwen('#ui-form-flash','#ui-content')">
</div>
<div class="ui-form-item">  
    <label class="ui-label">标题：</label>
    <input type="text" class="ui-input ui-input-title ui-input-hover" name="title" value="" id="title" maxlength="20">
</div>
<div id="ui-content">
<div class="ui-form-item ui-form-upload">
                <label class="ui-label">图片：</label>
                <span id="fileuploader">上传图片</span>
                <span id="show_info" style="display:none">等待……</span>
                <input type="hidden" id="image" name="thumb" />
</div>
<div class="ui-form-item ui-form-upload">
                <script id="content" name="content" type="text/plain" style="width:600px;height:240px !important;"></script> 
</div>
</div>

            <div class="ui-form-item" id="ui-form-flash" style="display:none;"> 
                <label class="ui-label">视频：</label>
                <input type="text" name="url" value="" class="ui-input ui-input-title ui-input-hover" placeholder="优酷、土豆、腾讯视频网址" id="title" style="color: rgb(190, 190, 190);">
            </div>
<div id="post-tags" class="ui-form-item">   
                        <label class="ui-label">标签：</label>
                        <input type="text" name="tag" id="tag" class="ui-input ui-placeholder" value="" placeholder="" style="color: rgb(153, 153, 153);">
                        <p class="ui-message">最多3个标签，用逗号“,”（英文格式）分隔</p>                     
                    </div>
<div id="post-tags-select" class="ui-form-item">    
                        <div id="tags-select"> 
                            <p><strong>热门标签</strong>
                            <?php if(is_array($tags)): $i = 0; $__LIST__ = $tags;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><a href="javascript:;"><?php echo ($vo["title"]); ?></a><?php endforeach; endif; else: echo "" ;endif; ?>
                            </p>
                        </div>
                        <!-- // tags-select -->
                    </div>
</div>

</div>





</div>

    <div class="bk15"></div>
    <p class="stdformbutton">
        <input type="hidden" id="type" name="type" value="1">
        <button class="submit radius2 fm_btn" id="dosubmit" name="dosubmit">提交</button>
    </p>
</form>
</div>
</div>
<script type="text/javascript">
    $("#tags-select a").click(function() {
    var name = $(this).text();
    if ($("#tag").val()=='标签') $("#tag").val('');
    var tag  = $("#tag").val();
    if (tag.length==0) {
        $("#tag").val(name);return false;
    }
    if (tag.lastIndexOf(name) != -1) {
        return false;
    }
    tag = tag.split(',');
    if (tag.length>2) {
        return false;
    } else {
        $("#tag").val(tag+','+name);
    }
});

    seajs.use(['app','uploadfile','ueditor_config','ueditor'],function(App,uploadfile) {

        
        //投稿编辑器
        var ue = UE.getEditor('content', {
            toolbars: [],
            initialFrameWidth :598,
            initialFrameHeight : 250,
            autoHeightEnabled : true,
            pasteplain : true,
            initialContent : '',
            autoClearinitialContent : true,
            enterTag : 'br',
            serverUrl : '',
            imageScaleEnabled : false
        });

        //上传图片
        $("#fileuploader").uploadFile({
            url:'/account/uploadfile/',
            fileName: "Filedata",
            dragDrop : false,
            doneStr : '使用',
            uploadStr:'插入图片',
            returnType : 'json',
            showStatusAfterSuccess : false,
            allowedTypes : 'jpg,jpeg,gif,png,bmp',
            acceptFiles : "image/",
            multiple : false,
            showDone : false,
            showError : false,
            onSubmit:function(files) {
                if(UE.getEditor('content').getContent().indexOf('<img')>-1 || $('#fileuploader').show().html() == '上传中...'){
                    $('#fileuploader').show().html('只能上传一张图片');
                    return false;
                }else{
                    $('#fileuploader').show().html('上传中...');
                }
            },
            onSuccess:function(files,data,xhr,pd){
                if(data.status == 0) {
                    $('#fileuploader').show().html(data.info);
                }else {
                    var image = data.url;
                    var m_image = data.m_url;
                    $('#image').val(m_image);
                    var imgHtml = '<img src="/'+image+'" class=""  />';         
                        if(parseInt(ue.getContentLength(true)) == 0){
                            ue.focus();
                        };
                        ue.execCommand('insertHtml', imgHtml);  //插入图片
                        $('#fileuploader').show().html('上传完成');
                }
            }
        });


    });

</script>
</body>
</html>