All pastes #109472 Raw Edit

k4st

public php v1 · immutable
·published 2006-08-01 03:06 UTC
rendered paste body
<?php//--------------------------------------------// Controller for no action//--------------------------------------------class IndexController extends k4PageController {	function getPreFilters() 	{		return array('request', 'session', 'user', 'debug_pre', 'template');	}		function getPostFilters() 	{		return array('user_post', 'debug_post', 'history_post');	}		function getRoutes() 	{		return array();	}		//--------------------------------------------	// This happens when the path is '/'	//--------------------------------------------		function index(&$reg, &$req, &$resp) 	{			$user = &$reg->get('user');				//--------------------------------------------		// Get the most recent threads.		//--------------------------------------------				$finder = &$this->getFinder('threads');		$threads = &$finder->findAllWhere("t.deleted=0", array(), 't.created DESC', '', 30);		$size = $threads->numRows() >= 15 ? '_mini' : ($threads->numRows() > 6 ? '_small' : '');				//--------------------------------------------		// Get the 10 most popular tags in the 100 most		// recent threads.		//--------------------------------------------				$finder = &$this->getFinder('tags');		$finder->addTempFrom("k4_thread_tags tt1 JOIN k4_thread_tags tt2 USING ( thread_id ), k4_threads t");		$top_recent_tags = &$finder->selectAllWhere("COUNT(tt2.tag_id) AS tag_count", "ts.tag_id = tt2.tag_id AND t.thread_id=tt2.thread_id", $tag_ids, 'tag_count DESC', 'tt2.tag_id', 10);				//--------------------------------------------		// Set some permissions to the template.		//--------------------------------------------				$resp->assign('can_view_threads', intval($user->canDo('view', 'threads')));				//--------------------------------------------		// Get the channels in order.		//--------------------------------------------				$finder = &$this->getFinder('channels');		$channels = &$finder->findAll('order_key ASC', '', 0, -1);		$channels->setUser($user);		$resp->assignRef('channels', $channels);				//--------------------------------------------		// Get 100 of the thread tags.		//--------------------------------------------				$finder = &$this->getFinder('tags');		$finder->addTempFrom("k4_thread_tags tt1 JOIN k4_thread_tags tt2 USING ( thread_id ) ");		$tags = &$finder->selectAllWhere("COUNT(tt2.tag_id) AS tag_count", "ts.tag_id = tt2.tag_id", $tag_ids, 'ts.tag_name ASC, tag_count DESC', 'tt2.tag_id', 250);		$num_total_tags = $finder->getCountWhere("", array());				//--------------------------------------------		// Get the tag cloud iterator.		//--------------------------------------------				require_once FA_COMPONENTS_DIR .'/tag_cloud_iterator.php';		$resp->assignRef('tag_cloud', new TagCloudIterator($tags, $num_total_tags));				//--------------------------------------------		// Set the main templates and those other things we like.		//--------------------------------------------				$resp->assignRef('thread_list', $threads);		$resp->assignRef('top_recent_tags', $top_recent_tags);		$resp->assign('thread_excerpt_view', 'thread_excerpt_view'. $size .'.html');		$resp->assign('content', 'index.html');		$this->setPage("Lobby");		$this->setLayout('forum_base.html');	}}?>