<?php

/**
 * IndexController
 *
 * @author Arkadiusz Rychlik <a.rychlik at eppe.com.pl>
 */
class Main_News_Controller_IndexController extends Eppe_Frontend_Controller_Action {
	
	public function indexAction() {
		$this->view->news = News_Model_Newsentry::getLatest();
	}
	
	public function showAction() {
		$id = $this->_getParam('newsid');
		$b = R::findOne('newsentry','id = ?',[$id]);
		$this->view->news = $b;
	}
	
	public function imageAction() {
		$this->_disableLayout();
		$this->_disableView();
		
		$id = $this->_getParam('newsid');
		$width = $this->_getParam('width');
		$height = $this->_getParam('height');
		
		$b = R::findOne('newsentry','id = ?',[$id]);
		$path = News_Newsentry_Storage::factory($b)->getPath().'image.jpg';
		
		Rtn_ImageWc::generate($path, $width, $height);
		exit;
	}
	
}
