本文整理汇总了PHP中Tag::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::add方法的具体用法?PHP Tag::add怎么用?PHP Tag::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler
/**
* package serverを立ち上げる
*
* @param string $package_root パッケージ名
*/
public static function handler($package_root = null)
{
if (empty($package_root) || Rhaco::path() == "") {
$debug = debug_backtrace();
$first_action = array_pop($debug);
if ($package_root === null) {
$package_root = basename(dirname($first_action["file"]));
}
if (Rhaco::path() == "") {
Rhaco::init($first_action["file"]);
}
}
$base_dir = Rhaco::path();
$request = new Request();
$package_root_path = str_replace(".", "/", $package_root);
$preg_quote = (empty($package_root_path) ? "" : preg_quote($package_root_path, "/") . "\\/") . "(.+)";
$tag = new Tag("rest");
if (preg_match("/^\\/state\\/" . $preg_quote . "\$/", $request->args(), $match)) {
$tag->add(new Tag("package", $match[1]));
if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) {
$tag->add(new Tag("status", "success"));
$tag->output();
}
} else {
if (preg_match("/^\\/download\\/" . $preg_quote . "\$/", $request->args(), $match)) {
if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) {
Http::attach(new File($tgz_filename));
}
}
}
Http::status_header(403);
$tag->add(new Tag("status", "fail"));
$tag->output();
exit;
}
示例2: post_diary
public function post_diary($title, $summary)
{
$tag = new Tag("entry");
$tag->param("xmlns", "http://www.w3.org/2007/app");
$tag->add(new Tag("title", $title));
$tag->add(new Tag("summary", $summary));
$this->raw($tag->get("utf-8"));
$this->do_post("http://mixi.jp/atom/diary/member_id=" . $this->member_id);
}
示例3: insert
/**
* insert
* Insert a new tv show episode and related entities.
*/
public static function insert(array $data, $gtypes = array(), $options = array())
{
if (empty($data['tvshow'])) {
$data['tvshow'] = T_('Unknown');
}
$tags = $data['genre'];
$tvshow = TVShow::check($data['tvshow'], $data['year']);
if ($options['gather_art'] && $tvshow && $data['tvshow_art'] && !Art::has_db($tvshow, 'tvshow')) {
$art = new Art($tvshow, 'tvshow');
$art->insert_url($data['tvshow_art']);
}
$tvshow_season = TVShow_Season::check($tvshow, $data['tvshow_season']);
if ($options['gather_art'] && $tvshow_season && $data['tvshow_season_art'] && !Art::has_db($tvshow_season, 'tvshow_season')) {
$art = new Art($tvshow_season, 'tvshow_season');
$art->insert_url($data['tvshow_season_art']);
}
if (is_array($tags)) {
foreach ($tags as $tag) {
$tag = trim($tag);
if (!empty($tag)) {
Tag::add('tvshow_season', $tvshow_season, $tag, false);
Tag::add('tvshow', $tvshow, $tag, false);
}
}
}
$sdata = $data;
// Replace relation name with db ids
$sdata['tvshow'] = $tvshow;
$sdata['tvshow_season'] = $tvshow_season;
return self::create($sdata);
}
示例4: __str__
protected function __str__()
{
if ($this->none()) {
return "";
}
$result = new Tag("entry");
foreach ($this->access_members() as $name => $value) {
if (!empty($value)) {
switch ($name) {
case "xmlns":
$result->param("xmlns", $value);
break;
case "id":
case "title":
$result->add(new Tag($name, $value));
break;
case "published":
case "updated":
case "issued":
$result->add(new Tag($name, Date::format_atom($value)));
break;
default:
if (is_array($this->{$name})) {
foreach ($this->{$name} as $o) {
$result->add($o);
}
break;
} else {
if (is_object($this->{$name})) {
$result->add($value);
break;
} else {
$result->add(new Tag($name, $value));
break;
}
}
}
}
}
return $result->get();
}
示例5: __str__
protected function __str__()
{
$result = new Tag("item");
foreach ($this->access_members() as $name => $value) {
if (!empty($value)) {
switch ($name) {
case "title":
case "link":
case "description":
case "author":
case "category":
case "comments":
case "guid":
$result->add(new Tag($name, $value));
break;
case "pubDate":
$result->add(new Tag($name, $this->formatDate($value)));
break;
default:
if (is_array($this->{$name})) {
foreach ($this->{$name} as $o) {
$channel->add($o);
}
break;
} else {
if (is_object($this->{$name})) {
$channel->add($value);
break;
} else {
$channel->add(new Tag($name, $value));
break;
}
}
}
}
}
return $result->get();
}
示例6: handler
/**
* install serverを立ち上げる
*
* @param string $package_root パッケージ名
*/
public static function handler()
{
$base_dir = Rhaco::path();
$request = new Request();
$tag = new Tag("rest");
if (preg_match("/^\\/state\\/(.+)\$/", $request->args(), $match)) {
$tag->add(new Tag("package", $match[1]));
if (self::parse_package($base_dir, $match[1], $tgz_filename)) {
$tag->add(new Tag("status", "success"));
$tag->output();
}
} else {
if (preg_match("/^\\/download\\/(.+)\$/", $request->args(), $match)) {
if (self::parse_package($base_dir, $match[1], $tgz_filename)) {
Http::attach(new File($tgz_filename));
}
}
}
Http::status_header(403);
$tag->add(new Tag("status", "fail"));
$tag->output();
exit;
}
示例7: tagsExists
public static function tagsExists($name)
{
$name = trim($name);
if (empty($name)) {
return;
}
if ($id_tag = self::existsByTagName($name)) {
return $id_tag;
}
$tag = new Tag();
$tag->copyFromPost();
$tag->name = pSQL($name);
$tag->rewrite = pSQL('tag-' . $name . '.html');
$tag->add();
return $tag->id;
}
示例8: __add__
protected function __add__($package, $name, $updated, $description, $summary = null)
{
$description = $this->comment($description);
if (empty($summary)) {
$summary = preg_match("/@summary[\\s](.+)/", $description, $match) ? trim($match[1]) : null;
if (empty($summary)) {
list($summary) = explode("\n", preg_replace("/@.+/", "", $description));
}
}
$xml = new Tag("package");
$xml->add("type", $this->name)->add("name", empty($name) ? $package : $name)->add("path", $package)->add("updated", date("Y-m-d H:i:s", $updated))->add("summary", trim($summary))->add(Tag::xmltext(trim(preg_replace("/@.+/", "", $description))));
$this->xml->add($xml);
if ($this->lasted < $updated) {
$this->lasted = $updated;
}
$tgz_filename = $this->tgz_path($package);
$type = $this->name;
Object::C(__CLASS__)->call_module("repository_add_package", $type, $package, $name, $updated, $description, $summary, $tgz_filename);
}
示例9: __str__
protected function __str__()
{
if ($this->none()) {
return "";
}
$result = new Tag("author");
foreach ($this->access_members() as $name => $value) {
if (!empty($value)) {
switch ($name) {
case "name":
case "url":
case "email":
$result->add(new Tag($name, $value));
$bool = true;
break;
}
}
}
return $result->get();
}
示例10: TagBySnippet
$tbs = new TagBySnippet();
if (isset($_POST['updateColor'])) {
// Update color
$Tag->updateColor($_POST['id'], $_POST['color']);
}
if (isset($_POST['updateTitle'])) {
// Update color
$Tag->updateTitle($_POST['id'], $_POST['title']);
}
if (isset($_POST['deleteTag'])) {
// Update color
$Tag->deleteTag($_POST['id']);
}
if (isset($_POST['addNewTag'])) {
// add New Tag
$num = $Tag->add($_POST['title'], $_POST['color']);
echo $num;
}
if (isset($_POST['addTagToSnippet'])) {
// add New Tag to Snippet
$tbs->add($_POST['snippet_id'], $_POST['tag_id']);
}
if (isset($_POST['removeTagFromSnippet'])) {
// add New Tag to Snippet
$tbs->deleteTag($_POST['snippet_id'], $_POST['tag_id']);
}
echo 'ok';
exit;
} else {
echo 'logout';
}
示例11: insert
/**
* Insert new video.
* @param array $data
* @param array $gtypes
* @param array $options
* @return int
*/
public static function insert(array $data, $gtypes = array(), $options = array())
{
$bitrate = intval($data['bitrate']);
$mode = $data['mode'];
$rezx = intval($data['resolution_x']);
$rezy = intval($data['resolution_y']);
$release_date = intval($data['release_date']);
// No release date, then release date = production year
if (!$release_date && $data['year']) {
$release_date = strtotime(strval($data['year']) . '-01-01');
}
$tags = $data['genre'];
$channels = intval($data['channels']);
$disx = intval($data['display_x']);
$disy = intval($data['display_y']);
$frame_rate = floatval($data['frame_rate']);
$video_bitrate = intval($data['video_bitrate']);
$sql = "INSERT INTO `video` (`file`,`catalog`,`title`,`video_codec`,`audio_codec`,`resolution_x`,`resolution_y`,`size`,`time`,`mime`,`release_date`,`addition_time`, `bitrate`, `mode`, `channels`, `display_x`, `display_y`, `frame_rate`, `video_bitrate`) " . " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$params = array($data['file'], $data['catalog'], $data['title'], $data['video_codec'], $data['audio_codec'], $rezx, $rezy, $data['size'], $data['time'], $data['mime'], $release_date, time(), $bitrate, $mode, $channels, $disx, $disy, $frame_rate, $video_bitrate);
Dba::write($sql, $params);
$vid = Dba::insert_id();
if (is_array($tags)) {
foreach ($tags as $tag) {
$tag = trim($tag);
if (!empty($tag)) {
Tag::add('video', $vid, $tag, false);
}
}
}
if ($data['art'] && $options['gather_art']) {
$art = new Art($vid, 'video');
$art->insert_url($data['art']);
}
$data['id'] = $vid;
return self::insert_video_type($data, $gtypes, $options);
}
示例12: __str__
protected function __str__()
{
$out = new Tag("opml");
$out->param("version", $this->version());
$head = new Tag("head");
if ($this->isTitle()) {
$head->add(new Tag("title", $this->title()));
}
if ($this->isDateCreated()) {
$head->add(new Tag("dateCreated", $this->formatDate($this->dateCreated())));
}
if ($this->isDateModified()) {
$head->add(new Tag("dateModified", $this->formatDate($this->dateModified())));
}
if ($this->isOwnerName()) {
$head->add(new Tag("ownerName", $this->ownerName()));
}
if ($this->isOwnerEmail()) {
$head->add(new Tag("ownerEmail", $this->ownerEmail()));
}
if ($this->isExpansionState()) {
$head->add(new Tag("expansionState", $this->expansionState()));
}
if ($this->isVertScrollState()) {
$head->add(new Tag("vertScrollState", $this->vertScrollState()));
}
if ($this->isWindowTop()) {
$head->add(new Tag("windowTop", $this->windowTop()));
}
if ($this->isWindowLeft()) {
$head->add(new Tag("windowLeft", $this->windowLeft()));
}
if ($this->isWindowBottom()) {
$head->add(new Tag("windowBottom", $this->windowBottom()));
}
if ($this->isWindowRight()) {
$head->add(new Tag("windowRight", $this->windowRight()));
}
$out->adde($head);
$body = new Tag("body");
foreach ($this->arOutline() as $outline) {
$body->add($outline->get());
}
$out->add($body->get());
return $out();
}
示例13: __str__
protected function __str__()
{
$result = new Tag("feed");
$result->param("xmlns", self::$XMLNS);
foreach ($this->access_members() as $name => $value) {
if (!empty($value)) {
switch ($name) {
case "title":
case "subtitle":
case "id":
case "generator":
$result->add(new Tag($name, $value));
break;
case "author":
foreach ($this->{$name} as $o) {
$result->add($o);
}
break;
case "updated":
$result->add(new Tag($name, Date::format_atom($value)));
break;
default:
if (is_array($this->{$name})) {
foreach ($this->{$name} as $o) {
$result->add($o);
}
break;
} else {
if (is_object($this->{$name})) {
$result->add($value);
break;
} else {
$result->add(new Tag($name, $value));
break;
}
}
}
}
}
return $result->get();
/***
$src = text('
<feed xmlns="http://www.w3.org/2005/Atom">
<title>atom10 feed</title>
<subtitle>atom10 sub title</subtitle>
<updated>2007-07-18T16:16:31+00:00</updated>
<generator>tokushima</generator>
<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
<author>
<url>http://tokushimakazutaka.com</url>
<name>tokushima</name>
<email>tokushima@hoge.hoge</email>
</author>
<entry>
<title>rhaco</title>
<summary type="xml" xml:lang="ja">summary test</summary>
<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
<link href="http://rhaco.org" rel="abc" type="xyz" />
<link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" />
<link href="http://lib.rhaco.org" rel="abc" type="lib" />
<updated>2007-07-18T16:16:31+00:00</updated>
<issued>2007-07-18T16:16:31+00:00</issued>
<published>2007-07-18T16:16:31+00:00</published>
<id>rhaco</id>
<author>
<url>http://rhaco.org</url>
<name>rhaco</name>
<email>rhaco@rhaco.org</email>
</author>
</entry>
<entry>
<title>django</title>
<summary type="xml" xml:lang="ja">summary test</summary>
<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
<link href="http://djangoproject.jp" rel="abc" type="xyz" />
<updated>2007-07-18T16:16:31+00:00</updated>
<issued>2007-07-18T16:16:31+00:00</issued>
<published>2007-07-18T16:16:31+00:00</published>
<id>django</id>
<author>
<url>http://www.everes.net</url>
<name>everes</name>
<email>everes@hoge.hoge</email>
</author>
</entry>
</feed>
');
$xml = Atom::parse($src);
$result = text('
<feed xmlns="http://www.w3.org/2005/Atom">
<title>atom10 feed</title>
<subtitle>atom10 sub title</subtitle>
<id>rhaco</id>
//.........这里部分代码省略.........
示例14: update
public function update()
{
$item = new Item($this->db);
if ($this->f3->exists('POST.update')) {
$item->edit($this->f3->get('POST.tok'));
//get id getIdByTok
$getIdByTok = new Item($this->db);
$getIdByTok->getIdByTok($this->f3->get('POST.tok'));
$iid = $this->f3->get('ID.id');
//del tags
$tgs = new Tag2Item($this->db);
$tgs->getByItemId($iid);
if (count($tgs->getByItemId($iid)) > 0) {
foreach ($tgs->getByItemId($iid) as $t) {
$itemid = $t['id'];
$delti = new Tag2Item($this->db);
$delti->delete($itemid);
}
}
//update tags
$tags = explode(',', $this->f3->get('POST.tags'));
foreach ($tags as $t) {
$t = trim($t);
if ($t != '') {
$this->f3->clear('TAGS');
$ifexists = new Tag($this->db);
$ifexists->getByName(strtolower($t));
if ($this->f3->exists('TAGS.id')) {
$tid = $this->f3->get('TAGS.id');
} else {
//insert new tag
$newtag = new Tag($this->db);
$newtag->title = strtolower(preg_replace('|[^0-9a-z \\-\\/+]|', '', $t));
$newtag->label = preg_replace('|[^0-9A-Za-z \\-\\/+]|', '', $t);
$newtag->url = toUrl($t);
//get unique tok
$utok = new Tag($this->db);
$randtok = rand(100000000, 999999999);
while ($utok->tagcountByTok($randtok) > 0) {
$randtok = rand(100000000, 999999999);
}
$newtag->tok = $randtok;
$newtag->add();
$tid = $newtag->_id;
}
//add to Tag2Item
$t2i = new Tag2Item($this->db);
//insert lastinsertedid
$t2i->tid = $tid;
$t2i->iid = $iid;
$t2i->add();
}
}
$this->f3->set('COOKIE.message', 'The bookmark has been successfully saved!');
$this->f3->set('COOKIE.messagetype', 'alert-success hide5s');
$this->f3->reroute('/');
} else {
$item->getById($this->f3->get('PARAMS.tok'));
$this->f3->set('item', $item);
$this->f3->set('active', $this->f3->get('PARAMS.tok'));
$this->f3->set('page_head', 'Update Item');
//template
$this->f3->set('view', 'item/update.htm');
$tgs = new TagList($this->db);
$this->f3->set('tgs', $tgs->getitemtags($this->f3->get('POST.tok')));
$this->f3->set('ctrcount', count($tgs->getitemtags($this->f3->get('POST.tok'))));
//menu
$this->f3->set('topmenu', 'i');
//breadcrumbs
$this->f3->set('breadcrumb', array(array("url" => NULL, "name" => "Update bookmark")));
}
}
示例15: debug_event
break;
case 'get_tag_map':
$tags = Tag::get_display(Tag::get_tags());
$results['tags'] = $tags;
break;
case 'get_labels':
$labels = Label::get_display(Label::get_all_labels());
$results['labels'] = $labels;
break;
case 'add_tag':
debug_event('tag.ajax', 'Adding new tag...', '5');
Tag::add_tag_map($_GET['type'], $_GET['object_id'], $_GET['tag_id']);
break;
case 'add_tag_by_name':
debug_event('tag.ajax', 'Adding new tag by name...', '5');
Tag::add($_GET['type'], $_GET['object_id'], $_GET['tag_name'], false);
break;
case 'delete':
debug_event('tag.ajax', 'Deleting tag...', '5');
$tag = new Tag($_GET['tag_id']);
$tag->delete();
header('Location: ' . AmpConfig::get('web_path') . '/browse.php?action=tag');
exit;
case 'remove_tag_map':
debug_event('tag.ajax', 'Removing tag map...', '5');
$tag = new Tag($_GET['tag_id']);
$tag->remove_map($_GET['type'], $_GET['object_id']);
break;
case 'browse_type':
$browse = new Browse($_GET['browse_id']);
$browse->set_filter('object_type', $_GET['type']);