本文整理汇总了PHP中Tags::getTagNamesByObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::getTagNamesByObject方法的具体用法?PHP Tags::getTagNamesByObject怎么用?PHP Tags::getTagNamesByObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::getTagNamesByObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addObjectTag
/**
* Add tags for an object
*
* @access public
* @param string $tag_name tag to be added
* @param ProjectDataObject $obj
* @return null
*/
function addObjectTag($tag_name, ApplicationDataObject $obj)
{
$tag_name = trim($tag_name);
if (!(isset($obj) && $obj && $obj instanceof ApplicationDataObject)) {
return true;
}
$prevTags = Tags::getTagNamesByObject($obj);
if ($prevTags) {
foreach ($prevTags as $tag_iter) {
if (strcmp($tag_name, $tag_iter) == 0) {
return true;
}
//tag already added
}
}
if (strcmp($tag_name, '')) {
$exists = true;
if (Tags::countObjectsByTag($tag_name) <= 0) {
$exists = false;
}
$tag = new Tag();
$tag->setTag($tag_name);
$tag->setRelObjectId($obj->getId());
$tag->setRelObjectManager(get_class($obj->manager()));
$tag->setIsPrivate(false);
$tag->save();
if (!$exists) {
$real_tag = self::findById($tag->getId());
evt_add("tag added", array("name" => $real_tag->getTag()));
}
}
// if
return true;
}
示例2: getTagNames
/**
* Return tag names for this object
*
* @access public
* @param void
* @return array
*/
function getTagNames()
{
if (plugin_active('tags')) {
if (!$this->isTaggable()) {
throw new Error('Object not taggable');
}
// if
return Tags::getTagNamesByObject($this, get_class($this->manager()));
}
return array();
}
示例3: getTagNames
/**
* Return tag names for this object
*
* @access public
* @param void
* @return array
*/
function getTagNames()
{
if (!$this->isTaggable()) {
throw new Error('Object not taggable');
}
return Tags::getTagNamesByObject($this, get_class($this->manager()));
}
示例4: getTagNames
/**
* Return tag names for this object
*
* @access public
* @param void
* @return array
*/
function getTagNames()
{
if (!$this->isTaggable()) {
return array();
}
if (!is_null($this->tags)) {
$result = array();
for ($i = 0; $i < count($this->tags); $i++) {
$result[] = $this->tags[$i]->getTag();
}
return $result;
}
return Tags::getTagNamesByObject($this, get_class($this->manager()));
}