Location: PHPKode > projects > DIY Blog > diy-blog/classes/diy-blog/frontend/view/postRead/ReadPostView.class.php
<?php

/**
 * Blog post view.
 * @package diy-blog.frontend.view.postRead
 * @author	Martynas Jusevicius <hide@address.com>
 * @link	http://www.xml.lt
 */

class ReadPostView extends FrontEndView
{
	public function __construct(Resource $resource = null)
	{
		parent::__construct($resource);

		$this->template->load(APP_VIEW_DIR."postRead/ReadPost.xsl");
		$this->proc->registerPhpFunctions();
	}

	function display(Request $request, Response $response)
	{
		$c = new Criteria();
		$criterion = $c->getNewCriterion(FrontEndResourcePeer::TYPE, FrontEndResourcePeer::CLASSKEY_MONTHLYPOSTLISTRESOURCE);
		$criterion->addOr($c->getNewCriterion(FrontEndResourcePeer::TYPE, FrontEndResourcePeer::CLASSKEY_YEARLYPOSTLISTRESOURCE));
		$c->add($criterion);
		$dateResources = FrontEndResourcePeer::doSelect($c);

		$post = $this->resource->getPagesJoinBackEndResource();
		$post = $post[0];

		$c = new Criteria();
		$c->addAscendingOrderByColumn(CommentPeer::DATETIME);
		$comments = $post->getComments($c);

		$randNumber1 = rand(1, 9);
		$randNumber2 = rand(1, 9);
		$this->proc->setParameter("", "rand-number-1", $randNumber1);
		$this->proc->setParameter("", "rand-number-2", $randNumber2);
		$request->getSession()->setAttribute("captcha", $randNumber1 + $randNumber2);

		$this->resolver->setArgument("post", XMLSerializer::serialize($post));
		$this->resolver->setArgument("comments", XMLSerializer::serialize($comments));
		$this->resolver->setArgument("date-resources", XMLSerializer::serialize($dateResources));

		if ($request->getAttribute("comment-result") != null)
		{
			$this->proc->setParameter("", "comment-result", $request->getAttribute("comment-result"));

			$this->resolver->setArgument("comment-errors", XMLSerializer::serialize($request->getAttribute("comment-errors")));
			$this->resolver->setArgument("comment-form", XMLSerializer::serialize($request->getAttribute("comment-form")));

		}

		parent::display($request, $response);

		$response->setStatus(Response::SC_OK);
	}

}

?>
Return current item: DIY Blog