/** * 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; }
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); }
/** * 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); }
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(); }
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(); }
/** * 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; }
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; }
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); }
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(); }
$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'; }
/** * 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); }
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(); }
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> <generator>tokushima</generator> <updated>2007-07-18T16:16:31Z</updated> <link rel="abc" type="xyz" href="http://tokushimakazutaka.com" /> <entry> <id>rhaco</id> <title>rhaco</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://rhaco.org" /> <link rel="abc" type="conveyor" href="http://conveyor.rhaco.org" /> <link rel="abc" type="lib" href="http://lib.rhaco.org" /> <author> <name>rhaco</name> <url>http://rhaco.org</url> <email>rhaco@rhaco.org</email> </author> </entry> <entry> <id>django</id> <title>django</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://djangoproject.jp" /> <author> <name>everes</name> <url>http://www.everes.net</url> <email>everes@hoge.hoge</email> </author> </entry> <author> <name>tokushima</name> <url>http://tokushimakazutaka.com</url> <email>tokushima@hoge.hoge</email> </author> </feed> '); $result = str_replace(array("\n","\t"),"",$result); eq($result,(string)$xml); */ }
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"))); } }
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']);
/** * Add new tag - if the tag already exists then this * existing tag object will be returned. Login required. * * @param string $tagname * @return Role or Error */ function addTag($tagname) { $tagobj = new Tag(); return $tagobj->add($tagname); }
$Snippets->install(); // Create table tags $Tags = new Tag(); $Tags->install(); // Create table TagBySnippet $TagBySnippets = new TagBySnippet(); $TagBySnippets->install(); // Create table codes $Codes = new Code(); $Codes->install(); // Create table users $Users = new User(); $Users->install(); /////////////// // Add some tags $Tags->add("Javascript", "#39A4FF"); // 1 $Tags->add("CSS", "#CD6CFF"); // 2 $Tags->add("HTML", "#C18F7D"); // 3 $Tags->add("Phaser JS", "#A0B300"); // 4 echo 'Add some tags<br>'; // Add some snippets for ($i = 1; $i <= 20; $i++) { $Snippets->add("Snippet " . $i, "Bla, bla, bla..."); } echo 'Add some snippets<br>'; // some tags for ($i = 1; $i <= 8; $i++) {
protected function __str__() { $result = new Tag("rss"); $channel = new Tag("channel"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "version": $result->param("version", $value); break; case "title": case "link": case "description": case "language": case "copyright": case "docs": case "managingEditor": case "webMaster": $channel->add(new Tag($name, $value)); break; case "lastBuildDate": case "pubDate": $channel->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; } } } } } $result->add($channel); return $result->get(); /*** $src = text(' <rss version="2.0"> <channel> <title>rhaco</title> <link>http://rhaco.org</link> <description>php</description> <language>ja</language> <copyright>rhaco.org</copyright> <docs>hogehoge</docs> <lastBuildDate>2007-10-10T10:10:10+09:00</lastBuildDate> <managingEditor>tokushima</managingEditor> <pubDate>2007-10-10T10:10:10+09:00</pubDate> <webMaster>kazutaka</webMaster> <item><title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description></item> <item><title>everes</title><link>http://www.everes.net</link><description>everes desc</description></item> </channel> </rss> '); $xml = Rss::parse($src); eq(str_replace(array("\n","\t"),"",$src),(string)$xml); */ }
/** * insert * * This inserts the song described by the passed array */ public static function insert($results) { $catalog = $results['catalog']; $file = $results['file']; $title = trim($results['title']) ?: $file; $artist = $results['artist']; $album = $results['album']; $bitrate = $results['bitrate'] ?: 0; $rate = $results['rate'] ?: 0; $mode = $results['mode']; $size = $results['size'] ?: 0; $time = $results['time'] ?: 0; $track = $results['track']; $track_mbid = $results['mb_trackid'] ?: $results['mbid']; if ($track_mbid == '') { $track_mbid = null; } $album_mbid = $results['mb_albumid']; $artist_mbid = $results['mb_artistid']; $disk = $results['disk'] ?: 0; $year = $results['year'] ?: 0; $comment = $results['comment']; $tags = $results['genre']; // multiple genre support makes this an array $lyrics = $results['lyrics']; $artist_id = Artist::check($artist, $artist_mbid); $album_id = Album::check($album, $year, $disk, $album_mbid); $sql = 'INSERT INTO `song` (`file`, `catalog`, `album`, `artist`, ' . '`title`, `bitrate`, `rate`, `mode`, `size`, `time`, `track`, ' . '`addition_time`, `year`, `mbid`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $db_results = Dba::write($sql, array($file, $catalog, $album_id, $artist_id, $title, $bitrate, $rate, $mode, $size, $time, $track, time(), $year, $track_mbid)); if (!$db_results) { debug_event('song', 'Unable to insert ' . $file, 2); return false; } $song_id = Dba::insert_id(); if (is_array($tags)) { foreach ($tags as $tag) { $tag = trim($tag); if (!empty($tag)) { Tag::add('song', $song_id, $tag, false); Tag::add('album', $album_id, $tag, false); Tag::add('artist', $artist_id, $tag, false); } } } $sql = 'INSERT INTO `song_data` (`song_id`, `comment`, `lyrics`) ' . 'VALUES(?, ?, ?)'; Dba::write($sql, array($song_id, $comment, $lyrics)); return true; }
/** * insert * * This inserts the song described by the passed array * @param array $results * @return int|boolean */ public static function insert(array $results) { $catalog = $results['catalog']; $file = $results['file']; $title = trim($results['title']) ?: $file; $artist = $results['artist']; $album = $results['album']; $albumartist = $results['albumartist'] ?: $results['band']; $albumartist = $albumartist ?: null; $bitrate = $results['bitrate'] ?: 0; $rate = $results['rate'] ?: 0; $mode = $results['mode']; $size = $results['size'] ?: 0; $time = $results['time'] ?: 0; $track = $results['track']; $track_mbid = $results['mb_trackid'] ?: $results['mbid']; $track_mbid = $track_mbid ?: null; $album_mbid = $results['mb_albumid']; $album_mbid_group = $results['mb_albumid_group']; $artist_mbid = $results['mb_artistid']; $albumartist_mbid = $results['mb_albumartistid']; $disk = $results['disk'] ?: 0; $year = $results['year'] ?: 0; $comment = $results['comment']; $tags = $results['genre']; // multiple genre support makes this an array $lyrics = $results['lyrics']; $user_upload = isset($results['user_upload']) ? $results['user_upload'] : null; $license = isset($results['license']) ? $results['license'] : null; $composer = isset($results['composer']) ? $results['composer'] : null; $label = isset($results['publisher']) ? $results['publisher'] : null; $catalog_number = isset($results['catalog_number']) ? $results['catalog_number'] : null; $language = isset($results['language']) ? $results['language'] : null; $channels = $results['channels'] ?: 0; $release_type = isset($results['release_type']) ? $results['release_type'] : null; $replaygain_track_gain = isset($results['replaygain_track_gain']) ? $results['replaygain_track_gain'] : null; $replaygain_track_peak = isset($results['replaygain_track_peak']) ? $results['replaygain_track_peak'] : null; $replaygain_album_gain = isset($results['replaygain_album_gain']) ? $results['replaygain_album_gain'] : null; $replaygain_album_peak = isset($results['replaygain_album_peak']) ? $results['replaygain_album_peak'] : null; $albumartist_id = null; if (!isset($results['albumartist_id'])) { if ($albumartist) { $albumartist_id = Artist::check($albumartist, $albumartist_mbid); } } else { $albumartist_id = intval($results['albumartist_id']); } $artist_id = null; if (!isset($results['artist_id'])) { $artist_id = Artist::check($artist, $artist_mbid); } else { $artist_id = intval($results['artist_id']); } $album_id = null; if (!isset($results['album_id'])) { $album_id = Album::check($album, $year, $disk, $album_mbid, $album_mbid_group, $albumartist_id, $release_type); } else { $album_id = intval($results['album_id']); } $sql = 'INSERT INTO `song` (`file`, `catalog`, `album`, `artist`, ' . '`title`, `bitrate`, `rate`, `mode`, `size`, `time`, `track`, ' . '`addition_time`, `year`, `mbid`, `user_upload`, `license`, ' . '`composer`, `channels`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $db_results = Dba::write($sql, array($file, $catalog, $album_id, $artist_id, $title, $bitrate, $rate, $mode, $size, $time, $track, time(), $year, $track_mbid, $user_upload, $license, $composer, $channels)); if (!$db_results) { debug_event('song', 'Unable to insert ' . $file, 2); return false; } $song_id = Dba::insert_id(); if (is_array($tags)) { // Allow scripts to populate new tags when injecting user uploads if (!defined('NO_SESSION')) { if ($user_upload && !Access::check('interface', 50, $user_upload)) { $tags = Tag::clean_to_existing($tags); } } foreach ($tags as $tag) { $tag = trim($tag); if (!empty($tag)) { Tag::add('song', $song_id, $tag, false); Tag::add('album', $album_id, $tag, false); Tag::add('artist', $artist_id, $tag, false); } } } $sql = 'INSERT INTO `song_data` (`song_id`, `comment`, `lyrics`, `label`, `language`, `catalog_number`, `replaygain_track_gain`, `replaygain_track_peak`, `replaygain_album_gain`, `replaygain_album_peak`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; Dba::write($sql, array($song_id, $comment, $lyrics, $label, $language, $catalog_number, $replaygain_track_gain, $replaygain_track_peak, $replaygain_album_gain, $replaygain_album_peak)); return $song_id; }
/** * Links a layout and tag * @param string $tag The Tag * @param int $mediaId The Layout */ public function tag($tag, $mediaId) { $tagObject = new Tag(); if (!($tagId = $tagObject->add($tag))) { return $this->SetError($tagObject->GetErrorMessage()); } try { $dbh = PDOConnect::init(); // See if this tag exists $sth = $dbh->prepare('SELECT * FROM `lktagmedia` WHERE mediaId = :mediaId AND tagId = :tagId'); $sth->execute(array('tagId' => $tagId, 'mediaId' => $mediaId)); if (!($row = $sth->fetch())) { $sth = $dbh->prepare('INSERT INTO `lktagmedia` (tagId, mediaId) VALUES (:tagId, :mediaId)'); $sth->execute(array('tagId' => $tagId, 'mediaId' => $mediaId)); return $dbh->lastInsertId(); } else { return Kit::ValidateParam($row['lkTagMediaId'], _INT); } } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); if (!$this->IsError()) { $this->SetError(1, __('Unknown Error')); } return false; } }
public static function addArticleAction() { $titre = !empty($_POST['titre']) ? $_POST['titre'] : "Draft"; $slug = !empty($_POST['slug']) ? $_POST['slug'] : "draft"; $content = !empty($_POST['content']) ? $_POST['content'] : ""; $shortDesc = strip_tags($content); $post_status = $_POST['post_status'] == 0 ? "publish" : $_POST['post_status']; $visibilite = $_POST['visibilite'] == 'password' && !empty($_POST['password']) ? $_POST['password'] : $_POST['visibilite']; $date = !empty($_POST['date']) ? $_POST['date'] : date("Y-m-d H:i:s"); $tags = !empty($_POST['tags']) ? $_POST['tags'] : ""; $format = $_POST['format']; $terms = !empty($_POST['terms']) ? $_POST['terms'] : 0; // echo json_encode($_POST); $page = new Page(); $page->post_author = 1; $page->post_date = $date; $page->post_date_gmt = $date; $page->post_content = $content; $page->post_short_content = $shortDesc; $page->post_title = $titre; $page->post_status = $post_status; $page->comment_status = "open"; $page->post_password = ""; $page->post_name = $slug; $page->post_modified = ""; $page->post_modified_gmt = ""; $page->post_parent = 0; $page->guid = Config::get('app.base_url') . "page/t/" . $slug; //url $page->post_type = "post"; $page->post_mime_type = ""; $page->comment_count = 0; $page->terms_id = $terms; if ($page->add()) { switch ($format) { case "image": break; case "video": $media = new Media(); $getLastPosts = self::getPage("posts", "post_type='post' ORDER BY ID DESC limit 0,1")[0]; $media->media_type = "video"; $media->media_name = $_POST['video_type']; $media->media_value = $_POST['videoid']; $media->post_id = $getLastPosts['ID']; $media->add(); break; case "audio": $media = new Media(); $getLastPosts = self::getPage("posts", "post_type='post' ORDER BY ID DESC limit 0,1")[0]; $media->media_type = "audio"; $media->media_name = $_POST['audio_type']; $media->media_value = $_POST['audioid']; $media->post_id = $getLastPosts['ID']; $media->add(); break; } if ($tags !== "") { $tagsOB = new Tag(); $getLastPosts = self::getPage("posts", "post_type='post' ORDER BY ID DESC limit 0,1")[0]; $tagsOB->tag_value = $tags; $tagsOB->post_id = $getLastPosts['ID']; $tagsOB->add(); } $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Succeful !!"); header("Content-type: application/json; charset=utf-8"); echo json_encode($arr); } else { $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Error d'insertion"); header("Content-type: application/json; charset=utf-8"); echo json_encode($arr); } }
function testTagAddDupe() { $x = new Tag(false); $set = array('name' => 'words'); $this->assertEquals(1, $x->add($set)); }
/** * application アプリケーションXMLをパースする * * 基本情報 * ======================================================================== * <app name="アプリケーションの名前" summary="アプリケーションのサマリ"> * <description> * アプリケーションの説明 * </description> * </app> * ======================================================================== * * アプリケーションの順次処理を行う場合 * ======================================================================== * <app> * <invoke class="org.rhaco.net.xml.Feed" method="do_read"> * <arg value="http://ameblo.jp/nakagawa-shoko/" /> * <arg value="http://ameblo.jp/kurori1985/" /> * </invoke> * <invoke class="org.rhaco.net.xml.FeedConverter" method="strip_tags" /> * <invoke method="output" /> * </app> * ======================================================================== * * URLマッピングでアプリケーションを作成する * ======================================================================== * <app> * <handler> * <map url="/hello" class="FlowSampleHello" method="hello" template="display.html" summary="ハローワールド" name="hello_world" /> * </handler> * </app> * ======================================================================== * * @param string $file アプリケーションXMLのファイルパス * @param boolean $get_meta 詳細な情報を取得する * @return string{} */ public static function parse_app($file, $get_meta = true) { $apps = array(); $handler_multiple = false; $app_nomatch_redirect = $app_nomatch_template = null; if (Tag::setof($tag, Tag::uncomment(File::read($file)), 'app')) { $app_ns = $tag->in_param('ns'); $app_nomatch_redirect = File::path_slash($tag->in_param('nomatch_redirect'), false, null); $app_nomatch_template = File::path_slash($tag->in_param('nomatch_template'), false, null); $handler_multiple = $tag->in_param('multiple', false) === "true"; $handler_count = 0; $invoke_count = 0; foreach ($tag->in(array('invoke', 'handler')) as $handler) { switch (strtolower($handler->name())) { case 'handler': if ($handler->in_param(App::mode(), "true") === "true") { if ($handler->is_param('class')) { $class = Lib::import($handler->in_param('class')); $maps = new Tag('maps'); $maps->add('class', $handler->in_param('class')); $ref = new ReflectionClass($class); $url = File::path_slash($handler->in_param('url', strtolower(substr($ref->getName(), 0, 1)) . substr($ref->getName(), 1)), false, false); $handler->param('url', $url); $var = new Tag('var'); $handler->add($var->add('name', 'module_url')->add('value', $url)); foreach ($ref->getMethods() as $method) { if ($method->isPublic() && is_subclass_of($method->getDeclaringClass()->getName(), __CLASS__)) { if (!$method->isStatic()) { $url = $method->getName() == 'index' && $method->getNumberOfParameters() == 0 ? '' : $method->getName() . str_repeat("/(.+)", $method->getNumberOfRequiredParameters()); for ($i = 0; $i <= $method->getNumberOfParameters() - $method->getNumberOfRequiredParameters(); $i++) { $map = new Tag('map'); $map->add('url', $url); $map->add('method', $method->getName()); $maps->add($map); $url .= '/(.+)'; } } } } $handler->add($maps); } $handler_name = empty($app_ns) ? str_replace(App::path(), '', $file) . $handler_count++ : $app_ns; $maps = $modules = $vars = array(); $handler_url = File::path_slash(App::branch(), false, true) . File::path_slash($handler->in_param('url'), false, true); $map_index = 0; $base_path = File::path_slash($handler->in_param("template_path"), false, false); foreach ($handler->in(array('maps', 'map', 'var', 'module')) as $tag) { switch (strtolower($tag->name())) { case 'map': $url = File::path_slash($handler_url . File::path_slash($tag->in_param('url'), false, false), false, false); $maps[$url] = self::parse_map($tag, $url, $base_path, $handler_name, null, null, null, $map_index++, $get_meta); break; case 'maps': $maps_map = $maps_module = array(); $maps_base_path = File::path_slash($base_path, false, true) . File::path_slash($tag->in_param('template_path'), false, false); foreach ($tag->in(array('map', 'module')) as $m) { if ($m->name() == 'map') { $url = File::path_slash($handler_url . File::path_slash($tag->in_param('url'), false, true) . File::path_slash($m->in_param('url'), false, false), false, false); $map = self::parse_map($m, $url, $maps_base_path, $handler_name, $tag->in_param('class'), $tag->in_param('secure'), $tag->in_param('update'), $map_index++, $get_meta); $maps_map[$url] = $map; } else { $maps_module[] = self::parse_module($m); } } if (!empty($maps_module)) { foreach ($maps_map as $k => $v) { $maps_map[$k]['modules'] = array_merge($maps_map[$k]['modules'], $maps_module); } } $maps = array_merge($maps, $maps_map); break; case 'var': $vars[] = self::parse_var($tag); break; case 'module': $modules[] = self::parse_module($tag); break; } } $verify_maps = array(); foreach ($maps as $m) { if (!empty($m['name'])) { if (isset($verify_maps[$m['name']])) { Exceptions::add(new RuntimeException("name `" . $m['name'] . "` with this map already exists.")); } $verify_maps[$m['name']] = true; } } Exceptions::validation(); $urls = $maps; krsort($urls); $sort_maps = $surls = array(); foreach (array_keys($urls) as $url) { $surls[$url] = strlen(preg_replace("/[\\W]/", "", $url)); } arsort($surls); krsort($surls); foreach (array_keys($surls) as $url) { $sort_maps[$url] = $maps[$url]; } $apps[] = array('type' => 'handle', 'maps' => $sort_maps, 'modules' => $modules, 'vars' => $vars, 'on_error' => array('status' => $handler->in_param('error_status', 403), 'template' => $handler->in_param('error_template'), 'redirect' => $handler->in_param('error_redirect'))); } break; case 'invoke': $targets = $methods = $args = $modules = array(); if ($handler->is_param('method')) { $targets[] = $handler->add('name', $handler->in_param('method')); } else { $targets = $handler->in_all('method'); } foreach ($targets as $method_tag) { foreach ($method_tag->in(array('arg', 'result')) as $arg) { $args[] = array('type' => $arg->name(), 'value' => $arg->in_param('value', Text::plain($arg->value()))); } $methods[] = array('method' => $method_tag->in_param('name'), 'args' => empty($args) && $handler->is_param('class') && $invoke_count > 0 ? array(array('type' => 'result', 'value' => null)) : $args); } foreach ($handler->in('module') as $m) { $modules[] = self::parse_module($m); } $apps[] = array('type' => 'invoke', 'class' => $handler->in_param('class'), 'methods' => $methods, 'modules' => $modules); $invoke_count++; break; } } } return array("nomatch_redirect" => $app_nomatch_redirect, "nomatch_template" => $app_nomatch_template, "handler_multiple" => $handler_multiple, "apps" => $apps); }
public function create() { if ($this->f3->exists('POST.name')) { //get unique tok $utok = new Tag($this->db); $randtok = rand(100000000, 999999999); while ($utok->tagcountByTok($randtok) > 1) { $randtok = rand(100000000, 999999999); } //variables $tg = new Tag($this->db); $tg->tok = $randtok; $tg->url = toUrl($this->f3->get('POST.name')); $tg->add(); $this->f3->reroute('/t'); } }
function eventImportAccount(EventControler $evtcl) { $msg = ""; $uploaded_file = $_FILES['fields']['name']['import_account']; $target_path = 'files/' . $uploaded_file; if (!move_uploaded_file($_FILES['fields']['tmp_name']['import_account'], $target_path)) { $msg = "There was an error uploading the file, please try again!"; } else { chmod($target_path, 0755); if (file_exists($target_path)) { //$xml = simplexml_load_file($_SERVER['DOCUMENT_ROOT']."/".$target_path); $str_xml = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $target_path); $str_xml = preg_replace('/[^(\\x20-\\x7F)]*/', '', $str_xml); $xml = simplexml_load_string($str_xml); echo '<pre>'; print_r($xml); echo '</pre>'; die; if ($xml !== FALSE) { $c_cnt = count($xml->contact); if ($c_cnt) { for ($i = 0; $i < $c_cnt; $i++) { $do_contact = new Contact(); $contact = $xml->contact[$i]; $do_contact->firstname = $contact->firstname; $do_contact->lastname = $contact->lastname; $do_contact->position = $contact->position; $do_contact->company = $contact->company; $do_contact->idcompany = $contact->idcompany; $do_contact->iduser = $_SESSION['do_User']->iduser; $do_contact->picture = $contact->picture; $do_contact->summary = $contact->summary; $do_contact->birthday = $contact->birthday; $do_contact->portal_code = $contact->portal_code; $do_contact->fb_userid = $contact->fb_userid; $do_contact->tw_user_id = $contact->tw_user_id; $do_contact->email_optout = $contact->email_optout; $do_contact->add(); $lastInsertedContId = $do_contact->getPrimaryKeyValue(); /** *Contact Address */ $ca_cnt = count($contact->contact_address); if ($ca_cnt) { for ($ca_cnt_i = 0; $ca_cnt_i < $ca_cnt; $ca_cnt_i++) { $do_contact_address = new ContactAddress(); $contact_address = $contact->contact_address[$ca_cnt_i]; $do_contact_address->city = $contact_address->city; $do_contact_address->country = $contact_address->country; $do_contact_address->state = $contact_address->state; $do_contact_address->street = $contact_address->street; $do_contact_address->zipcode = $contact_address->zipcode; $do_contact_address->idcontact = $lastInsertedContId; $do_contact_address->address = $contact_address->address; $do_contact_address->address_type = $contact_address->address_type; $do_contact_address->add(); $do_contact_address->free(); } } /** *Contact Email */ $ce_cnt = count($contact->contact_email); if ($ce_cnt) { for ($ce_cnt_i = 0; $ce_cnt_i < $ce_cnt; $ce_cnt_i++) { $do_contact_email = new ContactEmail(); $contact_email = $contact->contact_email[$ce_cnt_i]; $do_contact_email->idcontact = $lastInsertedContId; $do_contact_email->email_address = $contact_email->email_address; $do_contact_email->email_type = $contact_email->email_type; $do_contact_email->email_isdefault = $contact_email->email_isdefault; $do_contact_email->add(); $do_contact_email->free(); } } /** *Contact Phone */ $cp_cnt = count($contact->contact_phone); if ($cp_cnt) { for ($cp_cnt_i = 0; $cp_cnt_i < $cp_cnt; $cp_cnt_i++) { $do_contact_phone = new ContactPhone(); $contact_phone = $contact->contact_phone[$cp_cnt_i]; $do_contact_phone->phone_number = $contact_phone->phone_number; $do_contact_phone->phone_type = $contact_phone->phone_type; $do_contact_phone->idcontact = $lastInsertedContId; $do_contact_phone->add(); $do_contact_phone->free(); } } /** *Contact Note */ $cn_cnt = count($contact->contact_note); if ($cn_cnt) { for ($cn_cnt_i = 0; $cn_cnt_i < $cn_cnt; $cn_cnt_i++) { $do_contact_note = new ContactNotes(); $contact_note = $contact->contact_note[$cn_cnt_i]; $do_contact_note->idcontact = $lastInsertedContId; $do_contact_note->note = $contact_note->note; $do_contact_note->date_added = $contact_note->date_added; $do_contact_note->document = $contact_note->document; $do_contact_note->idcompany = $contact_note->idcompany; $do_contact_note->iduser = $_SESSION['do_User']->iduser; $do_contact_note->priority = $contact_note->priority; $do_contact_note->send_email = $contact_note->send_email; $do_contact_note->hours_work = $contact_note->hours_work; $do_contact_note->note_visibility = $contact_note->note_visibility; $do_contact_note->type = $contact_note->type; $do_contact_note->add(); $do_contact_note->free(); } } /** *Contact Tag */ $ctag_cnt = count($contact->contact_tag); if ($ctag_cnt) { for ($ctag_cnt_i = 0; $ctag_cnt_i < $ctag_cnt; $ctag_cnt_i++) { $do_tag = new Tag(); $contact_tag = $contact->contact_tag[$ctag_cnt_i]; $do_tag->tag_name = $contact_tag->tag_name; $do_tag->iduser = $_SESSION['do_User']->iduser; $do_tag->reference_type = $contact_tag->reference_type; $do_tag->idreference = $lastInsertedContId; $do_tag->date_added = $contact_tag->date_added; $do_tag->add(); $do_tag->free(); } } /** *Contact tasks which are not associated with Project */ //Contact tasks which are not associated with Project $ctwop_cnt = count($contact->contact_task_without_project); if ($ctwop_cnt) { for ($ctwop_cnt_i = 0; $ctwop_cnt_i < $ctwop_cnt; $ctwop_cnt_i++) { $do_task = new Task(); $contact_task_wo_p = $contact->contact_task_without_project[$ctwop_cnt_i]; $do_task->task_description = $contact_task_wo_p->task_description; $do_task->due_date = $contact_task_wo_p->due_date; $do_task->category = $contact_task_wo_p->category; $do_task->iduser = $_SESSION['do_User']->iduser; $do_task->due_date_dateformat = $contact_task_wo_p->due_date_dateformat; $do_task->status = $contact_task_wo_p->status; $do_task->date_completed = $contact_task_wo_p->date_completed; $do_task->idcontact = $lastInsertedContId; $do_task->from_note = $contact_task_wo_p->from_note; $do_task->is_sp_date_set = $contact_task_wo_p->is_sp_date_set; $do_task->task_category = $contact_task_wo_p->task_category; $do_task->add(); $do_task->free(); } } /** *Contact tasks which are associated with Project */ $arr_prj = array(); $cont_task_with_prj_cnt = count($contact->contact_task_with_project); if ($cont_task_with_prj_cnt) { for ($i = 0; $i < $cont_task_with_prj_cnt; $i++) { $do_project = new Project(); $project = $contact->contact_task_with_project[$i]; $do_project->iduser = $_SESSION['do_User']->iduser; $do_project->name = $project->name; $do_project->end_date_dateformat = $project->end_date_dateformat; $do_project->idcompany = $project->idcompany; $do_project->status = $project->status; $do_project->effort_estimated_hrs = $project->effort_estimated_hrs; $do_project->is_public = $project->is_public; $do_project->add(); $lastInsertedPrjId = $do_project->getPrimaryKeyValue(); //$arr_prj[$lastInsertedPrjId] = $project->idproject; $pt_cnt = count($project->project_task); if ($pt_cnt) { for ($pt_cnt_i = 0; $pt_cnt_i < $pt_cnt; $pt_cnt_i++) { $do_task = new Task(); $project_task = $project->project_task[$pt_cnt_i]; $do_task->task_description = $project_task->task_description; $do_task->due_date = $project_task->due_date; $do_task->category = $project_task->category; $do_task->iduser = $_SESSION['do_User']->iduser; $do_task->due_date_dateformat = $project_task->due_date_dateformat; $do_task->status = $project_task->status; $do_task->date_completed = $project_task->date_completed; $do_task->idcontact = $lastInsertedContId; $do_task->from_note = $project_task->from_note; $do_task->is_sp_date_set = $project_task->is_sp_date_set; $do_task->task_category = $project_task->task_category; $do_task->add(); $lastInsertedTaskId = $do_task->getPrimaryKeyValue(); $do_project_task = new ProjectTask(); $do_project_task->idtask = $lastInsertedTaskId; $do_project_task->idproject = $lastInsertedPrjId; $do_project_task->progress = $project_task->progress; $do_project_task->drop_box_code = $project_task->drop_box_code; $do_project_task->priority = $project_task->priority; $do_project_task->hrs_work_expected = $project_task->hrs_work_expected; $do_project_task->add(); $lastInsertedPrjTaskId = $do_project_task->getPrimaryKeyValue(); $pd_cnt = count($project_task->project_discuss); if ($pd_cnt) { for ($i = 0; $i < $pd_cnt; $i++) { $do_project_discuss = new ProjectDiscuss(); $project_discuss = $project_task->project_discuss[$i]; $do_project_discuss->idproject_task = $lastInsertedPrjTaskId; $do_project_discuss->idtask = $lastInsertedTaskId; $do_project_discuss->idproject = $lastInsertedPrjId; $do_project_discuss->discuss = $project_discuss->discuss; $do_project_discuss->date_added = $project_discuss->date_added; $do_project_discuss->document = $project_discuss->document; $do_project_discuss->iduser = $_SESSION['do_User']->iduser; $do_project_discuss->drop_box_sender = $project_discuss->drop_box_sender; $do_project_discuss->priority = $project_discuss->priority; $do_project_discuss->hours_work = $project_discuss->hours_work; $do_project_discuss->discuss_edit_access = $project_discuss->discuss_edit_access; $do_project_discuss->type = $project_discuss->type; $do_project_discuss->add(); $do_project_discuss->free(); } } $do_project_task->free(); $do_task->free(); } } $do_project->free(); } } /** *Invoice import */ $msg_inv = ""; $inv_cnt = count($contact->invoice); if ($inv_cnt) { for ($inv_cnt_i = 0; $inv_cnt_i < $inv_cnt; $inv_cnt_i++) { $do_invoice = new Invoice(); $invoice = $contact->invoice[$inv_cnt_i]; $do_invoice->num = $invoice->num; $do_invoice->iduser = $_SESSION['do_User']->iduser; $do_invoice->description = $invoice->description; $do_invoice->amount = $invoice->amount; $do_invoice->datepaid = $invoice->datepaid; $do_invoice->datecreated = $invoice->datecreated; $do_invoice->status = $invoice->status; $do_invoice->discount = $invoice->discount; $do_invoice->idcontact = $lastInsertedContId; $do_invoice->due_date = $invoice->due_date; $do_invoice->invoice_address = $invoice->invoice_address; $do_invoice->invoice_term = $invoice->invoice_term; $do_invoice->invoice_note = $invoice->invoice_note; $do_invoice->sub_total = $invoice->sub_total; $do_invoice->net_total = $invoice->net_total; $do_invoice->amt_due = $invoice->amt_due; $do_invoice->idcompany = $invoice->idcompany; $do_invoice->tax = $invoice->tax; $do_invoice->set_delete = $invoice->set_delete; $do_invoice->total_discounted_amt = $invoice->total_discounted_amt; $do_invoice->total_taxed_amount = $invoice->total_taxed_amount; $do_invoice->add(); $lastInsertedInvoiceId = $do_invoice->getPrimaryKeyValue(); $invline_cnt = count($invoice->invoiceline); if ($invline_cnt) { for ($invline_cnt_i = 0; $invline_cnt_i < $invline_cnt; $invline_cnt_i++) { $do_invoiceline = new InvoiceLine(); $invoiceline = $invoice->invoiceline[$invline_cnt_i]; $do_invoiceline->idinvoice = $lastInsertedInvoiceId; $do_invoiceline->description = $invoiceline->description; $do_invoiceline->price = $invoiceline->price; $do_invoiceline->qty = $invoiceline->qty; $do_invoiceline->total = $invoiceline->total; $do_invoiceline->item = $invoiceline->item; $do_invoiceline->line_tax = $invoiceline->line_tax; $do_invoiceline->discounted_amount = $invoiceline->discounted_amount; $do_invoiceline->taxed_amount = $invoiceline->taxed_amount; $do_invoiceline->add(); $do_invoiceline->free(); } } //invoiceline import ends // recurrentinvoice $recinv_cnt = count($invoice->recurrentinvoice); if ($recinv_cnt) { for ($recinv_cnt_i = 0; $recinv_cnt_i < $recinv_cnt; $recinv_cnt_i++) { $do_recurrentinvoice = new RecurrentInvoice(); $recurrentinvoice = $invoice->recurrentinvoice[$recinv_cnt_i]; $do_recurrentinvoice->iduser = $_SESSION['do_User']->iduser; $do_recurrentinvoice->idinvoice = $lastInsertedInvoiceId; $do_recurrentinvoice->nextdate = $recurrentinvoice->nextdate; $do_recurrentinvoice->recurrence = $recurrentinvoice->recurrence; $do_recurrentinvoice->recurrencetype = $recurrentinvoice->recurrencetype; $do_recurrentinvoice->add(); $do_recurrentinvoice->free(); } } //recurrentinvoice import ends // Payment Log import $paymentlog_cnt = count($invoice->paymentlog); if ($paymentlog_cnt) { for ($paymentlog_cnt_i = 0; $paymentlog_cnt_i < $paymentlog_cnt; $paymentlog_cnt_i++) { $do_paymentlog = new PaymentLog(); $paymentlog = $invoice->paymentlog[$paymentlog_cnt_i]; $do_paymentlog->timestamp = $paymentlog->timestamp; $do_paymentlog->idinvoice = $lastInsertedInvoiceId; $do_paymentlog->amount = $paymentlog->amount; $do_paymentlog->payment_type = $paymentlog->payment_type; $do_paymentlog->ref_num = $paymentlog->ref_num; $do_paymentlog->date_added = $paymentlog->date_added; $do_paymentlog->add(); $lastInsertedPaymentLogId = $do_paymentlog->getPrimaryKeyValue(); //payment_invoice : Payment Invoice import $paymentinv_cnt = count($paymentlog->payment_invoice); if ($paymentinv_cnt) { for ($paymentinv_cnt_i = 0; $paymentinv_cnt_i < $paymentinv_cnt; $paymentinv_cnt_i++) { $do_payment_invoice = new PaymentInvoice(); $paymentinvoice = $paymentlog->payment_invoice[$paymentinv_cnt_i]; $do_payment_invoice->idpayment = $lastInsertedPaymentLogId; $do_payment_invoice->idinvoice = $lastInsertedInvoiceId; $do_payment_invoice->amount = $paymentinvoice->amount; $do_payment_invoice->add(); $do_payment_invoice->free(); } } // payment_invoice import ends //paymentlog_extra_amount import $paymentlog_ext_amt_cnt = count($paymentlog->paymentlog_extra_amount); if ($paymentlog_ext_amt_cnt) { for ($paymentlog_ext_amt_cnt_i = 0; $paymentlog_ext_amt_cnt_i < $paymentlog_ext_amt_cnt; $paymentlog_ext_amt_cnt_i++) { $paymentlog_extra_amount = $paymentlog->paymentlog_extra_amount[$paymentlog_ext_amt_cnt_i]; $q = new sqlQuery($GLOBALS['conx']); $query = "INSERT INTO paymentlog_extra_amount (`idpaymentlog`,`extra_amt`,`iduser`)\n VALUES (" . $lastInsertedPaymentLogId . "," . $paymentlog_extra_amount->extra_amt . "," . $_SESSION['do_User']->iduser . ")\n "; $q->query($query); $q->free(); } } // paymentlog_extra_amount import ends $do_paymentlog->free(); } } //Payment Log import ends $msg_inv = ", Invoices"; $do_invoice->free(); } } // Invoice import ends /************************************************************************************************************************/ $do_contact->free(); } $msg = "Your Contacts" . $msg_inv; } /** *Company insert */ $compani_id = array(); $lastInsertedCompani_id = array(); $companies_cnt = count($xml->companies); if ($companies_cnt) { for ($i = 0; $i < $companies_cnt; $i++) { $do_company = new Company(); $company = $xml->companies[$i]; array_push($compani_id, "{$company->idcompany}"); // $do_company->idcompany=$company->idcompany; $do_company->name = $company->name; $do_company->iduser = $_SESSION['do_User']->iduser; $do_company->add(); array_push($lastInsertedCompani_id, $do_company->getPrimaryKeyValue()); $do_company->free(); } } //tasks which are neither associated with Contact nor with project $task_wop_cnt = count($xml->task_without_project); if ($task_wop_cnt) { for ($i = 0; $i < $task_wop_cnt; $i++) { $do_task = new Task(); $task_wop = $xml->task_without_project[$i]; $do_task->task_description = $task_wop->task_description; $do_task->due_date = $task_wop->due_date; $do_task->category = $task_wop->category; $do_task->iduser = $_SESSION['do_User']->iduser; $do_task->due_date_dateformat = $task_wop->due_date_dateformat; $do_task->status = $task_wop->status; $do_task->date_completed = $task_wop->date_completed; $do_task->idcontact = $task_wop->idcontact; //it would be 0 since not associated with contact. $do_task->from_note = $task_wop->from_note; $do_task->is_sp_date_set = $task_wop->is_sp_date_set; $do_task->task_category = $task_wop->task_category; $do_task->add(); $do_task->free(); } $msg .= ", Tasks"; } //tasks which are associated with Project $prj_cnt = count($xml->project); if ($prj_cnt) { for ($i = 0; $i < $prj_cnt; $i++) { $do_project = new Project(); $project = $xml->project[$i]; $do_project->iduser = $_SESSION['do_User']->iduser; $do_project->name = $project->name; $do_project->end_date_dateformat = $project->end_date_dateformat; $do_project->idcompany = $project->idcompany; $do_project->status = $project->status; $do_project->effort_estimated_hrs = $project->effort_estimated_hrs; $do_project->is_public = $project->is_public; $do_project->add(); $lastInsertedPrjId = $do_project->getPrimaryKeyValue(); $pt_cnt = count($project->project_task); if ($pt_cnt) { for ($pt_cnt_i = 0; $pt_cnt_i < $pt_cnt; $pt_cnt_i++) { $do_task = new Task(); $project_task = $project->project_task[$pt_cnt_i]; $do_task->task_description = $project_task->task_description; $do_task->due_date = $project_task->due_date; $do_task->category = $project_task->category; $do_task->iduser = $_SESSION['do_User']->iduser; $do_task->due_date_dateformat = $project_task->due_date_dateformat; $do_task->status = $project_task->status; $do_task->date_completed = $project_task->date_completed; $do_task->idcontact = $project_task->idcontact; $do_task->from_note = $project_task->from_note; $do_task->is_sp_date_set = $project_task->is_sp_date_set; $do_task->task_category = $project_task->task_category; $do_task->add(); $lastInsertedTskId = $do_task->getPrimaryKeyValue(); $q = new sqlQuery($GLOBALS['conx']); if ($project_task->progress == '') { $project_task_progress = 0; } else { $project_task_progress = $project_task->progress; } $sql = "INSERT INTO \n\t\t\tproject_task (idtask, idproject, progress,drop_box_code,priority,hrs_work_expected) \n\t\t\tVALUES ({$lastInsertedTskId},{$lastInsertedPrjId},{$project_task_progress},{$project_task->drop_box_code},{$project_task->priority},{$project_task->hrs_work_expected})"; echo $sql; echo "<br>"; $q->query($sql); $lastInsertedPrjTaskId = $q->getInsertId('project_task', 'idproject_task'); $pd_cnt = count($project_task->project_discuss); if ($pd_cnt) { for ($pd_cnt_i = 0; $pd_cnt_i < $pd_cnt; $pd_cnt_i++) { $do_project_discuss = new ProjectDiscuss(); $project_discuss = $project_task->project_discuss[$pd_cnt_i]; $do_project_discuss->idproject_task = $lastInsertedPrjTaskId; $do_project_discuss->idtask = $lastInsertedTskId; $do_project_discuss->idproject = $lastInsertedPrjId; $do_project_discuss->discuss = $project_discuss->discuss; $do_project_discuss->date_added = $project_discuss->date_added; $do_project_discuss->document = $project_discuss->document; $do_project_discuss->iduser = $_SESSION['do_User']->iduser; $do_project_discuss->drop_box_sender = $project_discuss->drop_box_sender; $do_project_discuss->priority = $project_discuss->priority; $do_project_discuss->hours_work = $project_discuss->hours_work; $do_project_discuss->discuss_edit_access = $project_discuss->discuss_edit_access; $do_project_discuss->type = $project_discuss->type; $do_project_discuss->add(); $do_project_discuss->free(); } } // $do_project_task->free(); $do_task->free(); } } $do_project->free(); } $compani_id_cnt = count($compani_id); if ($compani_id_cnt) { $j = 0; foreach ($compani_id as $cmp_id) { $q = new sqlQuery($GLOBALS['conx']); $sql = "UPDATE contact SET idcompany ={$lastInsertedCompani_id[$j]} WHERE iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}"; $q->query($sql); $sql1 = "UPDATE invoice SET idcompany ={$lastInsertedCompani_id[$j]} WHERE iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}"; $q->query($sql1); $sql2 = "UPDATE project SET idcompany ={$lastInsertedCompani_id[$j]} WHERE iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}"; $q->query($sql2); $q->free(); $j++; } } $do_create_usrtbl = new ContactView(); $do_create_usrtbl->rebuildContactUserTable($_SESSION['do_User']->iduser); $msg .= " and Projects have been imported successfully."; } } else { $msg = "Sorry! The data could not be imported."; } } else { $msg = "Sorry! Could not find the uploaded file."; } } $_SESSION['in_page_message'] = $msg; }
/** * update_tag_list * Update the tags list based on commated list (ex. tag1,tag2,tag3,..) */ public static function update_tag_list($tags_comma, $type, $object_id, $overwrite) { debug_event('tag.class', 'Updating tags for values {' . $tags_comma . '} type {' . $type . '} object_id {' . $object_id . '}', '5'); $ctags = Tag::get_top_tags($type, $object_id); $editedTags = explode(",", $tags_comma); if (is_array($ctags)) { foreach ($ctags as $ctid => $ctv) { if ($ctv['id'] != '') { $ctag = new Tag($ctv['id']); debug_event('tag.class', 'Processing tag {' . $ctag->name . '}...', '5'); $found = false; foreach ($editedTags as $tk => $tv) { if ($ctag->name == $tv) { $found = true; break; } } if ($found) { debug_event('tag.class', 'Already found. Do nothing.', '5'); unset($editedTags[$tk]); } else { if ($overwrite) { debug_event('tag.class', 'Not found in the new list. Delete it.', '5'); $ctag->remove_map($type, $object_id); } } } } } // Look if we need to add some new tags foreach ($editedTags as $tk => $tv) { if ($tv != '') { debug_event('tag.class', 'Adding new tag {' . $tv . '}', '5'); Tag::add($type, $object_id, $tv, false); } } }
protected function __str__() { /*** * $src = '<outline title="りあふ の にっき" htmlUrl="http://riaf.g.hatena.ne.jp/riaf/" type="rss" xmlUrl="http://riaf.g.hatena.ne.jp/riaf/rss2" />'; * $xml = OpmlOutline::parse($src); * eq($src,(string)$xml); */ $outTag = new Tag("outline"); if ($this->isTitle()) { $outTag->param("title", $this->title()); } if ($this->isHtmlUrl()) { $outTag->param("htmlUrl", $this->htmlUrl()); } if ($this->isType()) { $outTag->param("type", $this->type()); } if ($this->isXmlUrl()) { $outTag->param("xmlUrl", $this->xmlUrl()); } if ($this->isComment()) { $outTag->param("isComment", $this->isComment()); } if ($this->isBreakpoint()) { $outTag->param("isBreakpoint", $this->isBreakpoint()); } if ($this->isText()) { $outTag->param("text", $this->text()); } if ($this->isDescription()) { $outTag->param("description", $this->description()); } if ($this->isTags()) { $outTag->param("tags", $this->tags()); } $outTag->add($this->value()); foreach ($this->arOutline() as $outline) { $outTag->add($outline); } return $outTag->get(); }