SET QUOTED_IDENTIFIER ON 
SET NOCOUNT ON


--sitePara 系统参数
if NOT exists(select * from sitePara where pcode='picWidth')
insert into sitePara(ptype,pcode,pvalue,pseq)values('sys','picWidth','1000','1')
if NOT exists(select * from sitePara where pcode='MbNewsTmpid')
insert into sitePara(ptype,pcode,pvalue,pseq,pnote)values('PAGE','MbNewsTmpid','0','2','手机版新闻页模版id')
if NOT exists(select * from sitePara where pcode='IsStatic')
insert into sitePara(ptype,pcode,pvalue,pseq,pnote)values('sys','IsStatic','0','3','是否开启静态化功能')

--更新系统栏目外框模板数据(001-009)
if exists(select * from artDesignTemplate where pkId=1)
update artDesignTemplate set artCode='nsy-s001',artStyle='.nsy-s001 {<br>	border: 1px solid #333;<br>}<br>.nsy-s001 .nsy-hd {<br>	height: 30px;<br>	line-height: 30px;<br>	background: url(../artdesign/artSystem/s001_hd.png) repeat;<br>}<br>.nsy-s001 .module-title {<br>	padding-left: 10px;<br>	font-size: 14px;
<br>	font-weight: normal;<br>}<br>.nsy-s001 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=1 
else if not exists(select * from artDesignTemplate where artCode='nsy-s001')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('测试模板','nsy-s001','.nsy-s001 {<br>	border: 1px solid #333;<br>}<br>.nsy-s001 .nsy-hd {<br>	height: 30px;<br>	line-height: 30px;<br>	background: url(../artdesign/artSystem/s001_hd.png) repeat;<br>}<br>.nsy-s001 .module-title {
<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s001 .model {<br>	margin: 10px;<br>}',0,1)

if exists(select * from artDesignTemplate where pkId=2)
update artDesignTemplate set artCode='nsy-s002',artStyle='.nsy-s002 {<br>	border: 1px solid #DD9990;<br>}<br>.nsy-s002 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-bottom: 1px solid #DD9990;<br>	background: url(../artdesign/artSystem/s002_hd.png) repeat;
<br>}<br>.nsy-s002 .module-title {<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s002 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=2 
else  if not exists(select * from artDesignTemplate where artCode='nsy-s002')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('花色年华','nsy-s002','.nsy-s002 {<br>	border: 1px solid #DD9990;<br>}<br>.nsy-s002 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-bottom: 1px solid #DD9990;<br>	background: url(../artdesign/artSystem/s002_hd.png) repeat;
<br>}<br>.nsy-s002 .module-title {<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s002 .model {<br>	margin: 10px;<br>}',0,1)

if exists(select * from artDesignTemplate where pkId=7)
update artDesignTemplate set artCode='nsy-s003',artStyle='.nsy-s003 {<br>	border: 1px solid #CE8820;<br>}<br>.nsy-s003 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background-color: #F79709;<br>}<br>.nsy-s003 .module-title {<br>	padding-left: 10px;
<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s003 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=7 
else  if not exists(select * from artDesignTemplate where artCode='nsy-s003')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('搜狐','nsy-s003','.nsy-s003 {<br>	border: 1px solid #CE8820;<br>}<br>.nsy-s003 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background-color: #F79709;<br>}<br>.nsy-s003 .module-title {<br>	padding-left: 10px;
<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s003 .model {<br>	margin: 10px;<br>}',0,1)

--010
if exists(select * from artDesignTemplate where pkId=8)
update artDesignTemplate set artCode='nsy-s010',artStyle='.nsy-s010 {	<br>}<br>.nsy-s010 .nsy-hd {	<br>}<br>.nsy-s010 .module-title {<br>}<br>.nsy-s010 .nsy-bd {<br>}',artState=0,isSystem=1 where pkId=8
else  if not exists(select * from artDesignTemplate where artCode='nsy-s010')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('空白模板','nsy-s010','.nsy-s010 {	<br>}<br>.nsy-s010 .nsy-hd {	<br>}<br>.nsy-s010 .module-title {<br>}<br>.nsy-s010 .nsy-bd {<br>}',0,1)

--004
if exists(select * from artDesignTemplate where pkId=9)
update artDesignTemplate set artCode='nsy-s004',artStyle='.nsy-s004 {<br>	border: 1px solid #82B6D7;<br>}<br>.nsy-s004 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-bottom: 1px solid #82B6D7;<br>	background: url(../artdesign/artSystem/s004_hd.png) repeat;
<br>}<br>.nsy-s004 .module-title {<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s004 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=9 
else  if not exists(select * from artDesignTemplate where artCode='nsy-s004')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('海蓝','nsy-s004','.nsy-s004 {<br>	border: 1px solid #82B6D7;<br>}<br>.nsy-s004 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-bottom: 1px solid #82B6D7;<br>	background: url(../artdesign/artSystem/s004_hd.png) repeat;
<br>}<br>.nsy-s004 .module-title {<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s004 .model {<br>	margin: 10px;<br>}',0,1)

--005
if exists(select * from artDesignTemplate where pkId=10)
update artDesignTemplate set artCode='nsy-s005',artStyle='.nsy-s005 {<br>	border: 1px solid #C6CFCC;<br>}<br>.nsy-s005 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background: url(../artdesign/artSystem/s005_hd.png) repeat;<br>}<br>.nsy-s005 .module-title {
<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s005 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=10
else   if not exists(select * from artDesignTemplate where artCode='nsy-s005')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('淡雅','nsy-s005','.nsy-s005 {<br>	border: 1px solid #C6CFCC;<br>}<br>.nsy-s005 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background: url(../artdesign/artSystem/s005_hd.png) repeat;<br>}<br>.nsy-s005 .module-title {
<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s005 .model {<br>	margin: 10px;<br>}',0,1)

--006
if exists(select * from artDesignTemplate where pkId=15)
update artDesignTemplate set artCode='nsy-s006',artStyle='.nsy-s006 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background: url(../artdesign/artSystem/s006_hd.png) right center repeat;<br>}<br>.nsy-s006 .module-title {<br>	display:inline-block;<br>	*display:inline;
<br>	*zoom:1;<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>	background: url(../artdesign/artSystem/s006_hd.png) left center repeat;<br>}<br>.nsy-s006 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s006 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=15
else  if not exists(select * from artDesignTemplate where artCode='nsy-s006')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('银装素裹','nsy-s006','.nsy-s006 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	background: url(../artdesign/artSystem/s006_hd.png) right center repeat;<br>}<br>.nsy-s006 .module-title {<br>	display:inline-block;<br>	*display:inline;
<br>	*zoom:1;<br>	padding-left: 10px;<br>	font-size: 14px;<br>	font-weight: normal;<br>	background: url(../artdesign/artSystem/s006_hd.png) left center repeat;<br>}<br>.nsy-s006 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s006 .model {<br>	margin: 10px;<br>}',0,1)

--007
if exists(select * from artDesignTemplate where pkId=16)
update artDesignTemplate set artCode='nsy-s007',artStyle='.nsy-s007 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-left:1px solid #3EB7A9;<br>	border-right:1px solid #3EB7A9;<br>	background: url(../artdesign/artSystem/s007_hd.png) right center repeat;<br>}<br>.nsy-s007 .module-title {<br>	padding-left: 24px;<br>	font-size: 14px;
<br>	font-weight: normal;<br>	color:#fff;<br>	background:url(../artdesign/artSystem/s007_icon.png) 10px center no-repeat;<br>}<br>.nsy-s007 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s007 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=16
else  if not exists(select * from artDesignTemplate where artCode='nsy-s007')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('绿宝石','nsy-s007','.nsy-s007 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-left:1px solid #3EB7A9;<br>	border-right:1px solid #3EB7A9;<br>	background: url(../artdesign/artSystem/s007_hd.png) right center repeat;<br>}<br>.nsy-s007 .module-title {<br>	padding-left: 24px;<br>	font-size: 14px;
<br>	font-weight: normal;<br>	color:#fff;<br>	background:url(../artdesign/artSystem/s007_icon.png) 10px center no-repeat;<br>}<br>.nsy-s007 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s007 .model {<br>	margin: 10px;<br>}',0,1)

--008
if exists(select * from artDesignTemplate where pkId=18)
update artDesignTemplate set artCode='nsy-s008',artStyle='.nsy-s008 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-left:1px solid #3E72B7;<br>	border-right:1px solid #3E72B7;<br>	background: url(../artdesign/artSystem/s008_hd.png) right center repeat;<br>}<br>.nsy-s008 .module-title {<br>	padding-left: 24px;
<br>	font-size: 14px;<br>	font-weight: normal;<br>	color:#fff;<br>	background:url(../artdesign/artSystem/s008_icon.png) 10px center no-repeat;<br>}<br>.nsy-s008 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s008 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=18
else  if not exists(select * from artDesignTemplate where artCode='nsy-s008')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('碧海深情','nsy-s008','.nsy-s008 .nsy-hd {<br>	height: 26px;<br>	line-height: 26px;<br>	border-left:1px solid #3E72B7;<br>	border-right:1px solid #3E72B7;<br>	background: url(../artdesign/artSystem/s008_hd.png) right center repeat;<br>}<br>.nsy-s008 .module-title {<br>	padding-left: 24px;
<br>	font-size: 14px;<br>	font-weight: normal;<br>	color:#fff;<br>	background:url(../artdesign/artSystem/s008_icon.png) 10px center no-repeat;<br>}<br>.nsy-s008 .nsy-bd{<br>	border: 1px solid #C9C9C9;<br>}<br>.nsy-s008 .model {<br>	margin: 10px;<br>}',0,1)

--009
if exists(select * from artDesignTemplate where pkId=75)
update artDesignTemplate set artCode='nsy-s009',artStyle='.nsy-s009{<br>	border:1px solid #eee;<br>	background:url(../artdesign/artSystem/s009_bg.png) right top no-repeat;<br>}<br>.nsy-s009 .nsy-hd {<br>	height: 34px;<br>	line-height: 34px;<br>	background:url(../artdesign/artSystem/s009_icon.png) 10px center no-repeat;
<br>}<br>.nsy-s009 .module-title {<br>	padding-left:26px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s009 .model {<br>	margin: 10px;<br>}',artState=0,isSystem=1 where pkId=75
else  if not exists(select * from artDesignTemplate where artCode='nsy-s009')
insert into artDesignTemplate(name,artCode,artStyle,artState,isSystem)values('更多内容模板','nsy-s009','.nsy-s009{<br>	border:1px solid #eee;<br>	background:url(../artdesign/artSystem/s009_bg.png) right top no-repeat;<br>}<br>.nsy-s009 .nsy-hd {<br>	height: 34px;<br>	line-height: 34px;<br>	background:url(../artdesign/artSystem/s009_icon.png) 10px center no-repeat;
<br>}<br>.nsy-s009 .module-title {<br>	padding-left:26px;<br>	font-size: 14px;<br>	font-weight: normal;<br>}<br>.nsy-s009 .model {<br>	margin: 10px;<br>}',0,1)

GO
--更新用户自定义栏目外框模板数据
DECLARE @num int
DECLARE @code varchar(20)
SET @num=1
DECLARE My_Cursor CURSOR --定义游标
FOR (SELECT * FROM artDesignTemplate where isSystem='0' or isSystem is NUll) --查出需要的集合放到游标中
OPEN My_Cursor; --打开游标
FETCH NEXT FROM My_Cursor ; --读取第一行数据
WHILE @@FETCH_STATUS = 0
    BEGIN
        set @code='nsy-m'+replicate('0',3-len(@num))+cast(@num as varchar(10))
        UPDATE artDesignTemplate SET  artCode=@code,
		artStyle='.'+@code+'{	
				<br>}<br>/*栏目头*/
				<br>.'+@code+' .nsy-hd {	
				<br>height: 30px;
				<br>line-height: 30px;
				<br>background: url(../subject/centerTopBackImage/'+centerTopBackImageVar+') repeat-x;
				<br>}<br>/*栏目标题*/
				<br>.'+@code+' .module-title {
				<br>padding-left: 10px;
				<br>font-size: 14px;
				<br>font-weight: normal;
				<br>color:#fff;
				<br>}<br>/*栏目内容*/
				<br>.'+@code+' .nsy-bd {border: 1px solid #eee;
				<br>border-top:none;
				<br>overflow:hidden;
				<br>}
				<br>.'+@code+' .model{
				<br>margin: 10px;
				<br>}',artState='0',isSystem='0'
        WHERE CURRENT OF My_Cursor; --更新
		set @num=@num+1;
        FETCH NEXT FROM My_Cursor; --读取下一行数据
    END
CLOSE My_Cursor; --关闭游标
DEALLOCATE My_Cursor; --释放游标
GO

--对应menu布局补足栏目样式表bigclassdesign的数据
insert into bigclassdesign(menuId,cssname,isflag,imageFlag,isnew,imagenew,ishot,imagehot,istop,imagetop,ismore,imagemore,isdept,isclick,istime)
select  pkid,'',0,'./Images/artdesign/itemImage/system_flag.png' ,0,'./images/artdesign/newImage/system_new.gif',0,'./images/artdesign/hotImage/system_hot.gif',0,'./images/artdesign/topImage/system_top.gif',0,'更多&gt;&gt;',0,0,0
from menu where modeid=4 and pkid not in(select menuid from bigclassDesign)

GO

--新增发文统计排行栏目
if not exists(select * from template where pkId=75)
insert into template ([name],[remark],[code],[previewTemplate],[typeId])values('发文统计排行','发文统计排行','releaseTop','releaseTop.htm',5)

GO

--新增文章列表（头条）栏目
if not exists(select * from template where pkId=76)
insert into template ([name],[remark],[code],[previewTemplate],[typeId])values('文章列表(头条)','文章列表(头条)','news1','news1.htm',1)

GO


if not exists(select * from templatePrivilege where templateid=76)
begin
insert into templatePrivilege (templateId,privilegeId)values(76,1)
insert into templatePrivilege (templateId,privilegeId)values(76,3)
insert into templatePrivilege (templateId,privilegeId)values(76,4)
insert into templatePrivilege (templateId,privilegeId)values(76,5)
insert into templatePrivilege (templateId,privilegeId)values(76,6)
insert into templatePrivilege (templateId,privilegeId)values(76,7)
insert into templatePrivilege (templateId,privilegeId)values(76,8)
insert into templatePrivilege (templateId,privilegeId)values(76,9)
end
GO

--新增图文翻动(宽版)栏目
if not exists(select * from template where pkId=77)
insert into template ([name],[remark],[code],[previewTemplate],[typeId])values('图文翻动(宽版)','图文翻动(宽版)','scrollFlashNews1','scrollFlashNews1.htm',2)

GO

if not exists(select * from templatePrivilege where templateid=77)
begin
insert into templatePrivilege (templateId,privilegeId)values(77,1)
insert into templatePrivilege (templateId,privilegeId)values(77,3)
insert into templatePrivilege (templateId,privilegeId)values(77,4)
insert into templatePrivilege (templateId,privilegeId)values(77,5)
insert into templatePrivilege (templateId,privilegeId)values(77,6)
insert into templatePrivilege (templateId,privilegeId)values(77,7)
insert into templatePrivilege (templateId,privilegeId)values(77,8)
insert into templatePrivilege (templateId,privilegeId)values(77,9)
end
GO


--sitePara 系统参数
update sitepara set pseq = 5,pnote='是否开启频道静态页' where pcode='IsStatic';
if NOT exists(select * from sitePara where pcode='MbIndex')
insert into sitePara(ptype,pcode,pvalue,pseq,pnote)values('PAGE','MbIndex','0','3','手机版首页频道id');
if NOT exists(select * from sitePara where pcode='IsAllowCtb')
insert into sitePara(ptype,pcode,pvalue,pseq,pnote)values('sys','IsAllowCtb','1','10','是否开启主站投稿');

GO
update template set [name]='网站搜索(无选择条件)' where pkid='17'
GO
update template set [name]='会员登录(横向)' where pkid='18'
GO
update template set [name]='网站搜索(无选择条件)' where pkid='17'
GO
update template set [name]='新闻点击排行' where pkid='7'
GO

--修改templateType表中数据
--1.新闻类2.图文类3.链接类4.互动类5.工具类
update templatetype set [name]='news',type='新闻类' where pkid='1'
GO
UPDATE templateType SET [name] ='picVedio',type ='图文类' where pkId='2'
GO
UPDATE templateType SET [name] ='interact',type ='互动类'  where pkId='4'
GO
UPDATE templateType SET [name] ='tool' ,type = '功能类' where pkId='5' 
GO
update template set typeId='1' where pkid in (1,5,7,10,13,23,28,36)
GO
update template set typeId='2' where pkid in (6,12,24,25,26,27,43,71)
GO
update template set typeId='3' where pkid='37'
GO
update template set typeId='4' where pkid in (14,22,32,33,45,46,47,48,60,63,65)
GO
update template set typeId='5' where pkid in (9,11,15,16,17,18,19,30,58,65,66,67,69,72,73,74)
GO
update template set typeId='6' where pkid in (49,50,51,52,53,54,55,56,57,62,64,68,70)
GO

--由于V6.1修改了抄送机制，需补足抄送新闻的完整信息(原来只有抄送标志)
create table Table_2
(
	id int identity(1,1) not null,
	pkid int,
	title varchar(500),
	[content] text,
	imageName varchar(100),
	width int,
	height int
)
go
insert into Table_2  (pkid,title,[content],imageName,width,height) select pkid,intacttitle,[content],imageName,width,height from news where pkid in (select duplicatedpkid from news where isDuplicated='1')
go

update news set intacttitle =
(
	select Table_2.title from Table_2 where Table_2.pkid = news.duplicatedpkid 
) 
where isDuplicated='1'
GO
update news set [content] =
(
	select Table_2.[content] from Table_2 where Table_2.pkid = news.duplicatedpkid 
) 
where isDuplicated='1'
GO
update news set imageName =
(
	select Table_2.imageName from Table_2 where Table_2.pkid = news.duplicatedpkid 
) 
where isDuplicated='1'
GO
update news set width =
(
	select Table_2.width from Table_2 where Table_2.pkid = news.duplicatedpkid 
) 
where isDuplicated='1'
GO
update news set height =
(
	select Table_2.height from Table_2 where Table_2.pkid = news.duplicatedpkid 
) 
where isDuplicated='1'

go
select unitname from unitinfo
go
DROP TABLE Table_2
go



SET NOCOUNT OFF
SET QUOTED_IDENTIFIER OFF 