本文整理汇总了PHP中Tag::setTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::setTag方法的具体用法?PHP Tag::setTag怎么用?PHP Tag::setTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::setTag方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordTags
public static function recordTags($phrase, $model, $obj)
{
$tags = TagTools::splitPhrase($phrase);
foreach ($tags as $settag) {
$tag = new Tag();
if ($model == "etime") {
$modelTag = new EtimeTag();
} else {
$modelTag = new EventTag();
}
$tag->setTag($settag);
$c = new Criteria();
$c->add(TagPeer::NORMALIZED_TAG, $tag->getNormalizedTag());
$tag_exists = TagPeer::doSelectOne($c);
if (!$tag_exists) {
$tag->save();
} else {
$tag = $tag_exists;
}
if ($model == "etime") {
$modelTag->setEtime($obj);
} else {
$modelTag->setEvent($obj);
}
$modelTag->setTag($tag);
$modelTag->save();
}
return true;
}
示例2: controlerJob
public function controlerJob($maincont)
{
if ($maincont->isLoggued()) {
if (isset($_POST["title"])) {
$p = new Post();
$p->setTitle($_POST["title"]);
$p->setBody($_POST["body"]);
$p->setHour(date("h:i:s"));
$p->setDate(date("Y-m-d"));
// gestion des tags
$tags = explode(" ", $_POST["tags"]);
foreach ($tags as $t) {
if ($t == "") {
continue;
}
$ta = Tag::getByTag($t);
//echo "Tag : $t<br />";
if (count($ta) == 0) {
$mytag = new Tag();
$mytag->setTag($t);
} else {
$mytag = $ta[0];
}
// création du posttag liant le tag et le post
$pt = new Posttag();
$pt->setPostid($p->id);
$pt->setTagid($mytag->id);
}
}
$maincont->goModule("post", "admin");
} else {
$maincont->goModule("home", "display");
}
}
示例3: create
public function create()
{
if (isset($_POST["tag"])) {
$tag = new Tag();
$tag->setTag($_POST["tag"]);
$result_e = $tag->insert();
}
$this->redirect("Tags", "index");
}
示例4: setObjectTags
/**
* Set tags for specific object
*
* @access public
* @param array $tags Array of tags... Can be NULL or empty
* @param ProjectDataObject $object
* @param string $manager_class
* @param Project $project
* @return null
*/
function setObjectTags($tags, ProjectDataObject $object, $manager_class, $project = null)
{
self::clearObjectTags($object, $manager_class);
if (is_array($tags) && count($tags)) {
foreach ($tags as $tag_name) {
if (trim($tag_name) != '') {
$tag = new Tag();
if ($project instanceof Project) {
$tag->setProjectId($project->getId());
}
$tag->setTag($tag_name);
$tag->setRelObjectId($object->getId());
$tag->setRelObjectManager($manager_class);
$tag->setIsPrivate($object->isPrivate());
$tag->save();
}
// if
}
// foreach
}
// if
return true;
}
示例5: setObjectTags
/**
* Set tags for specific object
*
* @access public
* @param array $tags Array of tags... Can be NULL or empty
* @param ProjectDataObject $object
* @param string $manager_class
* @return null
*/
function setObjectTags($tags, ProjectDataObject $object, $manager_class)
{
self::clearObjectTags($object, $manager_class);
if (is_array($tags) && count($tags)) {
foreach ($tags as $tag_name) {
if (trim($tag_name) != '') {
$tag = new Tag();
$tag->setTag($tag_name);
$tag->setRelObjectId($object->getId());
$tag->setRelObjectManager($manager_class);
$tag->setIsPrivate($object->isPrivate());
$tag->save();
evt_add("tag added", array("name" => $tag_name));
}
// if
}
// foreach
}
// if
return true;
}
示例6: addTags
/**
* Function creates new propel Tag objects and saves them.
* @param array $tagToAdd
*/
protected function addTags($tagsToAdd, $objectType, $partnerId)
{
foreach ($tagsToAdd as $tagToAdd) {
if (strlen($tagToAdd) >= TagSearchPlugin::MIN_TAG_SEARCH_LENGTH) {
$tag = new Tag();
$tag->setTag(trim($tagToAdd));
$tag->setObjectType($objectType);
$tag->setPartnerId($partnerId);
$tag->save();
}
}
}
示例7: addTag
/**
* Add a tag to the object.
*
* @access public
* @param void
* @return boolean
*/
function addTag($tag_name)
{
$tag = new Tag();
$tag->setTag($tag_name);
$tag->setRelObjectId($this->getId());
$tag->setRelObjectManager(get_class($this->manager()));
$tag->setIsPrivate($this->isPrivate());
$tag->save();
$this->tags = null;
if ($this->isSearchable()) {
$this->addTagsToSearchableObject();
}
}
示例8: trimObjectTags
if (!$numTagsFound) {
$requiredTags = $entryTags;
} else {
$crit = new Criteria();
$crit->addAnd(TagPeer::ID, $c->getFetchedIds(), KalturaCriteria::IN);
$foundTagObjects = TagPeer::doSelect($crit);
$foundTags = array();
foreach ($foundTagObjects as $foundTag) {
$foundTag->incrementInstanceCount();
$foundTags[] = $foundTag->getTag();
}
$requiredTags = array_diff($entryTags, $foundTags);
}
foreach ($requiredTags as $tagString) {
$tag = new Tag();
$tag->setTag($tagString);
$tag->setPartnerId($entry->getPartnerId());
$tag->setObjectType(taggedObjectType::ENTRY);
$tag->save();
}
}
$countLimitEachLoop += $countLimitEachLoop;
$c->setOffset($countLimitEachLoop);
$entryResults = entryPeer::doSelect($c, $con);
usleep(100);
}
function trimObjectTags($tagsString)
{
$arr = explode(",", $tagsString);
for ($i = 0; $i < count($arr); $i++) {
$arr[$i] = trim($arr[$i]);