<commit_before><?php defined('SYSPATH') or die('No direct script access.');
/**
 * Alpaca Topic Entry
 *
 * @package controller
 * @author icyleaf
 */
class Controller_Topic extends Controller_Alpaca {
	
	public function before()
	{
		parent::before();
		
		// add auto resize to textarea
		$this->header->javascript->append_file('media/js/jquery/autoresize.js', '1.04');
		$this->header->title->set($this->config->title);
	}
	
	/**
	 * View a topic
	 *
	 * @param int $topic_id 
	 */
	public function action_view($topic_id)
	{
		$topic = ORM::factory('topic', $topic_id);
		if ($topic->loaded())
		{
			$topic->hits += 1;
			$topic->save();
			
			$pagination = Pagination::factory(array(
				'view'				=> 'pagination/digg',
				'total_items' 		=> $topic->count,
				'items_per_page'	=> $this->config->post['per_page'],
				));
			
			$this->header->title->prepend($this->config->title);
			
			$this->template->content = View::factory('topic/view')
				->bind('topic', $topic)
				->bind('topic_posts', $topic_posts)
				->bind('write_post', $write_post);
				
			$topic_posts = View::factory('post/list')
				->set('post_count', $topic->posts->find_all()->count())
				->bind('posts', $posts)
				->bind('pagination', $pagination);
				
			$posts = $topic->posts
				->where('reply_id', '=', 0)
				->limit($pagination->items_per_page)
				->offset($pagination->offset)
				->find_all();
			
			$write_post = View::factory('post/write')
				->bind('topic', $topic);
	
			$this->template->sidebar = View::factory('sidebar/topic')
				->set('topic', $topic);
		}
		else
		{
			$this->template->content = View::factory('template/general')
				->bind('title', $title)
				->bind('content', $content);
				
			$title = __('Ooops');
			$content = __('Not found this topic!');
		}
	}
	
	/**
	 * Create a new topic
	 *
	 * @param int $group_id <commit_msg>Fixed: no title while view topic<commit_after><?php defined('SYSPATH') or die('No direct script access.');
/**
 * Alpaca Topic Entry
 *
 * @package controller
 * @author icyleaf
 */
class Controller_Topic extends Controller_Alpaca {
	
	public function before()
	{
		parent::before();
		
		// add auto resize to textarea
		$this->header->javascript->append_file('media/js/jquery/autoresize.js', '1.04');
		$this->header->title->set($this->config->title);
	}
	
	/**
	 * View a topic
	 *
	 * @param int $topic_id 
	 */
	public function action_view($topic_id)
	{
		$topic = ORM::factory('topic', $topic_id);
		if ($topic->loaded())
		{
                        $title = $topic->title;
			$topic->hits += 1;
			$topic->save();
			
			$pagination = Pagination::factory(array(
				'view'                  => 'pagination/digg',
				'total_items' 		=> $topic->count,
				'items_per_page'	=> $this->config->post['per_page'],
				));
			
			$this->template->content = View::factory('topic/view')
				->bind('topic', $topic)
				->bind('topic_posts', $topic_posts)
				->bind('write_post', $write_post);
				
			$topic_posts = View::factory('post/list')
				->set('post_count', $topic->posts->find_all()->count())
				->bind('posts', $posts)
				->bind('pagination', $pagination);
				
			$posts = $topic->posts
				->where('reply_id', '=', 0)
				->limit($pagination->items_per_page)
				->offset($pagination->offset)
				->find_all();
			
			$write_post = View::factory('post/write')
				->bind('topic', $topic);
	
			$this->template->sidebar = View::factory('sidebar/topic')
                                ->bind('title', $title)
				->set('topic', $topic);
		}
		else
		{
			$this->template->content = View::factory('template/general')
				->bind('title', $title)
				->bind('content', $content);
				
			$title = __('Ooops');
			$content = __('Not found this topic!');
		}

                $this->header->title->prepend($title);
	}
	
	/**
	 * Create a new topic
	 *
	 * @param int $group_id 
{'fraction_non_alphanumeric': 0.20417209908735331, 'fraction_numerical': 0.002607561929595828, 'mean_word_length': 3.1380798274002157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2755883', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1274, 'n_words': 225}