/** * * 保存添加的话题 */ public function doaddAction() { $tag = $this->getInput('tag'); if (!$tag['name']) { $this->showError('Tag:tagname.empty'); } if ($this->_getTagDs()->getTagByName($tag['name'])) { $this->showError("话题{$tag['name']}已存在"); } $tag = $this->getInput('tag'); $logo = $this->uploadLogo(); $dm = new PwTagDm(); $dm->setName($tag['name'])->setTagLogo($logo)->setTypeId(PwTag::TYPE_THREAD_TOPIC)->setIfhot(1)->setCreateUid($this->loginUser->uid)->setExcerpt($tag['excerpt'])->setSeoTitle($tag['seo_title'])->setSeoDescript($tag['seo_description'])->setSeoKeywords($tag['seo_keywords']); $logo && $dm->setIflogo(1); if (is_numeric($tagId = $this->_getTagDs()->addTag($dm))) { // 话题内容关系 $tag['category'] && $this->_getTagCateGoryDs()->addCategoryRelations($tagId, $tag['category']); //关联话题 if ($tag['relate_tags']) { $tagNames = explode(',', $tag['relate_tags']); foreach ($tagNames as $v) { $this->_addRelateTag($tagId, $v); } } $this->_deleteHotTagCache(); $this->showMessage('话题添加成功!'); } else { if ($tagId instanceof PwError) { $this->showError($tagId->getError()); } $this->showError('话题添加失败!'); } }