| Current Path : /var/www/iplanru/data/www/i-plan.ru/modules/mod_agents/ |
| Current File : /var/www/iplanru/data/www/i-plan.ru/modules/mod_agents/helper.php |
<?php
defined('_JEXEC') or die;
class modAgentsHelper
{
public static function getText()
{
$lang=JFactory::getLanguage();
$lang=$lang->getTag();
$lang = substr($lang,0,2);
if ($lang=="ru") $index=0;
if ($lang=="en") $index=1;
if (empty($index)) $index=0;
$aid=modAgentsHelper::getIDfilter();
if (count($aid)==0) $aid=modAgentsHelper::getIDfull();
shuffle($aid);
$sql="SELECT * FROM jos_users where id=".$aid[0];
$db= &JFactory::getDBO();
$count='';
$ret= array();
$db->setQuery($sql, 0, $count);
$rows = $db->loadObjectList();
if (count($rows)<>0)
foreach ($rows as $row)
{
$fio=explode("|",$row->fio);
$post=explode("|",$row->post);
$ret[]="<div id=\"agent-item\">";
if (!empty($row->image))
{
//$ret[]="";
$ret[]="<div id=\"agent-image\">
<a class=\"agent-link\" href=\"http://i-plan.ru/index.php?option=com_content&view=article&id=62\">
<img src=\"".JRoute::_($row->image)."\" />
</a>
</div>";
//$ret[]="";
}
$ret[]="<div id=\"agent-text\">";
if (!empty($row->fio)) $ret[]="<div id=\"agent-fio\">{$fio[$index]}</div>";
if (!empty($row->tel)) $ret[]="<div id=\"agent-tel\">{$row->tel}</div>";
if (!empty($row->post)) $ret[]="<div id=\"agent-post\">{$post[$index]}</div>";
$ret[]="</div>";
$ret[]="</div>";
}
return implode("\r\n",$ret);
}
public static function getIDfilter()
{
if ($_GET[option]=='com_content') $matid=$_GET[id];
$sql="SELECT u.id as id
FROM jos_users u, jos_user_usergroup_map g
where u.id=g.user_id
and group_id=10
and u.image<>''
and
(
(instr(concat(',',fitemid,','),concat(',','{$_GET['Itemid']}',','))<>0) or
(instr(concat(',',fitemid,','),concat(',','{$_SERVER['REQUEST_URI']}',','))<>0) or
(((instr(concat(',',fmat,','),concat(',','',','))<>0)) and (fmat<>''))
)";
//echo $sql;
$db= &JFactory::getDBO();
$count='';
$ret= array();
$db->setQuery($sql, 0, $count);
$rows = $db->loadObjectList();
if (count($rows)<>0)
foreach ($rows as $row)
{$ret[]=$row->id;}
return $ret;
}
public static function getIDfull()
{
$sql="SELECT u.id as id
FROM jos_users u, jos_user_usergroup_map g
where u.id=g.user_id and group_id=10 and u.image<>''";
$db= &JFactory::getDBO();
$count='';
$db->setQuery($sql, 0, $count);
$rows = $db->loadObjectList();
if (count($rows)<>0)
foreach ($rows as $row)
{$ret[]=$row->id;}
return $ret;
}
public static function getValue($sql)
{
$db= &JFactory::getDBO();
$count='';
$ret='';
$field='val';
$db->setQuery($sql, 0, $count);
$rows = $db->loadObjectList();
if (count($rows)<>0)
foreach ($rows as $row)
{$ret=$row->$field;};
return $ret;
}
}