本文整理匯總了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()));
}