parser($values, $values['icon-before']); $values['icon-after'] = $this->parser($values, $values['icon-after']); // Generazione dell'etichetta if (!empty($values['label'])) { $result .= '
'; } if (!empty($values['icon-before']) || !empty($values['icon-after'])) { $result .= '
'; if (!empty($values['icon-before'])) { $result .= ' '.$values['icon-before'].''; } } return $result; } public function after(&$values, &$extras) { $result = ''; if (!empty($values['icon-before']) || !empty($values['icon-after'])) { if (!empty($values['icon-after'])) { $result .= ' '.$values['icon-after'].''; } $result .= '
'; unset($values['icon-before']); unset($values['icon-after']); unset($values['icon-custom']); } if (!empty($values['help']) && !empty($values['show-help'])) { $result .= ' '.$values['help'].''; unset($values['help']); unset($values['show-help']); } $rand = rand(0, 99); $values['data-parsley-errors-container'] = '#'.$values['id'].$rand.'-errors'; $result .= '
'; if (!empty($values['label'])) { $result .= '
'; unset($values['label']); } return $result; } protected function parser(&$values, $string) { $result = $string; if (starts_with($string, 'add|')) { $result = $this->add($values, $string); $values['icon-custom'] = 'no-padding'; } elseif (starts_with($string, 'choice|')) { $result = $this->choice($values, $string); $values['icon-custom'] = 'no-padding'; } return $result; } protected function add(&$values, $string) { $result = null; $pieces = explode('|', $string); $id_module = $pieces[1]; $extra = empty($pieces[2]) ? '' : '&'.$pieces[2]; $classes = empty($pieces[3]) ? '' : ' '.$pieces[3]; $module = \Modules::getModule($id_module); if (in_array($module['permessi'], ['r', 'rw'])) { $result = ' '; } return $result; } protected function choice(&$values, $string) { $result = null; $choices = [ [ 'id' => 'UNT', 'descrizione' => _('€'), ], [ 'id' => 'PRC', 'descrizione' => '%', ], ]; $pieces = explode('|', $string); $type = $pieces[1]; $value = (empty($pieces[2]) || !in_array($pieces[2], array_column($choices, 'id'))) ? 'UNT' : $pieces[2]; if ($type == 'untprc') { $result = '{[ "type": "select", "name": "tipo_'.\HTMLBuilder\prepareToField($values['name']).'", "value": "'.\HTMLBuilder\prepareToField($value).'", "values": "json='.substr(str_replace('"', '\"', json_encode($choices)), 2, -2).'", "class": "no-search" ]}'; $result = \HTMLBuilder\HTMLBuilder::replace($result); } return $result; } }