当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentModel::getInstance方法代码示例

本文整理汇总了PHP中ContentModel::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::getInstance方法的具体用法?PHP ContentModel::getInstance怎么用?PHP ContentModel::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentModel的用法示例。


在下文中一共展示了ContentModel::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: del

 public function del()
 {
     if (IS_POST) {
         $uid = Q('uid', 0, 'intval');
         //删除文章
         if (Q('post.delcontent')) {
             $ModelCache = cache('model');
             foreach ($ModelCache as $model) {
                 $contentModel = ContentModel::getInstance($model['mid']);
                 $contentModel->where(array('uid' => $uid))->del();
             }
         }
         //删除评论
         if (Q('post.delcomment')) {
             M('comment')->where(array('uid' => $uid))->del();
         }
         //删除附件
         if (Q('post.delupload')) {
             M('upload')->where(array('uid' => $uid))->del();
         }
         //删除用户
         M('user')->del($uid);
         $this->success('删除成功...');
     } else {
         $uid = Q("uid", 0, "intval");
         $field = M('user')->find($uid);
         $this->assign('field', $field);
         $this->display();
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:30,代码来源:UserControl.class.php

示例2: index

 public function index()
 {
     //编号,也就是下载第几个链接,有的是多文件下载用的!
     $k = I('get.k', 0, 'intval');
     //字段名称
     $f = I('get.f', '');
     if (empty($this->id) || empty($this->catid) || empty($f)) {
         $this->error("参数有误!");
     }
     //模型ID
     $modelid = getCategory($this->catid, 'modelid');
     $Model_field = F("Model_field_" . $modelid);
     //判断字段类型
     if (!in_array($Model_field[$f]['formtype'], array('downfiles', 'downfile'))) {
         $this->error('下载地址错误!');
     }
     $this->db = ContentModel::getInstance($modelid);
     $data = $this->db->relation(true)->where(array("id" => $this->id, 'status' => 99))->find();
     if (empty($data)) {
         $this->error("该信息不存在!");
     }
     $this->db->dataMerger($data);
     if (!empty($data)) {
         //取得下载字段信息
         $downfiles = $data[$f];
         $dowUnserialize = unserialize($downfiles);
         if ($dowUnserialize) {
             $info = $dowUnserialize[$k];
             if (empty($info)) {
                 $this->error("该下载地址已经失效!");
             }
         } else {
             $info = array();
             $info['filename'] = basename($downfiles);
             $info['point'] = 0;
             $info['groupid'] = 0;
         }
         //当前客户端标识
         $aut = md5($this->userid . $this->groupid . substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
         //加密
         //格式:aut|栏目ID|信息id|下载编号|字段
         $key = authcode(implode('|', array($aut, $this->catid, $this->id, $k, $f)), '', '', 3600);
         $this->assign("info", $data);
         $this->assign("fileurl", U("Download/d", array('key' => urlencode($key))));
         $this->assign("filename", $info['filename']);
         $this->assign("point", $info['point']);
         $this->assign("groupid", $info['groupid']);
         $this->assign("Member_group", F("Member_group"));
         $this->assign("SEO", seo($this->catid, urldecode($info['filename']), '', ''));
         $this->display("Public:download");
     } else {
         $this->error("该信息不存在!");
     }
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:54,代码来源:DownloadAction.class.php

示例3: audit

 /**
  * 审核文章
  */
 public function audit()
 {
     if ($aids = Q('aid')) {
         $ContentModel = ContentModel::getInstance($this->mid);
         foreach ($aids as $aid) {
             $data = array('aid' => $aid, 'content_status' => 1);
             $ContentModel->save($data);
         }
         $this->success('操作成功');
     } else {
         $this->error('参数错误');
     }
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:16,代码来源:ContentAuditController.class.php

示例4: del

 public function del($aid)
 {
     $ContentModel = ContentModel::getInstance($this->mid);
     if ($ContentModel->del($aid)) {
         //删除文章tag属性
         M('content_tag')->where(array('cid' => $this->cid))->del();
         //生成栏目静态
         $this->createCategoryHtml($this->cid);
         Hook::listen('content_del');
         return true;
     } else {
         $this->error = '删除文章失败';
     }
 }
开发者ID:lililishuang,项目名称:hdcms,代码行数:14,代码来源:Content.class.php

示例5: del

 /**
  * 删除文章
  * @param $aid 文章aid
  * @return bool
  */
 public function del($aid)
 {
     $ContentModel = ContentModel::getInstance($this->mid);
     $map['aid'] = array('IN', $aid);
     //删除文章静态文件
     $content = $ContentModel->where($map)->find();
     //执行删除
     if ($ContentModel->del($aid)) {
         //删除文章tag
         $map['cid'] = $content['cid'];
         $map['aid'] = $content['aid'];
         M('content_tag')->where($map)->del();
         Hook::listen('CONTENT_DEL');
         return true;
     } else {
         $this->error = '删除文章失败';
     }
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:23,代码来源:Content.class.php

示例6: delUser

 /**
  * 删除用户
  * @return mixed
  */
 public function delUser()
 {
     $uid = Q('uid', 0, 'intval');
     //删除文章
     if (Q('post.delcontent')) {
         $map = array('uid' => array('EQ', $uid));
         $ModelCache = S('model');
         foreach ($ModelCache as $model) {
             $contentModel = ContentModel::getInstance($model['mid']);
             $contentModel->where($map)->del();
         }
     }
     //评论表存在时删除评论
     if (Q('post.delcomment') && M()->tableExists('addon_comment')) {
         $map = array('userid' => array('EQ', $uid));
         M('addon_comment')->where($map)->del();
     }
     //删除附件
     if (Q('post.delupload')) {
         $map = array('uid' => array('EQ', $uid));
         M('upload')->where($map)->del();
     }
     //后台历史菜单
     M('menu_favorite')->where($map)->del();
     $map = array('space_uid' => array('EQ', $uid), 'guest_uid' => array('EQ', $uid), '_logic' => 'OR');
     //删除访客
     M('user_guest')->where($map)->del();
     //日志记录
     $map = array('uid' => array('EQ', $uid));
     M('user_credits')->where($map)->del();
     if (M('user')->del($uid)) {
         return true;
     } else {
         $this->error = '删除失败';
     }
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:40,代码来源:UserModel.class.php

示例7: edit

 public function edit()
 {
     $aid = Q('aid', 0, 'intval');
     if (!$aid) {
         $this->error('文章不存在');
     }
     $mid = $this->_category[$this->_cid]['mid'];
     $ContentModel = new Content($mid);
     $result = $ContentModel->find($aid);
     if ($result['uid'] != $_SESSION['uid']) {
         $this->error('没有修改权限');
     }
     if (IS_POST) {
         if ($ContentModel->edit($_POST)) {
             $this->success('发表成功!');
         } else {
             $this->error($ContentModel->error);
         }
     } else {
         $aid = Q('aid', 0, 'intval');
         if (!$aid) {
             $this->error('参数错误');
         }
         $ContentModel = ContentModel::getInstance($this->_mid);
         $editData = $ContentModel->find($aid);
         //获取分配字段
         $form = K('ContentForm');
         $this->assign('form', $form->get($editData));
         //分配验证规则
         $this->assign('formValidate', $form->formValidate);
         $this->assign('editData', $editData);
         $this->display('edit.php');
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:34,代码来源:ContentControl.class.php

示例8: push

 public function push()
 {
     if (IS_POST) {
         $id = I('post.id');
         $modelid = I('post.modelid');
         $catid = I('post.catid');
         $action = I('get.action');
         if (!$id || !$action || !$modelid || !$catid) {
             $this->error("参数不正确");
         }
         switch ($action) {
             //推荐位
             case "position_list":
                 $posid = $_POST['posid'];
                 if ($posid && is_array($posid)) {
                     $position_data_db = D('Position');
                     $fields = F("Model_field_" . $modelid);
                     $tablename = ucwords($this->model[$modelid]['tablename']);
                     if (!$tablename) {
                         $this->error("模型不能为空!");
                     }
                     $ids = explode("|", $id);
                     $Content = ContentModel::getInstance($modelid);
                     foreach ($ids as $k => $aid) {
                         //取得信息
                         $re = $Content->relation(true)->where(array("id" => $aid))->find();
                         if ($re) {
                             $Content->dataMerger($re);
                             //推送数据
                             $textcontent = array();
                             foreach ($fields as $_key => $_value) {
                                 //判断字段是否入库到推荐位字段
                                 if ($_value['isposition']) {
                                     $textcontent[$_key] = $re[$_key];
                                 }
                             }
                             //样式进行特别处理
                             $textcontent['style'] = $re['style'];
                             //推送到推荐位
                             $status = $position_data_db->position_update($aid, $modelid, $catid, $posid, $textcontent, 0, 1);
                             $r = $re = null;
                         }
                     }
                     $this->success("推送到推荐位成功!");
                 } else {
                     $this->error("请选择推荐位!");
                 }
                 break;
                 //同步发布到其他栏目
             //同步发布到其他栏目
             case "push_to_category":
                 $ids = explode("|", $id);
                 $relation = I("post.relation");
                 if (!$relation) {
                     $this->error("请选择需要推送的栏目!");
                 }
                 $relation = explode("|", $relation);
                 if (is_array($relation)) {
                     //过滤相同栏目和自身栏目
                     foreach ($relation as $k => $classid) {
                         if ($classid == $catid) {
                             unset($relation[$k]);
                         }
                     }
                     //去除重复
                     $relation = array_unique($relation);
                     if (count($relation) < 1) {
                         $this->error("请选择需要推送的栏目!");
                     }
                     $tablename = ucwords($this->model[$modelid]['tablename']);
                     if (!$tablename) {
                         $this->error("模型不能为空!");
                     }
                     $Content = ContentModel::getInstance($modelid);
                     import('Content');
                     $ContentAPI = new Content();
                     foreach ($ids as $k => $aid) {
                         //取得信息
                         $r = $Content->relation(true)->where(array("id" => $aid))->find();
                         $linkurl = $r['url'];
                         if ($r) {
                             $ContentAPI->othor_catid($relation, $linkurl, $r, $modelid);
                         }
                     }
                     $this->success("推送其他栏目成功!");
                 } else {
                     $this->error("请选择需要推送的栏目!");
                 }
                 break;
             default:
                 $this->error("请选择操作!");
                 break;
         }
     } else {
         $id = I('get.id');
         $action = I('get.action');
         $modelid = I('get.modelid');
         $catid = I("get.catid");
         if (!$id || !$action || !$modelid || !$catid) {
             $this->error("参数不正确!");
//.........这里部分代码省略.........
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:101,代码来源:ContentAction.class.php

示例9: get

 /**
  * 获得入库数据
  *
  * @return array|bool
  */
 public function get()
 {
     $data = $_POST;
     //添加文章时设置 作者uid
     if (!isset($data['aid'])) {
         $data['uid'] = $_SESSION['user']['uid'];
     }
     //文章状态设置 0 待审核 1 发表 2 自动
     $auto_send_time = Q('auto_send_time', null, 'strtotime');
     if ($auto_send_time && $auto_send_time > time()) {
         $data['content_status'] = 2;
     } else {
         if ($data['content_status'] == 2) {
             $data['content_status'] = 1;
         }
     }
     //没有添加内容时初始设置
     if (empty($data['content'])) {
         $data['content'] = '';
     }
     //添加时间
     if (!empty($data['addtime'])) {
         $data['addtime'] = strtotime($data['addtime']);
     }
     //修改时间
     $data['updatetime'] = time();
     //阅读积分处理
     if (!empty($data['readpoint']) && !is_numeric($data['readpoint'])) {
         $data['readpoint'] = 0;
     }
     //文章模型
     $ContentModel = ContentModel::getInstance($this->mid);
     //自动提取文章描述
     if (empty($data['description'])) {
         $len = isset($data['auto_desc_length']) ? $data['auto_desc_length'] : 200;
         $data['description'] = mb_substr(strip_tags($data['content']), 0, $len, 'utf-8');
     }
     foreach ($this->field as $fieldInfo) {
         //字段禁用
         if ($fieldInfo['status'] == 0) {
             continue;
         }
         //不需要处理的字段
         if (in_array($fieldInfo['field_name'], $this->noDealField)) {
             continue;
         }
         $field = $fieldInfo['field_name'];
         //字段set选项
         $set = $fieldInfo['set'];
         //字段二次处理方法
         $METHOD = $fieldInfo['field_type'];
         $data[$field] = empty($data[$field]) ? '' : $data[$field];
         if (method_exists($this, $METHOD)) {
             $Value = $this->{$METHOD}($fieldInfo, $data[$field]);
             if ($fieldInfo['table_type'] == 1) {
                 //主表数据
                 $data[$field] = $Value;
             } else {
                 //副表
                 $data[$fieldInfo['table_name']][$field] = $Value;
             }
         }
         //封面栏目与链接不允许发表
         if (!isset($data['cid']) || !in_array($this->category[$data['cid']]['cattype'], array(1, 4))) {
             $this->error = '栏目选择错误';
             return false;
         }
         //如果字段设置唯一性验证时执行验证操作
         if ((int) $fieldInfo['isunique'] == 1) {
             if (M($fieldInfo['table_name'])->where($field . "='{$Value}'")->find()) {
                 $this->error = $fieldInfo['title'] . '已经存在';
                 return false;
             }
         }
         //模型自动验证规则设置
         $validateRule = array();
         //验证时机 1 有这个表单就验证  2 必须验证 3 表单不为空才验证
         $validateOccasion = (int) $fieldInfo['required'] ? 2 : 3;
         //设置验证规则
         if (isset($set['minlength']) && isset($set['maxlength'])) {
             $maxlength = (int) $set['maxlength'];
             $minlength = (int) $set['minlength'];
             if ($maxlength > $minlength) {
                 $validateRule[] = array($field, "minlen:{$minlength}", $fieldInfo['title'] . " 数量不能小于{$minlength}个字", $validateOccasion, 3);
                 $validateRule[] = array($field, "maxlen:{$maxlength}", $fieldInfo['title'] . " 数量不能大于{$maxlength}个字", $validateOccasion, 3);
             }
         }
         //验证规则
         if (!empty($fieldInfo['validate'])) {
             $regexp = $fieldInfo['validate'];
             $error = empty($fieldInfo['error']) ? $fieldInfo['title'] . '输入错误' : $set['error'];
             $validateRule[] = array($field, "regexp:{$regexp}", $error, $validateOccasion, 3);
         }
         //必须输入验证
         if ($fieldInfo['required'] == 1) {
//.........这里部分代码省略.........
开发者ID:suhanyujie,项目名称:spider,代码行数:101,代码来源:ContentInputModel.class.php

示例10: related_content

 /**
  * 上下篇生成
  * @param type $catid
  * @param type $id 
  */
 public function related_content($catid, $id, $action = "edit")
 {
     if (!$catid || !$id) {
         return;
     }
     $modelid = getCategory($catid, 'modelid');
     $db = ContentModel::getInstance($modelid);
     $where = array();
     $where['catid'] = $catid;
     $where['status'] = array("EQ", "99");
     $where['id'] = array("LT", $id);
     $data[] = $db->relation(true)->where($where)->order(array("id" => "DESC"))->find();
     if ($action == "edit") {
         $where['id'] = array("GT", $id);
         $data[] = $db->relation(true)->where($where)->find();
     }
     import('Html');
     $html = get_instance_of('Html');
     foreach ($data as $r) {
         if ($r['islink'] || empty($r['id'])) {
             continue;
         }
         $db->dataMerger($r);
         $setting = getCategory($r['catid'], 'setting');
         $content_ishtml = $setting['content_ishtml'];
         if (!$content_ishtml) {
             continue;
         }
         $html->show($r, 1, 'edit');
     }
     return true;
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:37,代码来源:Content.class.php

示例11: del

 public function del($aid)
 {
     $ContentModel = ContentModel::getInstance($this->_mid);
     $data = $ContentModel->find($aid);
     if (!$data) {
         $this->error = '文章不存在';
         return false;
     }
     if ($ContentModel->del($aid)) {
         //删除文章tag属性
         M('content_tag')->where(array('mid' => $this->_mid, 'cid' => $data['cid']))->del();
         return true;
     } else {
         $this->error = '删除文章失败';
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:16,代码来源:Content.class.php

示例12: shows

 public function shows()
 {
     $catid = I('get.catid', 0, 'intval');
     $id = I('get.id', 0, 'intval');
     $page = intval($_GET[C("VAR_PAGE")]);
     $page = max($page, 1);
     //获取当前栏目数据
     $category = getCategory($catid);
     if (empty($category)) {
         send_http_status(404);
         exit;
     }
     //反序列化栏目配置
     $category['setting'] = $category['setting'];
     //检查是否禁止访问动态页
     if ($category['setting']['showoffmoving']) {
         send_http_status(404);
         exit;
     }
     //模型ID
     $this->modelid = $category['modelid'];
     $this->db = ContentModel::getInstance($this->modelid);
     $data = $this->db->relation(true)->where(array("id" => $id, 'status' => 99))->find();
     if (empty($data)) {
         send_http_status(404);
         exit;
     }
     $this->db->dataMerger($data);
     //分页方式
     if (isset($data['paginationtype'])) {
         //分页方式
         $paginationtype = $data['paginationtype'];
         //自动分页字符数
         $maxcharperpage = (int) $data['maxcharperpage'];
     } else {
         //默认不分页
         $paginationtype = 0;
     }
     //载入字段数据处理类
     if (false == require_cache(RUNTIME_PATH . 'content_output.class.php')) {
         D("Category")->category_cache();
         D("Content_cache")->model_content_cache();
         require RUNTIME_PATH . 'content_output.class.php';
     }
     $content_output = new content_output($this->modelid);
     //获取字段类型处理以后的数据
     $output_data = $content_output->get($data);
     $output_data['id'] = $id;
     $output_data['title'] = strip_tags($output_data['title']);
     //SEO
     $seo_keywords = '';
     if (!empty($output_data['keywords'])) {
         $seo_keywords = implode(',', $output_data['keywords']);
     }
     $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords);
     //内容页模板
     $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template'];
     //去除模板文件后缀
     $newstempid = explode(".", $template);
     $template = $newstempid[0];
     unset($newstempid);
     //分页处理
     $pages = $titles = '';
     //分页方式 0不分页 1自动分页 2手动分页
     if ($data['paginationtype'] == 1) {
         //自动分页
         if ($maxcharperpage < 10) {
             $maxcharperpage = 500;
         }
         //按字数分割成几页处理开始
         import('Contentpage', APP_PATH . C("APP_GROUP_PATH") . '/Contents/ORG');
         $contentpage = new Contentpage();
         $contentfy = $contentpage->get_data($output_data['content'], $maxcharperpage);
         //自动分页有时会造成返回空,如果返回空,就不分页了
         if (!empty($contentfy)) {
             $output_data['content'] = $contentfy;
         }
     }
     //分配解析后的文章数据到模板
     $this->assign($output_data);
     //seo分配到模板
     $this->assign("SEO", $seo);
     //栏目ID
     $this->assign("catid", $catid);
     //分页生成处理
     //分页方式 0不分页 1自动分页 2手动分页
     if ($data['paginationtype'] > 0) {
         $urlrules = $this->url->show($data, $page);
         //手动分页
         $CONTENT_POS = strpos($output_data['content'], '[page]');
         if ($CONTENT_POS !== false) {
             $contents = array_filter(explode('[page]', $output_data['content']));
             $pagenumber = count($contents);
             $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => $urlrules['page']))->show("default");
             //判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $content = $contents[$page];
             } else {
                 $content = $contents[$page - 1];
             }
//.........这里部分代码省略.........
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:101,代码来源:IndexAction.class.php

示例13: move

 public function move()
 {
     if (IS_POST) {
         $ContentModel = ContentModel::getInstance($this->_mid);
         //移动方式  1 从指定ID  2 从指定栏目
         $from_type = Q("post.from_type", NULL, "intval");
         //目标栏目cid
         $to_cid = Q("post.to_cid", NULL, 'intval');
         if ($to_cid) {
             switch ($from_type) {
                 case 1:
                     //移动aid
                     $aid = Q("post.aid", NULL, "trim");
                     $aid = explode("|", $aid);
                     if ($aid && is_array($aid)) {
                         foreach ($aid as $id) {
                             if (is_numeric($id)) {
                                 $ContentModel->join(null)->save(array("aid" => $id, "cid" => $to_cid));
                             }
                         }
                     }
                     break;
                 case 2:
                     //来源栏目cid
                     $from_cid = Q("post.from_cid", NULL, 'intval');
                     if ($from_cid) {
                         foreach ($from_cid as $d) {
                             if (is_numeric($d)) {
                                 $ContentModel->join(null)->where("cid={$d}")->save(array("cid" => $to_cid));
                             }
                         }
                     }
                     break;
             }
         }
         $this->success('移动成功!');
     } else {
         $category = array();
         foreach ($this->_category as $n => $v) {
             //排除非本模型或外部链接类型栏目或单文章栏目
             if ($v['mid'] != $this->_mid || $v['cattype'] == 3 || $v['cattype'] == 4) {
                 continue;
             }
             $selected = '';
             if ($this->_cid == $v['cid']) {
                 $v['selected'] = "selected";
             }
             //非本栏目模型关闭
             if ($v['cattype'] != 1) {
                 $v['disabled'] = 'disabled';
             }
             $category[$n] = $v;
         }
         $this->category = $category;
         $this->display();
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:57,代码来源:ContentControl.class.php

示例14: move

 /**
  * 移动文章
  */
 public function move()
 {
     if (IS_POST) {
         $ContentModel = ContentModel::getInstance($this->mid);
         //移动方式  1 从指定ID  2 从指定栏目
         $from_type = Q("post.from_type", 0, "intval");
         //目标栏目cid
         $to_cid = Q("post.to_cid", 0, 'intval');
         if ($to_cid) {
             switch ($from_type) {
                 case 1:
                     //移动aid
                     $aid = Q("post.aid", 0, "trim");
                     $aid = explode("|", $aid);
                     if ($aid && is_array($aid)) {
                         foreach ($aid as $id) {
                             if (is_numeric($id)) {
                                 $ContentModel->save(array("aid" => $id, "cid" => $to_cid));
                             }
                         }
                     }
                     break;
                 case 2:
                     //来源栏目cid
                     $from_cid = Q("post.from_cid", 0);
                     if ($from_cid) {
                         foreach ($from_cid as $d) {
                             if (is_numeric($d)) {
                                 $table = $this->model[$this->category[$d]['mid']]['table_name'];
                                 M($table)->where("cid={$d}")->save(array("cid" => $to_cid));
                             }
                         }
                     }
                     break;
             }
             $this->success('移动成功!');
         } else {
             $this->error('请选择目录栏目');
         }
     } else {
         $category = array();
         foreach ($this->category as $n => $v) {
             //排除非本模型或外部链接类型栏目或单文章栏目
             if ($v['mid'] != $this->mid || $v['cattype'] == 3 || $v['cattype'] == 4) {
                 continue;
             }
             if ($this->cid == $v['cid']) {
                 $v['selected'] = "selected";
             }
             //封面栏目
             if ($v['cattype'] == 2) {
                 $v['disabled'] = 'disabled';
             }
             $category[$n] = $v;
         }
         $this->assign('category', $category);
         $this->display();
     }
 }
开发者ID:suhanyujie,项目名称:spider,代码行数:62,代码来源:ContentController.class.php

示例15: batch_show

 /**
  * 根据id批量生成内容页 
  */
 public function batch_show()
 {
     if (IS_POST) {
         $catid = intval($_GET['catid']);
         if (!$catid) {
             $this->error("栏目ID不能为空!");
         }
         $modelid = getCategory($catid, 'modelid');
         $setting = getCategory($catid, 'setting');
         $content_ishtml = $setting['content_ishtml'];
         if ($content_ishtml) {
             //主表名
             $table_name = ucwords($this->model[$modelid]['tablename']);
             if (empty($table_name)) {
                 $this->error("模型不存在!");
             }
             $this->db = ContentModel::getInstance($modelid);
             if (empty($_POST['ids'])) {
                 $this->error("您没有勾选信息!");
             }
             import('Html');
             $this->html = get_instance_of('Html');
             $ids = implode(',', $_POST['ids']);
             $where = array();
             $where['catid'] = array("EQ", $catid);
             $where['id'] = array("IN", $ids);
             $where['status'] = array("EQ", 99);
             $rs = $this->db->relation(true)->where($where)->select();
             foreach ($rs as $r) {
                 $this->db->dataMerger($r);
                 if ($r['islink']) {
                     continue;
                 }
                 if ($r['status'] != 99) {
                     continue;
                 }
                 $this->html->show($r, 0, 'edit');
             }
             $this->success("生成成功!");
         } else {
             $this->error("该栏目无需生成!");
         }
     } else {
         $catid = intval($_GET['catid']);
         if (!$catid) {
             $this->error("栏目ID不能为空!");
         }
         $modelid = getCategory($catid, 'modelid');
         $setting = getCategory($catid, 'setting');
         $content_ishtml = $setting['content_ishtml'];
         if ($content_ishtml) {
             //主表名
             $table_name = ucwords($this->model[$modelid]['tablename']);
             if (empty($table_name)) {
                 $this->error("模型不存在!");
             }
             $this->db = ContentModel::getInstance($modelid);
             if (empty($_GET['ids'])) {
                 $this->error("您没有勾选信息!");
             }
             import('Html');
             $this->html = get_instance_of('Html');
             $ids = (int) $_GET['ids'];
             $where = array();
             $where['catid'] = array("EQ", $catid);
             $where['id'] = array("EQ", $ids);
             $where['status'] = array("EQ", 99);
             $r = $this->db->relation(true)->where($where)->find();
             //数据处理,把关联查询的结果集合并
             $this->db->dataMerger($r);
             if ($r['status'] != 99) {
                 $this->error("该信息未审核!无需生成");
             }
             if ($r['islink']) {
                 $this->error("链接文章无需生成!");
             } else {
                 $this->html->show($r, 0, 'edit');
             }
             $this->success("生成成功!");
         } else {
             $this->error("该栏目无需生成!");
         }
     }
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:87,代码来源:CreatehtmlAction.class.php


注:本文中的ContentModel::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。