當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pool::find_by_id方法代碼示例

本文整理匯總了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
開發者ID:laiello,項目名稱:my-imouto-booru,代碼行數:31,代碼來源:index.php

示例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;
         }
     }
//.........這裏部分代碼省略.........
開發者ID:laiello,項目名稱:my-imouto-booru,代碼行數:101,代碼來源:post.php


注:本文中的Pool::find_by_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。