| Current Path : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zooitemsql/ |
| Current File : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zooitemsql/helper.php |
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* Class Module Helper
* @author kirdinyuri
*/
class modZooitemsqlHelper
{
/**
* getData method
* @param $params
* @return array
*/
static function getData( $params , $ImageCache)
{
$temp=$params->get( 'temp', '' );
$par1=explode("\r\n",$params->get( 'par1', '' ));
$par2=explode("\r\n",$params->get( 'par2', '' ));
$jinput = JFactory::getApplication()->input;
$item_id=htmlspecialchars($jinput->get('item_id','','INT'));
$db = JFactory::getDbo();
$count='';
$db->setQuery($params->get( 'sql', '' ), 0, $count);
$rows = $db->loadAssocList();
if ($params->get( 'shuffle', 'no' )=="yes") shuffle($rows);
if (count($rows)<>0)
{
$i=0;
foreach ($rows as $row)
{
if ($item_id==$row['id'] and $item_id<>'') {continue;}
$i++;
if ($params->get( 'count', '3' )<$i) break;
$a=json_decode($row['elements'],true);
if ($a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']=="biznes-plan"){$a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']="Бизнес-план";}
if ($a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']=="marketingovoe-issledovanie"){$a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']="Маркетинговое исследование";}
if ($a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']=="organizatsiya-finansirovaniya"){$a['dda61284-ed03-4e55-ba8b-b78607d28df3']['option']['0']="Организация финансирования";}
//разбор параметров
$tempitem=$temp;
foreach ($par1 as $item){
$par11=explode("=",$item);
$tempitem=str_replace('{'.$par11[0].'}',$row[$par11[1]],$tempitem);
}
foreach ($par2 as $item){
$par22=explode("|",$item);
if (count($par22)==3) $tempitem=str_replace('{'.$par22[0].'}',$a[$par22[1]][$par22[2]],$tempitem);
if (count($par22)==4) $tempitem=str_replace('{'.$par22[0].'}',$a[$par22[1]][$par22[2]][$par22[3]],$tempitem);
if (count($par22)==5)
{
$imagepath=$ImageCache->ImageCacheJPG($a[$par22[1]][$par22[2]],'mod_zooitemsql',$par22[3],$par22[4],80,"ratio");
if ($imagepath) $a[$par22[1]][$par22[2]]=$imagepath;
$tempitem=str_replace('{'.$par22[0].'}',$a[$par22[1]][$par22[2]],$tempitem);
}
}
$ret[]="{$tempitem}";
}
}
return implode("\r\n",$ret);
}
}