本文整理汇总了PHP中Post::batch_api_data方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::batch_api_data方法的具体用法?PHP Post::batch_api_data怎么用?PHP Post::batch_api_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::batch_api_data方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove_post_confirm
?>
</ul>
</div>
</div>
<script type="text/javascript">
function remove_post_confirm(post_id, pool_id) {
if (!$("del-mode") || !$("del-mode").checked) {
return true
}
Pool.remove_post(post_id, pool_id)
return false
}
Post.register_resp(<?php
echo to_json(Post::batch_api_data($posts));
?>
);
</script>
<?php
echo render_partial('post/hover');
?>
<div id="paginator">
<?php
paginator();
?>
<div style="display: none;" id="info">When delete mode is enabled, clicking on a thumbnail will remove the post from this pool.</div>
</div>
<?php
示例2: json_encode
<div id="post-view">
<?php
if (!$this->post) {
?>
<h2><?php
echo $this->t('.empty');
?>
</h2>
<?php
} else {
?>
<?php
if ($this->post->can_be_seen_by(current_user())) {
?>
<script type="text/javascript">Post.register_resp(<?php
echo json_encode(Post::batch_api_data(array($this->post)));
?>
);</script>
<?php
}
?>
<?php
echo $this->partial('post/show_partials/status_notices', array('pools' => $this->pools));
?>
<div class="sidebar">
<?php
echo $this->partial('search');
?>
<?php
示例3: removePost
public function removePost()
{
$pool = Pool::find($this->params()->pool_id);
$post = Post::find($this->params()->post_id);
if ($this->request()->isPost()) {
try {
$pool->remove_post($this->params()->post_id, array('user' => current_user()));
} catch (Exception $e) {
if ($e->getMessage() == 'Access Denied') {
$this->access_denied();
}
}
$api_data = Post::batch_api_data(array($post));
$this->response()->headers()->add("X-Post-Id", $this->params()->post_id);
$this->respond_to_success("Post removed", array('post#show', 'id' => $this->params()->post_id), array('api' => $api_data));
}
}
示例4: required_params
required_params('id');
auto_set_params('reason');
if (!($post = Post::find(Request::$params->id))) {
exit_with_status(404);
}
if (!empty(Request::$params->unflag)) {
# Allow the user who flagged a post to unflag it.
#
# posts
# "approve" is used both to mean "unflag post" and "approve pending post".
if ($post->status != "flagged") {
respond_to_error("Can only unflag flagged posts", array("#show", 'id' => Request::$params->id));
}
if (!User::is('>=40') and User::$current->id != $post->flag_detail->user_id) {
access_denied();
}
$post->approve(User::$current->id);
$message = "Post approved";
} else {
if ($post->status != "active") {
respond_to_error("Can only flag active posts", array("#show", 'id' => Request::$params->id));
}
$post->flag(Request::$params->reason, User::$current->id);
$message = "Post flagged";
}
# Reload the post to pull in post.flag_reason.
$post->reload();
if (Request::$format == "json" || Request::$format == "xml") {
$api_data = Post::batch_api_data(array($post));
}
respond_to_success($message, array("#show", 'id' => Request::$params->id), array('api' => $api_data));
示例5: it
$p = Post::find($post_id);
$ids[] = $p->id;
# If an entry has only an ID, it was just included in the list to receive changes to
# a post without changing it (for example, to receive the parent's data after reparenting
# a post under it).
if (empty($post)) {
continue;
}
$old_parent_id = $p->parent_id;
Post::filter_api_changes($post);
if ($p->update_attributes(array_merge($post, array('updater_user_id' => $user_id, 'updater_ip_addr' => Request::$remote_ip)))) {
// post.merge(:updater_user_id => user_id, :updater_ip_addr => request.remote_ip))
# Reload the post to send the new status back; not all changes will be reflected in
# @post due to after_save changes.
// $p->reload();
}
if ($p->parent_id != $old_parent_id) {
$p->parent_id && ($ids[] = $p->parent_id);
$old_parent_id && ($ids[] = $old_parent_id);
}
}
# Updates to one post may affect others, so only generate the return list after we've already
# updated everything.
# TODO: need better SQL functions.
$ids = implode(', ', $ids);
$posts = Post::find_all(array('conditions' => array("id IN ({$ids})")));
$api_data = Post::batch_api_data($posts);
$url = !empty(Request::$params->url) ? Request::$params->url : '#index';
// $url = Request::$params->url;
// $url = {:action => "index"} if not url
respond_to_success("Posts updated", $url, array('api' => $api_data));
示例6: remove_post_confirm
?>
</ul>
</div>
</div>
<script type="text/javascript">
function remove_post_confirm(post_id, pool_id) {
if (!$("del-mode") || !$("del-mode").checked) {
return true
}
Pool.remove_post(post_id, pool_id)
return false
}
Post.register_resp(<?php
echo json_encode(Post::batch_api_data($this->posts->members()));
?>
);
</script>
<?php
echo $this->partial("post/hover");
?>
<div id="paginator">
<?php
echo $this->willPaginate($this->posts, ['class' => "no-browser-link"]);
?>
<div style="display: none;" id="info"><?php
echo $this->t('.delete_mode_info');
?>
示例7: to_json
<div id="post-view">
<?php
if (empty($post->id)) {
?>
<h2>Nobody here but us chickens!</h2>
<?php
} else {
if ($post->can_be_seen_by()) {
?>
<script type="text/javascript"> Post.register_resp(<?php
echo to_json(Post::batch_api_data(array($post)));
?>
); </script>
<?php
}
?>
<?php
render_partial("post/show_partials/status_notices", 'pools');
?>
<div class="sidebar">
<?php
render_partial("search");
render_partial("tags");
render_partial("post/show_partials/statistics_panel");
render_partial("post/show_partials/options_panel");
render_partial("post/show_partials/related_posts_panel");
?>
</div>
<div class="content" id="right-col">
示例8: undelete
public function undelete()
{
$post = Post::where(['id' => $this->params()->id])->first();
if (!$post) {
$this->respond_to_error("Post not found", ['#show', 'id' => $this->params()->id]);
return;
}
$post->undelete();
$affected_posts = [$post];
if ($post->parent_id) {
$affected_posts[] = $post->get_parent();
}
if ($this->params()->format == "json" || $this->params()->format == "xml") {
$api_data = Post::batch_api_data($affected_posts);
} else {
$api_data = [];
}
$this->respond_to_success("Post was undeleted", ['#show', 'id' => $this->params()->id], ['api' => $api_data]);
}
示例9: respond_to_error
}
// @preload = @preload.delete_if { |post| not post.can_be_seen_by?(@current_user) }
}
if ($from_api and isset(Request::$params->api_version) && Request::$params->api_version == "2" and Request::$format != "json") {
respond_to_error("V2 API is JSON-only", array(), array('status' => 424));
}
// @posts.replace(results)
$posts = $results;
unset($results);
switch (Request::$format) {
case 'json':
if (empty(Request::$params->api_version) || Request::$params->api_version != "2") {
render('json', to_json(array_map(function ($p) {
return $p->api_attributes();
}, (array) $posts)));
return;
}
$api_data = Post::batch_api_data($posts, array('exclude_tags' => !empty(Request::$params->include_tags) ? false : true, 'exclude_votes' => !empty(Request::$params->include_votes) ? false : true, 'exclude_pools' => !empty(Request::$params->include_pools) ? false : true));
render('json', to_json($api_data));
break;
case 'xml':
ActionView::$layout = false;
return;
break;
}
if (!empty($split_tags)) {
$tags = Tag::parse_query($tags);
} else {
$tags['include'] = Tag::count_by_period(gmd_math('sub', '1D'), gmd(), array('limit' => 25, 'exclude_types' => CONFIG::$exclude_from_tag_sidebar));
}
calc_pages();
示例10: required_params
<?php
required_params('id');
$post = Post::find(Request::$params->id);
$post->undelete();
$affected_posts = array($post);
if ($post->parent_id) {
$affected_posts[] = $post->get_parent();
}
if (Request::$format == "json" || Request::$format == "xml") {
$api_data = Post::batch_api_data($affected_posts);
} else {
$api_data = array();
}
respond_to_success("Post was undeleted", array('#show', array('id' => Request::$params->id), array('api' => $api_data)));