您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程
公告模块其中内容直接复制到phpcms文件夹下
凡旋2025-06-09phpcms教程已有人查阅
导读该文件夹下有三个文件夹(没有扩展名的皆为文件夹)所有文件内容,按从上到下顺序announce.sql:index.html:model.php:
该文件夹下有三个文件夹(没有扩展名的皆为文件夹)
announce_model.class.php:
model.php:
model.php:
model--announce_model.class.php
modules--announce--classes --announce_tag.class.php
--install --languages--zh-cn --announce.lang.php
--templates
--announce.sql
--config.inc.php
--extention.inc.php
--index.html
--model.php
--module.sql
--templates --announce_add.tpl.php
--announce_edit.tpl.php
--announce_list.tpl.php
--uninstall --announce.sql
--extention.inc.php
--index.html
--model.php
--admin_announce.php
--index.php
templates--default --announce--show.html
--show2.html
所有文件内容,按从上到下顺序announce_model.class.php:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);
class announce_model extends model {
public $table_name;
public function __construct() {
$this->db_config = pc_base::load_config('database');
$this->db_setting = 'default';
$this->table_name = 'announce';
parent::__construct();
}
}
?>
announce_tag.class.php:
<?php
/**
*
* 公告类
*
*/
defined('IN_PHPCMS') or exit('No permission resources.');
class announce_tag {
private $db;
public function __construct() {
$this->db = pc_base::load_model('announce_model');
}
/**
* 公告列表方法
* @param array $data 传递过来的参数
* @param return array 数据库中取出的数据数组
*/
public function lists($data) {
$where = '1';
$siteid = $data['siteid'] ? intval($data['siteid']) : get_siteid();
if ($siteid) $where .= " AND `siteid`='".$siteid."'";
$where .= ' AND `passed`=\'1\' AND (`endtime` >= \''.date('Y-m-d').'\' or `endtime`=\'0000-00-00\')';
return $this->db->select($where, '*', $data['limit'], 'aid DESC');
}
public function count() {
}
/**
* pc标签初始方法
*/
public function pc_tag() {
//获取站点
$sites = pc_base::load_app_class('sites','admin');
$sitelist = $sites->pc_tag_list();
$result = getcache('special', 'commons');
if(is_array($result)) {
$specials = array(L('please_select', '', 'announce'));
foreach($result as $r) {
if($r['siteid']!=get_siteid()) continue;
$specials[$r['id']] = $r['title'];
}
}
return array(
'action'=>array('lists'=>L('lists', '', 'announce')),
'lists'=>array(
'siteid'=>array('name'=>L('sitename', '', 'announce'),'htmltype'=>'input_select', 'defaultvalue'=>get_siteid(), 'data'=>$sitelist),
),
);
}
}
?>
announce.lang.php:
<?php
/*Language Format:
Add a new file(.lang.php) with your module name at /phpcms/languages/
translation save at the array:$LANG
*/
$LANG['announce']='公告';
$LANG['announce_manage']='公告管理';
$LANG['announce_list']='公告列表';
$LANG['announce_add']='添加公告';
$LANG['announce_title']='公告标题:';
$LANG['title_cannot_empty']='公告标题不能为空';
$LANG['announcements_cannot_be_empty']='公告内容不能为空';
$LANG['announcement_successful_added']='公告添加成功';
$LANG['announced_a']='公告修改成功';
$LANG['announce_passed']='公告批量通过完成!';
$LANG['announce_deleted']='公告批量删除完成!';
$LANG['startdate']='起始日期';
$LANG['enddate']='截止日期';
$LANG['announce_content']='公告内容:';
$LANG['announce_status']='公告状态:';
$LANG['edit_announce']='编辑公告';
$LANG['inputer']='录入者';
$LANG['check_annonuce']='审核公告';
$LANG['preview']='前台预览';
$LANG['index']='前台';
$LANG['cancel_all_selected']='取消批准选定的公告';
$LANG['pass_all_selected']='通过选定的公告';
$LANG['remove_all_selected']='删除选定的公告';
$LANG['overdue_announce']='过期公告';
$LANG['no_pass_announce']='未审核公告';
$LANG['no_exists']='此公告不存在或已删除!';
$LANG['affirm_delete']='您确定要删除吗?';
$LANG['input_announce_title']='请输入公告标题!';
$LANG['title_min_3_chars']='公告标题至少3个汉字以上';
$LANG['right']='输入正确!';
$LANG['server_no_data']='服务器没有返回数据,可能服务器忙,请重试';
$LANG['announce_exist']='该公告已存在';
$LANG['checking']='正进行合法性校验...';
$LANG['select_stardate']='请选择开始时间!';
$LANG['right_all']='正确!';
$LANG['select_downdate']='请选择下线时间!';
$LANG['select_style']='请选择风格!';
$LANG['available_style']='可用风格';
$LANG['lists']='列表';
$LANG['sitename']='站点';
?>
announce.sql:
DROP TABLE IF EXISTS `phpcms_announce`;
CREATE TABLE IF NOT EXISTS `phpcms_announce` (
`aid` smallint(4) unsigned NOT NULL AUTO_INCREMENT,
`siteid` smallint(5) unsigned NOT NULL DEFAULT '0',
`title` char(80) NOT NULL,
`content` text NOT NULL,
`starttime` date NOT NULL DEFAULT '0000-00-00',
`endtime` date NOT NULL DEFAULT '0000-00-00',
`username` varchar(40) NOT NULL,
`addtime` int(10) unsigned NOT NULL DEFAULT '0',
`hits` smallint(5) unsigned NOT NULL DEFAULT '0',
`passed` tinyint(1) unsigned NOT NULL DEFAULT '0',
`style` char(15) NOT NULL ,
`show_template` char(30) NOT NULL,
PRIMARY KEY (`aid`),
KEY `siteid` (`siteid`,`passed`,`endtime`)
) TYPE=MyISAM ;
config.inc.php:
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
$module = 'announce';
$modulename = '公告';
$introduce = '独立模块';
$author = 'phpcms Team';
$authorsite = 'http:// .phpcms.cn';
$authoremail = '';
?>
extention.inc.php:
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
$parentid = $menu_db->insert(array('name'=>'announce', 'parentid'=>29, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=1', 'listorder'=>0, 'display'=>'1'), true);
$menu_db->insert(array('name'=>'announce_add', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'add', 'data'=>'', 'listorder'=>0, 'display'=>'0'));
$menu_db->insert(array('name'=>'edit_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'edit', 'data'=>'s=1', 'listorder'=>0, 'display'=>'0'));
$menu_db->insert(array('name'=>'check_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=2', 'listorder'=>0, 'display'=>'1'));
$menu_db->insert(array('name'=>'overdue', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'init', 'data'=>'s=3', 'listorder'=>0, 'display'=>'1'));
$menu_db->insert(array('name'=>'del_announce', 'parentid'=>$parentid, 'm'=>'announce', 'c'=>'admin_announce', 'a'=>'delete', 'data'=>'', 'listorder'=>0, 'display'=>'0'));
$language = array('announce'=>'公告', 'announce_add'=>'添加公告', 'edit_announce'=>'编辑公告', 'check_announce'=>'审核公告', 'overdue'=>'过期公告', 'del_announce'=>'删除公告');
?>
index.html:model.php:
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
return array('announce');
?>
module.sql:
INSERT INTO `phpcms_module` (`module`, `name`, `url`, `iscore`, `version`, `description`, `setting`, `listorder`, `disabled`, `installdate`, `updatedate`) VALUES ('announce', '公告', 'announce/', 0, '1.0', '公告', '', 0, 0, '2010-9-05', '2010-9-05');
announce_add.tpl.php:
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-10">
<form method="post" action="?m=announce&c=admin_announce&a=add" name="myform" id="myform">
<table class="table_form" width="100%" cellspacing="0">
<tbody>
<tr>
<th width="80"><strong><?php echo L('announce_title')?></strong></th>
<td><input name="announce[title]" id="title" class="input-text" type="text" size="50" ></td>
</tr>
<tr>
<th><strong><?php echo L('startdate')?>:</strong></th>
<td><?php echo form::date('announce[starttime]', date('Y-m-d H:i:s'), 1)?></td>
</tr>
<tr>
<th><strong><?php echo L('enddate')?>:</strong></th>
<td><?php echo form::date('announce[endtime]', $an_info['endtime'], 1);?></td>
</tr>
<tr>
<th><strong><?php echo L('announce_content')?></strong></th>
<td><textarea name="announce[content]" id="content"></textarea><?php echo form::editor('content');?></td>
</tr>
<tr>
<th><strong><?php echo L('available_style')?>:</strong></th>
<td>
<?php echo form::select($template_list, $info['default_style'], 'name="announce[style]" id="style" onchange="load_file_list(this.value)"', L('please_select'))?>
</td>
</tr>
<tr>
<th><strong><?php echo L('template_select')?>:</strong></th>
<td id="show_template"><script type="text/javascript">$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style=<?php echo $info['default_style']?>&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});</script></td>
</tr>
<tr>
<th><strong><?php echo L('announce_status')?></strong></th>
<td><input name="announce[passed]" type="radio" value="1" checked> <?php echo L('pass')?><input name="announce[passed]" type="radio" value="0"> <?php echo L('unpass')?></td>
</tr>
</tbody>
</table>
<input type="submit" name="dosubmit" id="dosubmit" value=" <?php echo L('ok')?> " class="dialog"> <input type="reset" class="dialog" value=" <?php echo L('clear')?> ">
</form>
</div>
</body>
</html>
<script type="text/javascript">
function load_file_list(id) {
if (id=='') return false;
$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});
}
$(document).ready(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
$('#title').formValidator({onshow:"<?php echo L('input_announce_title')?>",onfocus:"<?php echo L('title_min_3_chars')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:1,onerror:"<?php echo L('title_cannot_empty')?>"}).ajaxValidator({type:"get",url:"",data:"m=announce&c=admin_announce&a=public_check_title",datatype:"html",cached:false,async:'true',success : function(data) {
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
error: function(){alert("<?php echo L('server_no_data')?>");},
onerror : "<?php echo L('announce_exist')?>",
onwait : "<?php echo L('checking')?>"
});
$('#starttime').formValidator({onshow:"<?php echo L('select_stardate')?>",onfocus:"<?php echo L('select_stardate')?>",oncorrect:"<?php echo L('right_all')?>"});
$('#endtime').formValidator({onshow:"<?php echo L('select_downdate')?>",onfocus:"<?php echo L('select_downdate')?>",oncorrect:"<?php echo L('right_all')?>"});
$("#content").formValidator({autotip:true,onshow:"",onfocus:"<?php echo L('announcements_cannot_be_empty')?>"}).functionValidator({
fun:function(val,elem){
//获取编辑器中的内容
var oEditor = CKEDITOR.instances.content;
var data = oEditor.getData();
if(data==''){
return "<?php echo L('announcements_cannot_be_empty')?>"
} else {
return true;
}
}
});
$('#style').formValidator({onshow:"<?php echo L('select_style')?>",onfocus:"<?php echo L('select_style')?>",oncorrect:"<?php echo L('right_all')?>"}).inputValidator({min:1,onerror:"<?php echo L('select_style')?>"});
});
</script>
announce_edit.tpl.php:
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-10">
<form method="post" action="?m=announce&c=admin_announce&a=edit&aid=<?php echo $_GET['aid']?>" name="myform" id="myform">
<table class="table_form" width="100%">
<tbody>
<tr>
<th width="80"><?php echo L('announce_title')?></th>
<td><input name="announce[title]" id="title" value="<?php echo htmlspecialchars($an_info['title'])?>" class="input-text" type="text" size="50" ></td>
</tr>
<tr>
<th><?php echo L('startdate')?>:</th>
<td><?php echo form::date('announce[starttime]', $an_info['starttime'], 1)?></td>
</tr>
<tr>
<th><?php echo L('enddate')?>:</th>
<td><?php $an_info['endtime'] = $an_info['endtime']=='0000-00-00' ? '' : $an_info['endtime']; echo form::date('announce[endtime]', $an_info['endtime'], 1);?></td>
</tr>
<tr>
<th><?php echo L('announce_content')?></th>
<td >
<textarea name="announce[content]" id="content"><?php echo $an_info['content']?></textarea>
<?php echo form::editor('content','basic');?>
</td>
</tr>
<tr>
<th><strong><?php echo L('available_style')?>:</strong></th>
<td><?php echo form::select($template_list, $an_info['style'], 'name="announce[style]" id="style" onchange="load_file_list(this.value)"', L('please_select'))?></td>
</tr>
<tr>
<th><?php echo L('template_select')?>:</th>
<tdid="show_template"><?php if ($an_info['style']) echo '<script type="text/javascript">$.getJSON(\'?m=admin&c=category&a=public_tpl_file_list&style='.$an_info['style'].'&id='.$an_info['show_template'].'&module=announce&templates=show&name=announce&pc_hash=\'+pc_hash, function(data){$(\'#show_template\').html(data.show_template);});</script>'?></td>
</tr>
<tr>
<th><?php echo L('announce_status')?></th>
<td><input name="announce[passed]" type="radio" value="1" <?php if($an_info['passed']==1) {?>checked<?php }?>></input> <?php echo L('pass')?><input name="announce[passed]" type="radio" value="0" <?php if($an_info['passed']==0) {?>checked<?php }?>> <?php echo L('unpass')?></td>
</tr>
</tbody>
</table>
<input type="submit" name="dosubmit" id="dosubmit" value=" <?php echo L('ok')?> " class="dialog"> <input type="reset" class="dialog" value=" <?php echo L('clear')?> ">
</form>
</div>
</body>
</html>
<script type="text/javascript">
function load_file_list(id) {
$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=announce&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});
}
$(document).ready(function(){
$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
$('#title').formValidator({onshow:"<?php echo L('input_announce_title')?>",onfocus:"<?php echo L('title_min_3_chars')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:1,onerror:"<?php echo L('title_cannot_empty')?>"}).ajaxValidator({type:"get",url:"",data:"m=announce&c=admin_announce&a=public_check_title&aid=<?php echo $_GET['aid']?>",datatype:"html",cached:false,async:'true',success : function(data) {
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
error: function(){alert("<?php echo L('server_no_data')?>");},
onerror : "<?php echo L('announce_exist')?>",
onwait : "<?php echo L('checking')?>"
}).defaultPassed();
$('#starttime').formValidator({onshow:"<?php echo L('select_stardate')?>",onfocus:"<?php echo L('select_stardate')?>",oncorrect:"<?php echo L('right_all')?>"}).defaultPassed();
$('#endtime').formValidator({onshow:"<?php echo L('select_downdate')?>",onfocus:"<?php echo L('select_downdate')?>",oncorrect:"<?php echo L('right_all')?>"}).defaultPassed();
$("#content").formValidator({autotip:true,onshow:"",onfocus:"<?php echo L('announcements_cannot_be_empty')?>"}).functionValidator({
fun:function(val,elem){
//获取编辑器中的内容
var oEditor = CKEDITOR.instances.content;
var data = oEditor.getData();
if(data==''){
return "<?php echo L('announcements_cannot_be_empty')?>"
} else {
return true;
}
}
}).defaultPassed();
$('#style').formValidator({onshow:"<?php echo L('select_style')?>",onfocus:"<?php echo L('select_style')?>",oncorrect:"<?php echo L('right_all')?>"}).inputValidator({min:1,onerror:"<?php echo L('select_style')?>"}).defaultPassed();
});
</script>
announce_list.tpl.php:
<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-lr-10">
<form name="myform" action="?m=announce&c=admin_announce&a=listorder" method="post">
<div class="table-list">
<table width="100%" cellspacing="0">
<thead>
<tr>
<th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('aid[]');"></th>
<th align="center"><?php echo L('title')?></th>
<th width="68" align="center"><?php echo L('startdate')?></th>
<th width='68' align="center"><?php echo L('enddate')?></th>
<th width='68' align="center"><?php echo L('inputer')?></th>
<th width="50" align="center"><?php echo L('hits')?></th>
<th width="120" align="center"><?php echo L('inputtime')?></th>
<th width="69" align="center"><?php echo L('operations_manage')?></th>
</tr>
</thead>
<tbody>
<?php
if(is_array($data)){
foreach($data as $announce){
?>
<tr>
<td align="center">
<input type="checkbox" name="aid[]" value="<?php echo $announce['aid']?>">
</td>
<td><?php echo $announce['title']?></td>
<td align="center"><?php echo $announce['starttime']?></td>
<td align="center"><?php echo $announce['endtime']?></td>
<td align="center"><?php echo $announce['username']?></td>
<td align="center"><?php echo $announce['hits']?></td>
<td align="center"><?php echo date('Y-m-d H:i:s', $announce['addtime'])?></td>
<td align="center">
<?php if ($_GET['s']==1) {?><a href="?m=announce&c=index&a=show&aid=<?php echo $announce['aid']?>" title="<?php echo L('preview')?>"target="_blank"><?php }?><?php echo L('index')?><?php if ($_GET['s']==1) {?></a><?php }?> |
<a href="javascript:edit('<?php echo $announce['aid']?>', '<?php echo safe_replace($announce['title'])?>');void(0);"><?php echo L('edit')?></a>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div class="btn"><label for="check_box"><?php echo L('selected_all')?>/<?php echo L('cancel')?></label>
<?php if($_GET['s']==1) {?><input name='submit' type='submit' class="button" value='<?php echo L('cancel_all_selected')?>' onClick="document.myform.action='?m=announce&c=admin_announce&a=public_approval&passed=0'"><?php } elseif($_GET['s']==2) {?><input name='submit' type='submit' class="button" value='<?php echo L('pass_all_selected')?>' onClick="document.myform.action='?m=announce&c=admin_announce&a=public_approval&passed=1'"><?php }?>
<input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="document.myform.action='?m=announce&c=admin_announce&a=delete';return confirm('<?php echo L('affirm_delete')?>')"></div></div>
<div id="pages"><?php echo $this->db->pages;?></div>
</form>
</div>
</body>
</html>
<script type="text/javascript">
function edit(id, title) {
window.top.art.dialog({id:'edit'}).close();
window.top.art.dialog({title:'<?php echo L('edit_announce')?>--'+title, id:'edit', iframe:'?m=announce&c=admin_announce&a=edit&aid='+id ,width:'700px',height:'500px'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;
var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}
</script>
announce.sql:
DROP TABLE IF EXISTS `phpcms_announce`;
extention.inc.php:
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('UNINSTALL') or exit('Access Denied');
?>
index.html:model.php:
<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('UNINSTALL') or exit('Access Denied');
return array('announce');
?>
admin_announce.php:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class admin_announce extends admin {
private $db; public $username;
public function __construct() {
parent::__construct();
//if (!module_exists(ROUTE_M)) showmessage(L('module_not_exists'));
$this->username = param::get_cookie('admin_username');
$this->db = pc_base::load_model('announce_model');
}
public function init() {
//公告列表
$sql = '';
$_GET['status'] = $_GET['status'] ? intval($_GET['status']) : 1;
$sql = '`siteid`=\''.$this->get_siteid().'\'';
switch($_GET['s']) {
case '1': $sql .= ' AND `passed`=\'1\' AND (`endtime` >= \''.date('Y-m-d').'\' or `endtime`=\'0000-00-00\')'; break;
case '2': $sql .= ' AND `passed`=\'0\''; break;
case '3': $sql .= ' AND `passed`=\'1\' AND `endtime`!=\'0000-00-00\' AND `endtime` <\''.date('Y-m-d').'\' '; break;
}
$page = max(intval($_GET['page']), 1);
$data = $this->db->listinfo($sql, '`aid` DESC', $page);
$big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=announce&c=admin_announce&a=add\', title:\''.L('announce_add').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('announce_add'));
include $this->admin_tpl('announce_list');
}
/**
* 添加公告
*/
public function add() {
if(isset($_POST['dosubmit'])) {
$_POST['announce'] = $this->check($_POST['announce']);
if($this->db->insert($_POST['announce'])) showmessage(L('announcement_successful_added'), HTTP_REFERER, '', 'add');
} else {
//获取站点模板信息
pc_base::load_app_func('global', 'admin');
$siteid = $this->get_siteid();
$template_list = template_list($siteid, 0);
$site = pc_base::load_app_class('sites','admin');
$info = $site->get_by_id($siteid);
foreach ($template_list as $k=>$v) {
$template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname'];
unset($template_list[$k]);
}
$show_header = $show_validator = $show_scroll = 1;
pc_base::load_sys_class('form', '', 0);
include $this->admin_tpl('announce_add');
}
}
/**
* 修改公告
*/
public function edit() {
$_GET['aid'] = intval($_GET['aid']);
if(!$_GET['aid']) showmessage(L('illegal_operation'));
if(isset($_POST['dosubmit'])) {
$_POST['announce'] = $this->check($_POST['announce'], 'edit');
if($this->db->update($_POST['announce'], array('aid' => $_GET['aid']))) showmessage(L('announced_a'), HTTP_REFERER, '', 'edit');
} else {
$where = array('aid' => $_GET['aid']);
$an_info = $this->db->get_one($where);
pc_base::load_sys_class('form', '', 0);
//获取站点模板信息
pc_base::load_app_func('global', 'admin');
$template_list = template_list($this->siteid, 0);
foreach ($template_list as $k=>$v) {
$template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname'];
unset($template_list[$k]);
}
$show_header = $show_validator = $show_scroll = 1;
include $this->admin_tpl('announce_edit');
}
}
/**
* ajax检测公告标题是否重复
*/
public function public_check_title() {
if (!$_GET['title']) exit(0);
if (CHARSET=='gbk') {
$_GET['title'] = iconv('UTF-8', 'GBK', $_GET['title']);
}
$title = $_GET['title'];
if ($_GET['aid']) {
$r = $this->db->get_one(array('aid' => $_GET['aid']));
if ($r['title'] == $title) {
exit('1');
}
}
$r = $this->db->get_one(array('siteid' => $this->get_siteid(), 'title' => $title), 'aid');
if($r['aid']) {
exit('0');
} else {
exit('1');
}
}
/**
* 批量修改公告状态 使其成为审核、未审核状态
*/
public function public_approval($aid = 0) {
if((!isset($_POST['aid']) || empty($_POST['aid'])) && !$aid) {
showmessage(L('illegal_operation'));
} else {
if(is_array($_POST['aid']) && !$aid) {
array_map(array($this, 'public_approval'), $_POST['aid']);
showmessage(L('announce_passed'), HTTP_REFERER);
} elseif($aid) {
$aid = intval($aid);
$this->db->update(array('passed' => $_GET['passed']), array('aid' => $aid));
return true;
}
}
}
/**
* 批量删除公告
*/
public function delete($aid = 0) {
if((!isset($_POST['aid']) || empty($_POST['aid'])) && !$aid) {
showmessage(L('illegal_operation'));
} else {
if(is_array($_POST['aid']) && !$aid) {
array_map(array($this, 'delete'), $_POST['aid']);
showmessage(L('announce_deleted'), HTTP_REFERER);
} elseif($aid) {
$aid = intval($aid);
$this->db->delete(array('aid' => $aid));
}
}
}
/**
* 验证表单数据
* @paramarray $data 表单数组数据
* @paramstring $a 当表单为添加数据时,自动补上缺失的数据。
* @return array 验证后的数据
*/
private function check($data = array(), $a = 'add') {
if($data['title']=='') showmessage(L('title_cannot_empty'));
if($data['content']=='') showmessage(L('announcements_cannot_be_empty'));
$r = $this->db->get_one(array('title' => $data['title']));
if (strtotime($data['endtime'])<strtotime($data['starttime'])) {
$data['endtime'] = '';
}
if ($a=='add') {
if (is_array($r) && !empty($r)) {
showmessage(L('announce_exist'), HTTP_REFERER);
}
$data['siteid'] = $this->get_siteid();
$data['addtime'] = SYS_TIME;
$data['username'] = $this->username;
if ($data['starttime'] == '') $announce['starttime'] = date('Y-m-d');
} else {
if ($r['aid'] && ($r['aid']!=$_GET['aid'])) {
showmessage(L('announce_exist'), HTTP_REFERER);
}
}
return $data;
}
}
?>
index.php:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class index {
function __construct() {
$this->db = pc_base::load_model('announce_model');
}
public function init() {
}
/**
* 展示公告
*/
public function show() {
if(!isset($_GET['aid'])) {
showmessage(L('illegal_operation'));
}
$_GET['aid'] = intval($_GET['aid']);
$where = '';
$where .= "`aid`='".$_GET['aid']."'";
$where .= " AND `passed`='1' AND (`endtime` >= '".date('Y-m-d')."' or `endtime`='0000-00-00')";
$r = $this->db->get_one($where);
if($r['aid']) {
$this->db->update(array('hits'=>'+=1'), array('aid'=>$r['aid']));
$template = $r['show_template'] ? $r['show_template'] : 'show';
extract($r);
$SEO = seo(get_siteid(), '', $title);
include template('announce', $template, $r['style']);
} else {
showmessage(L('no_exists'));
}
}
}
?>
show.html:
{template 'content', 'header'}
<!--main-->
<div class="main">
<div class="col-left">
<div class="crumbs"><a href="">首页</a><span> > </span><a href="">公告</a></div>
<div id="Article">
<h1>{$title}<br />
<span></span></h1>
<div class="content">
{$content}
</div>
</div>
</div>
<div class="col-auto">
<div class="box pd_b0">
{pc:comment action="bang" cache="3600"}
<ul class="itemli">
{loop $data $r}
<li><a href="{$r[url]}" target="_blank">{str_cut($r[title], 26)}</a></li>
{/loop}
</ul>
{/pc}
</div>
</div>
</div>
{template 'content', 'footer'}
show2.html:代码和show.html同
本文标签:
很赞哦! ()
相关教程
图文教程
phpcms导航栏多个栏目调用代码示例
做网站时用的到的简单的栏目导航()phpcms多个栏目catid in(9,10,11)可以修改id排序order by listorder ASC/DESC{if}...{/if}为判断点击为栏目
phpcms是框架吗,有哪些功能
Phpcms是国内领先的网站内容管理系统,同时也是一个开源的PHP开发框架。该软件采用模块化开发,支持多种分类方式,使用它可方便实现个性化网站的设计、开发与维护。
PHPCMS插件开发步骤教程
虽说PHPCMS开源,但其它开发文档及参考资料实在少得可怜。进行二次开发时,自己还得慢慢去研究它的代码,实在让人郁闷。
PHPCMS建站常用模板调用代码
一、建立虚拟站点1、先更改 目录下的站点名称,再找到apache, 打开“Apache2\conf\extra”下的“httpd-vhosts.conf”文件,添加上自己需要添加的站点。例:
相关源码
-
(PC+WAP)蓝色钢结构机械五金工程建筑基建营销型pbootcms模板下载于PbootCMS开发的钢结构与工程机械专用模板,助力企业构建专业级产品展示平台;模板内置工程案例展示、产品参数对照表等专业模块,预设项目进度、施工方案等建筑行业专属栏目查看源码 -
帝国cms7.2淘宝客导购自媒体博客网站模板源码本模板基于帝国CMS7.2内核深度开发,为淘宝客、商品导购类自媒体及博客网站设计。通过可视化后台管理,可快速搭建具备商品推荐、比价功能的内容平台,帮助用户实现流量高效转化。查看源码 -
(PC+WAP)历史复古古典古籍文章资讯类pbootcms模板下载本模板基于PbootCMS系统开发,为古籍研究、历史文献类网站设计,特别适合展示古典书籍、历史档案等文化内容。采用复古风格设计,同时具备现代化响应式布局,确保在PC和移动设备上都能呈现优雅的阅读体验。查看源码 -
(自适应)蓝色建材亚克力板材装饰材料pbootcms网站模板这款基于PbootCMS开发的响应式模板为建材板材行业优化设计,适用于亚克力板材、建筑装饰材料等企业展示需求。采用HTML5技术实现手机/PC跨终端适配,管理员通过统一后台即可同步查看源码 -
(pc+wap)pbootcms网站模板蓝色小程序网站开发公司基于PbootCMS内核开发的营销型门户模板,为小程序开发公司、电商软件企业打造。采用HTML5自适应架构,实现PC与手机端数据实时同步展示查看源码 -
(自适应)html5宽屏电线电缆材料加工制造类企业网站源码下载本模板基于PbootCMS系统开发,特别适合电线电缆、电缆材料及相关加工制造类企业使用。采用HTML5宽屏设计,能够展示各类电缆产品的技术参数和规格详情,帮助客户全面了解产品特性。查看源码
| 分享笔记 (共有 篇笔记) |