本文整理汇总了PHP中Thread::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::get方法的具体用法?PHP Thread::get怎么用?PHP Thread::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* To view all comments on a particular thread.
**/
public function view()
{
$thread = Thread::get(Param::get('thread_id'));
$comments = $thread->getComments();
$user_name = $_SESSION['username'];
$this->set(get_defined_vars());
}
示例2: view
public function view()
{
$comment = Comment::get(Param::get('id'));
$auth_user = User::getAuthenticated();
$thread = Thread::get($comment->thread_id);
$title = "#{$comment->id}";
$this->set(get_defined_vars());
}
示例3: redirect
public function redirect()
{
$follow = Follow::getOrFail(Param::get('id'));
$thread = Thread::get($follow->thread_id);
$last_comment_id = Comment::getLastIdInThread($thread);
$follow->last_comment = $last_comment_id;
$follow->update();
redirect(VIEW_THREAD_URL, array('id' => $thread->id, 'page' => ThreadController::LAST_PAGE));
}
示例4: getTrending
public static function getTrending($limit)
{
$trends = Comment::countToday();
$threads = array();
foreach ($trends as $trend) {
$thread = Thread::get($trend['thread_id']);
$thread->count = $trend['count'];
$threads[] = $thread;
}
usort($threads, function ($thread_a, $thread_b) {
$diff = $thread_b->count - $thread_a->count;
if ($diff != 0) {
return $diff;
} else {
return $thread_b->id - $thread_a->id;
}
});
return array_slice($threads, 0, $limit);
}
示例5: write
public function write()
{
$thread = Thread::get(Param::get('thread_id'));
$comment = new Comment();
$page = Param::get('page_next');
switch ($page) {
case 'write_end':
$comment->username = Param::get('username');
$comment->body = Param::get('body');
try {
$thread->write($comment);
} catch (ValidationException $e) {
$page = 'write';
}
break;
default:
throw new NotFoundException("{$page} is not found");
break;
}
$this->set(get_defined_vars());
$this->render($page);
}
示例6: delete
public function delete()
{
redirect_guest_user(LOGIN_URL);
$page = Param::get('page_next', 'delete');
$thread = Thread::get(Param::get('id'));
$auth_user = User::getAuthenticated();
if (!$thread->isAuthor($auth_user)) {
throw new PermissionException();
}
switch ($page) {
case 'delete':
break;
case 'delete_end':
$thread->delete();
redirect(LIST_THREADS_URL);
break;
default:
break;
}
$title = 'Delete thread';
$this->set(get_defined_vars());
}
示例7: update
/**
* Edit title of thread by owner
*/
public function update()
{
$thread = Thread::get(Param::get('thread_id'));
$thread->title = Param::get('title');
$status = "";
if ($thread->title) {
try {
$thread->update(User::getId($_SESSION['username']));
$status = notify("Update Success");
} catch (AppException $e) {
$status = notify($e->getMessage(), 'error');
}
}
$this->set(get_defined_vars());
}
示例8: isThreadBody
public function isThreadBody()
{
$thread = Thread::get($this->thread_id);
$first_comment = Comment::getFirstInThread($thread);
return $first_comment->id == $this->id;
}
示例9: view
public function view()
{
$id = Param::get('id');
$auth_user = User::getAuthenticated();
if ($id) {
$user = User::getOrFail($id);
} elseif ($auth_user) {
$user = $auth_user;
} else {
redirect(LOGIN_URL);
}
$threads = Thread::getAllByUser($user);
$comments = Comment::getAllByUser($user);
$follows = Follow::getAll($user);
foreach ($follows as $follow_key => $follow_element) {
$thread = Thread::get($follow_element->thread_id);
$follow_element->thread_title = $thread->title;
}
$title = $user->username;
$this->set(get_defined_vars());
}