在新闻发布中添加缩略图功能,栏目编辑中加入是否显示的选项
This commit is contained in:
parent
d6b803a552
commit
31e57813d7
|
@ -128,9 +128,15 @@ class Admin_NewsController extends Zend_Controller_Action
|
||||||
$keyword = $this->_request->getParam('keyword');
|
$keyword = $this->_request->getParam('keyword');
|
||||||
$description = $this->_request->getParam('description');
|
$description = $this->_request->getParam('description');
|
||||||
$displayorder = $this->_request->getParam('displayorder');
|
$displayorder = $this->_request->getParam('displayorder');
|
||||||
|
$display = (int)$this->_request->getParam('display');
|
||||||
$fid = $this->_request->getParam('fid');
|
$fid = $this->_request->getParam('fid');
|
||||||
|
|
||||||
$sql="update news_category set title='$title',keywords='$keyword',description='$description',displayorder='$displayorder',url='$url',fid=$fid where id=$edit";
|
if(empty($displayorder))
|
||||||
|
{
|
||||||
|
$displayorder = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql="update news_category set title='$title',keywords='$keyword',description='$description',displayorder=$displayorder,url='$url',fid=$fid,display=$display where id=$edit";
|
||||||
if($this->db->exec($sql)>0)
|
if($this->db->exec($sql)>0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('提示信息:栏目编辑成功!');
|
$this->messenger->addMessage('提示信息:栏目编辑成功!');
|
||||||
|
@ -350,13 +356,20 @@ class Admin_NewsController extends Zend_Controller_Action
|
||||||
|
|
||||||
$id = $this->_request->getParam('id');
|
$id = $this->_request->getParam('id');
|
||||||
|
|
||||||
$sql = "select * from news_archives arc where arc.id=$id
|
$sql = "select * from news_archives arc where arc.id=$id";
|
||||||
";
|
|
||||||
$rs = $this->db->query($sql);
|
$rs = $this->db->query($sql);
|
||||||
$row = $rs->fetch();
|
$row = $rs->fetch();
|
||||||
|
|
||||||
$this->view->ev = $row;
|
$this->view->ev = $row;
|
||||||
|
|
||||||
|
if(!empty($row['image']))
|
||||||
|
{
|
||||||
|
$sql = "SELECT * FROM attachments WHERE filename='".str_replace("/upload/",'',$row['image'])."'";
|
||||||
|
$rs = $this->db->query($sql);
|
||||||
|
$row = $rs->fetch();
|
||||||
|
$this->view->att = $row;
|
||||||
|
}
|
||||||
|
|
||||||
$sql="select * from news_category order by displayorder desc";
|
$sql="select * from news_category order by displayorder desc";
|
||||||
$re = $this->db->query($sql);
|
$re = $this->db->query($sql);
|
||||||
$types = $re->fetchAll();
|
$types = $re->fetchAll();
|
||||||
|
@ -491,5 +504,145 @@ class Admin_NewsController extends Zend_Controller_Action
|
||||||
|
|
||||||
}//文章删除
|
}//文章删除
|
||||||
|
|
||||||
|
|
||||||
|
function uploadAction(){
|
||||||
|
try{
|
||||||
|
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
if($auth->hasIdentity())
|
||||||
|
{
|
||||||
|
$user = $auth->getIdentity();
|
||||||
|
$userid = $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once('files.php');
|
||||||
|
$files=new files();
|
||||||
|
$msg = $files -> upload('../htdocs/upload/',$_FILES['Filedata'],'image');
|
||||||
|
|
||||||
|
if(empty($msg['error']))
|
||||||
|
{
|
||||||
|
$msg['error']="";
|
||||||
|
$filename = $msg['db_path'];
|
||||||
|
$filesize = $msg['file_size'];
|
||||||
|
$filedesc = $this->_request->getParam('filedesc');
|
||||||
|
$filetype = 'thumb';
|
||||||
|
$realname = $msg['realname'];
|
||||||
|
$fileurl = $msg['file_url'];
|
||||||
|
|
||||||
|
$sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','$filetype','$filedesc','$userid','$filesize','$realname') RETURNING id";
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
$att = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$msg['attid'] = $attid = $att['id'];
|
||||||
|
|
||||||
|
$imgct = files::getImageType('../htdocs/upload/'.$filename);
|
||||||
|
|
||||||
|
if(!isset($imgct['error'])) $preview = '<img src="/upload/'.$filename.'" style="display:block;max-height:300px;" />';
|
||||||
|
else $preview = "";
|
||||||
|
|
||||||
|
$msg['html'] = $preview.$realname.'[已完成]<input type="hidden" name="image" value="/upload/'.$filename.'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$attid.'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
|
||||||
|
$msg['preview'] = "/images/".$attid;
|
||||||
|
echo Zend_Json::encode($msg);
|
||||||
|
exit();
|
||||||
|
}else{
|
||||||
|
$msg['error'] = '附件上传失败:'.$msg['error'];
|
||||||
|
@unlink($filename);
|
||||||
|
echo Zend_Json::encode($msg);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(Exception $e){
|
||||||
|
$msg['error'] = "错误:".$e->getMessage();
|
||||||
|
echo Zend_Json::encode($msg);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getattsAction(){
|
||||||
|
|
||||||
|
$this->_helper->layout()->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
|
$id = $this->_request->getParam('id');
|
||||||
|
|
||||||
|
if($id!='')
|
||||||
|
{
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
if($auth->hasIdentity())
|
||||||
|
{
|
||||||
|
$sql = "select att.realname,att.id,att.filename from attachments att
|
||||||
|
left join archives_att ratt on att.id=ratt.attid
|
||||||
|
where ratt.arcid=$id";
|
||||||
|
$rs = $this->db->query($sql);
|
||||||
|
$atts = $rs->fetchAll();
|
||||||
|
|
||||||
|
include_once('files/files.php');
|
||||||
|
|
||||||
|
foreach($atts as $k=>$v)
|
||||||
|
{
|
||||||
|
$imgct = files::getImageType('../htdocs/upload/'.$v['filename']);
|
||||||
|
|
||||||
|
if(!isset($imgct['error'])) $preview = '<img src="/images/'.$v['id'].'" style="display:block;" />';
|
||||||
|
else $preview = "";
|
||||||
|
|
||||||
|
$atts[$k]['html']= $preview.$v['realname'].'[已完成]<input type="hidden" name="atts[]" value="'.$v['id'].'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$v['id'].'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo Zend_Json::encode($atts);
|
||||||
|
exit();
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function delattAction(){
|
||||||
|
$this->_helper->layout()->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
|
$id = $this->_request->getParam('id');
|
||||||
|
$aid = $this->_getParam('aid');
|
||||||
|
$basepath = '../htdocs/upload/';
|
||||||
|
$info = $this->getFileinfo($id);
|
||||||
|
$filepath = $basepath.$info['filename'];
|
||||||
|
try{
|
||||||
|
if(empty($aid))
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM attachments WHERE id=$id";
|
||||||
|
if($this->db->exec($sql)>0)
|
||||||
|
{
|
||||||
|
@unlink($filepath);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$sql = "delete from archives_att where attid='$id' and arcid='$aid'";
|
||||||
|
if($this->db->exec($sql)>0)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM attachments WHERE id=$id";
|
||||||
|
if($this->db->exec($sql)>0){@unlink($filepath);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception $e){}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileinfo($id){
|
||||||
|
$sql = "select * from attachments where id='$id'";
|
||||||
|
$re= $this->db->query($sql);
|
||||||
|
$row= $re->fetch();
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jsonexit($data){
|
||||||
|
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($data));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label class="required" for="displayorder">显示顺序:</label><br/>
|
<label class="required" for="displayorder">显示顺序:</label><br/>
|
||||||
<input type="text" id="displayorder" class="half" value="" name="displayorder"/>
|
<input type="text" id="displayorder" class="half" value="<?= $this->info['displayorder']?>" name="displayorder"/>
|
||||||
<small>e.g. 高程,气象,地理</small>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -75,6 +74,14 @@
|
||||||
<small>80个汉字以内,不能使用折行</small>
|
<small>80个汉字以内,不能使用折行</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label class="required" for="display">是否显示:</label><br/>
|
||||||
|
<select name="display" id="display">
|
||||||
|
<option value="0" <?php if(empty($this->info['display']) || $this->info['display']==0)echo 'selected="selected"'; ?>>显示</option>
|
||||||
|
<option value="-1" <?php if($this->info['display']== -1 )echo 'selected="selected"'; ?>>隐藏</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
|
||||||
<input type="hidden" name="submit" value="1" />
|
<input type="hidden" name="submit" value="1" />
|
||||||
<input type="hidden" name="edit" value="<?= $this->info['id']?>"? />
|
<input type="hidden" name="edit" value="<?= $this->info['id']?>"? />
|
||||||
<p class="box"><input type="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
|
<p class="box"><input type="submit" class="btn btn-green big" value="提交"/> or <input type="reset" class="btn" value="重置"/></p>
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
$this->headScript()->appendFile('/static/js/kindeditor-min.js');
|
$this->headScript()->appendFile('/static/js/kindeditor-min.js');
|
||||||
$this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
|
$this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
|
||||||
$this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
|
$this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
|
||||||
|
$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');
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/news">新闻中心</a>');
|
$this->breadcrumb('<a href="/admin/news">新闻中心</a>');
|
||||||
|
@ -88,6 +91,14 @@ $(document).ready(function(){
|
||||||
<input type="text" id="source" class="half title" value="中国西部环境与生态科学数据中心" name="source"/>
|
<input type="text" id="source" class="half title" value="中国西部环境与生态科学数据中心" name="source"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
图片:
|
||||||
|
<ul id="datalist">
|
||||||
|
</ul>
|
||||||
|
<span id="fileupBtn"><input id="file_upload" name="Filedata" type="file" /></span>
|
||||||
|
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="description">内容简介(描述)</label><br/>
|
<label for="description">内容简介(描述)</label><br/>
|
||||||
<textarea id="description" class="small half" name="description"></textarea>
|
<textarea id="description" class="small half" name="description"></textarea>
|
||||||
|
@ -221,4 +232,55 @@ function getByteLen(val) {
|
||||||
}
|
}
|
||||||
return len;
|
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;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
|
@ -8,6 +8,9 @@
|
||||||
$this->headScript()->appendFile('/static/js/kindeditor-min.js');
|
$this->headScript()->appendFile('/static/js/kindeditor-min.js');
|
||||||
$this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
|
$this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
|
||||||
$this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
|
$this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
|
||||||
|
$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');
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/news">新闻中心</a>');
|
$this->breadcrumb('<a href="/admin/news">新闻中心</a>');
|
||||||
|
@ -90,6 +93,21 @@ $(document).ready(function(){
|
||||||
<input type="text" id="source" class="half title" value="<?php echo $this->ev['source']; ?>" name="source"/>
|
<input type="text" id="source" class="half title" value="<?php echo $this->ev['source']; ?>" name="source"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
图片:
|
||||||
|
<ul id="datalist">
|
||||||
|
<?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>
|
||||||
|
<span id="fileupBtn"><input id="file_upload" name="Filedata" type="file" /></span>
|
||||||
|
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="description">内容简介(描述)</label><br/>
|
<label for="description">内容简介(描述)</label><br/>
|
||||||
<textarea id="description" class="small half" name="description"><?php echo $this->ev['description']; ?></textarea>
|
<textarea id="description" class="small half" name="description"><?php echo $this->ev['description']; ?></textarea>
|
||||||
|
@ -175,6 +193,13 @@ $(function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
function addon(){
|
function addon(){
|
||||||
|
if($('#datalist').children('li').length > 1)
|
||||||
|
{
|
||||||
|
if(confirm("如果提交的缩略图多余1个只会采用最后一个图片作为缩略图,是否继续?") === false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
editor.sync();
|
editor.sync();
|
||||||
var url = "/admin/news/archivesedit/id/<?php echo $this->ev['id']; ?>";
|
var url = "/admin/news/archivesedit/id/<?php echo $this->ev['id']; ?>";
|
||||||
var data = $("#archivesadd").serialize()+'&keyword='+$('#keyword').val();
|
var data = $("#archivesadd").serialize()+'&keyword='+$('#keyword').val();
|
||||||
|
@ -221,4 +246,56 @@ function getByteLen(val) {
|
||||||
}
|
}
|
||||||
return len;
|
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;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue