<!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">
            <title>{{$lang.admin_title}}</title>
            <script type="text/javascript" src="{{$js_path}}global.js"></script>
            <script type="text/javascript" src="{{$admin_js_path}}admin.js"></script>  
            <script type="text/javascript" src="{{$admin_editor_path}}kindeditor.js"></script>
            <script type="text/javascript" src="{{$js_path}}transport.js"></script>
            <link href="{{$style_path}}main.css" rel="stylesheet" type="text/css" />
            <style type="text/css" rel="stylesheet">
                .ke-content {
                    font-family: Courier New;
                    font-size: 12px;
                    background-color: #ffffff;
                }
                .editor {
                    margin-top: 5px;
                    margin-bottom: 5px;
                }
            </style>
            <script type="text/javascript">
                KE.show({
                    id : 'content1',
                    cssPath : './index.css'
                });
                function clearEditor(id) {
                    KE.g[id].iframeDoc.open();
                    KE.g[id].iframeDoc.write(KE.util.getFullHtml(id));
                    KE.g[id].iframeDoc.close();
                    KE.g[id].newTextarea.value = '';
                }
                function insertHtml(id, html) {
                    KE.util.focus(id);
                    KE.util.selection(id);
                    KE.util.insertHtml(id, html);
                }

                var modelessDialog,modalDialog;
                function showPage1(pageSrc)
                {
                    modalDialog = window.showModalDialog(pageSrc,window,"dialogWidth=600px;dialogHeight=500px;dialogLeft:0px;dialogTop:0px;help:no;status:no;resizable:yes");

                }
                function fnInsertLocalImage(sVal) {
                    insertHtml('content1', '<strong><image alt=\'\' border=\'0\' src=\''+sVal+'\' /></strong>');
                }
                function insertLabelCode() {
                    KE.util.focus('content1');
                    KE.util.selection('content1');
                    KE.util.insertHtml('content1', '[code][/code]');
                }
                function clearEditor(id) {
                    KE.g[id].iframeDoc.open();
                    KE.g[id].iframeDoc.write(KE.util.getFullHtml(id));
                    KE.g[id].iframeDoc.close();
                    KE.g[id].newTextarea.value = '';
                }
            </script>
            <script type="text/javascript">
                var fnChangeCate = function(sType,sVal) {
                    Ajax.call('includes/transport.php?&act='+sType+'&val='+sVal,'', fnCheckRunResponse, 'GET', 'TEXT');
                }
                var fnCheckRunResponse = function(result) {
                    if (result.indexOf(',') ==  -1) {
                        alert(result);
                    } else {
                        var aCate = result.split(',');
                        $('cate_box') .innerHTML += '<li> <a href="javascript:;" onclick="fnSetCategory(this, ' +  aCate[0] +  ', \'category_id\');" title=' + aCate[1] + '>'  + aCate[1] + '</a> </li>';
                    }
                }
                var fnChangeTag = function(sType,sVal) {
                    Ajax.call('includes/transport.php?&act='+sType+'&val='+sVal,'', fnCheckTagResponse, 'GET', 'TEXT');
                }
                var fnCheckTagResponse = function(result) {
                    if (result.indexOf(',') == -1 ) {
                        alert(result);
                    } else {
                        var aCate = result.split(',');
                        $('tag_box') .innerHTML += '<li> <a href="javascript:;" onclick="fnSetCategory(this, ' +  aCate[0] +  ', \'category_id\');" title=' + aCate[1] + '>'  + aCate[1] + '</a> </li>';
                    }
                }
            </script>
    </head>
    <body>
        <div class="layout">
            <!-- 当前所在位置和相关链接 -->
            <div class="location_nav">
                <!-- 当前所在位置 -->
                <div class="location_link">
                    <ol id='breadcrumb'>
                        {{foreach from=$location_link item=link name=link}}
                        <li>
                            {{if !$smarty.foreach.link.last}}
                            {{$link}}&nbsp;&gt;&nbsp;
                            {{else}}
                            <!-- 如果是编辑文章 -->
                            {{if $only_article.article_id}}
                            {{$lang.edit_blog}}
                            {{else}}
                            {{$lang.add_blog}}
                            {{/if}}
                            {{/if}}
                        </li>
                        {{/foreach}}
                    </ol>
                </div>
                <!-- 相关链接 -->
                <div class="location_other linkButtonDiv">
                    <ul>
                        {{foreach from=$location_other item=other_link}}
                        <li>{{$other_link}}</li>
                        {{/foreach}}
                    </ul>
                </div>
            </div>
            <!-- 标签列表标题行 -->
            <div class="title_bgcolor">
                <span>
                    <!-- 如果是编辑文章 -->
                    {{if $only_article.article_id}}
                    {{$lang.edit_blog}}
                    {{else}}
                    {{$lang.add_blog}}
                    {{/if}}
                </span>
            </div>
            <!-- 添加博客表单 -->
            <div style="height:50px;">
                <form id="form_add_content" name="form_add_content" action="{{$current_page_url}}" method="post">
                    <!-- 如果是编辑文章 -->
                    {{if $only_article.article_id}}
                    <input type="hidden" name="text_edit_article_id" value="{{$only_article.article_id}}">
                        {{/if}}
                        <table width="100%" border="0" style="margin-top:10px;">
                            <tr>
                                <td align="right" width="15%">{{$lang.label_blog_subject}}：&nbsp;</td>
                                <td><input class="input_style" id="subject" name="text_blog_subject" type="text" size="55" value="{{$only_article.subject}}"/></td>
                            </tr>
                            <tr>
                                <td align="right" width="15%">{{$lang.label_blog_content_type}}</td>
                                <td>
                                    {{if $only_article.is_original}}
                                    <span class='yesno_yes '>
                                        <input type='radio' name='text_blog_type' value='1'   id="sub_can_post_yes" checked />
                                        <label for='sub_can_post_yes' class="label_radio">{{$lang.label_blog_radio_o}}</label>
                                    </span><span class='yesno_no '>
                                        <input type='radio'  id="sub_can_post_no"  name='text_blog_type' value='0'/>
                                        <label for='sub_can_post_no'>{{$lang.label_blog_radio_z}}</label>
                                    </span>
                                    {{else}}
                                    <span class='yesno_yes '>
                                        <input type='radio' name='text_blog_type' value='1'   id="sub_can_post_yes" {{if $only_article.is_original eq '0'}}{{else}}checked{{/if}}/>
                                               <label for='sub_can_post_yes' class="label_radio">{{$lang.label_blog_radio_o}}</label>
                                    </span><span class='yesno_no '>
                                        <input type='radio'  id="sub_can_post_no"  name='text_blog_type' {{if $only_article.is_original eq '0'}}checked{{/if}} value='0'/>
                                               <label for='sub_can_post_no'>{{$lang.label_blog_radio_z}}</label>
                                    </span>
                                    {{/if}}
                                </td>
                            </tr>
                            <!-- 是否允许评论 -->
                            <tr>
                                <td align="right" width="15%">{{$lang.label_blog_comment_allow}}</td>
                                <td>
                                    {{if $only_article.is_allow_comment}}
                                    <span class='yesno_yes '>
                                        <input type='radio' name='text_allow_comment' value='1'   id="sub_can_post_yes" checked />
                                        <label for='sub_can_post_yes' class="label_radio">{{$lang.open}}</label>
                                    </span><span class='yesno_no '>
                                        <input type='radio' name='text_allow_comment' value='0' />
                                        <label for='sub_can_post_no'>{{$lang.close}}</label>
                                    </span>
                                    {{else}}
                                    <span class='yesno_yes '>
                                        <input type='radio' name='text_allow_comment' value='1'   id="sub_can_post_yes" {{if $only_article.is_allow_comment eq '0'}}{{else}}checked{{/if}}/>
                                               <label for='sub_can_post_yes' class="label_radio">{{$lang.open}}</label>
                                    </span><span class='yesno_no '>
                                        <input type='radio'  id="sub_can_post_no"  name='text_allow_comment' {{if $only_article.is_allow_comment eq '0'}}checked{{/if}} value='0'/>
                                               <label for='sub_can_post_no'>{{$lang.close}}</label>
                                    </span>
                                    {{/if}}
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%">{{$lang.label_blog_keywords}}</td>
                                <td><input class="input_style" name="text_blog_keywords" type="text" size="55" value="{{$only_article.keywords}}"/>{{$lang.label_notice_keywords}}</td>
                            </tr>
                            <tr>
                                <td align="right" width="15%">{{$lang.label_add_cate}}</td>
                                <td>
                                        <input type='text' class='input_style' size='35' id="inp_cate"/>
                                        <a href="javascript:fnChangeCate('add_cate', $('inp_cate').value);"><img src="{{$image_path}}add.gif"/></a>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%" valign="top">
                                        {{$lang.label_blog_category}}
                                </td>
                                <td valign="top">
                                    <ul class="data_list1" id="cate_box">
                                        {{foreach from=$cate_list item=cats}}
                                        <li>
                                            <a href="javascript:;" onclick="fnSetCategory(this, '{{$cats.category_id}}', 'category_id');" {{if $only_article.category_id eq $cats.category_id}}style="background:#e3f6e5;border:1px solid #b4e3b9;"{{/if}} title="{{$cats.category_name}}">{{$cats.category_name|truncate:15:"..."}}</a>
                                        </li>
                                        {{/foreach}}
                                    </ul>
                                    <input type="hidden" id="category_id" name="text_selected_category" value="{{$only_article.category_id}}">
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%" valign="top">{{$lang.label_add_tag}}</td>
                                <td>   
                                    <input type='text' class='input_style' size='35' id="inp_tag"/>
                                            <a href="javascript:fnChangeTag('add_tag', $('inp_tag').value);"><img src="{{$image_path}}add.gif"/></a>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%" valign="top">{{$lang.label_blog_tag}}</td>
                                <td>
                                    <ul class="data_list1" id="tag_box">
                                        {{foreach from=$tags_list item=tags}}
                                        <li>
                                            <a href="javascript:;" onclick="fnSetTags(this, '{{$tags.tag_id}}', 'tags_id');" title="{{$tags.tag_name}}"
                                               {{ foreach from=$tags_sel item=t}}
                                               {{if $t eq $tags.tag_id}}
                                               style="background:#e3f6e5;border:1px solid #b4e3b9;"
                                               {{/if}}
                                               {{/foreach}}
                                               >{{$tags.tag_name|truncate:15:"..."}}</a>
                                        </li>
                                        {{/foreach}}

                                    </ul>
                                    <input type="hidden" id="tags_id" name="text_selected_tags" value="{{$only_article.tags_id}}">
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%" valign="top">
                                    <ul class="content_left_li">
                                        <li>{{$lang.label_blog_content}}</li>
                                        <li><input type='button' class='realbutton' onClick="showPage1('{{$local_image_url}}');" value='{{$lang.sub_select_local_img}}' /></li>
                                        <li><input type='button' class='realbutton' onClick="insertLabelCode();" value='{{$lang.sub_select_insert_code}}' /></li>
                                        <li><input type='button' class='realbutton' onClick="clearEditor('content1');" value='{{$lang.sub_clear_editor}}' /></li>
                                    </ul>
                                </td>
                                <td>
                                    <div class="editor">
                                        <textarea id="content1" name="text_content" style="width:700px;height:300px;visibility:hidden;">{{$only_article.content}}</textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" width="15%" valign="top"></td>
                                <td>
                                    <input type='submit' class='button primary'name="sub_add_content" value='{{$lang.submit}}' />
                                    &nbsp;<input type='reset' class='realbutton' value='{{$lang.reset}}' />
                                </td>
                            </tr>
                        </table>
                </form>
            </div>

        </div>
    </body>
</html>