コード例 #1
0
ファイル: show.php プロジェクト: laiello/my-imouto-booru
<?php

create_page_params(true);
required_params('id');
if (isset(Request::$params->samples) && Request::$params->samples == 0) {
    unset(Request::$params->samples);
}
$pool = Pool::find(array(Request::$params->id));
if (!$pool) {
    return 404;
}
$browse_mode = User::$current->pool_browse_mode;
// $q = Tag::parse_query("");
$q = array();
$q['pool'] = (int) Request::$params->id;
$q['show_deleted_only'] = false;
if ($browse_mode == 1) {
    $q['limit'] = 1000;
    $q['order'] = "portrait_pool";
} else {
    $q['limit'] = 24;
}
// $count = Post::count_by_sql(Post::generate_sql($q, array('from_api' => true, 'count' => true)));
// WillPaginate::Collection.new(params[:page], q[:limit], count)
$sql = Post::generate_sql($q, array('from_api' => true, 'offset' => $offset, 'limit' => $pagination_limit));
$posts = Post::find_by_sql(array($sql), array('calc_rows' => 'found_posts'));
calc_pages();
set_title($pool->pretty_name());
switch (Request::$format) {
    case 'json':
        render('json', $pool->to_json());
コード例 #2
0
ファイル: index.php プロジェクト: laiello/my-imouto-booru
<?php

auto_set_params(array('commit', 'query'));
set_title("Tag Implications");
create_page_params();
if (Request::$params->commit == "Search Aliases") {
    redirect_to("tag_alias#index", array('query' => Request::$params->query));
}
if (Request::$params->query) {
    $name = "%" . Request::$params->query . "%";
    $implications = TagImplication::find_all(array('calc_rows', 'order' => "is_pending DESC, (SELECT name FROM tags WHERE id = tag_implications.predicate_id), (SELECT name FROM tags WHERE id = tag_implications.consequent_id)", 'per_page' => 20, 'conditions' => array("predicate_id IN (SELECT id FROM tags WHERE name LIKE ?) OR consequent_id IN (SELECT id FROM tags WHERE name LIKE ?)", $name, $name), 'page' => Request::$params->page));
} else {
    $implications = TagImplication::find_all(array('calc_rows', 'order' => "is_pending DESC, (SELECT name FROM tags WHERE id = tag_implications.predicate_id), (SELECT name FROM tags WHERE id = tag_implications.consequent_id)", 'per_page' => 20, 'page' => Request::$params->page));
}
calc_pages();
respond_to_list("implications");
コード例 #3
0
ファイル: index.php プロジェクト: laiello/my-imouto-booru
<?php

set_title("Comments");
auto_set_params(array('page' => 1));
create_page_params(array('limit' => 10));
if (Request::$format == "json" || Request::$format == "xml") {
    $comments = Comment::find_all(array_merge(Comment::generate_sql(Request::$params), array('per_page' => 25, 'page' => Request::$params->page, 'order' => 'id DESC')));
    // Comment.paginate(Comment.generate_sql(params).merge(:per_page => 25, :page => params[:page], :order => "id DESC"))
    respond_to_list($comments);
} else {
    $posts = Post::find_all(array('calc_rows', 'order' => 'last_commented_at DESC', 'conditions' => 'last_commented_at IS NOT NULL', 'per_page' => 10, 'page' => Request::$params->page));
    // Post.paginate :order => "last_commented_at DESC", :conditions => "last_commented_at IS NOT NULL", :per_page => 10, :page => params[:page]
    // vde($posts);
    $comments = array();
    foreach ($posts as $post) {
        $comments[] = $post->recent_comments();
    }
    // @posts.each { |post| comments.push(*post.recent_comments) }
    // exit;
    // newest_comment = comments.max {|a,b| a.created_at <=> b.created_at }
    // if !@current_user.is_anonymous? && newest_comment && @current_user.last_comment_read_at < newest_comment.created_at
    // @current_user.update_attribute(:last_comment_read_at, newest_comment.created_at)
    // end
    // $posts = $posts.select {|x| x.can_be_seen_by?(@current_user, {:show_deleted => true})}
    $i = 0;
    foreach ($posts as &$x) {
        if (!$x->can_be_seen_by(User::$current, array('show_deleted' => true))) {
            unset($posts->{$i});
        }
        unset($x);
        $i++;