2011-09-23 07:34:40 +00:00
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/static/js/jquery.tagInput.min.js');
2014-05-09 06:22:07 +00:00
$theme = new Theme;
$theme->appendPlus($this,'kindeditor');
2012-08-31 07:38:09 +00:00
$this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css');
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
2014-09-02 05:20:24 +00:00
$this->headLink()->appendStylesheet('/css/admin.css');
2012-04-12 04:04:23 +00:00
$this->breadcrumb('< a href = "/" > 首页< / a > ');
2012-03-27 07:02:36 +00:00
$this->breadcrumb('< a href = "/admin" > 后台首页< / a > ');
$this->breadcrumb('< a href = "/admin/news" > 新闻中心< / a > ');
$this->breadcrumb('新闻添加');
2011-10-09 10:15:50 +00:00
?>
2012-03-27 07:02:36 +00:00
< style >
2014-09-02 05:20:24 +00:00
.tagInputDiv {display:none;background-color:white;position:absolute;overflow:auto;border:1px solid lightgray;margin-top:-1px;}
.tagInputLine {color:black;font-weight:normal;padding:4px;}
.tagInputSel {background-color:gray;color:white;}
.tagInputLineTag {min-width:150px;display:inline-block;}
.tagInputLineFreq {min-width:50px;text-align:right;display:inline-block;float:right;}
.tagInputSuggestedTags {font-size: 11px;}
.tagInputSuggestedTags .label{display:block;background:0 none;color:#666;padding:0;margin-top:4px;}
.tagInputSuggestedTagList .tag{ padding:4px 6px;cursor:pointer;display:inline-block;margin:2px 1px;border:1px solid #bbb;}
.tagInputSuggestedTagList span.tag:hover{background-color:#bbb;color:#fff;}
.tagInputSuggestedTagList .tagUsed{border:1px solid #999;background-color:#999;color:#fff;}
.width3{width:40%;}
.first{float:left;}
2012-03-27 07:02:36 +00:00
< / style >
2011-09-23 07:34:40 +00:00
< script type = "text/javascript" >
/* sample tags */
var tags=[
2011-10-09 10:15:50 +00:00
{tag:"冻土",freq:30},{tag:"寒旱所",freq:25}, {tag:"大气",freq:10},{tag:"高原",freq:4},
{tag:"西部",freq:3},{tag:"地理",freq:8}, {tag:"环境",freq:3},{tag:"地质",freq:20}
2011-09-23 07:34:40 +00:00
];
2012-03-27 07:02:36 +00:00
$(document).ready(function(){
2011-09-23 07:34:40 +00:00
KindEditor.ready(function(K) {
2011-10-09 10:15:50 +00:00
editor=K.create('textarea[name="body"]', {
2014-09-18 05:19:23 +00:00
width : '800px',
height : '450px',
2011-09-23 07:34:40 +00:00
uploadJson : '/plugins/upload_json.php',
fileManagerJson : '/plugins/file_manager_json.php',
allowFileManager : true
});
});
2011-10-09 10:15:50 +00:00
2011-09-23 07:34:40 +00:00
/* tag input field */
2011-10-09 10:15:50 +00:00
$("#keyword").tagInput({
2011-09-23 07:34:40 +00:00
tags:tags,
//jsonUrl:"tags.json",
sortBy:"frequency",
suggestedTags:["冻土", "寒旱所", "大气", "高原", "西部", "环境"],
tagSeparator:",",
autoFilter:true,
autoStart:false,
//suggestedTagsPlaceHolder:$("#suggested"),
boldify:true
});
});
< / script >
2014-09-02 05:20:24 +00:00
< div class = "row" >
< div class = "hidden-sm hidden-xs col-md-2" >
<? = $this -> partial ( 'news/left.phtml' ); ?>
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< div class = "col-md-10 col-sm-12" >
< h3 > 新闻发布< / h3 >
< hr / >
< form name = "form" id = "archivesadd" method = "post" action = "#" class = "form-horizontal" >
< input type = "hidden" id = "image" class = "half title" value = "" name = "image" / >
< div class = "form-group" >
< label for = "title" class = "required col-md-2 col-sm-2 col-xs-2 control-label" > 标题:< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< input type = "text" class = "form-control" id = "producttitle" class = "half title" value = " <? = isset ( $this -> data [ 'title' ]) ? $this -> data [ 'title' ] : "" ?> " name = "title" />
< / div >
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "source" > 语言< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< label class = "radio-inline" >
< input type = "radio" id = "inlineCheckbox1" name = "language" value = "zh"
<? = isset ( $this -> data [ 'language' ]) && $this -> data [ 'language' ] == 'zh' ? 'checked="checked"' : "" ?>
<? = ! isset ( $this -> data [ 'language' ]) || empty ( $this -> data [ 'language' ]) ? 'checked="checked"' : "" ?>
> zh
< / label >
< label class = "radio-inline" >
< input type = "radio" id = "inlineCheckbox1" name = "language" value = "en" <? = isset ( $this -> data [ 'language' ]) && $this -> data [ 'language' ] == 'en' ? 'checked="checked"' : "" ?> > en
< / label >
2014-05-08 13:25:27 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "source" > 来源< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< input type = "text" id = "source" class = "form-control" name = "source" value = "寒区旱区科学数据中心" / >
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "image" > 图片< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< input id = "file_upload" name = "Filedata" type = "file" / >
< p > < / p >
< input type = "button" class = "btn btn-success btn-sm" onclick = "$('#file_upload').uploadifyUpload();" value = "上传" / >
< div id = "datalist" > < / div >
2012-03-27 07:02:36 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "description" > 内容简介(描述)< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< textarea id = "description" class = "form-control" name = "description" rows = "4" > < / textarea >
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "body" > 新闻内容< / label >
< div class = "col-sm-10" >
< textarea id = "body" class = "" name = "body" > < / textarea >
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "type" > 新闻栏目< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< div class = "checkbox" >
2013-05-15 07:49:18 +00:00
<?php
foreach($this->types as $v)
{
$head = "";
2014-05-09 06:22:07 +00:00
if(!empty($v[$this->deepField]))
{
$head = str_repeat('-',$v[$this->deepField]);
}
2014-09-02 05:20:24 +00:00
echo '< p > < label > < input type = "checkbox" name = "typeid[]" value = "'.$v['id'].'" / > '.$head.$v['title'].'< / label > < / p > ';
2013-05-15 07:49:18 +00:00
$head = "";
}
?>
< / div >
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "pub" > 发布选项< / label >
< div class = "col-md-6 col-sm-9 col-xs-9 form-inline" >
< select id = "pub" class = "full form-control" name = "pub" >
< option value = "true" > 立即发布< / option >
< option value = "false" > 存草稿< / option >
< / select >
< label class = "checkbox-inline" >
2013-05-15 07:49:18 +00:00
< input type = "checkbox" id = "pubtimeturn" name = "pubtimer" value = "1" / > 定时发布?
2014-09-02 05:20:24 +00:00
< / label >
< input class = "form-control" type = "text" name = "pubtime" id = "pubtime" value = " <?php echo date ( "Y-m-d H:i" , time () + 3600 * 24 ); ?> " readonly = "readonly" />
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" for = "pub" > 新闻标签< / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< textarea id = "keyword" class = "form-control" name = "keyword" > < / textarea >
2013-05-15 07:49:18 +00:00
< / div >
2014-09-02 05:20:24 +00:00
< / div >
< div class = "form-group" >
< label class = "required col-md-2 col-sm-2 col-xs-2 control-label" > < / label >
< div class = "col-md-6 col-sm-9 col-xs-9" >
< div id = "return" > < / div >
< input type = "button" onclick = "addon();" id = "submit" class = "btn btn-primary" value = "提交" / >
< input type = "reset" class = "btn btn-danger" value = "重置" / >
< / div >
< / div >
2013-05-15 07:49:18 +00:00
< / form >
< / div >
2012-03-27 07:02:36 +00:00
< / div >
2011-10-09 10:15:50 +00:00
< script type = "text/javascript" >
$(function(){
$('#nav_news').addClass("current");
$("#pubtimeturn").click( function () {
if($(this).is(":checked"))
{
$('#pubtimelable').html('定时发布时间');
2011-10-10 06:30:51 +00:00
$('#pubtime').removeAttr('readonly');
2011-10-09 10:15:50 +00:00
}
else
{
$('#pubtimelable').html('定时发布?');
2011-10-10 06:30:51 +00:00
$('#pubtime').attr("readonly","readonly");
2011-10-09 10:15:50 +00:00
}
});
});
function addon(){
editor.sync();
var url = "/admin/news/archivesadd";
var data = $("#archivesadd").serialize()+'&keyword='+$('#keyword').val();
$.ajax({
type: "POST",
url: url,
data: data,
success: function(html){
$('#return').html(html);
},
beforeSend:function(){
$('#submit').val('正在提交...');
$('#submit').attr("disabled","disabled");
},
complete:function(){
$('#submit').val('提交');
$('#submit').removeAttr('disabled');
}
});
}
2012-03-27 07:02:36 +00:00
$('#description').val('');
2012-12-13 08:36:14 +00:00
var limitNum = 1000;
var pattern = '还可以输入' + limitNum + '个字符';
2012-03-27 07:02:36 +00:00
$('#enablelen').html(pattern);
$('#description').keyup(
function() {
var remain = getByteLen($(this).val());
if (remain > limitNum) {
var result = remain -limitNum;
2012-12-13 08:36:14 +00:00
pattern = '字数超过限制,请适当删除部分内容(超出了'+result+'个字符)';
2012-03-27 07:02:36 +00:00
}else{
var result = limitNum - remain;
2012-12-13 08:36:14 +00:00
pattern = '还可以输入' + result + '个字符';
2012-03-27 07:02:36 +00:00
}
$('#enablelen').html(pattern);
}
);
function getByteLen(val) {
var len = 0;
for (var i = 0; i < val.length ; i + + ) {
if (val[i].match(/[^\x00-\xff]/ig) != null) //全角
len += 2;
else
len += 1;
}
return len;
2012-08-31 07:38:09 +00:00
}
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/static/js/uploadify/uploadify.swf',
'scriptData': {'PHPSESSID' : '<?php echo session_id (); ?> '},
'script' : '/admin/news/upload',
'cancelImg' : '/static/js/uploadify/cancel.png',
'folder' : '/uploads',
'sizeLimit' : 2097152,
'queueSizeLimit' : 1,
'multi' : true,
'auto' : false,
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
var html;
if(obj.error=='')
{html = obj.html;}
else{html = obj.error;}
$('< li / > ', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
$('#deletebtn_'+obj.attid).bind('click', function() {
deleteatt(obj.attid);
});
},
'onError' : function (event,ID,fileObj,errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
});
function deleteatt(attid){
$.ajax({
type:"POST",
url:'/admin/news/delatt/',
data:'id='+attid,
success:function(html){
$('#uploadedItem_'+attid).remove();
},
beforeSend:function(){
$('#deletebtn_'+attid).html('< img src = "/images/11887177066.gif" / > ');
}
});
}
function uploadError(msg,id){
var html = msg+'< div class = "cancel" > < a href = "javascript:;" id = "deletebtn_'+id+'" > < img border = "0" src = "/static/js/uploadify/cancel.png" / > < / a > < / div > ';
return html;
}
2011-09-23 07:34:40 +00:00
< / script >