Exemplo n.º 1
0
<?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");
Exemplo n.º 2
0
<?php

create_page_params();
if (request::$params->query) {
    $query = '%' . str_replace(' ', '%', request::$params->query) . '%';
    $forum_posts = ForumPost::find_all(array('order' => "id desc", 'per_page' => 30, 'conditions' => array('title LIKE ? OR body LIKE ?', $query, $query), 'page' => request::$params->page));
} else {
    $forum_posts = ForumPost::find_all(array('order' => "id desc", 'per_page' => 30, 'page' => request::$params->page));
}
calc_pages();
respond_to_list("forum_posts");
Exemplo n.º 3
0
<?php

set_title("Tag Aliases");
create_page_params();
auto_set_params(array('commit', 'query'));
if (Request::$params->commit == "Search Implications") {
    redirect_to('tag_implication#index', array('query' => Request::$params->query));
}
if (Request::$params->query) {
    $name = "%" . Request::$params->query . "%";
    $aliases = TagAlias::find_all(array('order' => "is_pending DESC, name", 'per_page' => 20, 'conditions' => array("name LIKE ? OR alias_id IN (SELECT id FROM tags WHERE name LIKE ?)", $name, $name), 'page' => Request::$params->page));
} else {
    $aliases = TagAlias::find_all(array('order' => "is_pending DESC, name", 'per_page' => 20, 'page' => Request::$params->page));
}
respond_to_list($aliases);
calc_pages();
Exemplo n.º 4
0
<?php

set_title(CONFIG::app_name . " Forum");
create_page_params();
auto_set_params(array('query', 'parent_id'));
if (isset(request::$params->parent_id)) {
    $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 100, 'conditions' => array("parent_id = ?", request::$params->parent_id), 'page' => request::$params->page));
} else {
    $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 30, 'conditions' => array("parent_id IS NULL"), 'page' => request::$params->page));
}
calc_pages();
respond_to_list($forum_posts);
Exemplo n.º 5
0
<?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++;