コード例 #1
0
 function add()
 {
     $model = $this->getModel();
     if (IS_POST) {
         $this->checkPostData();
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id);
             // 清空缓存
             method_exists($Model, 'clear') && $Model->clear($id, 'edit');
             D('Scratch')->getScratchInfo($id, true);
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->_deal_data();
         $this->display();
     }
 }
コード例 #2
0
 public function edit($model = null, $id = 0)
 {
     is_array($model) || ($model = $this->getModel($model));
     $id || ($id = I('id'));
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 清空旧关键词
         $keyword = $Model->where('id=' . $id)->getField('keyword');
         $keyword = preg_split('/[\\s,;]+/', $keyword);
         // 以空格tab逗号分号分割关键词
         $data['addon'] = 'Extensions';
         foreach ($keyword as $key) {
             $data['keyword'] = trim($key);
             $res = M('keyword')->where($data)->delete();
         }
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         parent::edit($model, $id);
     }
 }
コード例 #3
0
 public function add()
 {
     $model = $this->model;
     $Model = D(parse_name(get_table_name($model['id']), 1));
     $shop_id = $_POST['shop_id'] = $this->shop_id;
     if (IS_POST) {
         if ($_POST['imgs'] && count($_POST['imgs']) > 0) {
             $_POST['imgs'] = implode(',', $_POST['imgs']);
         }
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news');
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'] . '&shop_id=' . $shop_id));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $extra = $this->getCateData();
         if (!empty($extra)) {
             foreach ($fields as &$vo) {
                 if ($vo['name'] == 'category_id') {
                     $vo['extra'] .= "\r\n" . $extra;
                 }
             }
         }
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->display();
     }
 }
コード例 #4
0
    public function add()
    {
        if (IS_POST) {
            $Model = D(parse_name(get_table_name($this->model['id']), 1));
            // 获取模型的字段信息
            $Model = $this->checkAttr($Model, $this->model['id']);
            if ($Model->create() && ($id = $Model->add())) {
                $this->_saveKeyword($this->model, $id);
                // 清空缓存
                method_exists($Model, 'clear') && $Model->clear($id, 'edit');
                $param['reserve_id'] = $this->reserve_id;
                $param['model'] = $this->model['id'];
                $url = U('lists', $param);
                $this->success('添加' . $this->model['title'] . '成功!', $url);
            } else {
                $this->error($Model->getError());
            }
            exit;
        }
        $normal_tips = '字段类型为单选、多选、下拉选择的参数格式第行一项,每项的值和标题用英文冒号分开。如:<br/>0:男<br/>1:女<br/>2:保密<br/>';
        $normal_tips .= '字段类型为级联的参数格式有两种:
				<br/>一是数据源从数据库取,如: type=db&table=common_category&module=shop_category 
				<br/>二是手工输入,如: type=text&data=[广西[南宁,桂林], 广东[广州, 深圳[福田区, 龙岗区, 宝安区]]]';
        $this->assign('normal_tips', $normal_tips);
        parent::common_add($this->model);
    }
コード例 #5
0
ファイル: function.php プロジェクト: hanxiansen/onethink
/**
 * 获取扩展模型对象
 * @param  integer $model_id 模型编号
 * @return object         模型对象
 */
function logic($model_id)
{
    $name = parse_name(get_document_model($model_id, 'name'), 1);
    $class = is_file(MODULE_PATH . 'Logic/' . $name . 'Logic' . EXT) ? $name : 'Base';
    $class = MODULE_NAME . '\\Logic\\' . $class . 'Logic';
    return new $class($name);
}
コード例 #6
0
 /**
  * 模板显示 调用内置的模板引擎显示方法,
  * @access protected
  * @param string $templateFile 指定要调用的模板文件
  * @return void
  */
 protected function display($template)
 {
     $file = T('Addons://' . parse_name($_GET['_addons'], 1) . '@./' . ucfirst($_GET['_controller']) . '/' . $_GET['_action']);
     define('IS_ADDON', true);
     parent::display($file);
     // 重要:要避免陷入$this->display()循环
 }
コード例 #7
0
 function edit()
 {
     $map['id'] = $id = I('id');
     $map['token'] = get_token();
     $model = $this->getModel();
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
     } else {
         $normal_tips = "贺卡模板目前仅支持在贺卡插件目录下由制作人员添加";
         $this->assign('normal_tips', $normal_tips);
         $data = D('WishCard')->find($id);
         $this->assign('data', $data);
         $template = $this->_getTemplateInfo($data['template_cate'], $data['template']);
         $this->assign('template', $template);
         $this->display();
     }
 }
コード例 #8
0
 public function edit($id = 0)
 {
     $model = $this->getModel('credit_config');
     $id || ($id = I('id'));
     // 获取数据
     $data = M(get_table_name($model['id']))->find($id);
     $data || $this->error('数据不存在!');
     if (IS_POST) {
         $act = 'save';
         if ($data['token'] == 0) {
             $_POST['token'] = get_token();
             unset($_POST['id']);
             $act = 'add';
         }
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->{$act}()) {
             // dump($Model->getLastSql());
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             // dump($Model->getLastSql());
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $model['title'];
         $this->display('Addons/edit');
     }
 }
コード例 #9
0
 public function edit()
 {
     is_array($model) || ($model = $this->getModel($model));
     $id || ($id = I('id'));
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         // 获取数据
         $data = M(get_table_name($model['id']))->find($id);
         $data || $this->error('数据不存在!');
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $model['title'];
         $templateFile || ($templateFile = $model['template_edit'] ? $model['template_edit'] : '');
         $this->display($templateFile);
     }
 }
コード例 #10
0
 function edit()
 {
     $id = $this->shop_id;
     $model = $this->getModel();
     if (IS_POST) {
         // $_POST ['update_time'] = NOW_TIME;
         $Model = D(parse_name(get_table_name($model['id']), 1));
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!');
     } else {
         $fields = get_model_attribute($model['id']);
         // 获取数据
         $data = D('Shop')->getInfo($id, true);
         $data || $this->error('数据不存在!');
         $token = get_token();
         if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) {
             $this->error('非法访问!');
         }
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->display();
     }
 }
コード例 #11
0
ファイル: command.php プロジェクト: 262877348/Sublime-Text
function show_colums_after_connected_from_file($argv)
{
    $config = (include $argv[0]);
    $table = $argv[1];
    $argv = array(0 => $config['DB_HOST'] . ':' . $config['DB_PORT'], 1 => $config['DB_USER'], 2 => $config['DB_PWD'], 3 => $config['DB_NAME'], 4 => $config['DB_PREFIX'] . parse_name($table));
    show_colums($argv);
}
コード例 #12
0
 public function add()
 {
     $model = $this->model;
     $Model = D(parse_name(get_table_name($model['id']), 1));
     if (IS_POST) {
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id, 'custom_reply_text');
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $extra = $this->getCateData();
         if (!empty($extra)) {
             foreach ($fields[1] as &$vo) {
                 if ($vo['name'] == 'cate_id') {
                     $vo['extra'] .= "\r\n" . $extra;
                 }
             }
         }
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->display();
     }
 }
コード例 #13
0
 function edit()
 {
     $cateMap['token'] = $map['token'] = get_token();
     $map['id'] = $id = I('id');
     $model = $this->getModel('wish_card_content');
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         //读分类名称
         $cate_data['id'] = $_POST['content_cate_id'];
         $_POST['content_cate'] = M('WishCardContentCate')->where($cate_data)->getField('content_cate_name');
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
     } else {
         $cate = D('WishCardContentCate')->where($cateMap)->select();
         $data = D('WishCardContent')->find($id);
         for ($i = 0; $i < count($cate); $i++) {
             if ($cate[$i]['id'] == $data['content_cate_id']) {
                 $cate[$i]['checked'] = true;
             }
         }
         $this->assign('content_cate', $cate);
         $this->assign('data', $data);
         //dump($cate);
         $this->display(T('Addons://WishCard@WishCard/editWishContent'));
     }
 }
コード例 #14
0
 function export()
 {
     set_time_limit(0);
     // 获取模型信息
     $model = $this->model;
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $grids = $list_data['list_grids'];
     $fields = $list_data['fields'];
     foreach ($grids as $v) {
         if ($v['title'] == '操作') {
             array_pop($grids);
         } else {
             $arr = explode('|', $v['field'][0]);
             if (count($arr) > 1) {
                 $fun[$arr[0]] = $arr[1];
             }
             $ht[$arr[0]] = $v['title'];
         }
     }
     $dataArr[0] = $ht;
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $map['ask_id'] = $this->ask_id;
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select();
     if ($data) {
         $qdao = D('AskQuestion');
         foreach ($data as &$vv) {
             $user = get_followinfo($vv['uid']);
             $vv['nickname'] = $user['nickname'];
             $vv['times'] += 1;
             $vv['question_id'] = $qdao->getQuestionTitle($vv['question_id'], $this->ask_id);
             $vv['answer'] = implode(', ', unserialize($vv['answer']));
             $vv['is_correct'] = $vv['is_correct'] == 1 ? '是' : '否';
         }
         foreach ($data as &$vo) {
             foreach ($vo as $name => &$vv) {
                 if (isset($fun[$name])) {
                     if ($fun[$name] == 'get_name_by_status') {
                         $vv = get_name_by_status($vv, $name, $model['id']);
                     } else {
                         $vv = call_user_func($fun[$name], $vv);
                     }
                 }
             }
             foreach ($ht as $key => $val) {
                 $newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key];
             }
             $vo = $newArr;
         }
         $dataArr = array_merge($dataArr, $data);
     }
     if ($return) {
         return $dataArr;
     } else {
         outExcel($dataArr, $map['module']);
     }
 }
コード例 #15
0
ファイル: Client.class.php プロジェクト: fishling/chatPro
 function __call($method, $params)
 {
     $method = parse_name($method, 0);
     //函数命名风格转换,兼容驼峰法
     if (function_exists($method)) {
         return call_user_func_array($method, $params);
     } else {
         return -1;
         //api函数不存在
     }
 }
コード例 #16
0
ファイル: function.php プロジェクト: waqt/kdweb
/**
 * 创建service
 * @param string $name service名称
 * @return Model\BaseModel
 * @author liutj
 */
function model($name)
{
    $name = ucfirst(parse_name($name, 1));
    static $_model = array();
    if (isset($_model[$name])) {
        return $_model[$name];
    }
    $class = '\\Model\\' . $name . 'Model';
    $model = class_exists($class) ? new $class() : new \Think\Model($name);
    $_model[$name] = $model;
    return $model;
}
コード例 #17
0
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (get_opinion('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         $Addons = A("Addons://{$_addons}/{$_controller}")->{$_action}();
     } else {
         $this->error('没有指定插件名称,控制器或操作!');
     }
 }
コード例 #18
0
ファイル: App.class.php プロジェクト: gg1122/Dswjcms
 /**
  * 获得实际的模块名称
  * @access private
  * @return string
  */
 private static function getModule()
 {
     $var = C('VAR_MODULE');
     $module = !empty($_POST[$var]) ? $_POST[$var] : (!empty($_GET[$var]) ? $_GET[$var] : C('DEFAULT_MODULE'));
     if (C('URL_CASE_INSENSITIVE')) {
         // URL地址不区分大小写
         define('P_MODULE_NAME', strtolower($module));
         // 智能识别方式 index.php/user_type/index/ 识别到 UserTypeAction 模块
         $module = ucfirst(parse_name(strtolower($module), 1));
     }
     unset($_POST[$var], $_GET[$var]);
     return $module;
 }
コード例 #19
0
ファイル: function.php プロジェクト: vki/microbuilder
/**
 * @param string $url
 * @param string $vars
 * @return string
 */
function AU($url = '', $vars = '')
{
    if (!defined('MODULE_NAME') || !defined('ADDON_NAME')) {
        trigger_error('当前上下文不支持这个函数AU', E_USER_ERROR);
    }
    $entry = parse_name(MODULE_NAME);
    $addon = parse_name(ADDON_NAME);
    if ($entry == 'app') {
        $url = "/extend/{$addon}/{$url}";
    } else {
        $url = "/{$entry}/extend/{$addon}/{$url}";
    }
    return U($url, $vars);
}
コード例 #20
0
 /**
  * 外部执行插件方法
  * @author jry <*****@*****.**>
  */
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (C('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $TMPL_PARSE_STRING['__ADDONROOT__'] = __ROOT__ . "/Addons/{$_addons}";
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         $Addons = A("Addons://{$_addons}/{$_controller}")->{$_action}();
     } else {
         $this->error('没有指定插件名称,控制器或操作!');
     }
 }
コード例 #21
0
ファイル: command.php プロジェクト: nan1888/SublimeThinkPHP
function show_colums($argv)
{
    $config = connect_db();
    $table = $config[4] . parse_name($argv[0]);
    $result = mysql_query("SHOW FULL COLUMNS FROM {$table}");
    if (!$result) {
        error(mysql_error());
    } else {
        while ($row = mysql_fetch_assoc($result)) {
            $res[] = $row;
        }
        success('query success', $res);
    }
    mysql_close();
}
コード例 #22
0
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (C('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     A('Home/Amangotheme')->weixin_get_info(__SELF__);
     A('Home/Amangotheme')->init_config('addons');
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         //插件状态是否启用判断
         $addon_status = M('Addons')->where(array('name' => ucfirst($_addons), 'status' => 1))->count();
         if ($addon_status == 0) {
             $this->redirect('/index');
             //$this->error('请先确认该插件是否安装!');
         }
         $addonsmodel = A("Addons://{$_addons}/{$_controller}");
         //判断该操作是否存在
         $actionlist = get_class_methods($addonsmodel);
         if (!in_array($_action, $actionlist)) {
             $this->redirect('/index');
         }
         //登陆操作权限
         $login_action = array_change_key_case($addonsmodel->login_action, CASE_LOWER);
         if (!empty($login_action[$_action]) && is_array($login_action)) {
             $this->is_login($login_action[$_action]['errormsg'], $login_action[$_action]['errorurl']);
         }
         //禁止操作权限
         $deny_action = $addonsmodel->deny_action;
         $deny_action = array_change_key_case($addonsmodel->deny_action, CASE_LOWER);
         if (!empty($deny_action) && is_array($deny_action)) {
             if (in_array($_action, $deny_action)) {
                 $this->redirect('/index');
             }
         }
         defined('_ADDONS') or define('_ADDONS', $_addons);
         defined('_CONTROLLER') or define('_CONTROLLER', $_controller);
         defined('_ACTION') or define('_ACTION', $_action);
         $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
         $TMPL_PARSE_STRING['__ADDONROOT__'] = __ROOT__ . '/Addons/' . $_addons . '/Public';
         $TMPL_PARSE_STRING['ADDON_PUBLIC'] = __ROOT__ . '/Addons/' . $_addons . '/Public';
         C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
         $Addons = $addonsmodel->{$_action}();
     } else {
         //返回首页
         $this->redirect('/index');
         //$this->error('没有指定插件名称,控制器或操作!');
     }
 }
コード例 #23
0
 /**
  * 自动访问插件
  * @param null $_addons 插件
  * @param null $_controller 控制器
  * @param null $_action 操作
  * @return bool
  */
 protected function anonymousPlugin($_addons = null, $_controller = null, $_action = null)
 {
     if ($_action == null) {
         return false;
     }
     if (get_opinion('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         $Addons = A("Addons://{$_addons}/{$_controller}")->{$_action}();
         return true;
     } else {
         return false;
     }
 }
コード例 #24
0
 function edit()
 {
     $model = $this->getModel('business_card');
     $map['uid'] = $uid = $this->mid;
     $act = 'edit';
     // 	    $map['uid']=11857;
     $data = M('business_card')->where($map)->find();
     // 	    $id = I ( 'id' );
     // 获取数据
     // 	    $data = M ( get_table_name ( $model ['id'] ) )->find ( $id );
     $data || ($act = 'add');
     // $token = get_token ();
     // if (isset ( $data ['token'] ) && $token != $data ['token'] && defined ( 'ADDON_PUBLIC_PATH' )) {
     // $this->error ( '非法访问!' );
     // }
     if (IS_POST) {
         $_POST['uid'] = $this->mid;
         $_POST['token'] = get_token();
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($act == 'edit') {
             if ($Model->create() && $Model->save()) {
                 // 清空缓存
                 method_exists($Model, 'clear');
                 //     			$url=  '<script language=javascript>history.go(-1);</script>';
                 $this->success('保存' . $model['title'] . '成功!');
             } else {
                 $this->error($Model->getError());
             }
         } else {
             if ($Model->create() && ($id = $Model->add())) {
                 // 清空缓存
                 method_exists($Model, 'clear') && $Model->clear($id, 'add');
                 $this->success('添加' . $model['title'] . '成功!');
             } else {
                 $this->error($Model->getError());
             }
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->display();
     }
 }
コード例 #25
0
ファイル: function.php プロジェクト: devsnippet/microbuilder
function WAU($url = '', $vars = '')
{
    if (!defined('MODULE_NAME') || !defined('ADDON_NAME')) {
        trigger_error('当前上下文不支持这个函数AU', E_USER_ERROR);
    }
    $entry = parse_name(MODULE_NAME);
    $addon = parse_name(ADDON_NAME);
    $url = "/{$entry}/extend/{$addon}/{$url}";
    $url = U($url, $vars);
    $info = pathinfo(__APP__);
    $root = substr($info['dirname'], 0, -1) . 'w';
    if (!empty($info['basename'])) {
        $root .= '/' . $info['basename'];
    }
    $len = strlen(__APP__);
    $url = substr($url, $len);
    return $root . $url;
}
コード例 #26
0
ファイル: Model.php プロジェクト: pobingwanghai/g-framework
 public function __construct($tableName = null)
 {
     if (empty($tableName)) {
         $tableName = substr(get_class($this), 0, -5);
     }
     $this->tableName = parse_name($tableName);
     $this->db_prefix = $this->getDbPrefix();
     $this->trueTableName = $this->db_prefix . $this->tableName;
     $this->sql_bk = $this->sql = str_replace('{table}', $this->trueTableName, $this->sql);
     //实例化DB类
     $this->DB = new GF_DB();
     global $DB_CONN_STATUS;
     if ($DB_CONN_STATUS === false) {
         if ($this->DB->connect()) {
             $DB_CONN_STATUS = true;
         }
     }
 }
コード例 #27
0
 public function lists()
 {
     if (!is_administrator($this->mid)) {
         redirect(addons_url('UserCenter://UserCenter/lists'));
     }
     // $this->assign ( 'add_button', false );
     $this->assign('search_url', U('lists'));
     $model = $this->getModel('keyword');
     $page = I('p', 1, 'intval');
     // 默认显示第一页数据
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $fields = $list_data['fields'];
     // 		foreach ( $list_data ['list_grids'] as &$vo ) {
     // 			if (isset ( $vo ['href'] )) {
     // 				$vo ['href'] = '[DELETE]|删除';
     // 			}
     // 		}
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $map['token'] = get_token();
     $row = empty($model['list_row']) ? 20 : $model['list_row'];
     empty($fields) || in_array('id', $fields) || array_push($fields, 'id');
     $name = parse_name(get_table_name($model['id']), true);
     $list_data['list_data'] = M($name)->field(empty($fields) ? true : $fields)->where($map)->order('id DESC')->page($page, $row)->select();
     // 分页
     $count = M($name)->where($map)->count();
     if ($count > $row) {
         $page = new \Think\Page($count, $row);
         $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
         $list_data['_page'] = $page->show();
     }
     $addons = M('addons')->where("type=1")->field('name,title')->select();
     foreach ($addons as $a) {
         $addonsArr[$a['name']] = $a['title'];
     }
     foreach ($list_data['list_data'] as &$vo) {
         $vo['addon'] = $addonsArr[$vo['addon']];
     }
     $this->assign($list_data);
     // dump($list_data);
     $this->display('Addons/lists');
 }
コード例 #28
0
 /**
  * @Title: _before_insert
  * @Description: todo(插入数据前操作)
  * @author jiangx
  * @date 2013-7-27 
  * @throws
  */
 public function _before_insert()
 {
     if ($_POST['tablename']) {
         $_POST['modelname'] = parse_name($_POST['tablename'], 1);
         if ($_POST['methodname']) {
             if (!method_exists(A($_POST['modelname']), $_POST['methodname'])) {
                 $this->error('录入方法名错误,请检查修改');
             }
         }
         if ($_POST['type'] == 1) {
             $_POST['objectid'] = implode(',', $_POST['rolegroupid']);
         }
         if ($_POST['type'] == 0) {
             $_POST['objectid'] = implode(',', $_POST['personid']);
         }
     } else {
         $this->error('录入数据错误,请检查修改');
     }
 }
コード例 #29
0
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (C('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     defined('ADDON_PUBLIC_PATH') or define('ADDON_PUBLIC_PATH', __ROOT__ . '/Addons/' . $_addons . '/View/default/Public');
     defined('_ADDONS') or define('_ADDONS', $_addons);
     defined('_CONTROLLER') or define('_CONTROLLER', $_controller);
     defined('_ACTION') or define('_ACTION', $_action);
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $TMPL_PARSE_STRING['__ADDONROOT__'] = __ROOT__ . "/Addons/{$_addons}";
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         $Addons = A("Addons://{$_addons}/{$_controller}")->{$_action}();
     } else {
         $this->error('没有指定插件名称,控制器或操作!');
     }
 }
コード例 #30
0
 function form()
 {
     if (!is_login()) {
         Cookie('__forward__', $_SERVER['REQUEST_URI']);
         $this->error('您还没有登录,请先登录!', U('User/login'));
     }
     $model = M('Model')->find(I('get.model'));
     $this->assign('model', $model);
     $id = I('id', 0);
     $this->right_data($model);
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         $res = $Model->create();
         if ($id) {
             $res = $Model->save();
         } else {
             $res = $Model->add();
         }
         if ($res) {
             $url = U('index');
             if ($model['name'] == 'store') {
                 $url = U('store');
             }
             $this->success('保存成功!', $url);
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         // 获取数据
         if ($id) {
             $data = M(get_table_name($model['id']))->find($id);
             $data || $this->error('数据不存在!');
             $this->assign('data', $data);
         }
         $this->meta_title = '编辑' . $model['title'];
         $this->display();
     }
 }