';
if(empty($params['value']))
$params['value'] = array();
elseif(!is_array($params['value'])) {
$params['value'] = utilsGmp::jsonDecode($params['value']);
//$params['value'] = $params['value'][0];
}
$i = 0;
do {
$res .= '
';
foreach($params['options'] as $key => $p) {
switch($countOptions) {
case 1:
if(isset($params['value'][$i]))
$value = is_array($params['value'][$i]) ? $params['value'][$i][$key] : $params['value'][$i];
else
$value = '';
break;
case 2:
default:
$value = isset($params['value'][$i][$key]) ? $params['value'][$i][$key] : '';
break;
}
$paramsForText = array(
'value' => $value,
);
$res .= __($p['label']). htmlGmp::text($name. '['. $i. ']['. $key. ']', $paramsForText);
}
$res .= $remove. '
';
$i++;
} while($i < count($params['value']));
$res .= $add;
$res .= '
';
}
return $res;
}
static public function categorySelectlist($name, $params = array('attrs'=>'', 'size'=> 5, 'value' => '')) {
self::_loadCategoriesOptions();
if(self::$categoriesOptions) {
$params['options'] = self::$categoriesOptions;
return self::selectlist($name, $params);
}
return false;
}
static public function categorySelectbox($name, $params = array('attrs'=>'', 'size'=> 5, 'value' => '')) {
self::_loadCategoriesOptions();
if(!empty(self::$categoriesOptions)) {
$params['options'] = self::$categoriesOptions;
return self::selectbox($name, $params);
}
return false;
}
static public function productsSelectlist($name, $params = array('attrs'=>'', 'size'=> 5, 'value' => '')) {
self::_loadProductsOptions();
if(!empty(self::$productsOptions)) {
$params['options'] = self::$productsOptions;
return self::selectlist($name, $params);
}
return false;
}
static public function productsSelectbox($name, $params = array('attrs'=>'', 'size'=> 5, 'value' => '')) {
self::_loadProductsOptions();
if(!empty(self::$productsOptions)) {
$params['options'] = self::$productsOptions;
return self::selectbox($name, $params);
}
return false;
}
static protected function _loadCategoriesOptions() {
if(empty(self::$categoriesOptions)) {
$categories = frameGmp::_()->getModule('products')->getCategories();
if(!empty($categories)) {
foreach($categories as $c) {
self::$categoriesOptions[$c->term_taxonomy_id] = $c->cat_name;
}
}
}
}
static protected function _loadProductsOptions() {
if(empty(self::$productsOptions)) {
$products = frameGmp::_()->getModule('products')->getModel()->get(array('getFields' => 'post.ID, post.post_title'));
if(!empty($products)) {
foreach($products as $p) {
self::$productsOptions[$p['ID']] = $p['post_title'];
}
}
}
}
static public function slider($name, $params = array('value' => 0, 'min' => 0, 'max' => 0, 'step' => 1, 'slide' => '')) {
$id = self::nameToClassId($name, $params);
$paramsStr = '';
if(!isset($params['slide']) || (empty($params['slide']) && $params['slide'] !== false)) { //Can be set to false to ignore function onSlide event binding
$params['slide'] = 'toeSliderMove';
}
if(!empty($params)) {
if(isset($params['min']) && empty($params['min'])) {
$params['min'] = 0;
}
$paramsArr = array();
foreach($params as $k => $v) {
if(in_array($k, array('attrs')) || strpos($k, '-')) continue;
$value = (is_numeric($v) || in_array($k, array('slide'))) ? $v : '"'. $v. '"';
$paramsArr[] = $k. ': '. $value;
}
$paramsStr = implode(', ', $paramsArr);
}
$res = ''. (isset($params['value']) ? $params['value'] . ' ' : '') . '
';
$res .= '