/** * * 保存话题 */ public function doeditAction() { $tag = $this->getInput('tag'); if (!$tag['name']) { $this->showError('Tag:tagname.empty'); } $tagInfo = $this->_getTagDs()->getTag($tag['tag_id']); if (!$tagInfo) { $this->showError('话题不存在!'); } $logo = $this->uploadLogo(); $dm = new PwTagDm($tag['tag_id']); $dm->setName($tag['name'])->setExcerpt($tag['excerpt'])->setSeoTitle($tag['seo_title'])->setSeoDescript($tag['seo_description'])->setSeoKeywords($tag['seo_keywords']); if ($logo) { $dm->setTagLogo($logo)->setIflogo(1); } if ($logo && $logo != $tagInfo['tag_logo']) { Pw::deleteAttach($tagInfo['tag_logo']); } //取消原关联话题 $this->_getTagService()->removeRelatedTopic($tag['tag_id']); if ($tag['relate_tags']) { $tagInfo = $this->_getTagDs()->getTag($tag['tag_id']); $tagInfo['parent_tag_id'] && $this->showError(sprintf('话题"%s"已经有关联话题,不允许再合并关联', $tagInfo['tag_name'])); $tagNames = explode(',', $tag['relate_tags']); foreach ($tagNames as $v) { $mergeTag = $this->_getTagDs()->getTagByName($v); if ($mergeTag['parent_tag_id']) { $parentTag = $this->_getTagDs()->getTag($mergeTag['parent_tag_id']); $this->showError(sprintf('话题"%s"的关联话题为%s,不允许再合并关联', $mergeTag['tag_name'], $parentTag['tag_name'])); } $this->_addRelateTag($tag['tag_id'], $v); } } $this->_getTagCateGoryDs()->updateCategoryRelations($tag['tag_id'], $tag['category']); $result = $this->_getTagDs()->updateTag($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } $this->_deleteHotTagCache(); $this->showMessage('话题编辑成功!'); }