All pastes #75418 Raw Edit

k4st

public php v1 · immutable
#75418 ·published 2006-06-30 04:42 UTC
rendered paste body
<?php//--------------------------------------------// Controller for no action//--------------------------------------------class ListController extends k4PageController {	function getPreFilters() 	{		return array('request', 'session', 'user', 'debug_pre', 'template');	}		function getRoutes() 	{		return array(			'quickgetthreads' => '/quickgetthreads/:type/:limit',			'getthreads' => '/getthreads/:type/:limit',		);	}		//--------------------------------------------	// This happens when the path is '/list/'	//--------------------------------------------		function index(&$reg, &$req, &$resp) 	{		}		//--------------------------------------------	// Quick get the popular threads or the new threads.	//--------------------------------------------		function quickgetthreads(&$reg, &$req, &$resp)	{		//--------------------------------------------		// 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('created>?', array($cutoff), 'karma_reward DESC', '', $limit);		}		else		{			//--------------------------------------------			// Recent threads.			//--------------------------------------------						$threads = &$finder->findAllWhere('created>?', array($cutoff), 'created DESC', '', $limit);		}				//--------------------------------------------		// Do the template stuff.		//--------------------------------------------				$resp->assignRef('thread_list', $threads);		$this->setLayout('thread_excerpt_view.html');	}		//--------------------------------------------	// Get the threads normally.	//--------------------------------------------		function getthreads(&$reg, &$req, &$resp)	{		$this->quickgetthreads($reg, $req, $resp);				$type = $req->get('type') == 'popular' ? 'popular' : 'recent';				$resp->assign('content', 'list_'. $type .'_threads.html');		$this->setLayout('forum_base.html');	}}?>