修改新闻中心后台栏目添加时的流程处理,修改前台新闻控制器
This commit is contained in:
parent
9f59628516
commit
ab243ec84f
|
@ -80,21 +80,49 @@ class Admin_NewsController extends Zend_Controller_Action
|
|||
|
||||
if($add)
|
||||
{
|
||||
$this->_helper->viewRenderer('category-add');
|
||||
$this->view->categories = $this->getAllcategory();
|
||||
if(empty($submit)){
|
||||
$this->view->categories = $this->getAllcategory();
|
||||
$this->_helper->viewRenderer('category-add');
|
||||
}else{
|
||||
$title = $this->_request->getParam('ctitle');
|
||||
$url = $this->_request->getParam('url');
|
||||
$keyword = $this->_request->getParam('keyword');
|
||||
$description = $this->_request->getParam('description');
|
||||
$fid = $this->_request->getParam('fid');
|
||||
|
||||
$sql="insert into news_category (title,keywords,description,url,fid,display) values ('$title','$keyword','$description','$url','$fid',1)";
|
||||
if($this->db->exec($sql) > 0)
|
||||
//$this->_helper->viewRenderer('category-add');
|
||||
}else{
|
||||
$data = array();
|
||||
|
||||
$data['title'] = $this->_request->getParam('ctitle');
|
||||
$data['url'] = $this->_request->getParam('url');
|
||||
$data['keywords'] = $this->_request->getParam('keyword');
|
||||
$data['description'] = $this->_request->getParam('description');
|
||||
$data['fid'] = $this->_request->getParam('fid');
|
||||
$data['display'] = 1;
|
||||
|
||||
$this->view->info = $data;
|
||||
|
||||
if(empty($data['title']))
|
||||
{
|
||||
$this->messenger->addMessage('提示信息:栏目添加成功!');
|
||||
$this->_redirect('/admin/news/catlog');
|
||||
$this->view->error = "请输入标题";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($data['url']))
|
||||
{
|
||||
$this->view->error = "请输入栏目连接,如http://westdc.westgis.ac.cn/news/notice,则只需要输入notice";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!preg_match("/^[a-z]+$/",$data['url']))
|
||||
{
|
||||
$this->view->error = "url格式不正确,仅允许26个小写字母";
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->db->insert("news_category",$data))
|
||||
{
|
||||
$this->view->msg = '提示信息:栏目添加成功!';
|
||||
$this->view->jump_url = '/admin/news/catlog';
|
||||
return true;
|
||||
}else{
|
||||
$this->view->error = "添加失败,请重试";
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,15 +13,13 @@
|
|||
<?= $this->partial('news/left.phtml'); ?>
|
||||
</div>
|
||||
<div id="rightPanel">
|
||||
<?php if ($this->msg or $this->messages) :?>
|
||||
|
||||
<?php if (!empty($this->error)) :?>
|
||||
<div id="message">
|
||||
<?php if ($this->msg) : ?>
|
||||
<p><?php echo $this->msg; ?></p>
|
||||
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
||||
<p><?php echo $msg; ?></p>
|
||||
<?php endforeach;endif; ?>
|
||||
<?php echo $this->error;?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if(empty($this->msg)) {?>
|
||||
<form id="sampleform" method="post" action="#">
|
||||
|
||||
<fieldset>
|
||||
|
@ -29,7 +27,7 @@
|
|||
|
||||
<p>
|
||||
<label class="required" for="ctitle">栏目标题:</label><br/>
|
||||
<input type="text" id="ctitle" class="half" value="" name="ctitle"/>
|
||||
<input type="text" id="ctitle" class="half" value="<?php if(!empty($this->info['title'])) echo $this->info['title'];?>" name="ctitle"/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -38,7 +36,16 @@
|
|||
<option value="0">无</option>
|
||||
<?php if(!empty($this->categories)) :?>
|
||||
<?php foreach($this->categories as $v) : ?>
|
||||
<?php if(empty($this->info['fid'])) {?>
|
||||
<option value="<?= $v['id'];?>"><?= $v['title'];?></option>
|
||||
<?php }else{
|
||||
if($this->info['fid'] == $v['id'])
|
||||
{ ?>
|
||||
<option value="<?= $v['id'];?>" selected="selected"><?= $v['title'];?></option>
|
||||
<?php }else{?>
|
||||
<option value="<?= $v['id'];?>"><?= $v['title'];?></option>
|
||||
<?php }
|
||||
}?>
|
||||
<?php endforeach;?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
@ -46,19 +53,21 @@
|
|||
|
||||
<p>
|
||||
<label class="required" for="ctitle">栏目URL:</label><br/>
|
||||
<input type="text" id="url" class="half" value="" name="url"/>(仅小写英文字母与数字)
|
||||
<input type="text" id="url" class="half" value="<?php if(!empty($this->info['url'])) echo $this->info['url'];?>" name="url"/>(仅小写英文字母与数字)
|
||||
<small>如填写: technology 则前台访问地址为: http://westdc.westgis.ac.cn/news/technology </small>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label class="required" for="keyword">关键字:</label><br/>
|
||||
<input type="text" id="keyword" class="half" value="" name="keyword"/>
|
||||
<input type="text" id="keyword" class="half" value="<?php if(!empty($this->info['keywords'])) echo $this->info['keywords'];?>" name="keyword"/>
|
||||
<small>e.g. 高程,气象,地理</small>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label class="required" for="discript">描述:</label><br/>
|
||||
<textarea id="discript" class="medium half" name="description"></textarea>
|
||||
<textarea id="discript" class="medium half" name="description">
|
||||
<?php if(!empty($this->info['description'])) echo $this->info['description'];?>
|
||||
</textarea>
|
||||
<small>80个汉字以内,不能使用折行</small>
|
||||
</p>
|
||||
|
||||
|
@ -69,4 +78,11 @@
|
|||
</fieldset>
|
||||
|
||||
</form>
|
||||
<?php }else{ ?>
|
||||
<div class="alert alert-success">
|
||||
<a data-dismiss="alert" class="close">×</a>
|
||||
<?php echo $this->msg ?>
|
||||
</div>
|
||||
<script language="javascript">setTimeout("self.location='<?php echo $this->jump_url ?>'",3000);</script>
|
||||
<?php } ?>
|
||||
</div>
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
class NewsController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
private $limit=10;
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
$this->view->config = Zend_Registry::get('config');
|
||||
$this->db=Zend_Registry::get('db');
|
||||
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
||||
$this->view->messages = $this->messenger->getMessages();
|
||||
}
|
||||
|
||||
function indexAction()
|
||||
|
@ -116,11 +116,6 @@ class NewsController extends Zend_Controller_Action
|
|||
$sql .= " LEFT JOIN news_category type ON arc.typeid=type.id";
|
||||
$sql .= " LEFT JOIN users u ON arc.userid=u.id";
|
||||
$sql .= " WHERE arc.is_pub>0 AND arc.ts_published<'now()' AND arc.id=$archive";
|
||||
/*
|
||||
$sql = "SELECT arc.* FROM news_archives arc";
|
||||
$sql .= " LEFT JOIN news_category type ON arc.typeid=type.id";
|
||||
$sql .= " WHERE arc.is_pub>0 AND ts_published<'$time' AND arc.id=$archive";
|
||||
*/
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
|
|
Loading…
Reference in New Issue