Ejemplo n.º 1
0
 public function edit($single_id = null)
 {
     $model = D('Single');
     if (IS_POST) {
         if ($model->create()) {
             $result = $model->save();
             if ($result > 0) {
                 $this->success(L('_UPDATE_SUCCESS_'), U('Single/index'));
             } else {
                 $this->error(L('_UNKNOWN_ERROR_'));
             }
         } else {
             $this->error($model->geterror());
         }
     } else {
         if (empty($single_id)) {
             $this->error(L('_ID_NOT_NULL_'));
         }
         $data = M('Single')->where("single_id={$single_id}")->find();
         //$field=Api('Model/SingleModel');
         $field = get_model_attr('single');
         $this->meta_title = '编辑单页';
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 2
0
 /**
  * 编辑配置
  * @author 枫叶 <*****@*****.**>
  */
 public function edit($config_id = 0)
 {
     if (IS_POST) {
         $Config = D('Config');
         $data = $Config->create();
         if ($data) {
             if (0 < $Config->save()) {
                 F('DB_CONFIG_DATA', null);
                 //$this->success(L('_UPDATE_SUCCESS_'), U('index', array('group' => I('group'))));
                 $this->success(L('_UPDATE_SUCCESS_'), __PAGEURL__);
             } else {
                 $this->error('没有更改');
             }
         } else {
             $this->error($Config->getError());
         }
     } else {
         $info = array();
         /* 获取数据 */
         $info = M('Config')->field(true)->find($config_id);
         if (false === $info) {
             $this->error('获取配置信息错误');
         }
         $field = get_model_attr('config');
         $this->assign('data', $info);
         $this->assign('fieldarr', $field);
         $this->meta_title = '编辑配置';
         $this->display();
     }
 }
Ejemplo n.º 3
0
 public function edit($link_id = null)
 {
     $model = D('Link');
     if (IS_POST) {
         F('sys_link_tree', null);
         if ($model->create()) {
             $result = $model->save();
             if ($result !== false) {
                 $this->success(L('_UPDATE_SUCCESS_'), U('Link/index'));
             } else {
                 $this->error(L('_UNKNOWN_ERROR_'));
             }
         } else {
             $this->error($model->geterror());
         }
     } else {
         if (empty($link_id)) {
             $this->error(L('_ID_NOT_NULL_'));
         }
         $data = D('Link')->where("link_id={$link_id}")->find();
         $field = get_model_attr('link');
         $this->meta_title = '编辑友情链接';
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 4
0
 public function add($pid = 0)
 {
     $Category = D('Category');
     if (IS_POST) {
         //提交表单
         F('sys_category_' . I('category_type') . '_tree', null);
         if (false !== $Category->update()) {
             $this->success(L('_ADD_SUCCESS_'), U('index', array('category_type' => I('category_type'))));
         } else {
             $error = $Category->getError();
             $this->error(empty($error) ? L('_UNKNOWN_ERROR_') : $error);
         }
     } else {
         //$field=Api('Model/categoryModel');
         $field = get_model_attr('category');
         $data['pid'] = $pid;
         $data['category_type'] = I('category_type');
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->meta_title = '新增分类';
         $this->display('edit');
     }
 }
Ejemplo n.º 5
0
 public function add($pid = 0)
 {
     $GoodsType = D('GoodsType');
     if (IS_POST) {
         //提交表单
         F('sys_GoodsType_tree', null);
         if (false !== $GoodsType->create()) {
             $GoodsType->add();
             $this->success(L('_ADD_SUCCESS_'), U('index'));
         } else {
             $error = $GoodsType->getError();
             $this->error(empty($error) ? L('_UNKNOWN_ERROR_') : $error);
         }
     } else {
         //$field=Api('Model/GoodsTypeModel');
         $field = get_model_attr('goodstype');
         $this->assign('fieldarr', $field);
         $data = array('pid' => $pid);
         $this->assign('data', $data);
         $this->meta_title = '新增产品类型';
         $this->display('edit');
     }
 }
 function edit()
 {
     $model = D('MemberGroup');
     if (IS_POST) {
         if ($model->create()) {
             $result = $model->save();
             if (0 < $result) {
                 F('sys_membergroup_list', null);
                 $this->success(L('_UPDATE_SUCCESS_'), U('index'));
             } else {
                 $this->error(L('_UPDATE_FAIL_'));
             }
         } else {
             $this->error($model->getError());
         }
     } else {
         $data = $model->find(I('get.member_group_id'));
         $field = get_model_attr('memberGroup');
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->assign('meta_title', '编辑用户组');
         $this->display();
     }
 }
Ejemplo n.º 7
0
 /**
  * 编辑配置
  * @author yangweijie <*****@*****.**>
  */
 public function edit($id = 0)
 {
     if (IS_POST) {
         F('sys_menu_tree', null);
         $Menu = D('Menu');
         $data = $Menu->create();
         if ($data) {
             if ($Menu->save() !== false) {
                 $this->success(L('_UPDATE_SUCCESS_'));
             } else {
                 $this->error(L('_UPDATE_FAIL_'));
             }
         } else {
             $this->error($Menu->getError());
         }
     } else {
         $info = array();
         /* 获取数据 */
         $data = M('Menu')->find($id);
         $field = get_model_attr('menu');
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->meta_title = '编辑菜单';
         $this->display();
     }
 }
Ejemplo n.º 8
0
/**
 * 返回一个动态自动验证的数组
 */
function get_model_rules($model_id = '')
{
    $relus = get_model_attr($model_id);
    $rearr = array();
    foreach ($relus as $key => $val) {
        //查找出必填项
        if ($val['is_require'] == '1') {
            $rearr[] = array($val['name'], 'require', "{$val['title']}不能为空!");
        }
    }
    return $rearr;
}
Ejemplo n.º 9
0
 public function edit($model_id = null)
 {
     $model = D('Model');
     if (IS_POST) {
         if ($model->create()) {
             $result = $model->save();
             if (0 < $result) {
                 $this->addnewtable(I('post.table'));
                 $this->success(L('_UPDATE_SUCCESS_'), __PAGEURL__);
             } else {
                 $this->error(L('_UNKNOWN_ERROR_'));
             }
         } else {
             $this->error($model->geterror());
         }
     } else {
         if (empty($model_id)) {
             $this->error(L('_ID_NOT_NULL_'));
         }
         $data = D('Model')->where("model_id={$model_id}")->find();
         $field = get_model_attr('model');
         $this->meta_title = '编辑模型';
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 10
0
 function edit($member_id = null)
 {
     if ($member_id === null) {
         $member_id = I('post.member_id');
     }
     if (empty($member_id)) {
         $this->error(L('_ID_NOT_NULL_'));
     }
     if (IS_POST) {
         //先保存主用户表中的数据
         $model = D('Member');
         if ($model->create()) {
             $result = $model->save();
             if (0 < $result) {
                 $this->success(L('_UPDATE_SUCCESS_'));
             } else {
                 $this->error(L('_UPDATE_FAIL_'));
             }
         } else {
             $this->error($this->showRegError($model->geterror()));
         }
     } else {
         $field = get_model_attr('member');
         $data = M('Member')->find($member_id);
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->meta_title = '编辑用户信息';
         $this->display();
     }
 }
Ejemplo n.º 11
0
function get_list_field($data, $grid, $model)
{
    // 获取当前字段数据
    foreach ($grid['field'] as $field) {
        $array = explode('|', $field);
        //把字段值和函数分开
        $temp = $data[$array[0]];
        // 函数支持
        if (isset($array[1])) {
            if ($array[1] == '[extra]') {
                //使用模型的extra字段解析成数组
                $val = get_model_attr($model['model_id'], $array[0], 'extra');
                $temp = $val[$temp];
            } else {
                $temp = call_user_func($array[1], $temp);
            }
        }
        $data2[$array[0]] = $temp;
    }
    if (!empty($grid['format'])) {
        $value = preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use($data2) {
            return $data2[$match[1]];
        }, $grid['format']);
    } else {
        $value = implode(' ', $data2);
    }
    // 链接支持
    if (!empty($grid['href'])) {
        $links = explode(',', $grid['href']);
        foreach ($links as $link) {
            $array = explode('|', $link);
            $href = $array[0];
            if (preg_match('/^\\[([a-z_]+)\\]$/', $href, $matches)) {
                $val[] = $data2[$matches[1]];
            } else {
                $show = isset($array[1]) ? $array[1] : $value;
                // 替换系统特殊字符串
                $href = str_replace(array('[DEL]', '[DELE]', '[HUIFU]', '[EDIT]', '[MODEL]'), array('del?model_id=[MODEL]', 'dele?model_id=[MODEL]', 'huifu?model_id=[MODEL]', 'edit?model_id=[MODEL]', $model['model_id']), $href);
                // 替换数据变量
                $href = preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use($data) {
                    return $data[$match[1]];
                }, $href);
                //链接第三个数组为样式类
                $cln = $array[2];
                $val[] = '<a class="' . $cln . '" href="' . U($href) . '">' . $show . '</a>';
            }
        }
        $value = implode(' ', $val);
    }
    return $value;
}
Ejemplo n.º 12
0
 /**
  * 编辑文章
  * @author 枫叶 <*****@*****.**>
  */
 public function edit($article_id = 0)
 {
     if (IS_POST) {
         $status = I('status');
         //去保存草稿
         if ($status == '2') {
             $this->savedraftbox();
         }
         $model = D('Article');
         if ($model->create()) {
             //$model->position=implode(',',I('position'));
             if (!$model->pic) {
                 $model->pic = $this->getFirstPicture($model->content);
             }
             if ($model->save()) {
                 $this->success(L('_UPDATE_SUCCESS_'), __PAGEURL__);
             } else {
                 $this->error(L('_UPDATE_FAIL_'));
             }
         } else {
             $this->error($model->getError());
         }
     } else {
         $info = array();
         /* 获取数据 */
         $info = M('Article')->field(true)->find($article_id);
         if (false === $info) {
             $this->error('获取文章信息错误');
         }
         //$field=Api('Model/articleModel');
         $field = get_model_attr('article');
         $this->assign('data', $info);
         $this->assign('fieldarr', $field);
         $this->meta_title = '编辑文章';
         $this->display();
     }
 }
Ejemplo n.º 13
0
 public function add($pid = 0)
 {
     $Nav = D('Nav');
     if (IS_POST) {
         //提交表单
         F('sys_nav_tree', null);
         F('sys_navhome_list', null);
         if (false !== $Nav->update()) {
             $this->success(L('_ADD_SUCCESS_'), U('index'));
         } else {
             $error = $Nav->getError();
             $this->error(empty($error) ? L('_UNKNOWN_ERROR_') : $error);
         }
     } else {
         //$field=Api('Model/NavModel');
         $field = get_model_attr('nav');
         $this->assign('fieldarr', $field);
         $data = array('pid' => $pid);
         $this->assign('data', $data);
         $this->meta_title = '新增导航';
         $this->display('edit');
     }
 }
Ejemplo n.º 14
0
 public function edit($model_attr_id = null)
 {
     $Modelattr = D('ModelAttr');
     if (IS_POST) {
         if ($Modelattr->create()) {
             //为必填项时设置默认正则
             if ($Modelattr->is_require == '1') {
                 if (empty($Modelattr->data_ts)) {
                     $Modelattr->data_ts = "请输入内容!";
                 }
                 if (empty($Modelattr->data_ok)) {
                     $Modelattr->data_ok = "格式正确!";
                 }
                 if (empty($Modelattr->data_err)) {
                     $Modelattr->data_err = "内容不能为空!";
                 }
                 if (empty($Modelattr->data_reg)) {
                     $Modelattr->data_reg = ".+";
                 }
             }
             $result = $Modelattr->save();
             if (0 < $result) {
                 $atype = I('type');
                 if ($atype != 'custom') {
                     $this->addmodelfield($model_attr_id);
                 }
                 $this->success(L('_UPDATE_SUCCESS_'), U('Modelattr/index', array('model_id' => I('model_id'))));
             } else {
                 $this->error(L('_UNKNOWN_ERROR_'));
             }
         } else {
             $this->error($Modelattr->geterror());
         }
     } else {
         if (empty($model_attr_id)) {
             $this->error(L('_ID_NOT_NULL_'));
         }
         $data = D('ModelAttr')->where("model_attr_id={$model_attr_id}")->find();
         //$field=Api('Model/ModeattrlModel');
         $field = get_model_attr('modelattr');
         $this->meta_title = '表单模型>' . get_model_title(I('model_id')) . '>编辑表单';
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->display();
     }
 }
Ejemplo n.º 15
0
 /**
  * 编辑产品
  * @author 枫叶 <*****@*****.**>
  */
 public function edit($goods_id = 0)
 {
     if (IS_POST) {
         $status = I('status');
         //去保存草稿
         if ($status == '2') {
             $this->savedraftbox();
         }
         $model = D('Goods');
         if ($model->create()) {
             //$model->position=implode(',',I('position'));
             //取原来的产品类型
             $srcid = get_goods($goods_id);
             $srcid = $srcid['goods_type_id'];
             if (!$model->pic) {
                 $model->pic = $this->getFirstPicture($model->content);
             }
             $result = $model->save();
             if (0 < $result) {
                 //判断产品类型是否变化啦如果是的话就删除原有信息
                 if (I('goods_type_id') != $srcid) {
                     M('GoodsAttribute')->where('goods_id=' . $goods_id)->delete();
                 }
                 //保存产品附加属性表中的信息
                 $msg = $this->updateGoodsInfo($goods_id);
                 if ($msg['status'] === 0) {
                     $this->error($msg['info']);
                 } else {
                     $this->success($msg['info'], U('index', array('category_id' => I('category_id'))));
                 }
             } else {
                 $this->error($model->geterror());
             }
         } else {
             $this->error($model->getError());
         }
     } else {
         $info = array();
         /* 获取数据 */
         $info = M('Goods')->field(true)->find($goods_id);
         if (false === $info) {
             $this->error('获取产品信息错误');
         }
         //$field=Api('Model/GoodsModel');
         $field = get_model_attr('Goods');
         $this->assign('data', $info);
         $this->assign('fieldarr', $field);
         $this->meta_title = '编辑产品';
         $this->display();
     }
 }
Ejemplo n.º 16
0
 /**
  *编辑文档
  */
 public function edit()
 {
     $Document = D($this->m_info['table']);
     if (IS_POST) {
         if ($Document->create()) {
             $Document->create_time = NOW_TIME;
             $result = $Document->save();
             $result > 0 ? $this->success(L('_UPDATE_SUCCESS_'), __PAGEURL__) : $this->error(L('_UPDATE_FAIL_'));
         } else {
             $this->error($Document->geterror());
         }
     } else {
         $id = I('get.id', '');
         if (empty($id)) {
             $this->error('参数不能为空!');
         }
         /*获取一条记录的详细数据*/
         $data = $Document->find($id);
         if (!$data) {
             $this->error($Document->getError());
         }
         $this->assign('model_id', $this->m_info['model_id']);
         $field = get_model_attr($this->m_info['model_id']);
         $this->assign('fieldarr', $field);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $this->m_info['title'];
         $this->display();
     }
 }