/** * 删除内容 * @param $id 内容id * @param $catid 栏目id */ public function delete($id, $catid) { if (false == require_cache(RUNTIME_PATH . 'content_delete.class.php')) { D("Category")->category_cache(); D("Content_cache")->model_content_cache(); require RUNTIME_PATH . 'content_delete.class.php'; } $this->catid = (int) $catid; //模型ID $this->modelid = getCategory($this->catid, 'modelid'); if (getCategory($this->catid) == false) { $this->error = '获取不到栏目信息!'; return false; } //栏目配置信息 $setting = getCategory($this->catid, 'setting'); //内容页是否生成静态 $content_ishtml = $setting['content_ishtml']; $this->contentModel = ContentModel::getInstance($this->modelid); $data = $this->contentModel->relation(true)->where(array("id" => $id))->find(); if (empty($data)) { $this->error = '该信息不存在!'; return false; } $this->contentModel->dataMerger($data); tag('content_delete_begin', $data); if ($content_ishtml && !$data['islink']) { $this->deleteHtml($this->catid, $id, $data['inputtime'], $data['prefix'], $data); } //删除内容 $this->contentModel->relation(true)->where(array('id' => $id))->delete(); //调用 content_delete $content_update = new content_delete($this->modelid); $content_update->get($data); //删除评论 $comment_id = "c-{$this->catid}-{$id}"; D('Comments')->deleteCommentsMark($comment_id); //删除附件 $Attachment = service("Attachment"); $Attachment->api_delete('c-' . $this->catid . '-' . $id); //删除全站搜索数据 $this->search_api($id, $data, "delete"); //删除推荐位的信息 if (!empty($data['posid'])) { D('Position_data')->deleteByModeId($this->modelid, $id); } //标签 tag("content_delete_end", $data); return true; }
/** * 删除信息 * @param type $id 数组/信息id * @param type $catid 栏目id * @return boolean */ public function delete($id = '', $catid = '') { if (empty($id) || empty($catid)) { if (!empty($this->data)) { $data = $this->data; $id = $data['id']; $this->catid = $catid = $data['catid']; //模型ID $this->modelid = getCategory($this->catid, 'modelid'); // 重置数据 $this->data = array(); } else { $this->error = L('_DATA_TYPE_INVALID_'); return false; } } else { if (is_array($id)) { $data = $id; $id = $data['id']; $this->catid = $catid = $data['catid']; //模型ID $this->modelid = getCategory($this->catid, 'modelid'); } else { $this->catid = $catid; //模型ID $this->modelid = getCategory($this->catid, 'modelid'); $model = ContentModel::getInstance($this->modelid); $data = $model->relation(true)->where(array('id' => $id))->find(); } } ContentModel::getInstance($this->modelid)->dataMerger($data); if (getCategory($this->catid) == false) { $this->error = '获取不到栏目信息!'; return false; } //栏目配置信息 $setting = getCategory($this->catid, 'setting'); //内容页是否生成静态 $content_ishtml = $setting['content_ishtml']; if (empty($data)) { $this->error = '该信息不存在!'; return false; } tag('content_delete_begin', $data); if ($content_ishtml && !$data['islink']) { $this->data($data)->deleteHtml(); } //调用 content_delete $content_update = new \content_delete($this->modelid); $content_update->get($data); //删除内容 ContentModel::getInstance($this->modelid)->relation(true)->where(array('id' => $id))->delete(); //删除附件 $Attachment = service('Attachment'); $Attachment->api_delete('c-' . $this->catid . '-' . $id); //删除推荐位的信息 if (!empty($data['posid'])) { D('Content/PositionData')->deleteByModeId($this->modelid, $id); } //标签 tag('content_delete_end', $data); return true; }