Add a keyword

@param string|array $keyword

@return MetaTagsContract
358952
public function addKeyword($keyword)
    {
        if (is_array($keyword)):
            $this->keywords = array_merge($keyword, $this->keywords);
        else:
            $this->keywords[] = strip_tags($keyword);
        endif;

        return $this;
    }
45581
public function attachTags($tags)
    {
        // Use 'sync' not 'attach' to avoid Integrity constraint violation
        $this->tags()->sync($this->parseTags($tags), false);

        return $this;
    }
77263
public function setKeywords(array $keywords)
    {
        // Removes old keywords
        $oldKeywords = array_filter($this->keywords->toArray(), function (Keyword $keyword) use ($keywords) {
            return !in_array($keyword, $keywords);
        });
        array_walk($oldKeywords, function (Keyword $keyword) {
            $this->removeKeyword($keyword);
        });

        // Adds new ones
        array_walk($keywords, function (Keyword $keyword) {
            $this->addKeyword($keyword);
        });
    }
1008043
protected function resolveSearchKeywords(string $keyword): array
    {
        $basic = [];
        $advanced = [];

        $tags = \array_map(function ($value) {
            [$tag, ] = \explode(':', $value, 2);

            return "{$tag}:";
        }, \array_keys($this->getSearchableRules()));

        if (\preg_match_all('/([\w]+:\"[\w\s]*\"|[\w]+:[\w\S]+|[\w\S]+)\s?/', $keyword, $keywords)) {
            foreach ($keywords[1] as $index => $keyword) {
                if (! Str::startsWith($keyword, $tags)) {
                    \array_push($basic, $keyword);
                } else {
                    \array_push($advanced, $keyword);
                }
            }
        }

        return [
            'basic' => \implode(' ', $basic),
            'advanced' => $advanced,
        ];
    }
1299627
public function setMetatags(array $metatags)
    {
        if(array_key_exists('title', $metatags)) $this->metaTitle = $metatags['title'];
        if(array_key_exists('description', $metatags)) $this->metaDescription = $metatags['description'];
        if(array_key_exists('keywords', $metatags)) $this->metaKeywords = $metatags['keywords'];

        return $this;
    }
895336
public function addKeywords($keywords) {
		if (is_string($keywords)) {
			$keywords = explode(',', $keywords);
		}
		
		foreach ($keywords as $keyword) {
			$this->addKeyword($keyword);
		}
		
		return $this;
	}
909670
public function keyword($keyword)
    {
        $this->andWhere([
            'or',
            ['and', '{{type}}=:typeMatch', '{{keyword}}=:keyword'], // 直接匹配关键字
            ['and', '{{type}}=:typeInclude', 'INSTR(:keyword, {{keyword}})>0'], // 包含关键字
            ['and', '{{type}}=:typeRegular', ':keyword REGEXP {{keyword}}'], // 正则匹配关键字
        ])
        ->addParams([
            ':keyword' => $keyword,
            ':typeMatch' => ReplyRuleKeyword::TYPE_MATCH,
            ':typeInclude' => ReplyRuleKeyword::TYPE_INCLUDE,
            ':typeRegular' => ReplyRuleKeyword::TYPE_REGULAR
        ]);
        return $this;
    }
626839
public function setMetaKeywords($keywords)
    {
        if (is_array($keywords)) {
            $keywords = implode(', ', $keywords);
        }

        return $this->addMeta(['name' => 'keywords', 'content' => e($keywords)]);
    }
1047681
public function addMeta()
    {
        foreach (func_get_args() as $meta) {
            if (is_array($meta)) {
                $this->meta += $meta;
            }
        }

        return $this;
    }
109243
public static function suggest($keyword, $limit = 20)
    {
        /** @var self[] $tags */
        $tags = self::find()
            ->where(['like', 'name', $keyword])
            ->orderBy('frequency DESC, name')
            ->limit($limit)
            ->all();

        $names = array();

        foreach ($tags as $tag) {
            $names[] = ['word' => Html::encode($tag->name)];
        }

        return $names;
    }
231820
public function removeKeyword(Keyword $keyword)
    {
        if ($this->keywords->contains($keyword)) {
            $this->keywords->removeElement($keyword);
        }
    }
255349
public function addToken($token)
    {
        if (!in_array($token, $this->tokens)) {
            $this->tokens[] = $token;
        }

        return $this;
    }
1071727
function keyword_add($keyword, $usr_id = 0) {
        $usr_id = $usr_id ? $usr_id : Me::id();
        $keyword = $this->keyword_prepare($keyword);
        $len = mb_strlen($keyword);
        if ($len > 0 && $len < 31) {
            $kwd = ORM::factory('Meerkat_Keyword')->get_or_create(
                    array(
                        'value' => $keyword
                    )
            );
            $ret[] = $keyword;
            ORM::factory('Meerkat_Object_Keyword')->get_or_create(array(
                'keyword_id' => $kwd->pk(),
                'usr_id' => $usr_id,
                'meerkat_id' => $this->pk(),
            ));
        } else {
            return false;
        }
        return $kwd->value;
    }
708392
public function keywords($keywords = [])
    {
        $args = func_get_args();

        $this->mergeKeywords = (is_bool(end($args)) || is_int(end($args))) ? array_pop($args) : false;

        $keywords = is_array($keywords) ? $keywords : $args;

        array_walk($keywords, function (&$value) {
            $value = is_object($value) ? get_class($value) : $value;
        });

        $this->keywords = array_unique($keywords);

        return $this;
    }
13240
public function addMeta(array $attributes, $group = null)
    {
        $meta = '<meta'.(new Html())->attributes($attributes).' />';

        if (is_null($group)) {
            if (isset($attributes['name'])) {
                $group = $attributes['name'];
            } else {
                $group = str_random();
            }
        }

        return $this->addTagToGroup($group, $meta);
    }
498854
private function addTagsFromNewsKeywords($tags, $newsRecord)
    {
        if (!empty($newsRecord['keywords'])) {
            $keywordsList = GeneralUtility::trimExplode(',', $newsRecord['keywords']);
            foreach ($keywordsList as $keyword) {
                SearchHelper::makeTags($tags, array($keyword));
            }
        }

        return $tags;
    }
1282822
public function addHashtag($term)
    {
        $term = trim($term);

        //@todo implement is_hashtag filter method
        if (!is_string($term)) {
            return;
        }

        if ($hashtag = $this->getService('repos:hashtags.hashtag')->findOrAddNew(array('name' => $term))) {
            $this->hashtags->insert($hashtag);

            return $this;
        }

        return;
    }