<%@ Page Language="c#" Inherits="Web.Wpdcc.pageLayoutTemplate" CodeBehind="pageLayoutTemplate.aspx.cs" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>pageLayoutTemplate</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="text/css" rel="stylesheet" href="Css/public.css" />
    <link type="text/css" rel="stylesheet" href="Wpdcc/css/adminfunc.css" />

    <script type="text/javascript" src="Js/jQuery.js"></script>

    <script type="text/javascript" src="Js/validate.js" charset="utf-8"></script>

    <%--加载编辑器--%>
    <link rel="stylesheet" href="Editor/WpdccEditor/themes/default/default.css" />

    <script type="text/javascript" src="Editor/WpdccEditor/kindeditor.js"></script>

    <script type="text/javascript" src="Editor/WpdccEditor/lang/zh_CN.js" charset="utf-8"></script>

    <style type="text/css">
        form
        {
            margin: 0;
        }
        textarea
        {
            display: block;
        }
        .ke-icon-sethomepage
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-addfavorite
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysethomepage
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyaddtofavorite
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsybanner
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -48px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsymenu
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -72px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsylibrary
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -96px -24px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsychannel
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -96px -96px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsymorenavigation
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsymore
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -72px -96px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsybeautify
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsynewsnavigation
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsytitle
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -48px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysubtitle
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -72px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyupdownnews
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -144px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsycontent
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -96px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsycomment
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -168px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyabout
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -120px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyauthor
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -192px -72px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysource
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px -96px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsypublishtime
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -96px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyvisits
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsyauditor
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysetfont
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -48px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysetprint
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -72px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysetclose
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -96px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-nsysetzoom
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -120px -120px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-zdycss
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: 0px 0px;
            width: 24px;
            height: 24px;
        }
        .ke-icon-zdyjs
        {
            background-image: url(./Editor/WpdccEditor/themes/default/nsyicon.png);
            background-position: -24px 0px;
            width: 24px;
            height: 24px;
        }
    </style>
</head>
<body>
    <div class="edit-func-box func-box">
        <div class="hd">
            模板制作<div class="user-service">
                <a class="help" href="#" title="制作提示：一般先用photoShop和dreamWeaver等制作好html模板粘贴至此处，模板包含的文件须存放在'Images/pageItem'目录下的新建目录内，并根据该存放目录修正模版的相关路径。">
                    制作提示</a></div>
        </div>
        <form id="Form1" method="post" runat="server">
        <div class="bd" style="height: 616px; *height: 614px; overflow: auto;">
            <table class="edit-table">
                <tr>
                    <td>
                        <textarea name="content" style="width: 100%; height: 598px; *height: 588px; visibility: hidden;"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div class="ft">
            <div class="txt-l" style="float:left;">
                <asp:Button ID="btnSave" runat="server" class="btn" Text="保存" OnClientClick="return checkall();" OnClick="Btn_Click"></asp:Button>&nbsp;&nbsp;
                <asp:Button ID="btnSaveBack" runat="server" class="btn" Text="保存并返回" OnClientClick="return checkall();" OnClick="Btn_Click"></asp:Button>&nbsp;&nbsp;
                模板名称：
                <asp:TextBox ID="name" runat="server" class="input-txt" notNull="true" msgName="模板名称" MaxLength="50"></asp:TextBox>
                &nbsp;&nbsp;
                <asp:DropDownList ID="isArtDesign" runat="server" Visible="False">
                    <asp:ListItem Value="0">否</asp:ListItem>
                    <asp:ListItem Value="1" Selected="True">是</asp:ListItem>
                </asp:DropDownList>
                </div>
                <asp:Panel runat="server" ID="pnlBgpic">
                &nbsp;&nbsp;模板背景图：
                <div id="bgpic1" style="display: inline; width: 70px; height: 15px" runat="server">
                </div>
                <div style="display: inline;"><a id="upbgimg" href="javascript:void(0);">上传模板背景图片</a></div>
                <input id="HiddenPkId" runat="server" type="hidden" />&nbsp;&nbsp;<a href="#" onclick="findreplace()">查找替换</a>&nbsp;&nbsp;<a href="#" onclick="copycode()">模板图片路径修正</a>
                </asp:Panel>  
                <asp:TextBox ID="itemWidth" runat="server" Width="117px" Visible="False"></asp:TextBox>
                <asp:HiddenField ID="bgpic" runat="server" />
                <input id="content1" type="hidden" name="content1" runat="server" />
        </div>

        <script type="text/javascript" language="javascript">
    var cont=document.getElementById("content1").value;
    var editor;
    switch("<%=systemControl%>"){        
        case '1': //新闻页  
            KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
				    designMode : true,
	                fullscreenMode : false,
	                filterMode : false,//是否开启过滤HTML代码
	                wellFormatMode : true,
	                shadowMode : true,
	                loadStyleMode : true,
	                basePath : K.basePath,
	                themesPath : K.basePath + 'themes/',
	                langPath : K.basePath + 'lang/',
	                pluginsPath : K.basePath + 'plugins/',
	                themeType : 'default',
	                langType : 'zh_CN',
	                urlType : '',
	                newlineTag : 'p',
	                resizeType : 2,
	                syncType : 'form',
	                pasteType : 2,
	                dialogAlignType : 'page',
	                useContextmenu : true,//是否启用右键菜单
	                fullscreenShortcut : false,
	                bodyClass : 'ke-content',
	                indentChar : '\t',
	                cssPath : ['./Editor/WpdccEditor/plugins/code/prettify.css','./Css/public.css'],
	                cssData : '',
	                width : '100%',
	                minWidth : 650,
	                minHeight : 100,
	                minChangeSize : 5,
	                items : [
		                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'cut', 'copy', 'paste',
		                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		                'superscript', 'selectall', '|', 'fullscreen', '/',
		                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		                'italic', 'underline', 'strikethrough', 'lineheight', '|', 'image','multiimage','flash',
		                'media', 'insertfile', 'table', 'hr', 
		                'anchor', 'link', 'unlink', '|', 'baidumap', 
		                '/','zdycss','zdyjs','|','nsysethomepage','nsyaddtofavorite','nsybanner','nsymenu','nsylibrary', '|','nsybeautify','nsynewsnavigation','nsytitle','nsysubtitle','nsyupdownnews','nsycontent','nsycomment','nsyabout','nsyauthor','nsysource','nsypublishtime','|','nsyvisits','nsyauditor','nsysetfont','nsysetprint','nsysetclose','nsysetzoom'
	                ],
	                noDisableItems : ['source', 'fullscreen'],                
	                layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>',
	                
				    uploadJson : './Editor/WpdccEditor/aspnet/upload_json.ashx',
				    fileManagerJson : './Editor/WpdccEditor/aspnet/file_manager_json.ashx',
				    allowFileManager : true,
				    afterCreate : function() {
					    var self = this;
					    K.ctrl(document, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
					    K.ctrl(self.edit.doc, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
				    }
				});
				editor.insertHtml(cont);
			});
            break ;
            
        case '2'://更多页
            KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
				    designMode : true,
	                fullscreenMode : false,
	                filterMode : false,//是否开启过滤HTML代码
	                wellFormatMode : true,
	                shadowMode : true,
	                loadStyleMode : true,
	                basePath : K.basePath,
	                themesPath : K.basePath + 'themes/',
	                langPath : K.basePath + 'lang/',
	                pluginsPath : K.basePath + 'plugins/',
	                themeType : 'default',
	                langType : 'zh_CN',
	                urlType : '',
	                newlineTag : 'p',
	                resizeType : 2,
	                syncType : 'form',
	                pasteType : 2,
	                dialogAlignType : 'page',
	                useContextmenu : true,//是否启用右键菜单
	                fullscreenShortcut : false,
	                bodyClass : 'ke-content',
	                indentChar : '\t',
	                cssPath :[ './Editor/WpdccEditor/plugins/code/prettify.css','./Css/public.css'],
	                cssData : '',
	                width : '100%',
	                minWidth : 650,
	                minHeight : 100,
	                minChangeSize : 5,
	                items : [
		                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'cut', 'copy', 'paste',
		                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		                'superscript', 'selectall', '|', 'fullscreen', '/',
		                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		                'italic', 'underline', 'strikethrough', 'lineheight', '|', 'image','multiimage','flash',
		                'media', 'insertfile', 'table', 'hr', 
		                'anchor', 'link', 'unlink', '|', 'baidumap',
		                '/','zdycss','zdyjs','|','nsysethomepage','nsyaddtofavorite','nsybanner','nsymenu','nsylibrary', '|','nsybeautify','nsymorenavigation','nsymore'
	                ],
	                noDisableItems : ['source', 'fullscreen'],
	                
	                layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>',
	                
				    uploadJson : './Editor/WpdccEditor/aspnet/upload_json.ashx',
				    fileManagerJson : './Editor/WpdccEditor/aspnet/file_manager_json.ashx',
				    allowFileManager : true,
				    afterCreate : function() {
					    var self = this;
					    K.ctrl(document, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
					    K.ctrl(self.edit.doc, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
				    }
				});
				editor.insertHtml(cont);
			});
            break ;
        case '3': //频道模板
            KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
				    designMode : true,
	                fullscreenMode : false,
	                filterMode : false,//是否开启过滤HTML代码
	                wellFormatMode : true,
	                shadowMode : true,
	                loadStyleMode : true,
	                basePath : K.basePath,
	                themesPath : K.basePath + 'themes/',
	                langPath : K.basePath + 'lang/',
	                pluginsPath : K.basePath + 'plugins/',
	                themeType : 'default',
	                langType : 'zh_CN',
	                urlType : '',
	                newlineTag : 'p',
	                resizeType : 2,
	                syncType : 'form',
	                pasteType : 2,
	                dialogAlignType : 'page',
	                useContextmenu : true,//是否启用右键菜单
	                fullscreenShortcut : false,
	                bodyClass : 'ke-content',
	                indentChar : '\t',
	                cssPath : ['./Editor/WpdccEditor/plugins/code/prettify.css','./Css/public.css'],
	                cssData : '',
	                width : '100%',
	                minWidth : 650,
	                minHeight : 100,
	                minChangeSize : 5,
	                items : [
		                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'cut', 'copy', 'paste',
		                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		                'superscript', 'selectall', '|', 'fullscreen', '/',
		                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		                'italic', 'underline', 'strikethrough', 'lineheight', '|', 'image','multiimage','flash',
		                'media', 'insertfile','table', 'hr', 
		                'anchor', 'link', 'unlink', '|', 'baidumap',
		                '/','zdycss','zdyjs','|','nsysethomepage','nsyaddtofavorite','nsybanner','nsymenu','nsylibrary', '|','nsychannel'
	                ],
	                noDisableItems : ['source', 'fullscreen'],
	                
	                layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>',
	                
				    uploadJson : './Editor/WpdccEditor/aspnet/upload_json.ashx',
				    fileManagerJson : './Editor/WpdccEditor/aspnet/file_manager_json.ashx',
				    allowFileManager : true,
				    afterCreate : function() {
					    var self = this;
					    K.ctrl(document, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
					    K.ctrl(self.edit.doc, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
				    }
				});
				
				editor.insertHtml(cont);
			});
            break ;
            case '4':  //库模版
              // 自定义插件 #1 sethomepage
			KindEditor.lang({
				sethomepage : '设为首页'
			});
			KindEditor.plugin('sethomepage', function(K) {
				var self = this, name = 'sethomepage';
				self.clickToolbar(name, function() {
					self.insertHtml('<a href="#" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(location.href);" >设为首页</a>');
				});
			});

            // 自定义插件 #2 addfavorite
			KindEditor.lang({
				addfavorite : '加入收藏'
			});
			KindEditor.plugin('addfavorite', function(K) {
				var self = this, name = 'addfavorite';
				self.clickToolbar(name, function() {
					self.insertHtml('<a href="#" onclick="window.external.AddFavorite(location.href,document.title);" >加入收藏</a>');
				});
			});
             KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
				    designMode : true,
	                fullscreenMode : false,
	                filterMode : false,//是否开启过滤HTML代码
	                wellFormatMode : true,
	                shadowMode : true,
	                loadStyleMode : true,
	                basePath : K.basePath,
	                themesPath : K.basePath + 'themes/',
	                langPath : K.basePath + 'lang/',
	                pluginsPath : K.basePath + 'plugins/',
	                themeType : 'default',
	                langType : 'zh_CN',
	                urlType : '',
	                newlineTag : 'p',
	                resizeType : 2,
	                syncType : 'form',
	                pasteType : 2,
	                dialogAlignType : 'page',
	                useContextmenu : true,//是否启用右键菜单
	                fullscreenShortcut : false,
	                bodyClass : 'ke-content',
	                indentChar : '\t',	                
	                cssPath : './Editor/WpdccEditor/plugins/code/prettify.css',
	                cssData : '',
	                width : '100%',
	                minWidth : 650,
	                minHeight : 100,
	                minChangeSize : 5,
	                items : [
		                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'cut', 'copy', 'paste',
		                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		                'superscript', 'clearhtml',"|", 'selectall', '/',
		                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		                'italic', 'underline', 'strikethrough', 'lineheight', '|', 'image','multiimage','flash',
		                'media', 'insertfile', 'table', 'hr', 
		                'anchor', 'link', 'unlink', '|', 'fullscreen','/',
		                'sethomepage','addfavorite'
	                ],
	                noDisableItems : ['source', 'fullscreen'],
	                
	                layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>',
	                
				    uploadJson : './Editor/WpdccEditor/aspnet/upload_json.ashx',
				    fileManagerJson : './Editor/WpdccEditor/aspnet/file_manager_json.ashx',
				    allowFileManager : true,
				    afterCreate : function() {
					    var self = this;
					    K.ctrl(document, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
					    K.ctrl(self.edit.doc, 13, function() {
						    self.sync();
						    K('form[name=example]')[0].submit();
					    });
				    }
				});
				
				editor.insertHtml(cont);
			});
            break
        default:
            
            break ;
    }
			
			
        </script>

        <script type="text/javascript" language="javascript">
    //自定义上传图片控件加载，支持自定义上传图片功能需先引用三个文件，[themes/default/default.css] [kindeditor.js] [lang/zh_CN.js]
			KindEditor.ready(function(K) {
				var editor = K.editor({
				    uploadJson : './Editor/WpdccEditor/aspnet/upload_json.ashx',
				    fileManagerJson : './Editor/WpdccEditor/aspnet/file_manager_json.ashx',
					allowFileManager : true
				});
				K('#upbgimg').click(function() {
					editor.loadPlugin('zdyupbgimg', function() {
						editor.plugin.zdyupbgimgDialog({
							zdyupbgimgUrl : K('#bgpic').val(),
							clickFn : function(url) {
								K('#bgpic').val(url);
								editor.hideDialog();
								change();//加载预览图片
							}
						});
					});
				});
				
			});
			
        </script>

        <script type="text/javascript" language="javascript">
	
	//点击保存
	function checkall(){
	    if(checkAllValidate()){
	            var etxtisempty = editor.isEmpty();
	            if(etxtisempty){
	                alert("模板内容不能为空！");
	                return false ;
	            }else{
	                document.getElementById("content1").value =editor.html();
	                return true ;
	            }
	    }else{
	        return false ;
	    }
	}
	
	//加载预览图片
    function change()
    {
        if(document.Form1.bgpic.value!="")
        {
            var arr=document.Form1.bgpic.value;
            document.getElementById("bgpic1").innerHTML="<img src="+arr+" height='18' width='70' />";
        }
    } 
    //清除模板背景图片
    function clearzdy(clearname)
    {
        switch(clearname){
            case "zdyupbgimg":
            document.getElementById("bgpic1").innerHTML="";
            document.getElementById("bgpic").value="";
            break ;
        }
    }
    
    // 查找替换
    function findreplace(){
        editor.focus();
	    showModalDialog('./Editor/WpdccEditor/plugins/zdyfindreplace/findreplace.htm', window, "dialogWidth:320px;dialogHeight:165px;help:no;scroll:no;status:no");
        editor.focus();
    }
    
    // 模板图片路径修正
    function copycode(){
        
        editor.focus();
	    window.open("./Wpedt/WpdccEditor/plugins/zdyfindreplace/copycode.htm");
        //editor.focus();
    }
        </script>

        </form>
        <!--/action-field-->
    </div>
</body>
</html>
