'/quickgetthreads/:type/:limit', 'getthreads' => '/getthreads/:type/:limit', ); } //-------------------------------------------- // This happens when the path is '/list/' //-------------------------------------------- function index(&$reg, &$req, &$resp) { $this->redirect('/'); } //-------------------------------------------- // Quick get the popular threads or the new threads. //-------------------------------------------- function quickgetthreads(&$reg, &$req, &$resp) { $this->checkXHR(); //-------------------------------------------- // Can this user view the threads? //-------------------------------------------- $user = &$reg->get('user'); $resp->assign('can_view_threads', intval($user->canDo('view', 'threads'))); //-------------------------------------------- // Get the threads. //-------------------------------------------- $limit = intval($req->get('limit')); $cutoff = time() - 604800; $finder = &$this->getFinder('threads'); if($req->get('type') == 'popular') { //-------------------------------------------- // Popular threads. //-------------------------------------------- $threads = &$finder->findAllWhere('t.created>? AND t.deleted=0', array($cutoff), 't.karma_reward DESC', '', $limit); } else if($req->get('type') == 'new') { //-------------------------------------------- // New threads. //-------------------------------------------- $threads = &$finder->findAllWhere('t.deleted=0', array(), 't.created DESC', '', $limit); } else { //-------------------------------------------- // Fresh threads. //-------------------------------------------- $threads = &$finder->findAllWhere('t.deleted=0', array(), 't.recent_created DESC', '', $limit); } //-------------------------------------------- // Do the template stuff. //-------------------------------------------- $size = $threads->numRows() >= 15 ? '_mini' : ($threads->numRows() > 6 ? '_small' : ''); $resp->assignRef('thread_list', $threads); $this->setLayout('thread_excerpt_view'. $size .'.html'); } //-------------------------------------------- // Get the threads normally. //-------------------------------------------- function getthreads(&$reg, &$req, &$resp) { $this->quickgetthreads($reg, $req, $resp); //$type = $req->get('type') == 'popular' ? 'popular' : 'recent'; $types = array('popular' => 'Popular Threads', 'fresh' => 'Fresh Threads', 'new' => 'New Threads'); $type = $req->get('type'); if(!in_array($type, array_keys($types))) { $type = 'fresh'; } $this->setPage($names[$type]); $resp->assign('content', 'list_'. $type .'_threads.html'); $this->setLayout('forum_base.html'); } } ?>