protected function validate_couponWorth($data) { $coupon_type = I('post.coupon_type'); if ($coupon_type == 1) { return true; } if ($coupon_type == 2 && is_positive_int($data) && $data > 0 || $coupon_type == 0) { return true; } return false; }
function priceShow($str) { $str = floatVal($str) . '.00'; //Незнаю зачем эти два ноля но без них не определяет что число целое if (is_positive_int($str)) { $result = number_format($str, 0, '', ' ') . ' <i class="rouble">i</i>'; } else { $result = number_format($str, 2, '.', ' ') . ' <i class="rouble">i</i>'; } return $result; }
<? //prices foreach($arResult["ITEMS"] as $key=>$arItem) { $key = $arItem["ENCODED_ID"]; if(isset($arItem["PRICE"])): if ($arItem["VALUES"]["MAX"]["VALUE"] - $arItem["VALUES"]["MIN"]["VALUE"] <= 0) continue; ?> <? if(is_positive_int($arItem["VALUES"]["MIN"]["VALUE"])) $price_min = number_format($arItem["VALUES"]["MIN"]["VALUE"],0,'',' '); else $price_min = number_format($arItem["VALUES"]["MIN"]["VALUE"],2,'.',' '); if(is_positive_int($arItem["VALUES"]["MIN"]["VALUE"])) $price_max = number_format($arItem["VALUES"]["MAX"]["VALUE"],0,'',' '); else $price_max = number_format($arItem["VALUES"]["MAX"]["VALUE"],0,'.',' '); ?> <li> <div class="collapsible-header <?if($countActive <= $active_elements):?>active<?$countActive++; endif;?>">Цена</div> <div class="collapsible-body"> <div class="collapsible-body-content"> <div class="range-field price"> <div class="price-min"> <input class="min-value min-price inputtext-small" type="text" name="<?echo $arItem["VALUES"]["MIN"]["CONTROL_NAME"]?>" id="<?echo $arItem["VALUES"]["MIN"]["CONTROL_ID"]?>"
function check_opt_type($cmd, $opt, $name, $types, $msg_type = 'error') { # check if the opt is of the right type $types = explode(',', $types); foreach ($types as $i => $type) { # check for special enum types $sub_types = explode(':', $type); switch ($sub_types[0]) { case 'data_join_type': $main_type = 'enum'; $test = 'inner|outer'; break; case 'data_source_type': $main_type = 'enum'; $test = 'file|pass|search'; break; case 'data_structure_type': $main_type = 'enum'; $test = 'list_of_objects|list_of_columns'; break; case 'data_type': $main_type = 'enum'; $test = 'index|array_of_indexes'; break; case 'document_file_type': $main_type = 'enum'; $test = 'json|yaml'; break; case 'filter_data_type': $main_type = 'enum'; $test = 'join'; break; case 'http_request_method': $main_type = 'enum'; $test = 'get|post'; break; case 'message_type': $main_type = 'enum'; $test = 'error|warning|notice|none'; break; case 'suredone_action': $main_type = 'enum'; $test = 'add|edit'; break; case 'suredone_type': $main_type = 'enum'; $test = 'categories|items|orders|pages|posts|tags'; break; default: $main_type = $sub_types[0]; $test = @$sub_types[1]; break; } # reset the types $type = "{$main_type}"; if ($test) { $type .= ":{$test}"; } $types[$i] = $type; # check the main types # TODO: add integer:min=x,max=y switch ($main_type) { case 'array': $true = is_array($opt); break; case 'array_of_arrays': $true = is_array_of_arrays($opt); break; case 'array_of_integers': $true = is_array_of_integers($opt); break; case 'array_of_strings': $true = is_array_of_strings($opt); break; case 'boolean': $true = is_bool($opt); break; case 'enum': $true = is_enum($opt, $test); break; /*case 'dir' : $true = is_local_dir ($opt); break; case 'file' : $true = is_local_file ($opt); break;*/ /*case 'dir' : $true = is_local_dir ($opt); break; case 'file' : $true = is_local_file ($opt); break;*/ case 'float': $true = is_float($opt); break; case 'integer': $true = is_int($opt); break; case 'positive_integer': $true = is_positive_int($opt); break; case 'string': $true = is_string($opt); break; case 'yaml_array': $true = is_yaml_array($opt); break; case 'yaml_array_of_integers': $true = is_yaml_array_of_integers($opt); break; case 'yaml_array_of_strings': $true = is_yaml_array_of_strings($opt); break; default: return error($cmd, "invalid check opt type '{$type}'"); } if ($true) { return true; } } # build the types string $types_str = $types[0]; if (count($types) > 0) { for ($i = 1; $i < count($types); $i++) { $type = $types[$i]; $types_str = "{$types_str} or {$type}"; } } # build the message string $name = full_opt_name($cmd, $name); $msg = "option '{$name}' is not of type {$types_str}"; message($cmd, $msg, $msg_type); return false; }