| Current Path : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zoocost/fields/ |
| Current File : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zoocost/fields/zoofld.php |
<?php
/**
* @package ZOO Category
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
class JFormFieldzoofld extends JFormFieldList {
protected $type = 'zoofld';
public function getOptions() {
$options = array();
//get app
if ($handle = opendir(JPATH_ROOT."/media/zoo/applications")) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($file)) $zoo_app[] = $file;
}
closedir($handle);
}
foreach ($zoo_app as $item)
{
if ($handle = opendir(JPATH_ROOT."/media/zoo/applications/".$item."/types")) {
while (false !== ($file = readdir($handle))) {
if (substr(strrchr($file, '.'), 1)=='config')
{
$config_files[] = $item."|".$file;
}
}
closedir($handle);
}
}
foreach($config_files as $item)
{
list($app,$file)=explode("|",$item);
list($fname,$fex)=explode(".",$file);
$path=JPATH_ROOT."/media/zoo/applications/".$app."/types/".$file;
$fobj=fopen($path,"r");
$text=fread($fobj, filesize($path));
$a=json_decode($text,true);
fclose($fobj);
foreach($a[elements] as $key=>$value)
{
$options[]=array("text"=>$app." / ".$fname." / ".$a[elements][$key][name], "value"=>$key);
}
}
array_unshift($options, JHtml::_('select.option', '0', JText::_('Выберите поле')));
return $options;
}
}