<commit_before><?php

/**
 * post actions.
 *
 * @package    blog
 * @subpackage post
 * @author     <NAME>
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class postActions extends sfActions
{	
	public function executeIndex(sfWebRequest $request)
	{
		$this->postPager = new sfDoctrinePager('BlogPost', sfConfig::get('app_homepage_post_count', 10));
		$this->postPager->setQuery(
			Doctrine::getTable('BlogPost')
				->createQuery('p')
				->where('published = ?', true)
				->andWhere('micropost = ?', false)
				->orderBy('created_at desc')
		);
		$this->postPager->setPage($this->getRequestParameter('p_page', 1));
		$this->postPager->init();
		$this->posts = $this->postPager->getResults();
			
		$this->micropostPager = new sfDoctrinePager('BlogPost', sfConfig::get('app_homepage_micropost_count', 10));
		$this->micropostPager->setQuery(
			Doctrine::getTable('BlogPost')
				->createQuery('p')
				->where('published = ?', true)
				->andWhere('micropost = ?', true)
				->orderBy('created_at desc')
		);
		$this->micropostPager->setPage($this->getRequestParameter('mp_page', 1));
		$this->micropostPager->init();
		$this->microposts = $this->micropostPager->getResults();
	}
	
	public function executeShow(sfWebRequest $request)
	{
		$this->post = $this->getRoute()->getObject();
		
		$this->commentForm = new BlogCommentForm();
		$this->commentForm->setPost($this->post);
		
		if (!$this->post->getPublished()) {
			$this->forward404();
		}
		
		$this->post->setViews( $this->post->getViews() + 1 );
		$this->post->save();
		
		// update visitor data
		$this->post->setRead($this->getUser()->getVisitorID());
	}
	
	public function executePermalink(sfWebRequest $request)
	{
		$post = $this->getRoute()->getObject();
		$this->redirect($this->generateUrl('post_show', $post), 301);
	}
	
	public function executeFeed(sfWebRequest $request)
	{
		$this->getResponse()->setHttpHeader('Content-Type', 'application/rss+xml');
		
		$this->posts = Doctrine::getTable('BlogPost')
			->createQuery('p')
			->where('published = ?', true)
			->orderBy('created_at desc')
			->execute();
	}
	
	public function executeCommentsread(sfWebRequest $request)
	{
		$visitor = $this->getVisitor($request);
		Doctrine::getTable('BlogPostVisitor')
			->createQuery('v')
			->delete()
			->where('v.token = ?', $visitor)
			->execute();
		$this->redirect('homepage');
	}
}<commit_msg>fix bug whem marking comments read<commit_after><?php

/**
 * post actions.
 *
 * @package    blog
 * @subpackage post
 * @author     <NAME>
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class postActions extends sfActions
{	
	public function executeIndex(sfWebRequest $request)
	{
		$this->postPager = new sfDoctrinePager('BlogPost', sfConfig::get('app_homepage_post_count', 10));
		$this->postPager->setQuery(
			Doctrine::getTable('BlogPost')
				->createQuery('p')
				->where('published = ?', true)
				->andWhere('micropost = ?', false)
				->orderBy('created_at desc')
		);
		$this->postPager->setPage($this->getRequestParameter('p_page', 1));
		$this->postPager->init();
		$this->posts = $this->postPager->getResults();
			
		$this->micropostPager = new sfDoctrinePager('BlogPost', sfConfig::get('app_homepage_micropost_count', 10));
		$this->micropostPager->setQuery(
			Doctrine::getTable('BlogPost')
				->createQuery('p')
				->where('published = ?', true)
				->andWhere('micropost = ?', true)
				->orderBy('created_at desc')
		);
		$this->micropostPager->setPage($this->getRequestParameter('mp_page', 1));
		$this->micropostPager->init();
		$this->microposts = $this->micropostPager->getResults();
	}
	
	public function executeShow(sfWebRequest $request)
	{
		$this->post = $this->getRoute()->getObject();
		
		$this->commentForm = new BlogCommentForm();
		$this->commentForm->setPost($this->post);
		
		if (!$this->post->getPublished()) {
			$this->forward404();
		}
		
		$this->post->setViews( $this->post->getViews() + 1 );
		$this->post->save();
		
		// update visitor data
		$this->post->setRead($this->getUser()->getVisitorID());
	}
	
	public function executePermalink(sfWebRequest $request)
	{
		$post = $this->getRoute()->getObject();
		$this->redirect($this->generateUrl('post_show', $post), 301);
	}
	
	public function executeFeed(sfWebRequest $request)
	{
		$this->getResponse()->setHttpHeader('Content-Type', 'application/rss+xml');
		
		$this->posts = Doctrine::getTable('BlogPost')
			->createQuery('p')
			->where('published = ?', true)
			->orderBy('created_at desc')
			->execute();
	}
	
	public function executeCommentsread(sfWebRequest $request)
	{
		Doctrine::getTable('BlogPostVisitor')
			->createQuery('v')
			->delete()
			->where('v.token = ?', $this->getUser()->getVisitorID())
			->execute();
		$this->redirect('homepage');
	}
}
{'fraction_non_alphanumeric': 0.19825978868862648, 'fraction_numerical': 0.013258752848560183, 'mean_word_length': 4.60092807424594, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 140, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6883651', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1631, 'n_words': 243}