| Current Path : /var/www/iplanru/data/www/i-plan.ru/modules/mod_wfmenu/ |
| Current File : /var/www/iplanru/data/www/i-plan.ru/modules/mod_wfmenu/helper.php |
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* Class Module Helper
* @author kirdinyuri
*/
class modWfmenuHelper
{
/**
* getData method
* @param $params
* @return array
*/
static function getCat( $cat,$level)
{
$m=array();
$db = JFactory::getDbo();
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$cat}\"
and published=1
order by ordering")->loadAssocList();
if (count($list)<>0)
{
$m[]="<ul class=\"wfmenu level{$level}\">";
foreach($list as $row)
{
//$icon="<div class=\"wfmenu-icon\"><img src=\"\" /></div>";
$m[]=" <li><a href=\"/index.php?option=com_zoo&category_id={$row['id']}&Itemid=117&view=category\" >
{$icon}<span>{$row['name']}</span></a>";
if ($level==1){ $m[]="<div class=\"wfmenu-dropdown\">";}
$m = array_merge($m, modWfmenuHelper::getCat($row['id'], $level+1 ));
if ($level==1){ $m[]="</div>";}
$m[]="</li>";
}
$m[]="</ul>";
}
return $m;
}
static function getCatAccord( $cat,$level,$mymenuitem)
{
$m=array();
$level++;
$jinput = JFactory::getApplication()->input;
$db = JFactory::getDbo();
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$cat}\"
and published=1
order by ordering")->loadAssocList();
if (count($list)<>0)
{
foreach($list as $row)
{
if ($jinput->get( 'category_id', 0, 'INT' )==$row['id']) {$active=" active";} else {$active="";}
$m[]=" <h3 class=\"{$active}\"><a href=\"/index.php?option=com_zoo&category_id={$row['id']}&Itemid={$mymenuitem}&view=category\" >
{$icon}<span>{$row['name']}</span></a></h3>";
if ($level==2)
{ $m[]="<div class=\"accordion-level{$level}{$active}\" id=\"accordion-level{$level}-{$row['id']}\">"; }
else
{ $m[]="<div class=\"accordion-level{$level}{$active}\" id=\"level{$level}\">"; }
$m = array_merge($m, modWfmenuHelper::getCatAccord($row['id'], $level,$mymenuitem));
$m[]="</div>";
}
}
return $m;
}
static function getCatBtn( $cat,$level,$worktype,$mymenuitem)
{
$m=array();
$db = JFactory::getDbo();
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$cat}\"
and published=1
order by ordering")->loadAssocList();
if (count($list)<>0)
{
foreach($list as $row)
{
if ($worktype<>'') {$wt=" and instr(i.elements, '\"{$worktype}\"')<>0";}
$mat = $db->setQuery(" SELECT c.*
FROM jos_zoo_item i, jos_zoo_category_item ci, jos_zoo_category c
WHERE i.id=ci.item_id
and ci.category_id=c.id
and c.published=1
and i.state=1
and c.id={$cat}
{$wt}")->loadAssoc();
if ($row['id']<>'')
{
$m[]="<a href=\"/index.php?option=com_zoo&category_id={$row['id']}&Itemid={$mymenuitem}&view=category\" ><div>
{$icon}<span>{$row['name']}</span></div></a>";
}
$m = array_merge($m, modWfmenuHelper::getCatBtn($row['id'],$level+1, $worktype,$mymenuitem));
}
}
return $m;
}
static function getCatAccord2( $cat,$level,$mymenuitem,$mopened,$tar)
{
global $icon;
//получение языка
$lang=JFactory::getLanguage();
$lang=$lang->getTag();
$lang = substr($lang,0,2);
if ($lang=='ru'){$langtourl="";}else{$langtourl="&lang={$lang}";}
$m=array();
$jinput = JFactory::getApplication()->input;
$Itemid=$jinput->get( 'Itemid', 0, 'INT' );
$matid=$jinput->get( 'item_id', 0, 'INT' );
$category_id=$jinput->get( 'category_id', 0, 'INT' );
if ($Itemid==108 or $Itemid==109)
{
$mymenuitem=$Itemid;
}
$db = JFactory::getDbo();
$item = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
id=\"{$cat}\"
and published=1")->loadAssoc();
if ($level==0)
{
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$cat}\"
and published=1
order by id")->loadAssocList();
}
else
{
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$cat}\"
and published=1
order by ordering")->loadAssocList();
}
if (!empty($mopened) && in_array($cat, $mopened)) {$opened="";} else {$opened=" closed opacity";}
if ($cat==$category_id or $cat==$tar) {$active=" active";} else {$active="";}
if (count($list)<>0 and $level<=2)
{
if ($level<>0)
{
$m[]=" <h3 class=\"caption-level{$level}{$active}{$opened} nolink\" id=\"hacc_{$item['id']}\" onclick=\"runAcc({$item['id']});\"><a href=\"/index.php?option=com_zoo&category_id={$item['id']}&Itemid={$mymenuitem}&view=category{$langtourl}\" ><span>{$item['name']}</span></a></h3>";
$m[]="<div class=\"accordion-level{$level}{$opened}\" id=\"tacc_{$item['id']}\">";
}
foreach($list as $row){ $m = array_merge($m, modWfmenuHelper::getCatAccord2($row['id'], $level+1,$mymenuitem,$mopened,$tar)); }
if ($level<>0)
{
$m[]="</div>";
}
}
else
{
if ($level<>0)
{
$m[]=" <h3 class=\"caption-level{$level}{$active} acclink\"><a href=\"/index.php?option=com_zoo&category_id={$item['id']}&Itemid={$mymenuitem}&view=category{$langtourl}\" >{$icon}<span>{$item['name']}</span></a></h3>";
$m[]="<div class=\"accordion-level{$level}\" id=\"tacc_{$item['id']}\">";
foreach($list as $row){ $m = array_merge($m, modWfmenuHelper::getCatAccord2($row['id'], $level+1,$mymenuitem,$mopened,$tar)); }
$m[]="</div>";
}
}
return $m;
}
static function getCat2lvl($mymenuitem)
{
//получение языка
$lang=JFactory::getLanguage();
$lang=$lang->getTag();
$lang = substr($lang,0,2);
if ($lang=='ru'){$langtourl="";}else{$langtourl="&lang={$lang}";}
$m=array();
$jinput = JFactory::getApplication()->input;
$Itemid=$jinput->get( 'Itemid', 0, 'INT' );
if ($Itemid==108 or $Itemid==109)
{
$mymenuitem=$Itemid;
}
$db = JFactory::getDbo();
$list = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"2376\"
and published=1
order by ordering")->loadAssocList();
if ($list)
{
$cnt=(int)count($list)/2;
$i=0;
foreach($list as $row)
{
if ($i==0){$m[]="<table><tr><td>";}
if ($i==$cnt){$m[]="</td><td>";}
$m[]="<div class=\"fwmenu-cat\">";
$m[]="<div class=\"fwmenu-cat-caption\"><a href=\"/index.php?option=com_zoo&category_id={$row['id']}&Itemid={$mymenuitem}&view=category{$langtourl}\" ><span>{$row['name']}</span></a></div>";
$subcat = $db->setQuery(" SELECT id,name
FROM #__zoo_category
where
parent=\"{$row['id']}\"
and published=1
order by ordering")->loadAssocList();
if ($subcat)
{
$m[]="<div class=\"fwmenu-subcat\">";
$m[]="<ul>";
foreach($subcat as $item)
{
$m[]="<li><a href=\"/index.php?option=com_zoo&category_id={$item['id']}&Itemid={$mymenuitem}&view=category{$langtourl}\" ><span>{$item['name']}</span></a></li>";
}
$m[]="</ul>";
$m[]="</div>";
}
$m[]="</div>";
if ($i==count($list)-1){$m[]="</td></tr></table>";}
$i++;
}
}
return $m;
}
}