本文整理汇总了PHP中Tags::countObjectsByTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::countObjectsByTag方法的具体用法?PHP Tags::countObjectsByTag怎么用?PHP Tags::countObjectsByTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::countObjectsByTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: project_tag
/**
* Show project objects tagged with specific tag
*
* @access public
* @param void
* @return null
*/
function project_tag()
{
$tag = array_var($_GET, 'tag');
if (trim($tag) == '') {
flash_error(lang('tag dnx'));
$this->redirectTo('project', 'tags');
}
// if
$tagged_objects = active_or_personal_project()->getObjectsByTag($tag);
$total_tagged_objects = Tags::countObjectsByTag($tag);
if (is_array($tagged_objects)) {
foreach ($tagged_objects as $type => $objects) {
if (is_array($objects)) {
$total_tagged_objects += count($objects);
}
}
// foreach
}
// if
tpl_assign('tag', $tag);
tpl_assign('tagged_objects', $tagged_objects);
tpl_assign('total_tagged_objects', $total_tagged_objects);
}
示例2: 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;
}
示例3: countObjectsByTag
/**
* Return number of project objects tagged with $tag
*
* @param string $tag
* @return integer
*/
function countObjectsByTag($tag)
{
$exclude_private = !logged_user()->isMemberOfOwnerCompany();
return Tags::countObjectsByTag($tag, $exclude_private);
}