本文整理汇总了PHP中Pool::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::find_by_id方法的具体用法?PHP Pool::find_by_id怎么用?PHP Pool::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pool
的用法示例。
在下文中一共展示了Pool::find_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_title
}
$limit > 1000 && $limit == 1000;
$count = 0;
// begin
// count = Post.fast_count(tags)
// rescue => x
// respond_to_error("Error: #{x}", :action => "error")
// return
// end
set_title('/' . str_replace('_', ' ', $tags));
$tag_suggestions = array();
// if ($count < 16 && count($split_tags) == 1)
// $tag_suggestions = Tag::find_suggestions($tags);
$ambiguous_tags = array();
// $ambiguous_tags = Tag::select_ambiguous($split_tags);
$searching_pool = isset($q['pool']) && is_int($q['pool']) ? Pool::find_by_id($q['pool']) : null;
$from_api = Request::$format == "json" || Request::$format == "xml";
// @posts = WillPaginate::Collection.new(page, limit, count)
// offset = @posts.offset
// posts_to_load = @posts.per_page
if (!$from_api) {
# For forward preloading:
// posts_to_load += @posts.per_page
# If we're not on the first page, load the previous page for prefetching. Prefetching
# the previous page when the user is scanning forward should be free, since it'll already
# be in cache, so this makes scanning the index from back to front as responsive as from
# front to back.
// if page and page > 1 then
// offset -= @posts.per_page
// posts_to_load += @posts.per_page
// end
示例2: commit_tags
function commit_tags()
{
if ($this->is_empty_model()) {
return;
}
$this->tags = array_filter(explode(' ', str_replace(array("\r", "\n"), '', $this->tags)));
$this->current_tags = array_keys($this->parsed_cached_tags);
if (empty($this->old_tags)) {
$this->old_tags = $this->tags;
} elseif (!is_array($this->old_tags)) {
$this->old_tags = array_filter(explode(' ', $this->old_tags));
}
$this->commit_metatags();
foreach ($this->tags as $k => $tag) {
if (!preg_match('~^(-pool|pool|rating|parent|child):|^[qse]$~', $tag)) {
continue;
}
if (in_array($tag, array('q', 's', 'e'))) {
$tag = "rating:{$tag}";
}
$subparam = explode(':', $tag);
$metatag = array_shift($subparam);
$param = array_shift($subparam);
$subparam = empty($subparam) ? null : array_shift($subparam);
switch ($metatag) {
case 'rating':
# Change rating. This will override rating selected on radio buttons.
if (in_array($param, array('q', 's', 'e'))) {
$this->rating = $param;
}
unset($this->tags[$k]);
break;
case 'pool':
try {
$name = $param;
$seq = $subparam;
# Workaround: I don't understand how can the pool be found when finding_by_name
# using the id.
if (ctype_digit($name)) {
$pool = Pool::find_by_id($name);
} else {
$pool = Pool::find_by_name($name);
}
# Set :ignore_already_exists, so pool:1:2 can be used to change the sequence number
# of a post that already exists in the pool.
$options = array('user' => User::find($this->updater_user_id), 'ignore_already_exists' => true);
if ($seq) {
$options['sequence'] = $seq;
}
if (!$pool and !ctype_digit($name)) {
$pool = Pool::create(array('name' => $name, 'is_public' => false, 'user_id' => $this->updater_user_id));
}
if (!$pool) {
continue;
}
if (!$pool->can_change(User::$current, null)) {
continue;
}
$pool->add_post($this->id, $options);
} catch (PostAlreadyExistsError $e) {
} catch (AccessDeniedError $e) {
}
unset($this->tags[$k]);
break;
case '-pool':
unset($this->tags[$k]);
$name = $param;
$cmd = $subparam;
$pool = Pool::find_by_name($name);
if (!$pool->can_change(User::$current, null)) {
break;
}
if ($cmd == "parent") {
# If we have a parent, remove ourself from the pool and add our parent in
# our place. If we have no parent, do nothing and leave us in the pool.
if (!empty($this->parent_id)) {
$pool->transfer_post_to_parent($this->id, $this->parent_id);
break;
}
}
$pool && $pool->remove_post($id);
break;
case 'source':
$this->source = $param;
unset($this->tags[$k]);
break;
case 'parent':
if (is_numeric($param)) {
$this->parent_id = (int) $param;
}
unset($this->tags[$k]);
break;
case 'child':
unset($this->tags[$k]);
break;
default:
unset($this->tags[$k]);
break;
}
}
//.........这里部分代码省略.........