本文整理汇总了PHP中Tags::createTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::createTags方法的具体用法?PHP Tags::createTags怎么用?PHP Tags::createTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::createTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTagsToStream
public function addTagsToStream(array $tagNames, $stream)
{
if ($stream instanceof Zend_Db_Table_Row) {
$streamId = $stream->id;
}
$streamId = $stream;
// Remove all references
$this->deleteByStreamId($streamId);
$tags = array();
$tagTabel = new Tags();
if (!empty($tagNames)) {
$tags = $tagTabel->createTags($tagNames);
foreach ($tags as $tagRow) {
try {
$taggedRow = $this->createRow(array('tag_id' => $tagRow->id, 'stream_id' => $streamId));
$taggedRow->save();
} catch (Exception $e) {
}
}
}
return $tags;
}
示例2: updateAction
public function updateAction()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->identity = $auth->getIdentity();
}
if (!$this->identity->id) {
$this->_redirect('/user/login');
}
$id = $this->_request->getParam('id');
$modelBlog = new Page();
$formBlog = new Form_Blog();
if ($this->getRequest()->isPost()) {
if ($formBlog->isValid($_POST)) {
$blogData = $formBlog->getValues();
$blogData['uid'] = $this->identity->id;
$blogData['type'] = 'now';
$blogData['createtime'] = time();
$tags = str_replace(",", ",", $blogData['tags']);
unset($blogData['tags']);
unset($blogData['提交']);
$updateBlog = $modelBlog->updatePage($id, $blogData);
if ($updateBlog) {
if ($tags != null) {
$modelTags = new Tags();
$modelTags->deleteTags($id);
// 清空原tags
$modelTags->createTags($updateBlog, $tags);
$modelTagsTotal = new TagsTotal();
$arrTags = explode(",", $tags);
if (count($arrTags) > 0) {
foreach ($arrTags as $value) {
$modelTagsTotal->cutTag($value);
// 从total中减去
$modelTagsTotal->createTag($value);
//重新创建
}
} else {
$modelTagsTotal->createTag($tags);
}
}
$this->_redirect('blog/view/id/' . $updateBlog);
}
}
} else {
$blog = $modelBlog->getPage($id);
if ($this->identity->id != $blog->uid) {
echo "你不是本博客的作者,不能对本博客进行编辑操作。";
exit;
}
$arrBlog = $blog->toArray();
// 该blog的tags
$modelTags = new Tags();
$where = array('blog_id' => $id);
$tags = $modelTags->getTags($where);
if (count($tags) > 0) {
$strTags = '';
foreach ($tags as $tag) {
$strTags .= $tag->tag . ",";
}
$strTags = rtrim($strTags, ",");
}
$arrBlog['tags'] = $strTags;
$formBlog->populate($arrBlog);
}
$this->view->formBlog = $formBlog;
// $this->_helper->cache(array('index', 'view'), array('gook'));
}