Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/iplan.5018.vps.agava.net/modules/mod_zooanons/
Upload File :
Current File : /var/www/iplanru/data/www/iplan.5018.vps.agava.net/modules/mod_zooanons/helper.php

<?php


defined('_JEXEC') or die;


class modZooanonsHelper
{
	public static function getText($zoo_type,$zoo_count,$zoo_Itemid,$zoo_template)
	{
		jimport('imagecache.imagecache');
		$ImageCache = new ImageCache();
		
		$lang=JFactory::getLanguage();
		$lang=$lang->getTag();
		$lang = substr($lang,0,2);
		if ($lang<>'ru'){$langtourl="&lang={$lang}";}
		
		$sql_lang='';
		if ($lang<>"ru")
		{
			$sql_lang=" and instr(elements,'\"0\": \"est\"')<>0 ";
		}
		
		if ($zoo_template=="0")
		{
			$sql="SELECT id, name, DATE_FORMAT(created,\"%d.%m.%y\") as crdate, elements
					FROM jos_zoo_item 
					where type=\"{$zoo_type}\" and publish_up<NOW() and state=1 {$sql_lang}
					order by created desc
					limit {$zoo_count}";
			$db= &JFactory::getDBO();
			$count='';
			$db->setQuery($sql, 0, $count);
			$rows = $db->loadObjectList();
			if (count($rows)<>0)
			{
				foreach ($rows as $row)
				{			
					$ret[]="<div id=\"zoo-anons\">
						<span>{$row->crdate}</span>
						<span>
						<a id=\"zoo-anons-link1\" href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">{$row->name}</a>
						</span>
						</div>";				
				}
			}
		}
		
		if ($zoo_template=="1")
		{
			$sql="SELECT id, name, DATE_FORMAT(created,\"%d.%m.%y\") as crdate, elements
					FROM jos_zoo_item 
					where type=\"{$zoo_type}\" and publish_up<NOW() and state=1 {$sql_lang}
					order by created desc
					limit {$zoo_count}";
			$db= &JFactory::getDBO();
			$count='';
			$db->setQuery($sql, 0, $count);
			$rows = $db->loadObjectList();
			if (count($rows)<>0)
			{
				foreach ($rows as $row)
				{
					$a=json_decode($row->elements,true);
					$imagepath=$ImageCache->ImageCacheJPG($a['57172c66-27cb-442d-a964-19f64f744a3b']['file'],'mod_zooanons',61,86,70);
					$lname=$a['c3b4b9f6-9d61-42f4-a5f1-889be3cf412d']['0']['value'];
					if ($lname=='') {$lname=$row->name;}
					$ret[]="<div id=\"zoo-anons2\">
						<table>
							<tr>
								<td>
									<div id=\"zoo-anons-image\">
										<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">
										<img src=\"{$imagepath}\" />
										</a>
									</div>
								</td>						
								<td valign=\"top\">
								<div id=\"zoo-anons-text\">
									<span id=\"zoo-anons-date\">
										<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">
											{$row->crdate}
										</a>
										<br>
									</span>
									<span>
										<a id=\"zoo-anons-link1\" href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">{$lname}</a>
									</span>
								</div>
								</td>
							</tr>
						</table>					
						</div>
						";			
				}
			}
		}
		
		
		if ($zoo_template=="2")
		{
			//$ret[]='<div class="newstyle">';
			if ($lang=="ru") $ret[]="<div id=\"zagolovok2\">Анонсы готовых бизнес-планов<br> и маркетинговых исследований за 2014-2015 гг.</div>";
			if ($lang=="en") $ret[]="<div id=\"zagolovok2\">Announcements of ready business plans<br> and marketing research for 2014-2015</div>";
			$sql="SELECT id, name, DATE_FORMAT(created,\"%d.%m.%y\") as crdate, elements
					FROM jos_zoo_item 
					where type=\"{$zoo_type}\" and publish_up<NOW() and state=1 AND YEAR(`created`) >= 2014 {$sql_lang}
					order by created desc
					limit {$zoo_count}";
			$db= &JFactory::getDBO();
			$count='';
			$db->setQuery($sql, 0, $count);
			$rows = $db->loadObjectList();
			if (count($rows)<>0)
			{
				foreach ($rows as $row)
				{
					$a=json_decode($row->elements,true);
					$imagepath=$ImageCache->ImageCacheJPG($a['57172c66-27cb-442d-a964-19f64f744a3b']['file'],'mod_zooanons',80,113,70);						
					$ret[]="<div id=\"zoo-anons2\">
						<table>
							<tr>
								<td>
									<div id=\"zoo-anons-image\">
										<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">
										<img src=\"{$imagepath}\" />
										</a>
									</div>
								</td>						
								<td valign=\"top\">
								<div id=\"zoo-anons-text\">
									<span id=\"zoo-anons-date\">
										<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">
											{$row->crdate}</span><br>
										</a>
									<span id=\"zagolovok4\">
										<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">{$row->name}</a>
									</span>
								</div>
								</td>
							</tr>
						</table>					
						</div>
						";			
				}
			}
			
			if ($lang=="ru") $ret[]="<div id=\"zagolovok2\">Анонсы готовых бизнес-планов<br> и маркетинговых исследований за 2010-2013 гг.</div>";
			if ($lang=="en") $ret[]="<div id=\"zagolovok2\">Announcements of ready business plans<br> and marketing research for 2010-2013</div>";
			$sql="SELECT id, name, DATE_FORMAT(created,\"%d.%m.%y\") as crdate
					FROM jos_zoo_item 
					where type=\"{$zoo_type}\" and publish_up<NOW() and state=1 AND YEAR(`created`) <= 2013 {$sql_lang}
					order by created desc
					limit {$zoo_count}";
			$db= &JFactory::getDBO();
			$count='';
			$db->setQuery($sql, 0, $count);
			$rows = $db->loadObjectList();
			if (count($rows)<>0)
			{
				foreach ($rows as $row)
				{			
					$ret[]="<div id=\"zoo-anons\">
						<span>{$row->crdate}</span><br>
						<span id=\"zagolovok4\">
						<a href=\"".JRoute::_("/index.php?option=com_zoo&view=item&item_id={$row->id}&Itemid={$zoo_Itemid}{$langtourl}")."\">{$row->name}</a>
						</span>
						</div>";				
				}
			}
			//$ret[]='</div>';
		}
		
		return implode("\r\n",$ret);
	}
	
	
}