<?PHP

if($this->templates->Numrows > 0){

	$h1_list = '';

	while($row = $this->templates->Each()){

		$link = $this->Link('?page=page&show_page='.$row['name'].'&id='.$row['menu_id'], array('id'));

		if($this->permissions->Numrows > 0){

			echo '<div style="'.($row['is_big'] == 1 ? '' : 'height:650px;overflow:hidden;').'" id="'.($row['is_big'] == 1 ? 'suurpost' : 'vaikepost').'">';
		}
		else{

			echo '<div style="'.($row['is_big'] == 1 ? '' : 'height:610px;overflow:hidden;').'" id="'.($row['is_big'] == 1 ? 'suurpost' : 'vaikepost').'">';
		}
		$img_class = ($row['is_big'] == 1 ? 'right' : 'leftAlone');

		if($this->files->Numrows > 0){

			while($rowImage = $this->files->Assoc()){

				if($rowImage['is_main'] == 1 && $rowImage['file_type'] == 'IMAGE'){

					echo '<a title="'.$row['name'].'" href="'.$link.'">
						<img class="'.$img_class.'" src="'._RootUrl.'/files/page/'.$rowImage['file_name'].'" style="max-width:360px;max-height:270px;" alt="'.$row['name'].'"/>
					</a>';
				}
			}
		}
		$row['content'] = strip_tags($row['content']);

		echo '<span class="esikiri">
			<a title="'.$row['name'].'" href="'.$link.'">'.$row['name'].'</a>
		</span>';
		$h1_list .= $h1_list ? ' '.$row['name'] : $row['name'];
		if($row['author'])
			echo '<span class="autor">'.$row['author'].'</span>';

		if(strlen($row['name']) > 40)
			echo '<div class="tekst"><h2>'.(strlen($row['content']) > 850 ? substr($row['content'], 0, 850).' ...' : $row['content']).'</h2></div>';
		else
			echo '<div class="tekst"><h2>'.(strlen($row['content']) > 1000 ? substr($row['content'], 0, 1000).' ...' : $row['content']).'</h2></div>';

		echo '<a class="loe" href="'.$link.'">'.$this->Language('Loe edasi...').'</a>';

		if($this->permissions->Numrows > 0){

			echo '<a href="'._RootUrl.'/admin?model=content&page=edit&id='.$row['id'].'&template_id='.$row['template_id'].'" class="_blank" style="display:block;margin:10px 0px 10px 0px;text-transform:uppercase;font-size:15px;">['.$this->Language('Edit').']</a>';
		}

		echo '</div>';
	}
	echo '<h1 style="display:none;">'.$h1_list.'</h1>';
}

?>