本文整理汇总了PHP中Post::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getPost方法的具体用法?PHP Post::getPost怎么用?PHP Post::getPost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::getPost方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: home_timeline
/**
* Returns a collection of the most recent Post by the authenticating user and the users they follow
* @return Response
*/
public function home_timeline($id)
{
//get all follower where user id = follower_id
$followers = Relationship::where('follower_id', $id)->get(array('following_id'));
if ($followers->count() > 0) {
$follower_id = array();
array_push($follower_id, $id);
foreach ($followers as $follower) {
array_push($follower_id, $follower->following_id);
}
return Post::getPost($follower_id, $this->page, $this->per_page, $this->type);
} else {
return Response::json(array('status' => '0', 'message' => 'No user found'));
}
}
示例2: __construct
public function __construct(Post $post, $tags = array())
{
parent::__construct('save');
$this->service = PostService::getInstance();
$this->post = $post;
$this->setMethod('post');
$titleTextField = new TextField('title');
$this->addElement($titleTextField->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_title'))->setValue($post->getTitle())->setRequired(true));
$buttons = array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST, BOL_TextFormatService::WS_BTN_MORE, BOL_TextFormatService::WS_BTN_SWITCH_HTML, BOL_TextFormatService::WS_BTN_HTML, BOL_TextFormatService::WS_BTN_VIDEO);
$postTextArea = new WysiwygTextarea('post', $buttons);
$postTextArea->setSize(WysiwygTextarea::SIZE_L);
$postTextArea->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_post'));
$postTextArea->setValue($post->getPost());
$postTextArea->setRequired(true);
$this->addElement($postTextArea);
$draftSubmit = new Submit('draft');
$draftSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'draft');");
if ($post->getId() != null && !$post->isDraft()) {
$text = OW::getLanguage()->text('blogs', 'change_status_draft');
} else {
$text = OW::getLanguage()->text('blogs', 'sava_draft');
}
$this->addElement($draftSubmit->setValue($text));
if ($post->getId() != null && !$post->isDraft()) {
$text = OW::getLanguage()->text('blogs', 'update');
} else {
$text = OW::getLanguage()->text('blogs', 'save_publish');
}
$publishSubmit = new Submit('publish');
$publishSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'publish');");
$this->addElement($publishSubmit->setValue($text));
$tagService = BOL_TagService::getInstance();
$tags = array();
if (intval($this->post->getId()) > 0) {
$arr = $tagService->findEntityTags($this->post->getId(), 'blog-post');
foreach (!empty($arr) ? $arr : array() as $dto) {
$tags[] = $dto->getLabel();
}
}
$tf = new TagsInputField('tf');
$tf->setLabel(OW::getLanguage()->text('blogs', 'tags_field_label'));
$tf->setValue($tags);
$this->addElement($tf);
}
示例3: function
Flight::route('/', function () use($config) {
$post = new Post();
$page = 1;
$posts = $post->getPosts($page, $config->get('per_page'));
$totalItems = count($post->getPostNames());
$urlPattern = $config->get('base_url') . 'page/(:num)';
$paginator = new Paginator($totalItems, $config->get('per_page'), $page, $urlPattern);
Flight::render('index', array('posts' => $posts, 'config' => $config, 'paginator' => $paginator), 'content_layout');
Flight::render('layouts/default');
});
Flight::route('/page/@page', function ($page) use($config) {
$post = new Post();
$posts = $post->getPosts($page, $config->get('per_page'));
$totalItems = count($post->getPostNames());
$urlPattern = $config->get('base_url') . 'page/(:num)';
$paginator = new Paginator($totalItems, $config->get('per_page'), $page, $urlPattern);
Flight::render('index', ['posts' => $posts, 'config' => $config, 'paginator' => $paginator], 'content_layout');
Flight::render('layouts/default');
});
Flight::route('/posts/@name', function ($name) use($config) {
$name = str_replace('../', '', $name);
$name = 'posts/' . $name . '.md';
if (file_exists($name)) {
$onePost = new Post();
$onePost->setListView(FALSE);
$post = $onePost->getPost($name);
Flight::render('post', ['post' => $post, 'config' => $config], 'content_layout');
Flight::render('layouts/default');
}
});
Flight::start();
示例4: testGetPost
public function testGetPost()
{
$post = Post::getPost(1);
$this->assertTrue($post->id == 1);
}
示例5: Validator
// Create Validator Object
$validate = new Validator();
// Create Data Array
$data = array();
$data['post_id'] = $_GET['id'];
$data['name'] = $_POST['name'];
$data['email'] = $_POST['email'];
$data['comment_text'] = $_POST['comment_text'];
// Required fields
$input_array = array('name', 'email', 'comment_text');
if ($validate->isRequired($input_array)) {
if ($validate->isValidEmail($data['email'])) {
if ($post->addComment($data)) {
redirect('post.php?id=' . $post_id, 'Your comment has been posted', 'success');
} else {
redirect('post.php?id=' . $post_id, 'Something went wrong with your comment', 'error');
}
}
} else {
redirect('post.php?id=' . $post_id, 'Your comment form is blank!', 'error');
}
}
// Get Template & Assign Vars
$template = new Template('templates/post.php');
// Assign Vars
$template->post = $post->getPost($post_id);
$template->comments = $post->GetComments($post_id);
$template->recentPosts = $post->getRecentPosts();
$template->categories = $post->getAllCategories();
// Display The Template
echo $template;
示例6: getLastVersionByID
public static function getLastVersionByID($postId)
{
return Post::getPost($postId)->versions->orderBy('created_at', 'desc')->first();
}
示例7: die
echo "Error";
die("Inserttion failed");
}
//finally redirect the user to the same
$app->redirect('/Blog-It/author/' . $f_id);
});
$app->get('/post/:id', function ($pid) use($app) {
require_once 'core/user.inc.php';
require_once 'core/post.inc.php';
require_once 'core/comment.inc.php';
require_once 'core/tag.inc.php';
$user = new User();
$post = new Post();
$comment = new Comment();
$tag = new Tag();
$post_cur = $post->getPost($pid);
$loggedIn = 0;
$name;
if ($post_cur->num_rows == 0) {
$app->notFound();
} else {
session_start();
if ($user->isLoggedIn()) {
$loggedIn = 1;
}
$comments = $comment->getComments($pid);
$tag_result = $tag->getTagsByPostId($pid);
$post = $post_cur->fetch_assoc();
$name = $user->getName($post['author_id'])->fetch_assoc()['name'];
$app->render('post.php', array('post' => $post, 'name' => $name, 'loggedIn' => $loggedIn, 'comment' => $comments, 'user' => $user, 'tag_result' => $tag_result));
}
示例8: header
$router = new \Bramus\Router\Router();
// Custom 404 Handler
$router->set404(function () {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
echo '404, route not found!';
});
// Before Router Middleware
$router->before('GET', '/.*', function () {
header('Content-Type: application/json');
});
// // Static route: / (homepage)
// $router->get('/', function () {
// echo '';
// });
$router->mount('/post', function () use($router) {
// Route: /posts (fetch all posts)
$router->get('/', function () {
$postModel = new Post();
$posts = $postModel->getAllPosts();
echo json_encode($posts);
});
// Route: /post/id (fetch a single post)
$router->get('/(\\d+)', function ($id) {
$postModel = new Post();
$post = $postModel->getPost($id);
echo json_encode($post);
});
});
// Thunderbirds are go!
$router->run();
// EOF
示例9: Validator
// Create Validator Object
$validate = new Validator();
if (isset($_POST['edit'])) {
// Create Data Array
$data = array();
$data['title'] = $_POST['title'];
$data['body'] = $_POST['body'];
$data['category_id'] = $_POST['category'];
$data['author'] = $_POST['author'];
$data['id'] = $post_id;
// Required Fields
$input_array = array('title', 'body', 'category', 'author');
if ($validate->isRequired($input_array)) {
//Check for photo
if (empty($_FILES['photo']['name'])) {
$data['photo'] = $post->getPost($post_id)->photo;
} else {
$photo_errors = $post->uploadPhoto();
if (!empty($photo_errors)) {
foreach ($photo_errors as $error) {
redirect('edit_post.php?id=' . $post_id, $error, 'error');
}
} else {
$data['photo'] = time() . "_" . $_FILES['photo']['name'];
}
}
if ($post->editPost($data)) {
redirect('edit_post.php?id=' . $post_id, 'Your post has been updated!', 'success');
} else {
redirect('edit_post.php?id=' . $post_id, 'Something went wrong with your post', 'error');
}
示例10:
foreach ($posts as $post) {
?>
<?php
if ($post->getUser()->getgender() == 1) {
?>
<div class="bg-info">
<img src="<?php
echo $post->getUser()->getUsername();
?>
.jpg">
<h5><?php
echo $post->getUser()->getUsername();
?>
</h5>
<p><?php
echo $post->getPost();
?>
</p>
</div>
<?php
} else {
?>
<div class="bg-warning">
<img src="<?php
echo $post->getUser()->getUsername();
?>
.jpg">
<h5><?php
echo $post->getUser()->getUsername();
?>
</h5>
示例11: if
<?php
require 'funcionIndex.php';
include 'header.html';
require_once 'model/ModelPost.php';
require_once 'model/ModelComment.php';
if ($_GET['whatever'] != "") {
$titulo = $_GET['whatever'];
$results = Post::getPost($titulo);
$resultsComments = Comment::seleccComments($titulo);
$cuenta = $resultsComments->getCount();
}
?>
<? if (empty($results)): ?>
<h2>Error al seleccionar los datos</h2>
<br>
<? else: ?>
<!--<div class="demo-ribbon"></div>-->
<!-- <main class="demo-main mdl-layout__content">-->
<div class="demo-container mdl-grid">
<div class="mdl-cell mdl-cell--2-col mdl-cell--hide-tablet mdl-cell--hide-phone"></div>
<div
class="demo-content mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
<!--<div class="demo-crumbs mdl-color-text--grey-500">
Google > Material Design Lite > How to install MDL
</div>-->
<img class=" imagenPost" src="<? echo $results->getAlgo('img') ?>"/>
<small> <? echo $results->getAlgo('fecha') ?> por: <? echo $results->getAlgo('autor') ?></small>
<h3><? echo $results->getAlgo('titulo') ?></h3>
<? echo $results->getAlgo('texto') ?>
</div>
示例12: Post
<?php
include_once MODEL . 'post.php';
$post = new Post();
if ($_POST) {
$id = $_POST['id'];
$status = $post->postDeletePost($id);
}
$posts = $post->getPost();
if (count($posts) > 0) {
$smarty->assign('posts', $posts);
}
$smarty->display(VIEW . 'default.tpl');