コード例 #1
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);
}
コード例 #2
0
 /**
  * 获取子文档列表 Document_
  * @param   array|num  $modelid  模型ID
  * @return  array                子模型列表
  */
 public static function get_sublist($modelid)
 {
     $model_id = is_array($modelid) ? $modelid[0] : $modelid;
     $model_title = get_document_model($model_id);
     $sublist = array();
     $newsublist = array();
     $sublist = M('Document' . ucfirst($model_title['name']))->select();
     //读取附属全部字段
     foreach ($sublist as $key => $value) {
         $newsublist[$value['id']] = $value;
         unset($newsublist[$value['id']]['id']);
     }
     return $newsublist;
 }
コード例 #3
0
 public function detail($id = 0, $p = 1)
 {
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->error('文档ID错误!');
     }
     /* 页码检测 */
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     /* 获取详细信息 */
     $Document = D('Document');
     $info = $Document->detail($id);
     if (!$info) {
         $this->error($Document->getError());
     }
     /* 分类信息 */
     $category = $this->category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     $Document->where($map)->setInc('view');
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     $Catelist = D('category');
     $cateList = $Catelist->getTree(2, false);
     $this->assign('cateList', $cateList);
     // 分类树
     $this->display();
 }
コード例 #4
0
 public function detail($id = 0, $p = 1)
 {
     if (!($id && is_numeric($id))) {
         $this->error('文档ID错误!');
     }
     $Document = D('Document');
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     $Document = D('Document');
     $info = $Document->detail($id);
     if (!$info) {
         $this->error($Document->getError());
     }
     if (!trim($info['content'])) {
         header("Location:" . U("Index/index"));
     }
     $category = $this->category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     $Document->where($map)->setInc('view');
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     $this->display($tmpl);
 }
コード例 #5
0
 /**
  * 获取扩展模型对象
  * @param  integer $model 模型编号
  * @return object         模型对象
  */
 private function logic($model)
 {
     return D(get_document_model($model, 'name'), 'Logic');
 }
コード例 #6
0
						<?php 
        if (is_array($model)) {
            $i = 0;
            $__LIST__ = $model;
            if (count($__LIST__) == 0) {
                echo "";
            } else {
                foreach ($__LIST__ as $key => $vo) {
                    $mod = $i % 2;
                    ++$i;
                    ?>
<li><a href="<?php 
                    echo U('article/add', array('cate_id' => $cate_id, 'model_id' => $vo, 'pid' => I('pid', 0), 'group_id' => $group_id));
                    ?>
"><?php 
                    echo get_document_model($vo, 'title');
                    ?>
</a></li><?php 
                }
            }
        } else {
            echo "";
        }
        ?>
					</ul><?php 
    }
    ?>
				<?php 
} else {
    ?>
					<button class="btn disabled" >新 增
コード例 #7
0
 public function detail($id = 0, $p = 1)
 {
     /* 热词调用*/
     $hotsearch = C('HOT_SEARCH');
     $this->assign('hotsearch', $hotsearch);
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->error('不存在该商品!');
     }
     /* 获取详细信息 */
     $Document = D('Document');
     $info = $Document->detail($id);
     if (!$info) {
         $this->error($Document->getError());
     }
     /* 分类信息 */
     $category = $this->category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     $Document->where($map)->setInc('view');
     /*内容页统计代码实现,tag=3*/
     if (1 == C('IP_TONGJI')) {
         $record = IpLookup("", 3, $id);
     }
     /**获取商品所有评论**/
     $comment = M('comment');
     $count = $comment->where("status='1' and goodid='{$id}'")->count();
     //计算记录数
     $this->assign('count', $count);
     $limitRows = 5;
     // 设置每页记录数
     $p = new \Think\AjaxPage($count, $limitRows, "comment");
     //第三个参数是你需要调用换页的ajax函数名
     $limit_value = $p->firstRow . "," . $p->listRows;
     $data = $comment->where("status='1' and goodid='{$id}'")->order('id desc')->limit($limit_value)->select();
     // 查询数据
     $page = $p->show();
     // 产生分页信息,AJAX的连接在此处生成
     $this->assign('list', $data);
     $this->assign('page', $page);
     /**获取商品所有好评**/
     $comment = M('comment');
     $countbetter = $comment->where("status='1' and goodid='{$id}' and score='3'")->count();
     //计算记录数
     $this->assign('countbetter', $countbetter);
     $limitRowsbetter = 5;
     // 设置每页记录数
     $pbetter = new \Think\AjaxPage($countbetter, $limitRowsbetter, "commentgood");
     //第三个参数是你需要调用换页的ajax函数名
     $limitbetter = $pbetter->firstRow . "," . $pbetter->listRows;
     $listbetter = $comment->where("status='1' and goodid='{$id}' and score='3'")->order('id desc')->limit($limitbetter)->select();
     // 查询数据
     $pagebetter = $pbetter->show();
     // 产生分页信息,AJAX的连接在此处生成
     $this->assign('listbetter', $listbetter);
     $this->assign('pagebetter', $pagebetter);
     /**获取商品所有中评**/
     $comment = M('comment');
     $countmiddle = $comment->where("status='1' and goodid='{$id}' and score='2'")->count();
     //计算记录数
     $this->assign('countmiddle ', $countmiddle);
     $limitRows = 5;
     // 设置每页记录数
     $pmiddle = new \Think\AjaxPage($countmiddle, $limitRows, "commentmiddle");
     //第三个参数是你需要调用换页的ajax函数名
     $limitmiddle = $pmiddle->firstRow . "," . $pmiddle->listRows;
     $datamiddle = $comment->where("status='1' and goodid='{$id}' and score='2'")->order('id desc')->limit($limitmiddle)->select();
     // 查询数据
     $pagemiddle = $pmiddle->show();
     // 产生分页信息,AJAX的连接在此处生成
     $this->assign('listmiddle', $datamiddle);
     $this->assign('pagemiddle', $pagemiddle);
     /**获取商品所有差评**/
     $comment = M('comment');
     $countworse = $comment->where("status='1' and goodid='{$id}' and score='1'")->count();
     //计算记录数
     $this->assign('countworse ', $countworse);
     $limitRows = 5;
     // 设置每页记录数
     $pworse = new \Think\AjaxPage($countworse, $limitRows, "commentworse");
     //第三个参数是你需要调用换页的ajax函数名
     $limitworse = $pworse->firstRow . "," . $pworse->listRows;
     $dataworse = $comment->where("status='1' and goodid='{$id}' and score='1'")->order('id desc')->limit($limitworse)->select();
     // 查询数据
     $pageworse = $pworse->show();
     // 产生分页信息,AJAX的连接在此处生成
     $this->assign('listworse', $dataworse);
     $this->assign('pageworse', $pageworse);
     /** 好评率 **/
     $rate = $countbetter / $count * 100;
     $this->assign('rate', $rate);
     /** 咨询管理 **/
     $message = M("message");
     $reply = M("reply");
     $countmessage = $message->where(" goodid='{$id}'")->count();
     $Pagequestion = new \Think\AjaxPage($countmessage, 5, "quest");
     $limitquestion = $Pagequestion->firstRow . "," . $Pagequestion->listRows;
     $showquestion = $Pagequestion->show();
     $listquestion = $message->where("goodid='{$id}'")->order('id desc')->limit($limitquestion)->select();
     foreach ($listquestion as $n => $val) {
         $listquestion[$n]['id'] = $reply->where('messageid=\'' . $val['id'] . '\'')->select();
     }
     $this->assign('listquestion', $listquestion);
     // 赋值数据集
     $this->assign('pagequestion', $showquestion);
     //
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->meta_title = $info["title"];
     $this->display($tmpl);
 }
コード例 #8
0
        }
    }
    ?>
            </div><?php 
}
?>
            <!-- nav -->
            

            
	<script type="text/javascript" src="/Public/static/uploadify/jquery.uploadify.min.js"></script>
	<script type="text/javascript" src="/Public/static/UploadImages.js"></script>
<div class="main-title cf">
		<h2>
			编辑<?php 
echo get_document_model($data["model_id"], 'title');
?>
 [
			<?php 
if (is_array($rightNav)) {
    $i = 0;
    $__LIST__ = $rightNav;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $nav) {
            $mod = $i % 2;
            ++$i;
            ?>
<a href="<?php 
            echo U('goods/index', 'cate_id=' . $nav['id']);
コード例 #9
0
 /**
  * 合并分类
  * @author huajie <*****@*****.**>
  */
 public function merge()
 {
     $to = I('post.to');
     $from = I('post.from');
     $Model = M('Category');
     //检查分类绑定的模型
     $from_models = explode(',', $Model->getFieldById($from, 'model'));
     $to_models = explode(',', $Model->getFieldById($to, 'model'));
     foreach ($from_models as $value) {
         if (!in_array($value, $to_models)) {
             $this->error('请给目标分类绑定' . get_document_model($value, 'title') . '模型');
         }
     }
     //检查分类选择的文档类型
     $from_types = explode(',', $Model->getFieldById($from, 'type'));
     $to_types = explode(',', $Model->getFieldById($to, 'type'));
     foreach ($from_types as $value) {
         if (!in_array($value, $to_types)) {
             $types = C('DOCUMENT_MODEL_TYPE');
             $this->error('请给目标分类绑定文档类型:' . $types[$value]);
         }
     }
     //合并文档
     $res = M('Document')->where(array('category_id' => $from))->setField('category_id', $to);
     if ($res !== false) {
         //删除被合并的分类
         $Model->delete($from);
         $this->success('合并分类成功!', U('index'));
     } else {
         $this->error('合并分类失败!');
     }
 }
コード例 #10
0
 public function detail($id = 0, $p = 1)
 {
     /* 热词调用*/
     $hotsearch = R("Index/getHotsearch");
     $this->assign('hotsearch', $hotsearch);
     /* 购物车调用*/
     $cart = R("Shopcart/usercart");
     $this->assign('usercart', $cart);
     if (!session('user_auth')) {
         $usercart = $_SESSION['cart'];
         $this->assign('usercart', $usercart);
     }
     /* 左侧分类列表*/
     $mlist = R('Index/menulist');
     $this->assign('categoryq', $mlist);
     /* 浏览量排行前7个商品*/
     $view = M('Document')->where("display=1")->order("view desc")->select();
     $this->assign('viewlist', $view);
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->error('文档ID错误!');
     }
     /* 页码检测 */
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     /* 获取详细信息 */
     $Document = D('Document');
     $info = $Document->detail($id);
     if (!$info) {
         $this->error($Document->getError());
     }
     /* 分类信息 */
     $category = $this->category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     $Document->where($map)->setInc('view');
     /*内容页统计代码实现,tag=3*/
     if (1 == C('IP_TONGJI')) {
         $record = IpLookup("", 3, $id);
     }
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     $this->display($tmpl);
 }
コード例 #11
0
 /**
  * 获取分类的推荐列表
  * @param  num $cateid   文档分类ID
  * @param  num $pos      推荐位置ID
  * @param  num $limit    限制条数
  * @param  sting $order  排序顺序
  * @return array         推荐列表文档
  */
 public static function get_position($cateid, $pos, $limit, $order)
 {
     if (empty($cateid)) {
         return false;
     } else {
         $category = get_category($cateid);
         //判断该分类是否为顶级  是 读取顶级下所有的子分类id
         if ($category['pid'] == 0) {
             $list = M('Category')->where(array('pid' => $cateid, 'status' => 1))->order('create_time desc')->field('id')->select();
             foreach ($list as $key => $value) {
                 $categoryid[] = $value['id'];
             }
             $top = $cateid;
         } else {
             $categoryid = $cateid;
             $top = self::get_pid($cateid);
         }
         //表数据模型
         $model_info = get_document_model($category['model']);
         $submodel = M('Document' . ucfirst($model_info['name']));
         $map['status'] = 1;
         if (is_numeric($categoryid)) {
             $map['category_id'] = $categoryid;
         } else {
             $map['category_id'] = array('in', $categoryid);
         }
         $pos = empty($pos) ? 0 : $pos;
         if (strpos($pos, ',') !== false) {
             $map['position'] = array('in', $pos);
         }
         $map['create_time'] = array('lt', NOW_TIME);
         $map['_string'] = 'deadline = 0 OR deadline > ' . NOW_TIME;
         $limit = empty($limit) ? 6 : $limit;
         $order = empty($order) ? 'level desc,create_time desc' : $order;
         //先读取基础数据
         $newlist = array();
         $lists = M('Document')->where($map)->order($order)->limit($limit)->select();
         //拓展数据合并
         foreach ($lists as $key => $value) {
             $subinfo = array();
             $subinfo = $submodel->where(array('id' => $value['id']))->find();
             if (!empty($subinfo)) {
                 $newlist[$key] = array_merge($value, $subinfo);
             }
         }
         return $newlist;
     }
 }
コード例 #12
0
 public function edit($category = null, $model = null, $id = 0)
 {
     $this->login();
     //用户登录检测
     //TODO: 管理员权限检测,目前测试阶段不做限制
     /* 参数正确性检测 */
     if ((empty($id) || !is_numeric($id)) && (empty($category) || empty($model))) {
         $this->error('缺少参数!');
     }
     /* 获取被编辑的数据 */
     $info = array();
     if ($id) {
         /* 获取详细信息 */
         $Document = D('Document');
         $info = $Document->detail($id);
         if (!$info) {
             $this->error($Document->getError());
         }
         $category = $info['category_id'];
         $model = $info['model'];
     }
     /* 获取当前分类信息 */
     $category = D('Category')->info($category);
     if (0 == $category['allow_publish']) {
         $this->error('该分类禁止发布内容!');
     }
     /* 验证绑定模型 */
     if (in_array($model, $category['model'])) {
         $info['model_id'] = $model;
     } else {
         $this->error("该分类没有绑定模型:id-{$model}");
     }
     /* 获取模板 */
     if (empty($category['template_edit'])) {
         $model = get_document_model($model, 'name');
         $tmpl = "Article/{$model}/edit";
     } else {
         $tmpl = $category['template_edit'];
     }
     /* 模板赋值并渲染模板 */
     $this->assign('info', $info);
     $this->assign('category', $category);
     $this->display($tmpl);
 }
コード例 #13
0
            $i = $i + 1;
        }
    }
    ?>
            </div><?php 
}
?>
            <!-- nav -->
            

            
	<script type="text/javascript" src="/Public/static/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title cf">
		<h2>
			新增<?php 
echo get_document_model($info["model_id"], 'title');
?>
 [
			<?php 
if (is_array($rightNav)) {
    $i = 0;
    $__LIST__ = $rightNav;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $nav) {
            $mod = $i % 2;
            ++$i;
            ?>
<a href="<?php 
            echo U('article/index', 'cate_id=' . $nav['id']);
コード例 #14
0
ファイル: laravel.php プロジェクト: wmk223/amango_V3
function get_sorceDetail($cateid, $id)
{
    $readfields = D('Flycloud')->where(array('data_type' => 'category', 'data_table' => $cateid))->find();
    $fields = explode(',', $readfields['data_fields']);
    if (!empty($id)) {
        /*获取一条记录的详细数据*/
        // $document = D('Document');
        // $data = $document->detail($id);
        $info = D('Document')->field(true)->find($id);
        $aimtable = get_document_model($info['model_id'], 'name');
        $detail = D('Document' . ucfirst($aimtable))->field(true)->find($id);
        $data = array_merge($info, $detail);
        foreach ($fields as $value) {
            $newdata[] = $data[$value];
        }
        if (is_numeric($newdata[1])) {
            $url = D('Picture')->where(array('id' => $newdata[1]))->getField('path');
            $newdata[1] = base64_encode(str_replace('\\/', '/', false !== strpos($url, 'http://') ? $url : HEAD_URL . __ROOT__ . $url));
        }
        return $newdata;
    }
}
コード例 #15
0
 public function detail($id = 0, $p = 1)
 {
     global $_K;
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->error('文档ID错误!');
     }
     /* 页码检测 */
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     /* 获取详细信息 */
     $info = api('Document/get_detail', array('id' => $id));
     if (false === $info['status']) {
         $this->error($info['info']);
     }
     //芒果用户回复
     $this->assign('model_id', $info['model_id']);
     $model = get_document_model($info['model_id']);
     $fields = get_model_attribute($model['id']);
     $newfields = array();
     foreach ($fields[1] as $k => $v) {
         if ($v['reply_show'] == 1) {
             $newfields[] = $v;
         }
     }
     /* 分类信息 */
     $category = $this->category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     D('Document')->where($map)->setInc('view');
     /* 芒果微信分享信息   */
     $shareurl = Amango_U('Article/detail?id=' . $id);
     $biaoshi = $info['title'] . "来自:" . C('WEB_SITE_TITLE');
     $Shareinfo = array('ImgUrl' => get_cover_pic($info['cover_id']), 'TimeLink' => $shareurl, 'FriendLink' => $shareurl, 'WeiboLink' => $shareurl, 'tTitle' => $biaoshi, 'tContent' => $biaoshi, 'fTitle' => $biaoshi, 'fContent' => $biaoshi, 'wContent' => $biaoshi);
     $this->assign('Share', $Shareinfo);
     //是否允许发表新
     $this->assign('reply', $category['reply']);
     $this->assign('reply_show', $category['reply_show']);
     $this->assign('fields', $newfields);
     //一键关注链接
     $this->assign('accountsub', $_K['DEFAULT']['account_sub']);
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     //公共title
     $this->assign('Title', $info['title']);
     $this->display($tmpl);
 }
コード例 #16
0
 public function detail($id = 0, $p = 1)
 {
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->service_error(L('_DOC_ID_ERROR_'));
     }
     /* 页码检测 */
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     /* 获取详细信息 */
     $Document = D('Document');
     $info = $Document->detail($id);
     if (!$info) {
         $this->service_error($Document->getError());
     }
     /* 分类信息 */
     $category = $this->_category($info['category_id']);
     /* 获取模板 */
     if (!empty($info['template'])) {
         //已定制模板
         $tmpl = $info['template'];
     } elseif (!empty($category['template_detail'])) {
         //分类已定制模板
         $tmpl = $category['template_detail'];
     } else {
         //使用默认模板
         $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail';
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     $Document->where($map)->setInc('view');
     S('SEO_ARTICLE', $info);
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     $this->display($tmpl);
 }
コード例 #17
0
 /**
  * 文档编辑页面初始化
  * @author huajie <*****@*****.**>
  */
 public function edit()
 {
     //获取左边菜单
     $this->getMenu(array('elt', 1));
     $id = I('get.id', '');
     if (empty($id)) {
         $this->error('参数不能为空!');
     }
     // 获取详细数据
     $Document = D('Document');
     $data = $Document->detail($id);
     if (!$data) {
         $this->error($Document->getError());
     }
     if ($data['pid']) {
         // 获取上级文档
         $article = $Document->field('id,title,type')->find($data['pid']);
         $this->assign('article', $article);
     }
     // 获取当前的模型信息
     $model = get_document_model($data['model_id']);
     $this->assign('data', $data);
     $this->assign('model_id', $data['model_id']);
     $this->assign('model', $model);
     //获取表单字段排序
     $fields = get_model_attribute($model['id']);
     $this->assign('fields', $fields);
     //获取当前分类的文档类型
     $this->assign('type_list', get_type_bycate($data['category_id']));
     $this->meta_title = '编辑文档';
     $this->display();
 }
コード例 #18
0
            echo $list["title"];
            ?>
								</label><?php 
        }
    }
} else {
    echo "";
}
?>
						</div>
					</div>
					<div class="form-item">
						<label class="item-label">子文档绑定绑定模型<span class="check-tips">(子文档支持发布的文档模型)</span></label>
						<div class="controls">
							<?php 
$_result = get_document_model();
if (is_array($_result)) {
    $i = 0;
    $__LIST__ = $_result;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $list) {
            $mod = $i % 2;
            ++$i;
            ?>
<label class="checkbox">
									<input type="checkbox" name="model_sub[]" value="<?php 
            echo $list["id"];
            ?>
"><?php 
コード例 #19
0
 /**
  * 粘贴文档
  * @author huajie <*****@*****.**>
  */
 public function paste()
 {
     $moveList = session('moveArticle');
     $copyList = session('copyArticle');
     if (empty($moveList) && empty($copyList)) {
         $this->error('没有选择文档!');
     }
     if (!isset($_POST['cate_id'])) {
         $this->error('请选择要粘贴到的分类!');
     }
     $cate_id = I('post.cate_id');
     //当前分类
     $pid = I('post.pid', 0);
     //当前父类数据id
     //检查所选择的数据是否符合粘贴要求
     $check = $this->checkPaste(empty($moveList) ? $copyList : $moveList, $cate_id, $pid);
     if (!$check['status']) {
         $this->error($check['info']);
     }
     if (!empty($moveList)) {
         // 移动    TODO:检查name重复
         foreach ($moveList as $key => $value) {
             $Model = D('Document');
             $map['id'] = $value;
             $data['category_id'] = $cate_id;
             $data['pid'] = $pid;
             //获取root
             if ($pid == 0) {
                 $data['root'] = 0;
             } else {
                 $p_root = $Model->getFieldById($pid, 'root');
                 $data['root'] = $p_root == 0 ? $pid : $p_root;
             }
             $res = $Model->where($map)->save($data);
         }
         session('moveArticle', null);
         if (false !== $res) {
             $this->success('文档移动成功!');
         } else {
             $this->error('文档移动失败!');
         }
     } elseif (!empty($copyList)) {
         // 复制
         foreach ($copyList as $key => $value) {
             $Model = D('Document');
             $data = $Model->find($value);
             unset($data['id']);
             unset($data['name']);
             $data['category_id'] = $cate_id;
             $data['pid'] = $pid;
             $data['create_time'] = NOW_TIME;
             $data['update_time'] = NOW_TIME;
             //获取root
             if ($pid == 0) {
                 $data['root'] = 0;
             } else {
                 $p_root = $Model->getFieldById($pid, 'root');
                 $data['root'] = $p_root == 0 ? $pid : $p_root;
             }
             $result = $Model->add($data);
             if ($result) {
                 $logic = M(get_document_model($data['model_id'], 'name'), 'Logic');
                 $data = $logic->detail($value);
                 //获取指定ID的扩展数据
                 $data['id'] = $result;
                 $res = $logic->add($data);
             }
         }
         session('copyArticle', null);
         if ($res) {
             $this->success('文档复制成功!');
         } else {
             $this->error('文档复制失败!');
         }
     }
 }
コード例 #20
0
 public function detail($id = 0, $p = 1)
 {
     global $_K;
     /* 标识正确性检测 */
     if (!($id && is_numeric($id))) {
         $this->error('文档ID错误!');
     }
     /* 页码检测 */
     $p = intval($p);
     $p = empty($p) ? 1 : $p;
     /* 获取详细信息 */
     $info = api('Document/get_detail', array('id' => $id));
     if (false === $info['status']) {
         $this->error($info['info']);
     }
     //芒果用户回复
     $this->assign('model_id', $info['model_id']);
     $model = get_document_model($info['model_id']);
     $fields = get_model_attribute($model['id']);
     $newfields = array();
     foreach ($fields[1] as $k => $v) {
         if ($v['reply_show'] == 1) {
             $newfields[] = $v;
         }
     }
     $logicname = get_document_model($info['model_id'], 'name');
     /* 分类信息 */
     $category = $this->category($info['category_id']);
     $tmpl = $info['template'];
     if (empty($tmpl)) {
         $tmpl = empty($category['template_detail']) ? get_category($category['pid'], 'template_detail') : $category['template_detail'];
         if (empty($tmpl)) {
             $tmpl = 'Article/' . $logicname . '/detail';
         }
     }
     /* 更新浏览数 */
     $map = array('id' => $id);
     D('Document')->where($map)->setInc('view');
     /* 芒果微信分享信息   */
     $this->setShare($info['cover_id'], U('Article/detail', array('id' => $id), '', TRUE), $info['title'], $info['description']);
     //是否允许发表新
     $this->assign('reply', $category['reply']);
     $this->assign('reply_show', $category['reply_show']);
     $this->assign('fields', $newfields);
     //一键关注链接
     $this->assign('accountsub', $_K['DEFAULT']['account_sub']);
     /* 模板赋值并渲染模板 */
     $this->assign('category', $category);
     $this->assign('category_id', $category['id']);
     $this->assign('info', $info);
     $this->assign('page', $p);
     //页码
     //公共title
     $this->assign('Title', $info['title']);
     $this->assign('HideFastmenu', '1');
     $this->display($tmpl);
 }