|
|
现有的打开新页面很不方便管理,改为弹出窗更快捷。
已完成 参考模型管理界面
在category.php 编辑栏目那里 加href="javascript:edit(\''.$r['catid'].'\',\''.$r['catname'].'\')"
对应的展示模版页category_manage.tpl.php
增加
- function edit(id, name) {
- window.top.art.dialog({id:'edit'}).close();
-
- window.top.art.dialog({title:'<?php echo L('edit_category');?>《'+name+'》',id:'edit',iframe:'?m=admin&c=category&a=quickedit&catid='+id+'&pc_hash=<?php echo $_SESSION['pc_hash'];?>',width:'580',height:'420'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
-
- }
复制代码
同时 category.php 增加 quickedit方法 和edit类似 但是提交后没有弹出
- public function quickedit() {
-
- if(isset($_POST['dosubmit'])) {
- pc_base::load_sys_func('iconv');
- $catid = 0;
- $catid = intval($_POST['catid']);
- $setting = $_POST['setting'];
-
-
- //上级栏目不能是自身
- if($_POST['info']['parentid']==$catid){
- showmessage(L('operation_failure'),'?m=admin&c=category&a=init&module=admin&menuid=43');
- }
- //栏目生成静态配置
- if($_POST['type'] != 2) {
- if($setting['ishtml']) {
- $setting['category_ruleid'] = $_POST['category_html_ruleid'];
- } else {
- $setting['category_ruleid'] = $_POST['category_php_ruleid'];
- $_POST['info']['url'] = '';
- }
- }
- //内容生成静态配置
- if($setting['content_ishtml']) {
- $setting['show_ruleid'] = $_POST['show_html_ruleid'];
- } else {
- $setting['show_ruleid'] = $_POST['show_php_ruleid'];
- }
- if($setting['repeatchargedays']<1) $setting['repeatchargedays'] = 1;
- $_POST['info']['sethtml'] = $setting['create_to_html_root'];
- $_POST['info']['setting'] = array2string($setting);
- $_POST['info']['module'] = 'content';
- $catname = CHARSET == 'gbk' ? safe_replace($_POST['info']['catname']) : iconv('utf-8','gbk',safe_replace($_POST['info']['catname']));
- $catname = str_replace(array('%'),'',$catname);
- $letters = gbk_to_pinyin($catname);
- $_POST['info']['letter'] = strtolower(implode('', $letters));
-
- //封面和列表统一
- $_POST['setting']['category_template']=$_POST['setting']['list_template'];
-
- //应用权限设置到子栏目
- if($_POST['priv_child']) {
- $arrchildid = $this->db->get_one(array('catid'=>$catid), 'arrchildid');
- if(!empty($arrchildid['arrchildid'])) {
- $arrchildid_arr = explode(',', $arrchildid['arrchildid']);
- if(!empty($arrchildid_arr)) {
- foreach ($arrchildid_arr as $arr_v) {
- $this->update_priv($arr_v, $_POST['priv_groupid'], 0);
- }
- }
- }
-
- }
-
- //应用模板到所有子栏目
- if($_POST['template_child']){
- $this->categorys = $categorys = $this->db->select(array('siteid'=>$this->siteid,'module'=>'content'), '*', '', 'listorder ASC, catid ASC', '', 'catid');
- $idstr = $this->get_arrchildid($catid);
- if(!empty($idstr)){
- $sql = "select catid,setting from phpcms_category where catid in($idstr)";
- $this->db->query($sql);
- $arr = $this->db->fetch_array();
- if(!empty($arr)){
- foreach ($arr as $v){
- $new_setting = array2string(
- array_merge(string2array($v['setting']), array('category_template' => $_POST['setting']['category_template'],'list_template' => $_POST['setting']['list_template'],'show_template' => $_POST['setting']['show_template'])
- )
- );
- $this->db->update(array('setting'=>$new_setting), 'catid='.$v['catid']);
- }
- }
- }
- }
- //print_r($_POST['info']); exit;
-
- $this->db->update($_POST['info'],array('catid'=>$catid,'siteid'=>$this->siteid));
- $this->update_priv($catid, $_POST['priv_roleid']);
- $this->update_priv($catid, $_POST['priv_groupid'],0);
- $this->cache();
- //更新附件状态
- if($_POST['info']['image'] && pc_base::load_config('system','attachment_stat')) {
- $this->attachment_db = pc_base::load_model('attachment_model');
- $this->attachment_db->api_update($_POST['info']['image'],'catid-'.$catid,1);
- }
- showmessage(L('update_success'), '', '', 'edit');
- } else {
- //获取站点模板信息
- pc_base::load_app_func('global');
- $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_validator = $catid = $r = '';
- $catid = intval($_GET['catid']);
- pc_base::load_sys_class('form','',0);
- $r = $this->db->get_one(array('catid'=>$catid));
- if($r) extract($r);
- $setting = string2array($setting);
-
- $this->priv_db = pc_base::load_model('category_priv_model');
- $this->privs = $this->priv_db->select(array('catid'=>$catid));
-
- $type = $_GET['type'];
-
- //print_r($setting);
-
- $type = $_GET['type'];
- /*if($type==0) {
- include $this->admin_tpl('category_edit');
- } elseif ($type==1) {
- include $this->admin_tpl('category_page_edit');
- } else {
- include $this->admin_tpl('category_link');
- }*/
-
- include $this->admin_tpl('category_quickedit');
- }
- }
复制代码
|
|