本文整理汇总了PHP中Post::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::add方法的具体用法?PHP Post::add怎么用?PHP Post::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
public function submit()
{
if (empty($_POST['quote'])) {
error(__("Error"), __("Quote can't be empty.", "quote"));
}
return Post::add(array("quote" => $_POST['quote'], "source" => $_POST['source']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例2: submit
public function submit()
{
if (empty($_POST['video'])) {
error(__("Error"), __("Video can't be blank."));
}
return Post::add(array("embed" => $this->embed_tag($_POST['video']), "video" => $_POST['video'], "caption" => $_POST['caption']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例3: submit
public function submit()
{
if (empty($_POST['body'])) {
error(__("Error"), __("Body can't be blank."));
}
fallback($_POST['slug'], sanitize($_POST['title']));
return Post::add(array("title" => $_POST['title'], "body" => $_POST['body']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例4: main_index
public function main_index($main)
{
$config = Config::current();
if ($config->disable_aggregation or time() - $config->last_aggregation < $config->aggregate_every * 60) {
return;
}
$aggregates = (array) $config->aggregates;
if (empty($aggregates)) {
return;
}
foreach ($aggregates as $name => $feed) {
$xml_contents = preg_replace(array("/<(\\/?)dc:date>/", "/xmlns=/"), array("<\\1date>", "a="), get_remote($feed["url"]));
$xml = simplexml_load_string($xml_contents, "SimpleXMLElement", LIBXML_NOCDATA);
if ($xml === false) {
continue;
}
# Flatten namespaces recursively
$this->flatten($xml);
$items = array();
if (isset($xml->entry)) {
foreach ($xml->entry as $entry) {
array_unshift($items, $entry);
}
} elseif (isset($xml->item)) {
foreach ($xml->item as $item) {
array_unshift($items, $item);
}
} else {
foreach ($xml->channel->item as $item) {
array_unshift($items, $item);
}
}
foreach ($items as $item) {
$date = oneof(@$item->pubDate, @$item->date, @$item->updated, 0);
$updated = strtotime($date);
if ($updated > $feed["last_updated"]) {
# Get creation date ('created' in Atom)
$created = @$item->created ? strtotime($item->created) : 0;
if ($created <= 0) {
$created = $updated;
}
# Construct the post data from the user-defined XPath mapping:
$data = array("aggregate" => $name);
foreach ($feed["data"] as $attr => $field) {
$field = !empty($field) ? $this->parse_field($field, $item) : "";
$data[$attr] = is_string($field) ? $field : YAML::dump($field);
}
if (isset($data["title"]) or isset($data["name"])) {
$clean = sanitize(oneof(@$data["title"], @$data["name"]));
}
Post::add($data, $clean, null, $feed["feather"], $feed["author"], false, "public", datetime($created), datetime($updated));
$aggregates[$name]["last_updated"] = $updated;
}
}
}
$config->set("aggregates", $aggregates);
$config->set("last_aggregation", time());
}
示例5: submit
public function submit()
{
if (empty($_POST['source'])) {
error(__("Error"), __("URL can't be empty."));
}
if (!@parse_url($_POST['source'], PHP_URL_SCHEME)) {
$_POST['source'] = "http://" . $_POST['source'];
}
fallback($_POST['slug'], sanitize($_POST['name']));
return Post::add(array("name" => $_POST['name'], "source" => $_POST['source'], "description" => $_POST['description']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例6: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['photo']) and $_FILES['photo']['error'] == 0) {
$filename = upload($_FILES['photo'], array("jpg", "jpeg", "png", "gif", "bmp"));
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url'], array("jpg", "jpeg", "png", "gif", "bmp"));
} else {
error(__("Error"), __("Couldn't upload photo."));
}
} else {
$filename = $_POST['filename'];
}
return Post::add(array("filename" => $filename, "caption" => $_POST['caption']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例7: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['audio']) and $_FILES['audio']['error'] == 0) {
$filename = upload($_FILES['audio'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url'], array("mp3", "m4a", "mp4", "oga", "ogg", "webm"));
} else {
error(__("Error"), __("Couldn't upload audio file.", "audio"));
}
} else {
$filename = $_POST['filename'];
}
return Post::add(array("title" => $_POST['title'], "filename" => $filename, "description" => $_POST['description']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例8: submit
public function submit()
{
if (!isset($_POST['filename'])) {
if (isset($_FILES['filename']) and $_FILES['filename']['error'] == 0) {
$filename = upload($_FILES['filename']);
} elseif (!empty($_POST['from_url'])) {
$filename = upload_from_url($_POST['from_url']);
} else {
error(__("Error"), __("Couldn't upload file."));
}
} else {
$filename = $_POST['filename'];
}
# Prepend scheme if a URL is detected
if (preg_match('~^((([a-z]|[0-9]|\\-)+)\\.)+([a-z]){2,6}/~', @$_POST['option']['source'])) {
$_POST['option']['source'] = "http://" . $_POST['option']['source'];
}
return Post::add(array("filename" => $filename, "caption" => $_POST['caption'], "title" => $_POST['title']), $_POST['slug'], Post::check_url($_POST['slug']));
}
示例9: blogger_newPost
function blogger_newPost()
{
$params = func_get_args();
$post = new Post();
$post->content = $params[4];
$post->contentformatter = getDefaultFormatter();
$post->contenteditor = getDefaultEditor();
$post->title = htmlspecialchars(api_get_title($params[4]));
if ($params[5]) {
$post->visibility = "public";
} else {
$post->visibility = "private";
}
$result = api_login($params[2], $params[3]);
if ($result) {
return $result;
}
if (!$post->add($params[2])) {
$post->close();
return new XMLRPCFault(1, "Posting error");
}
RSS::refresh();
$id = "{$post->id}";
fireEvent('AddPostByBlogAPI', $id, $post);
$post->close();
return $id;
}
示例10: retrieveCallback
function retrieveCallback($lines, $uid)
{
$this->appendUid($uid);
$mail = $this->pop3->parse($lines);
if (isset($mail['date_string'])) {
$slogan = $mail['date_string'];
$docid = $mail['time_string'];
} else {
$slogan = date("Y-m-d");
$docid = date("H:i:s");
}
if (in_array($mail['subject'], array('제목없음'))) {
$mail['subject'] = '';
}
if (!$this->isAllowed($mail)) {
return false;
}
if (false && empty($mail['attachments'])) {
$this->logMail($mail, "SKIP");
return false;
}
$post = new Post();
$moblog_begin = "\n<div class=\"moblog-entry\">";
$moblog_end = "\n</div>\n";
if ($post->open("slogan = '{$slogan}'")) {
$post->loadTags();
$this->log("* 기존 글을 엽니다. (SLOGAN:{$slogan})");
if (empty($post->tags)) {
$post->tags = array();
}
$tags = $this->extractTags($mail);
/* mail content will be changed */
$post->tags = array_merge($post->tags, $tags);
$post->content .= $moblog_begin . $this->_getDecoratedContent($mail, $docid);
$post->modified = $mail['date'];
$post->visibility = $this->visibility;
} else {
$this->log("* 새 글을 작성합니다. (SLOGAN:{$slogan})");
if (isset($mail['date_year'])) {
$post->title = str_replace(array('%Y', '%M', '%D'), array($mail['date_year'], $mail['date_month'], $mail['date_day']), $this->subject);
} else {
$post->title = str_replace(array('%Y', '%M', '%D'), array(date("Y"), date("m"), date("d")), $this->subject);
}
$post->userid = $this->userid;
$post->category = $this->category;
$post->tags = $this->extractTags($mail);
/* Go with csv string, Tag class supports both string and array */
$post->content = $moblog_begin . $this->_getDecoratedContent($mail, $docid);
$post->contentformatter = getDefaultFormatter();
$post->contenteditor = getDefaultEditor();
$post->created = time();
$post->acceptcomment = true;
$post->accepttrackback = true;
$post->visibility = $this->visibility;
$post->published = time();
$post->modified = $mail['date'];
$post->slogan = $slogan;
if (!$post->add()) {
$this->logMail($mail, "ERROR");
$this->log(_t("실패: 글을 추가하지 못하였습니다") . " : " . $post->error);
return false;
} else {
CacheControl::flushCategory($post->category);
}
}
/* 슬로건을 지워야만 문제가 발생하지 않습니다. */
//unset($post->slogan);
if (isset($mail['attachments']) && count($mail['attachments'])) {
importlib("model.blog.api");
$post->content .= "<div class=\"moblog-attachments\">\n";
foreach ($mail['attachments'] as $mail_att) {
$this->log("* " . _t("첨부") . " : {$mail_att['filename']}");
$att = api_addAttachment(getBlogId(), $post->id, array('name' => $mail_att['filename'], 'content' => $mail_att['decoded_content'], 'size' => $mail_att['length']));
if (!$att) {
$this->logMail($mail, "ERROR");
$this->log(_t("실패: 첨부파일을 추가하지 못하였습니다") . " : " . $post->error);
return false;
}
$alt = htmlentities($mail_att['filename'], ENT_QUOTES, 'utf-8');
$content = '[##_1C|$FILENAME|width="$WIDTH" height="$HEIGHT" alt="' . $alt . '"|_##]';
$content = str_replace('$FILENAME', $att['name'], $content);
$content = str_replace('$WIDTH', $att['width'], $content);
$content = str_replace('$HEIGHT', $att['height'], $content);
$post->content .= $content;
}
$post->content .= "\n</div>";
}
$post->content .= $moblog_end;
if (!$post->update()) {
$this->logMail($mail, "ERROR");
$this->log(_t("실패: 첨부파일을 본문에 연결하지 못하였습니다") . ". : " . $post->error);
return false;
}
$this->logMail($mail, "OK");
return true;
}
示例11: import_movabletype
/**
* Function: import_movabletype
* MovableType importing.
*/
public function import_movabletype()
{
if (empty($_POST)) {
redirect("/admin/?action=import");
}
if (!Visitor::current()->group->can("add_post")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
}
$config = Config::current();
$trigger = Trigger::current();
$dbcon = $dbsel = false;
if ($link = @mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) {
$dbcon = true;
$dbsel = @mysql_select_db($_POST['database'], $link);
}
if (!$dbcon or !$dbsel) {
Flash::warning(__("Could not connect to the specified MovableType database."), "/admin/?action=import");
}
mysql_query("SET NAMES 'utf8'");
$get_authors = mysql_query("SELECT * FROM mt_author ORDER BY author_id ASC", $link) or error(__("Database Error"), mysql_error());
$users = array();
while ($author = mysql_fetch_array($get_authors)) {
# Try to figure out if this author is the same as the person doing the import.
if ($author["author_name"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->full_name or $author["author_url"] == Visitor::current()->website or $author["author_email"] == Visitor::current()->email) {
$users[$author["author_id"]] = Visitor::current();
} else {
$users[$author["author_id"]] = User::add($author["author_name"], $author["author_password"], $author["author_email"], $author["author_nickname"] != $author["author_name"] ? $author["author_nickname"] : "", $author["author_url"], $author["author_can_create_blog"] == "1" ? Visitor::current()->group : null, $author["author_created_on"], false);
}
}
$get_posts = mysql_query("SELECT * FROM mt_entry ORDER BY entry_id ASC", $link) or error(__("Database Error"), mysql_error());
$posts = array();
while ($post = mysql_fetch_array($get_posts)) {
$posts[$post["entry_id"]] = $post;
}
foreach ($posts as $post) {
$body = $post["entry_text"];
if (!empty($post["entry_text_more"])) {
$body .= "\n\n<!--more-->\n\n" . $post["entry_text_more"];
}
$regexp_url = preg_quote($_POST['media_url'], "/");
if (!empty($_POST['media_url']) and preg_match_all("/{$regexp_url}([^\\.\\!,\\?;\"\\'<>\\(\\)\\[\\]\\{\\}\\s\t ]+)\\.([a-zA-Z0-9]+)/", $body, $media)) {
foreach ($media[0] as $matched_url) {
$filename = upload_from_url($matched_url);
$body = str_replace($matched_url, $config->url . $config->uploads_path . $filename, $body);
}
}
$status_translate = array(1 => "draft", 2 => "public", 3 => "draft", 4 => "draft");
$clean = oneof($post["entry_basename"], sanitize($post["entry_title"]));
if (empty($post["entry_class"]) or $post["entry_class"] == "entry") {
$new_post = Post::add(array("title" => $post["entry_title"], "body" => $body, "imported_from" => "movabletype"), $clean, Post::check_url($clean), "text", @$users[$post["entry_author_id"]], false, $status_translate[$post["entry_status"]], oneof(@$post["entry_authored_on"], @$post["entry_created_on"], datetime()), $post["entry_modified_on"], "", false);
$trigger->call("import_movabletype_post", $post, $new_post, $link);
} elseif (@$post["entry_class"] == "page") {
$new_page = Page::add($post["entry_title"], $body, null, 0, true, 0, $clean, Page::check_url($clean));
$trigger->call("import_movabletype_page", $post, $new_page, $link);
}
}
mysql_close($link);
Flash::notice(__("MovableType content successfully imported!"), "/admin/?action=import");
}
示例12: metaWeblog_newPost
public function metaWeblog_newPost($args)
{
$this->auth($args[1], $args[2], 'add');
global $user;
# Support for extended body
$body = $args[3]['description'];
if (!empty($args[3]['mt_text_more'])) {
$body .= '<!--more-->' . $args[3]['mt_text_more'];
}
# Add excerpt to body so it isn't lost
if (!empty($args[3]['mt_excerpt'])) {
$body = $args[3]['mt_excerpt'] . "\n\n" . $body;
}
if (trim($body) === '') {
return new IXR_Error(500, __("Body can't be blank."));
}
$clean = sanitize(oneof(@$args[3]['mt_basename'], $args[3]['title']));
$url = Post::check_url($clean);
$_POST['user_id'] = $user->id;
$_POST['feather'] = XML_RPC_FEATHER;
$_POST['created_at'] = oneof($this->convertFromDateCreated($args[3]), datetime());
if ($user->group->can('add_post')) {
$_POST['status'] = $args[4] ? 'public' : 'draft';
} else {
$_POST['status'] = 'draft';
}
$trigger = Trigger::current();
$trigger->call('metaWeblog_newPost_preQuery', $args[3]);
$post = Post::add(array('title' => $args[3]['title'], 'body' => $body), $clean, $url);
if ($post->no_results) {
return new IXR_Error(500, __("Post not found."));
}
$trigger->call('metaWeblog_newPost', $args[3], $post);
# Send any and all pingbacks to URLs in the body
if (Config::current()->send_pingbacks) {
send_pingbacks($args[3]['description'], $post);
}
return $post->id;
}
示例13: getMail
/**
* Gets the mail from the inbox
* Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
*/
function getMail()
{
$config = Config::current();
if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
$hostname = '{' . $config->emailblog_server . '}INBOX';
# this isn't working well on localhost
$username = $config->emailblog_address;
$password = $config->emailblog_pass;
$subjpass = $config->emailblog_subjpass;
$inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
$emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
if ($emails) {
rsort($emails);
foreach ($emails as $email_number) {
$message = imap_body($inbox, $email_number);
$overview = imap_headerinfo($inbox, $email_number);
imap_delete($inbox, $email_number);
$title = htmlspecialchars($overview->Subject);
$title = preg_replace($subjpass, "", $title);
$clean = strtolower($title);
$body = htmlspecialchars($message);
# The subject of the email is used as the post title
# the content of the email is used as the body
# not sure about compatibility with images or audio feathers
Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
}
}
# close the connection
imap_close($inbox, CL_EXPUNGE);
$config->set("emailblog_mail_checked", time());
}
}
示例14: importer
function importer($path, $node, $line)
{
global $blogid, $migrational, $items, $item;
switch ($path) {
case '/blog/setting':
setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
$setting = new BlogSetting();
if (isset($node['title'][0]['.value'])) {
$setting->title = $node['title'][0]['.value'];
}
if (isset($node['description'][0]['.value'])) {
$setting->description = $node['description'][0]['.value'];
}
if (isset($node['banner'][0]['name'][0]['.value'])) {
$setting->banner = $node['banner'][0]['name'][0]['.value'];
}
if (isset($node['useSloganOnPost'][0]['.value'])) {
$setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
}
if (isset($node['postsOnPage'][0]['.value'])) {
$setting->postsOnPage = $node['postsOnPage'][0]['.value'];
}
if (isset($node['postsOnList'][0]['.value'])) {
$setting->postsOnList = $node['postsOnList'][0]['.value'];
}
if (isset($node['postsOnFeed'][0]['.value'])) {
$setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
}
if (isset($node['publishWholeOnFeed'][0]['.value'])) {
$setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
}
if (isset($node['acceptGuestComment'][0]['.value'])) {
$setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
}
if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
$setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
}
if (isset($node['language'][0]['.value'])) {
$setting->language = $node['language'][0]['.value'];
}
if (isset($node['timezone'][0]['.value'])) {
$setting->timezone = $node['timezone'][0]['.value'];
}
if (!$setting->save()) {
user_error(__LINE__ . $setting->error);
}
if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
Attachment::confirmFolder();
Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
fclose($node['banner'][0]['content'][0]['.stream']);
unset($node['banner'][0]['content'][0]['.stream']);
}
return true;
case '/blog/category':
setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
$category = new Category();
$category->name = $node['name'][0]['.value'];
$category->priority = $node['priority'][0]['.value'];
if (isset($node['root'][0]['.value'])) {
$category->id = 0;
}
if (!$category->add()) {
user_error(__LINE__ . $category->error);
}
if (isset($node['category'])) {
for ($i = 0; $i < count($node['category']); $i++) {
$childCategory = new Category();
$childCategory->parent = $category->id;
$cursor =& $node['category'][$i];
$childCategory->name = $cursor['name'][0]['.value'];
$childCategory->priority = $cursor['priority'][0]['.value'];
if (!$childCategory->add()) {
user_error(__LINE__ . $childCategory->error);
}
}
}
return true;
case '/blog/post':
setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
$post = new Post();
$post->id = $node['id'][0]['.value'];
$post->slogan = @$node['.attributes']['slogan'];
$post->visibility = $node['visibility'][0]['.value'];
if (isset($node['starred'][0]['.value'])) {
$post->starred = $node['starred'][0]['.value'];
} else {
$post->starred = 0;
}
$post->title = $node['title'][0]['.value'];
$post->content = $node['content'][0]['.value'];
$post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
$post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
$post->location = $node['location'][0]['.value'];
$post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
$post->acceptcomment = $node['acceptComment'][0]['.value'];
$post->accepttrackback = $node['acceptTrackback'][0]['.value'];
$post->published = $node['published'][0]['.value'];
if (isset($node['longitude'][0]['.value'])) {
$post->longitude = $node['longitude'][0]['.value'];
//.........这里部分代码省略.........
示例15: while
{
$query = "SELECT * FROM posts WHERE active=1 AND id > " . $lastId;
$result = $this->db->query($query);
while ($row = $result->fetch_object()) {
$out[] = $row;
}
if (empty($out)) {
$out[] = '';
}
return $out;
}
}
if (isset($_POST['findNew'])) {
$post = new Post();
$out = $post->findNew($_POST['findNew']);
if (!empty($out)) {
echo json_encode($out);
} else {
header('HTTP/1.1 500 Fuck');
exit;
}
}
if (isset($_POST['deleteId'])) {
$post = new Post();
$post->delete($_POST['deleteId']);
}
if (isset($_POST['body'])) {
$post = new Post();
$post->setBody($_POST['body']);
$post->add();
}