模塊功能分析:企業服務,企業填寫招聘申請表,管理審核之后,展示作為招聘通知的功能.
1.文件分布:
modules文件夾和model文件夾,這是我們的文件范圍,在modules下建立qiye這個文件夾,地址:F:/www/phpcms/modules/qiye
2.實例圖:
3.前臺控制器 index.php(class名必須與文件名一致),路徑:F:/www/phpcms/modules/qiye/index.php
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- class index {
- private $db,$ip;
- function __construct() {
- pc_base::load_app_func('global');
- $this->db = pc_base::load_model('qiye_model');
- $this->ip = ip();
- $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
- define("SITEID",$siteid);
- }
- public function init() {
- $siteid = SITEID;
- $page = intval($_GET['page'])<=0 ? 1 : intval($_GET['page']);
- include template('qiye', 'index');
- }
- public function lists() {
- $siteid = SITEID;
- $page = intval($_GET['page']);
- $page = max($page,1);
- $r = $this->db->select(array('siteid'=>$siteid));
- if($r) extract($r);
- include template('qiye', 'list');
- }
- public function show(){
- $siteid = SITEID;
- $comid = intval($_GET['comid']);
- if(!$comid) showmessage(L('information_does_not_exist'),'blank');
- $r = $this->db->get_one(array('comid'=>$comid));
- if(!$r) showmessage(L('info_does_not_exists'),'blank');
- extract($r);
- include template('qiye', 'show');
- }
- public function reg(){
- if(isset($_POST['comname'])){
- //如果用戶提交申請
- if($_POST['comname']==''){
- showmessage(L('qiye_noname'),"?m=qiye&c=index&a=reg&siteid=$siteid");
- }
- $db = pc_base::load_model('qiye_model');//加載模型
- //接收數據并存儲
- $s = array();
- $num = array();
- $num = $_POST['zp_num'];
- $s['siteid'] = SITEID;
- $s['comname'] = safe_replace($_POST['comname']);
- $s['dw_name'] = safe_replace($_POST['dw_name']);
- $s['dw_department'] = safe_replace($_POST['dw_department']);
- $s['dw_area'] = safe_replace($_POST['dw_area']);
- $s['dw_property'] = safe_replace($_POST['dw_property']);
- $s['dw_economic'] = safe_replace($_POST['dw_economic']);
- $s['dw_contact'] = safe_replace($_POST['dw_contact']);
- $s['dw_zipcode'] = safe_replace($_POST['dw_zipcode']);
- $s['dw_address'] = safe_replace($_POST['dw_address']);
- $s['dw_telphone'] = safe_replace($_POST['dw_telphone']);
- $s['dw_fax'] = safe_replace($_POST['dw_fax']);
- $s['dw_email'] = safe_replace($_POST['dw_email']);
- $s['zp_hr'] = safe_replace($_POST['zp_hr']);
- $s['zp_tel'] = safe_replace($_POST['zp_tel']);
- $s['zp_email'] = safe_replace($_POST['zp_email']);
- $s['zp_property'] = safe_replace($_POST['zp_property']);
- $s['zp_industry'] = safe_replace($_POST['zp_industry']);
- $s['zp_post'] = safe_replace($_POST['zp_post']);
- $s['zp_area'] = safe_replace($_POST['zp_area']);
- $s['zp_major'] = safe_replace($_POST['zp_major']);
- $s['zp_salary'] = safe_replace($_POST['zp_salary']);
- $s['zp_num'] = array2string($num);
- $s['attr_commercial'] = safe_replace($_POST['attr_commercial']);
- $s['attr_information'] = safe_replace($_POST['attr_information']);
- $s['url'] = 'index.php?m=qiye&c=index&a=show&id=`id`';
- $s['ip'] = $this->ip;
- $s['inputtime'] = SYS_TIME;
- $s['updatetime'] = SYS_TIME;
- $comid = $db->insert($s,true);
- if($comid){
- showmessage(L('qiye_success'), "?m=qiye&c=index&a=init&siteid=$siteid");
- }
- } else {
- //默認顯示申請頁面
- pc_base::load_sys_class('form', '', 0);
- $SEO = seo(SITEID, '', L('qiye_apply'), '', '');
- include template('qiye', 'register');
- }
- }
- }
- ?>
4.后臺控制器 qiye.php,class名必須與文件名一致,路徑:F:/www/phpcms/modules/qiye/qiye.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- pc_base::load_app_class('admin','admin',0);
- class qiye extends admin {
- private $db;
- function __construct() {
- parent::__construct();
- $this->db = pc_base::load_model('qiye_model');
- $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
- define("SITEID",$siteid);
- }
- //默認動作
- public function init() {
- $where = array('siteid'=>$this->get_siteid(),'status'=>0);
- $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
- $infos = $this->db->listinfo($where,$order = 'listorder DESC',$page, $pages = '9');
- $pages = $this->db->pages;
- extract($infos);
- include $this->admin_tpl('list');
- }
- public function show() {
- $comid = intval($_GET['comid']);
- if(!$comid) showmessage(L('information_does_not_exist'),'blank');
- $infos = $this->db->get_one(array('comid'=>$comid));
- if(!$infos) showmessage(L('info_does_not_exists'),'blank');
- extract($infos);
- include $this->admin_tpl('show');
- }
- public function list_pass() {
- $where = array('siteid'=>$this->get_siteid(),'status'=>1);
- $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
- $infos = $this->db->listinfo($where,$order = 'listorder DESC',$page, $pages = '9');
- $pages = $this->db->pages;
- extract($infos);
- include $this->admin_tpl('list_pass');
- }
- public function pass() {
- if((!isset($_GET['comid']) || emptyempty($_GET['comid'])) && (!isset($_POST['comid']) || emptyempty($_POST['comid']))) {
- showmessage(L('illegal_parameters'), HTTP_REFERER);
- } else {
- $comid = intval($_GET['comid']);
- if($comid < 1) return false;
- $result = $this->db->update(array('status'=>'1'),array('comid'=>$comid));
- $infos = $this->db->get_one(array('comid'=>$comid));
- if($result){
- if(is_email($infos['zp_email'])){
- pc_base::load_sys_func('mail');
- $siteinfo = siteinfo(SITEID);
- $sitename = $siteinfo['site_title'];
- $toemail = $infos['zp_email']; //發送通知郵件
- $subject = '信息審核通知';
- $message .= '尊敬的'.$infos['zp_hr'].':<br /> 您好!';
- $message .= '很高興的通知您,您在'.date('Y年m月d日',$infos['inputtime']).'在我們網站['.$sitename.']發布的信息已經通過審核。';
- $message .= '<br /><br />祝好!<br /><br />-----------------------------------------<br />';
- $message .= '<font color=green>這是一封由系統發送的郵件,請勿回復此郵件!</font>';
- sendmail($toemail,$subject,$message);
- }
- exit('1');
- } else {
- exit('0');
- }
- }
- }
- public function listorder() {
- if(isset($_POST['dosubmit'])) {
- foreach($_POST['listorders'] as $comid => $listorder) {
- $this->db->update(array('listorder'=>$listorder),array('comid'=>$comid));
- }
- showmessage(L('operation_success'),HTTP_REFERER);
- }
- }
- public function delete() {
- if((!isset($_GET['comid']) || emptyempty($_GET['comid'])) && (!isset($_POST['comid']) || emptyempty($_POST['comid']))) {
- showmessage(L('illegal_parameters'), HTTP_REFERER);
- } else {
- if(is_array($_POST['comid'])){ //1.批量刪除
- foreach($_POST['comid'] as $comid) {
- $this->db->delete(array('comid'=>$comid));
- //刪除附件
- if(pc_base::load_config('system','attachment_stat')) {
- $this->attachment_db = pc_base::load_model('attachment_model');
- $this->attachment_db->api_delete($comid);
- }
- }
- showmessage(L('operation_success'),'?m=qiye&c=qiye');
- }else{ //2.單條刪除
- $comid = intval($_GET['comid']);
- if($comid < 1) return false;
- $result = $this->db->delete(array('comid'=>$comid));
- //刪除附件
- if(pc_base::load_config('system','attachment_stat')) {
- $this->attachment_db = pc_base::load_model('attachment_model');
- $this->attachment_db->api_delete($comid);
- }
- if($result){
- exit('1');
- showmessage(L('operation_success'),'?m=qiye&c=qiye');
- }else {
- exit('0');
- showmessage(L("operation_failure"),'?m=qiye&c=qiye');
- } //開源軟件:Vevb.com
- }
- showmessage(L('operation_success'), HTTP_REFERER);
- }
- }
- public function setting() {
- include $this->admin_tpl('setting');
- }
- }
- ?>
5.PC標簽方法:qiye_tag.class.php,為模板數據調用而設置,路徑:F:/www/phpcms/modules/qiye/classes/qiye_tag.class.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- class qiye_tag {
- private $db;
- public function __construct() {
- $this->db = pc_base::load_model('qiye_model');
- }
- public function lists($data) {
- $siteid = $data['siteid'] ? intval($data['siteid']) : get_siteid();
- $sql = array('siteid'=>$siteid);
- $data = $this->db->select($sql, '*', $data['limit'], $data['order']);
- return $data;
- }
- public function pc_tag() {
- $sites = pc_base::load_app_class('sites','admin');
- $sitelist = $sites->pc_tag_list();
- return array(
- 'action'=>array('lists'=>L('lists', '', 'qiye')),
- 'lists'=>array(
- 'catid'=>array('name'=>L('catid', '', 'qiye'),'htmltype'=>'input_select_category','data'=>array('type'=>0),'validator'=>array('min'=>1)),
- 'order'=>array(
- 'name'=>L('sort', '', 'qiye'),
- 'htmltype'=>'select',
- 'data'=>array(
- 'id DESC'=>L('id_desc', '', 'qiye'),
- 'inputtime DESC'=>L('inputtime_desc', '', 'qiye'),
- 'updatetime DESC'=>L('updatetime_desc', '', 'qiye'),
- 'listorder ASC'=>L('listorder_asc', '', 'qiye')
- )
- )
- ),
- );
- }
- }
- ?>
這里設置了一個方法,lists內容列表,在模版的時候調用如下:
{pc:qiye action="lists" catid="$catid"order="listorder desc" num="8"}
6.函數方法庫
functions,因為我這里都用到的是系統的方法,所以里面是空的.
7.模塊安裝文件夾地址 F:/www/phpcms/modules/qiye/install
7.1 語言文件 qiye.lang.php(我這里只做了中文的語言),路徑:F:/www/phpcms/modules/qiye/install/languages/zh-cn/qiye.lang.php:
- <?php
- $LANG['qiye_apply'] = '企業服務申請';
- $LANG['qiye_noname'] = '企業名稱不能為空!';
- $LANG['qiye_success'] = '申請填寫成功!';
- $LANG['comname'] = '單位名稱';
- $LANG['attr_commercial'] = '營業執照';
- $LANG['dw_name'] = '簽約名稱';
- $LANG['dw_department'] = '隸屬部門';
- $LANG['dw_area'] = '單位地區';
- $LANG['dw_property'] = '單位性質';
- $LANG['dw_contact'] = '信息負責人';
- $LANG['dw_telphone'] = '負責人手機號';
- $LANG['zp_email'] = '負責人郵箱';
- $LANG['attr_information'] = '招聘信息';
- $LANG['qiye_download'] = '點擊下載';
- $LANG['qiye_control'] = '操作';
- $LANG['qiye_look'] = '查看';
- $LANG['click_open'] = '點擊下載';
- $LANG['remove_all_selected'] = '刪除選擇';
- $LANG['confirm_del'] = '確定刪除嗎?';
- $LANG['del_confirm'] = '確定刪除嗎?';
- $LANG['delete'] = '刪除';
- $LANG['pass'] = '通過';
- $LANG['pass_true'] = '確定通過嗎?';
- ?>
7.2 前臺模版文件夾,路徑:F:/www/phpcms/modules/qiye/install/templates
name.inc.php 模版安裝文件,安裝模塊時把模版文件復制到默認的default目錄下的控制文件:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- return array (
- 'index.html' => '企業信息首頁',
- 'list.html' => '企業信息列表頁',
- 'show.html' => '企業信息內容頁',
- 'register.html' => '企業信息申請頁',
- );
- ?>
7.3 模塊配置文件 config.inc.php地址 F:/www/phpcms/modules/qiye/install/config.inc.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- $module = 'qiye';
- $modulename = '企業服務';
- $introduce = '企業服務模塊';
- $author = 'novalue';
- $authorsite = 'http://www.liaochuanyou.name/';
- $authoremail = 'novalue@qq.com';
- ?>
7.4模塊菜單擴展文件 extention.inc.php(添加后臺菜單欄功能),路徑:F:/www/phpcms/modules/qiye/install/extention.inc.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- $parentid = $menu_db->insert(array('name'=>'qiye', 'parentid'=>29, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'init', 'data'=>'', 'listorder'=>0, 'display'=>'1'), true);
- $menu_db->insert(array('name'=>'qiye_list', 'parentid'=>$parentid, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'list_pass', 'data'=>'', 'listorder'=>1, 'display'=>'1'));
- $menu_db->insert(array('name'=>'qiye_setting', 'parentid'=>$parentid, 'm'=>'qiye', 'c'=>'qiye', 'a'=>'setting', 'data'=>'', 'listorder'=>2, 'display'=>'1'));
- $language = array('qiye'=>'企業服務','qiye_list'=>'審核通過','qiye_setting'=>'模塊配置');
- ?>
7.5 安裝文件夾下的 model.php,安裝模塊時返回所使用的模型名,路徑:F:/www/phpcms/modules/qiye/install/model.php:
- <?php
- defined('IN_PHPCMS') or exit('Access Denied');
- defined('INSTALL') or exit('Access Denied');
- return array('qiye');
- ?>
7.6 安裝文件夾下的 module.sql,里面只有一句sql語句,路徑:F:/www/phpcms/modules/qiye/install/module.sql:
- INSERT INTO `phpcms_module` VALUES ('qiye', '企業服務', '', '0', '1.0', '企業服務', '', '0', '0', '2012-06-18', '2012-06-18');
7.7 企業服務模塊安裝數據庫文件 qiye.sql,路徑:F:/www/phpcms/modules/qiye/install/qiye.sql:
- DROP TABLE IF EXISTS `phpcms_qiye`;
- CREATE TABLE `phpcms_qiye` (
- `comid` int(11) NOT NULL AUTO_INCREMENT ,
- `siteid` int(11) NULL DEFAULT NULL ,
- `comname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位名稱' ,
- `dw_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '簽約名稱' ,
- `dw_department` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '隸屬部門' ,
- `dw_area` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位地區' ,
- `dw_property` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位性質' ,
- `dw_economic` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '經濟類型' ,
- `dw_contact` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位聯系人' ,
- `dw_zipcode` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位郵編' ,
- `dw_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位地址' ,
- `dw_telphone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位電話' ,
- `dw_fax` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位傳真' ,
- `dw_email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '單位郵箱' ,
- `zp_hr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '負責人' ,
- `zp_tel` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_property` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_industry` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_post` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_area` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_major` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `zp_salary` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘薪水' ,
- `zp_num` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘人數' ,
- `attr_commercial` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '營業執照' ,
- `attr_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '招聘信息' ,
- `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `status` int(11) NULL DEFAULT 0 ,
- `listorder` int(11) NULL DEFAULT 0 ,
- `inputtime` int(11) NULL DEFAULT NULL ,
- `updatetime` int(11) NULL DEFAULT NULL ,
- PRIMARY KEY (`comid`)
- )
- ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=32 ROW_FORMAT=COMPACT;
8.后臺管理模版文件,路徑:F:/www/phpcms/modules/qiye/templates/
9.模塊卸載文件,路徑:F:/www/phpcms/modules/qiye/uninstall
三個文件extention.inc.php、qiye.sql、model.php里面的語句比較簡單,大家可以看其他模塊的寫法,修改里面對應的模塊名即可.
10.模型的model,這里和上面要注意了,不在同一個目錄下面了,在系統的model目錄了($ _ $)),路徑:F:/www/phpcms/model/qiye_model.class.php:
- <?php
- defined('IN_PHPCMS') or exit('No permission resources.');
- pc_base::load_sys_class('model', '', 0);
- class qiye_model extends model {
- function __construct() {
- $this->db_config = pc_base::load_config('database');
- $this->db_setting = 'default';
- $this->table_name = 'qiye';
- parent::__construct();
- }
- }
- ?>
新聞熱點
疑難解答