westdc-zf1/application/admin/views/scripts/news/newsedit.phtml

325 lines
14 KiB
PHTML
Raw Normal View History

<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/static/js/jquery.tagInput.min.js');
2014-05-09 04:23:28 +00:00
$theme = new Theme;
$theme->appendPlus($this,'kindeditor');
$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');
2012-04-12 04:04:23 +00:00
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/news">新闻中心</a>');
$this->breadcrumb('新闻编辑');
?>
<?php
2014-07-23 08:38:32 +00:00
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$uname=$user->username;
$realname = $user->realname;
}
?>
<style>
2014-07-23 08:38:32 +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;}
</style>
<script type="text/javascript">
/* sample tags */
var tags=[
{tag:"冻土",freq:30},{tag:"寒旱所",freq:25}, {tag:"大气",freq:10},{tag:"高原",freq:4},
{tag:"西部",freq:3},{tag:"地理",freq:8}, {tag:"环境",freq:3},{tag:"地质",freq:20}
];
$(document).ready(function(){
KindEditor.ready(function(K) {
editor=K.create('textarea[name="body"]', {
uploadJson : '/plugins/upload_json.php',
fileManagerJson : '/plugins/file_manager_json.php',
allowFileManager : true
});
});
/* tag input field */
$("#keyword").tagInput({
tags:tags,
//jsonUrl:"tags.json",
sortBy:"frequency",
suggestedTags:["冻土","寒旱所","大气","高原","西部","环境"],
tagSeparator:",",
autoFilter:true,
autoStart:false,
//suggestedTagsPlaceHolder:$("#suggested"),
boldify:true
});
});
</script>
2014-07-23 08:38:32 +00:00
<div class="row">
<div class="hidden-sm hidden-xs col-md-2">
<?= $this->partial('news/left.phtml'); ?>
</div>
<div class="col-md-10 col-sm-12">
<h3>发布新闻</h3>
<hr />
<h4>新闻信息</h4>
<form name="form" id="archivesadd" method="post" action="#" class="form-horizontal">
<input type="hidden" id="image" class="half title" value="" name="image"/>
2014-07-23 08:38:32 +00:00
<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="<?php echo $this->ev['title']; ?>" name="title"/>
</div>
</div>
<div class="form-group">
<label for="language" 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">
<label class="radio-inline">
<input type="radio" id="inlineCheckbox1" name="language" value="zh"
<?= isset($this->ev['language']) && $this->ev['language'] =='zh' ? 'checked="checked"':"" ?>
<?= !isset($this->ev['language']) || empty($this->ev['language']) ? 'checked="checked"':"" ?>
> zh
</label>
<label class="radio-inline">
<input type="radio" id="inlineCheckbox1" name="language" value="en"
<?= isset($this->ev['language']) && $this->ev['language'] =='en' ? 'checked="checked"':"" ?>
> en
</label>
2014-07-23 08:38:32 +00:00
</div>
</div>
<div class="form-group">
<label for="source" 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" id="source" class="half title form-control" value="<?php echo $this->ev['source']; ?>" name="source"/>
</div>
</div>
<div class="form-group">
<label for="Filedata" 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">
<ul id="datalist ist-unstyled">
<?php if(!empty($this->ev['image'])&& !empty($this->att)){ ?>
<li id="uploadedItem_<?= $this->att['id']?>" class="uploadifyQueueItem">
<img style="display:block;max-height:300px;" src="<?= $this->ev['image'] ?>"><?= $this->att['realname']?>
<input type="hidden" value="<?= $this->ev['image'] ?>" name="image">
<div class="cancel"><a id="deletebtn_<?= $this->att['id']?>" href="javascript:;" onclick="deleteatt(<?= $this->att['id']?>)">
<img border="0" src="/static/js/uploadify/cancel.png"></a></div></li>
<?php } ?>
</ul>
<div class="form-inline">
<span id="fileupBtn"><input id="file_upload" name="Filedata" type="file" /></span>
<p></p>
<input type="button" class="btn btn-success btn-sm" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
</div>
</div>
</div>
<div class="form-group">
<label for="description" 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">
<textarea rows="4" id="description" class="small half form-control" name="description"><?php echo $this->ev['description']; ?></textarea>
<h5><small id="enablelen"></small></h5>
</div>
</div>
<div class="form-group">
<label for="body" class="required col-md-2 col-sm-2 col-xs-2 control-label">新闻内容:</label>
<div class="col-md-9 col-sm-12 col-xs-12">
<textarea rows="8" id="body" class="large full form-control" name="body"><?php echo $this->ev['body']; ?></textarea>
</div>
</div>
<div class="form-group">
<label for="typeid" class="required col-md-2 col-sm-2 col-xs-2 control-label">新闻栏目:</label>
<div class="col-md-9 col-sm-12 col-xs-12">
<div class="leading">
<div class="checkbox">
<?php
foreach($this->types as $v)
{
2014-07-23 08:38:32 +00:00
$check = "";
foreach($this->typeid as $k=>$cid)
{
if($cid == $v['id'])
{
$check = 'checked="checked"';
$ctid = $k;
}
}
$head = "";
if(!empty($v[$this->deepField])) {$head = str_repeat('-',$v[$this->deepField]);}
echo '<p><label><input type="checkbox" name="typeid[]" '.$check.' value="'.$v['id'].'"/>'.$head.$v['title'].'</label></p>';
$head = "";
}
?>
2014-07-23 08:38:32 +00:00
</div>
</div>
<h5><small>e.g. 研究成果</small></h5>
<p><a class="btn btn-success btn-sm" href="/admin/news/catlog/add/1" target="_blank">+ 添加新栏目</a></p>
</div>
</div>
<div class="form-group">
<label for="description" class="required col-md-2 col-sm-2 col-xs-2 control-label">发布选项:</label>
<div class="col-md-9 col-sm-12 col-xs-12 form-inline">
<select id="pub" class="full form-control" name="pub">
<option value="true" <?php if($this->ev['is_pub']==true) echo 'selected="selected"'; ?>>立即发布</option>
<option value="false" <?php if($this->ev['is_pub']==false) echo 'selected="selected"'; ?>>存草稿</option>
2014-07-23 08:38:32 +00:00
</select>
<label class="checkbox-inline">
<input type="checkbox" id="pubtimeturn" name="pubtimer" value="1" <?php if($this->ev['is_pub']==true && !empty($this->ev['ts_published'])) echo 'checked="checked"'; ?>/>定时发布?
</label>
2014-12-16 02:59:49 +00:00
<input class="form-control" type="text" name="pubtime" id="pubtime" value="<?php echo date("Y-m-d H:i",strtotime($this->ev['ts_published']));?>" />
2014-07-23 08:38:32 +00:00
<span class="text-muted"> e.g. 2011-10-28 9:35 or 2011-10-28 21:35</span>
</div>
2014-07-23 08:38:32 +00:00
</div>
<div class="form-group">
<label for="description" class="required col-md-2 col-sm-2 col-xs-2 control-label">新闻标签:</label>
<div class="col-md-9 col-sm-12 col-xs-12">
<textarea id="keyword" class="small full form-control" name="keyword"><?php echo $this->keywords; ?></textarea>
<h5><small>输入Tag标签多个用半角逗号 " , "隔开每个Tag标签长度小于6个汉字</small></h5>
<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>
2014-07-23 08:38:32 +00:00
</form>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#pubtimeturn").click( function () {
if($(this).is(":checked"))
{
$('#pubtimelable').html('定时发布时间');
2014-07-23 08:38:32 +00:00
$('#pubtime').removeAttr('readonly');
$('#pubtime').removeAttr('disabled');
}
else
{
$('#pubtimelable').html('定时发布?');
$('#pubtime').attr("readonly","readonly");
}
});
});
<?php if(time() < strtotime($this->ev['ts_published']))
{
echo '$("#pubtimeturn").click();'."\r\n";
}?>
function addon(){
if($('#datalist').children('li').length > 1)
{
if(confirm("如果提交的缩略图多余1个只会采用最后一个图片作为缩略图是否继续") === false)
{
return false;
}
}
editor.sync();
var url = "/admin/news/archivesadd/update/<?php echo $this->ev['id']; ?>";
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-12-13 08:36:14 +00:00
var limitNum = 1000;
var pattern = '还可以输入' + (limitNum-getByteLen($('#description').val())) + '个字符';
$('#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+'个字符)';
}else{
var result = limitNum - remain;
2012-12-13 08:36:14 +00:00
pattern = '还可以输入' + result + '个字符';
}
$('#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;
}
$(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;
}
2014-12-16 02:59:49 +00:00
</script>