本文整理汇总了PHP中Post类的典型用法代码示例。如果您正苦于以下问题:PHP Post类的具体用法?PHP Post怎么用?PHP Post使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Post类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addPost
public function addPost($user_id, $title, $content)
{
$post = new Post();
$post->savePost($user_id, $title, $content);
$view = new PostView();
$view->renderSavedPost();
}
开发者ID:jpirih,项目名称:Php,代码行数:7,代码来源:PostControler.php
示例2: makePost
protected function makePost()
{
$post = new Post();
$post->title = "titulo";
$post->save();
return $post;
}
开发者ID:sargilla,项目名称:mamushka,代码行数:7,代码来源:TestCase.php
示例3: run
public function run()
{
$user = User::firstOrFail();
$post1 = new Post();
$post1->title = 'A Long Long';
$post1->subtitle = 'In a Galaxy Far Far Away';
$post1->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
$post1->image = '/img/264H.jpg';
$post1->user_id = $user->id;
$post1->save();
$post2 = new Post();
$post2->title = 'A Long Long Time';
$post2->subtitle = 'In a Galaxy Far Far Away';
$post2->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
$post2->image = '/img/264H.jpg';
$post2->user_id = $user->id;
$post2->save();
$post3 = new Post();
$post3->title = 'A Long Long Time Ago';
$post3->subtitle = 'In a Galaxy Far Far Away';
$post3->content = 'Lorem ipsum dolor sit amet, ut numquam repudiandae vim, vix no novum saperet appellantur. Periculis signiferumque ea pri, et dolore conceptam sit. Nominavi facilisi cu vix, eos ut probatus suavitate, solum utinam epicuri ex vis. Quis appareat quaestio et sit, ei pri illud eripuit lobortis, vis modus vivendo tacimates at. Quem moderatius pri in, ut brute noster dicunt his, graeci definitiones mei an';
$post3->image = '/img/264H.jpg';
$post3->user_id = $user->id;
$post3->save();
}
开发者ID:mkwarren21,项目名称:blog.dev,代码行数:25,代码来源:PostTableSeeder.php
示例4: run
public function run()
{
$user = User::firstOrFail();
$post1 = new Post();
$post1->title = '1st Blog Post';
$post1->username = 'admin';
$post1->date = '2016-01-11';
$post1->description = 'This is my first blog post on my laravel blog';
$post1->user_id = $user->id;
$post1->save();
$post2 = new Post();
$post2->title = '2nd Blog Post';
$post2->username = 'admin';
$post2->date = '2016-01-11';
$post2->description = 'This is my second blog post.';
$post2->user_id = $user->id;
$post2->save();
$post3 = new Post();
$post3->title = '3rd Blog Post';
$post3->username = 'admin';
$post3->date = '2016-01-11';
$post3->description = 'This is my third blog post';
$post3->user_id = $user->id;
$post3->save();
}
开发者ID:rogerchin,项目名称:blog.dev,代码行数:25,代码来源:PostTableSeeder.php
示例5: controlerJob
public function controlerJob($maincont)
{
if ($maincont->isLoggued()) {
if (isset($_POST["title"])) {
$p = new Post();
$p->setTitle($_POST["title"]);
$p->setBody($_POST["body"]);
$p->setHour(date("h:i:s"));
$p->setDate(date("Y-m-d"));
// gestion des tags
$tags = explode(" ", $_POST["tags"]);
foreach ($tags as $t) {
if ($t == "") {
continue;
}
$ta = Tag::getByTag($t);
//echo "Tag : $t<br />";
if (count($ta) == 0) {
$mytag = new Tag();
$mytag->setTag($t);
} else {
$mytag = $ta[0];
}
// création du posttag liant le tag et le post
$pt = new Posttag();
$pt->setPostid($p->id);
$pt->setTagid($mytag->id);
}
}
$maincont->goModule("post", "admin");
} else {
$maincont->goModule("home", "display");
}
}
开发者ID:rogerwilko,项目名称:Yet-Another-Blog,代码行数:34,代码来源:controler.php
示例6: run
public function run()
{
$user = User::firstOrFail();
$post1 = new Post();
$post1->title = 'Calculator';
$post1->body = 'Early in Codeup, I made a calculator that functions using JavaScript\'s internal math functions to do the computations. I styled the calculator to look somewhat real, and I was very happy with the glossy buttons I was able to make with some CSS befores and afters. I was also able to approximate the old school real LED display with some CSS gradients. Lastly, there\'s a not-at-all subtle Star Wars reference on the calculator in the lower left corner. Anyone catch the reference?';
$post1->image_url = 'img/cal.png';
$post1->user_id = $user->id;
$post1->save();
$post2 = new Post();
$post2->title = 'Weather API';
$post2->body = 'I got to say that the weather API was a lot of fun. It was incredible to see the two APIs (Open Weather and Google Maps) come together and see how AJAX requests work with JavaScript and jQuery. I kept the CSS simple here, but I like the layout in those square units I created. I feel like it gets the important info out there in a format that is easy to read and look at. I am especially proud of the search area which has the added reverse address look up. Normally, one types in an address and gets the weather for that location. But if one drags the map pin, the search area will also display an address for that location as well. Very neat!';
$post2->image_url = 'img/weather.png';
$post2->user_id = $user->id;
$post2->save();
$post3 = new Post();
$post3->title = 'Simon Says';
$post3->body = 'Simon Says was my first game using JavaScript and jQuery. I did my best to make my Simon to look like the childhood favorite of yesteryear. I\'m so happy with the name plate area. That CSS was a blast to figure out with the metalic shine and realistic buttons! Of course, the real star of this game is the jQuery animations that make it all work.';
$post3->image_url = 'img/simon.png';
$post3->user_id = $user->id;
$post3->save();
$post4 = new Post();
$post4->title = 'Whack-a-mole';
$post4->body = 'Or Whack-a-gopher as I\'ve made it! This game was an amazing build and it was so much fun! I admit it, I got carried away with making each and every game element out of HTML and CSS. I used no images whatsoever! And I think it was totally worth it. This is also where I started to really become fond of CSS animations as I figured out how to make each gopher spin like a 3D game piece upon being clicked. ';
$post4->image_url = 'img/mole.png';
$post4->user_id = $user->id;
$post4->save();
$post5 = new Post();
$post5->title = 'Spatula City';
$post5->body = 'Or our ad lister/Craigslist clone. I made this call-back to the 80s and Weird Al with Zeshan Segal and Reagan Wilkins. Together I think we made a fantastic site for selling and buying spatulas of all sorts, shapes and colors! I was responsible for the ad create form, the ad edit form, and the ads DB table. It was challenging to make the ad edit form which retrieved data from the DB for it to be altered. I also built the ads index page and the ads show pages. Within those two pages, I am super pleased with the categories bar that allows one to filter the ads showing on the ads index page in real time. I used PHP\'s ability to query MySQL and added a change listener with jQuery to submit the radio button selected. That was a great breakthrough for me. To showcase this project, which was never a live site, I have decided to show a few screenshots. Each screenshot shows one of the items I worked to develop such as the navbar, the ads index page (aka the Product page), and the deals page (the dancing spatulas).';
$post5->image_url = 'img/adlister.png';
$post5->user_id = $user->id;
$post5->save();
}
开发者ID:anthony87burns,项目名称:blog.dev,代码行数:34,代码来源:PostTableSeeder.php
示例7: testCounterIncrementsAndDecrementsWhen
public function testCounterIncrementsAndDecrementsWhen()
{
$post_with_comments = new Post();
$post_with_comments->title = 'post 1';
$this->assertTrue($post_with_comments->save());
$post_without_comments = new Post();
$post_without_comments->title = 'post 2';
$this->assertTrue($post_without_comments->save());
//Create 10 comments, ensure counter increments
for ($i = 1; $i <= 10; $i++) {
$comment = new Comment();
$comment->postId = $post_with_comments->id;
$comment->text = 'comment ' . $i;
$this->assertTrue($comment->save());
$post_with_comments->refresh();
$post_without_comments->refresh();
$this->assertEquals($post_with_comments->commentsCount, $i);
$this->assertEquals($post_without_comments->commentsCount, 0);
}
//Delete all comments, ensure counter decrements
$comments = Comment::find()->all();
$count = count($comments);
foreach ($comments as $comment) {
$this->assertEquals($comment->delete(), 1);
$count--;
$post_with_comments->refresh();
$this->assertEquals($post_with_comments->commentsCount, $count);
}
}
开发者ID:ostapetc,项目名称:yii2-cache-counter-behavior,代码行数:29,代码来源:CounterCacheBehaviorTest.php
示例8: actionCreate
/**
* 录入
*
*/
public function actionCreate()
{
parent::_acl();
$model = new Post();
$attr = $this->_gets->getPost('attr');
$imageList = $this->_gets->getPost('imageList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
if (isset($_POST['Post'])) {
$style = $this->_gets->getPost('style');
$acl = $this->_gets->getPost('acl');
$styleFormat = XUtils::titleStyle($style);
$file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(400, 250)));
$model->attributes = $_POST['Post'];
if (is_array($file)) {
$model->attach_status = 'Y';
$model->attach_file = $file['pathname'];
$model->attach_thumb = $file['paththumbname'];
}
$model->title_style = $styleFormat['text'];
$model->title_style_serialize = $styleFormat['serialize'];
$model->acl = is_array($acl) ? implode(',', $acl) : '';
$model->image_list = $imageListSerialize['dataSerialize'];
if ($model->save()) {
Attr::create($model->id, $attr);
Post2tags::build('create', $_POST['Post']['tags'], $model->id, $model->catalog_id);
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
$this->redirect(array('index'));
}
}
$attrData = Attr::dataReset($attr);
$attrModel = Attr::lists($model->catalog_id, 'post');
$this->render('create', array('model' => $model, 'imageList' => $imageListSerialize['data'], 'attrModel' => $attrModel, 'attrData' => $attrData));
}
开发者ID:tecshuttle,项目名称:51qsk,代码行数:37,代码来源:PostController.php
示例9: archiveMonths
public function archiveMonths()
{
$postManager = new Post();
$sql = "SELECT DISTINCT DATE_FORMAT(posted_at, '%Y') AS year, DATE_FORMAT(posted_at, '%m') AS month FROM posts WHERE is_active = 1 ORDER BY year DESC, month DESC";
$res = $postManager->getAdapter()->query($sql)->fetchAll();
return $res;
}
开发者ID:neilgarb,项目名称:codecaine,代码行数:7,代码来源:ArchiveMonths.php
示例10: toHistoryString
/**
* return the string to appear in the history
*
* @param Post $post
* @return string
*/
public static function toHistoryString($post)
{
$controller = sfContext::getInstance()->getController();
$link = $controller->genUrl('@view_thread?thread_id=' . $post->getThreadId());
$link = sprintf('<a href="%s">%s</a>', $link, 'forum thread');
return sprintf('posted on a %s', $link);
}
开发者ID:rayku,项目名称:rayku,代码行数:13,代码来源:PostPeer.php
示例11: editPost
public function editPost(Post $post)
{
$STH = $this->DBH->prepare("UPDATE Posts SET textpost=:textpost, title=:title\n WHERE id=:id");
$STH->bindValue(":textpost", $post->getTextpost());
$STH->bindValue(":title", $post->getTitle());
$STH->execute();
}
开发者ID:NotBadCode,项目名称:BlogTest,代码行数:7,代码来源:PostsMapper.php
示例12: send
public function send()
{
$author = !empty($_POST['author']) ? strip_tags($_POST['author']) : '';
$content = !empty($_POST['content']) ? htmlspecialchars($_POST['content']) : '';
$errors = array();
if (!empty($_POST)) {
$post = new Post();
foreach ($_POST as $key => $value) {
try {
$post->{$key} = $value;
} catch (Exception $e) {
$errors[$key] = $e->getMessage();
}
}
if (empty($errors)) {
$result_id = $post->insert();
if ($result_id > 0) {
header('Location: post.php?id=' . $result_id);
exit;
}
$errors['internal error'] = 'An error occured, please try again later';
}
}
$vars = array('author' => $author, 'content' => $content, 'errors' => $errors);
Post::displayTemplate('send.tpl', $vars);
}
开发者ID:vincenthib,项目名称:jdc-poo,代码行数:26,代码来源:PostController.class.php
示例13: new_comment
/**
* inserts a new comment
*
* @param $data array
*
* @return int(id)|string(error)
*/
public static function new_comment($data)
{
$database = new Database();
$post = new Post();
$PostID = $data['post_id'];
$content = $data['content'];
$token = $data['token'];
if (empty(trim($content))) {
die("Comment can't be empty");
}
$qna = new QNA();
if (!is_object($qna->get_question($PostID)) && !is_array($post->get_post($PostID, true))) {
die("Error! Post was not found.");
}
if (!Token::validateToken($token)) {
die("Error! Please try again later");
}
unset($data['token']);
$data['uid'] = USER_ID;
$insert = $database->insert_data(TABLE_COMMENTS, $data);
if ($insert === true && $database->error === false) {
// success
return (int) $database->lastId;
} else {
return array_shift($database->errors);
}
}
开发者ID:khaledkhalil94,项目名称:SH.A,代码行数:34,代码来源:Comment.php
示例14: viewAction
public function viewAction()
{
$label = $this->_getParam('label');
if ($label === null) {
throw new Zend_Exception('No label specified in TagsController::viewAction()');
}
$tagManager = new Tag();
$tag = $tagManager->fetchRow(array('label = ?' => $label));
if ($tag === null) {
throw new Zend_Exception('Tag not found in TagsController::viewAction()');
}
$this->view->tag = $tag;
// get posts
$page = array_key_exists('p', $_GET) ? $_GET['p'] : 1;
$page = $page < 1 ? 1 : $page;
$this->view->page = $page;
$postManager = new Post();
$postCount = $postManager->fetchAll(array('id IN (SELECT post_id FROM posts_tags WHERE tag_id = ?)' => $tag->id, 'is_active = ?' => 1))->count();
$this->view->pageCount = ceil($postCount / 10);
$this->view->posts = $postManager->fetchAll(array('id IN (SELECT post_id FROM posts_tags WHERE tag_id = ?)' => $tag->id, 'is_active = ?' => 1), 'posted_at DESC', 10, ($page - 1) * 10);
$this->view->paginationBase = '/tags/' . $tag->label;
// description
$this->view->metaDescription = 'Read my posts tagged with \'' . $tag->title . '\'.';
// set title
$this->_title('Posts tagged with \'' . $tag->title . '\'');
$this->_forward('listing', 'posts');
}
开发者ID:neilgarb,项目名称:codecaine,代码行数:27,代码来源:TagsController.php
示例15: prepareSidebar
/**
* Prepare sidebar data, random tags and archive list
*/
private function prepareSidebar()
{
//if tags cache exist, skip retrieving from DB, expires every 5 minutes
$cacheTagOK = Doo::cache('front')->testPart('sidebarTag', 300);
if (!$cacheTagOK) {
echo '<h2>Cache expired. Get Tags from DB!</h2>';
//get random 10 tags
Doo::loadModel('Tag');
$tags = new Tag();
$this->data['randomTags'] = $tags->limit(10, null, null, array('custom' => 'ORDER BY RAND()'));
} else {
$this->data['randomTags'] = array();
}
//if archive cache exist, skip retrieving from DB, archive expires when Post added, updated, deleted
$cacheArchiveOK = Doo::cache('front')->testPart('sidebarArchive', 31536000);
if (!$cacheArchiveOK) {
echo '<h2>Cache expired. Get Archives from DB!</h2>';
//you can pass data to constructor to set the Model properties
Doo::loadModel('Post');
$p = new Post(array('status' => 1));
$this->data['archives'] = $p->getArchiveSummary();
} else {
$this->data['archives'] = array();
}
}
开发者ID:mindaugas-valinskis,项目名称:doophp,代码行数:28,代码来源:ErrorController.php
示例16: parseItem
function parseItem($blog, $item, $ts)
{
if ($ts != 0 && $item->pubdate <= $ts) {
logmsg('Zatrzymanie na wpisie: %s', StringUtils::removeAccents($item->title));
return false;
}
logmsg(' - Parsowanie wpisu: %s', StringUtils::removeAccents($item->title));
$post = new Post();
$post->setBlog($blog);
foreach ($item->tags as $name) {
$tag = TagPeer::retriveByName($name, true);
if ($post->addTag($tag)) {
logmsg(' - Znaleziono tag: %s', $name);
}
}
if ($post->hasTags()) {
$shortened = $post->setFullContent($item->content);
$post->setLink(htmlspecialchars($item->link));
$post->setTitle($item->title);
$post->setCreatedAt($item->pubdate);
$post->setShortened($shortened);
$post->save();
} else {
logmsg(' - Nie znaleziono tagow');
}
return true;
}
开发者ID:noose,项目名称:Planeta,代码行数:27,代码来源:refresh.php
示例17: makePost
protected function makePost()
{
$post = new Post();
$post->text = 'Some title';
$post->save();
return $post;
}
开发者ID:topix-hackademy,项目名称:loggable-models,代码行数:7,代码来源:TestCase.php
示例18: run
public function run()
{
$user = User::firstOrFail();
$post1 = new Post();
$post1->title = 'Zee\'s first blog';
$post1->body = 'This is a blog post about my time creating my personal website. It has been interesting.';
$post1->user_id = $user->id;
$post1->save();
$post2 = new Post();
$post2->title = 'What new language should I learn? ';
$post2->body = 'there has been plenty of talk about Python and Ruby. I don\'t know which way to go. But, I think Javascript is where I am going to focus mos tof my practice.... for now.';
$post2->user_id = $user->id;
$post2->save();
$post3 = new Post();
$post3->title = 'Codeup is where this was created.';
$post3->body = 'Codeup is where I spent the last 6 months developing my skills as a software engineer. Locate din the heart of San Antonio, it has helped a few hundred folks get into the coding world.';
$post3->user_id = $user->id;
$post3->save();
$post4 = new Post();
$post4->title = 'Practice, Practice, Practice';
$post4->body = 'Practice makes perfect, right? Well I need to keep developing my skills. Upddating and changing my website as needed.';
$post4->user_id = $user->id;
$post4->save();
$post5 = new Post();
$post5->title = 'This is a blog post about my life.';
$post5->body = 'Born and raised in DFW, I moved to Austin at 18 years old. I have loved it ever since. It is the only city I have ever called home.';
$post5->user_id = $user->id;
$post5->save();
}
开发者ID:ZeshanNSegal,项目名称:blog.dev,代码行数:29,代码来源:PostTableSeeder.php
示例19: run
public function run()
{
$user = User::firstOrFail();
$post1 = new Post();
$post1->title = 'First post';
$post1->subtitle = 'This is a subtitle';
$post1->content = 'It is super easy to create a new post.';
$post1->image = 'This is an image';
$post1->user_id = $user->id;
$post1->save();
$post2 = new Post();
$post2->title = 'Second post';
$post2->subtitle = 'This is a subtitle';
$post2->content = 'It is super easy to create a new post.';
$post2->image = 'This is an image';
$post2->user_id = $user->id;
$post2->save();
$post3 = new Post();
$post3->title = 'Third post';
$post3->subtitle = 'This is a subtitle';
$post3->content = 'It is super easy to create a new post.';
$post3->image = 'This is an image';
$post3->user_id = $user->id;
$post3->save();
$post4 = new Post();
$post4->title = 'Fourth post';
$post4->subtitle = 'This is a subtitle';
$post4->content = 'It is super easy to create a new post.';
$post4->image = 'This is an image';
$post4->user_id = $user->id;
$post4->save();
}
开发者ID:crystalwyrick,项目名称:My-Laravel-Blog,代码行数:32,代码来源:PostTableSeeder.php
示例20: store
public function store()
{
$files = Input::file('path');
$filesStatus = Input::get('file_status');
$status = 'success';
if ($files == null) {
Session::flash('status', 'false');
$errors_message[] = "Over max upload size!";
Session::flash('errors_message', $errors_message);
return Redirect::to('user/upload')->header('Cache-Control', 'no-store, no-cache');
}
foreach ($files as $index => $file) {
if ($file->isValid() && $filesStatus[$index] != 0) {
$post = new Post();
$post->save();
$album = $this->saveAlbum($index, $post);
if ($album) {
if (!$this->saveImage($index, $album->id, $post)) {
$status = 'false';
break;
}
} else {
$status = 'false';
break;
}
}
}
Session::flash('status', $status);
return Redirect::to('album/create')->header('Cache-Control', 'no-store, no-cache');
}
开发者ID:huuson94,项目名称:btlwebapp,代码行数:30,代码来源:ImagesController.php
注:本文中的Post类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论