/** * cutPrefix * * cuts a prefix * * @param string $string * a string to cut * @param string $prefix * a prefix * * @return string * result */ function cutPrefix($string, $prefix) { if (!EasyContactFormsUtils::beginsWith($string, $prefix)) { return $string; } return substr($string, strlen($prefix)); }
/** * val * * @param $map * * * @return * */ function val($map) { foreach ($map as $key => $value) { if (!EasyContactFormsUtils::beginsWith($key, 'id-')) { continue; } $names = explode('-', $key); $fldid = intval($names[1]); if ($fldid == 0) { continue; } $fld = EasyContactFormsClassLoader::getObject('CustomFormFields', true, $fldid); if (!$fld) { continue; } $phase = (object) array('index' => 4); include $fld->getTMPFileName('proc'); } }
/** * updates field settings * * @param array $map * request data */ function updateFieldData($map) { $values = $map["a"]; $values = json_decode(stripslashes($values)); $form = $values[0]; $objid = intval($form->oid); $data = $form->a; $fld = EasyContactFormsClassLoader::getObject('CustomFormFields', true, $objid); $flds = array(); $type = $fld->get('Type'); $query = "SELECT\n\t\t\t\tCustomFormFieldTypes.Settings\n\t\t\tFROM\n\t\t\t\t#wp__easycontactforms_customformfieldtypes AS CustomFormFieldTypes\n\t\t\tWHERE\n\t\t\t\tCustomFormFieldTypes.id={$type}"; $typesettings = EasyContactFormsDB::getValue($query); $fieldsettings = $fld->get('Settings'); $typexml = simplexml_load_string($typesettings); $fldxml = new EasyContactFormsSimpleXML($fieldsettings); foreach ($typexml->children() as $item) { $name = $item->getName(); if (isset($data->{$name})) { $value = $data->{$name}; $value = str_replace('&', '&', $value); $value = str_replace(chr(39), ''', $value); unset($fldxml->{$name}); $fldxml->addCDATA($name, $value); if ($name == 'Label') { $flds['Description'] = $value; } } else { $typeval = (string) $typexml->{$name}; if (!isset($fldxml->{$name}) && !empty($typeval)) { $fldxml->{$name} = $typeval; } } } $options = array(); foreach ($data as $key => $value) { if (!EasyContactFormsUtils::beginsWith($key, 'ufo-fieldform-option-li')) { continue; } $options[$key] = $value; } if (sizeof($options) > 0) { unset($fldxml->Options); $fldxml->Options['type'] = 'items'; foreach ($options as $key => $value) { $value = htmlspecialchars($value, ENT_QUOTES); $option = $fldxml->Options->addChild('option', $value); $oid = explode('-', $key); $oid = $oid[count($oid) - 1]; $option['index'] = $oid; $dname = "ufo-fieldform-option-default-{$oid}"; if ($data->{$dname} == 'on') { $option['default'] = 'true'; } } } $phase = (object) array('index' => 2); include $fld->getTMPFileName('proc'); $xml = $fldxml->asXML(); $flds['Settings'] = $xml; parent::update($flds, $objid); $fld->set('Settings', $xml); $fld->updateTemplate(); }