本文整理汇总了PHP中DataForm::AddXMLValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP DataForm::AddXMLValidator方法的具体用法?PHP DataForm::AddXMLValidator怎么用?PHP DataForm::AddXMLValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataForm
的用法示例。
在下文中一共展示了DataForm::AddXMLValidator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Validator
catch (Exception $e)
{
$exception->AddMessage(_("Invalid extension"));
}
$registry_config = $Registry->GetManifest()->GetSectionConfig();
$Validator = new Validator();
// Validate additional domain information
if (count($registry_config->domain->registration->extra_fields->field) > 0)
{
$display["add_fields"] = UI::GetRegExtraFieldsForSmarty($registry_config);
$DataForm = new DataForm();
$DataForm->AddXMLValidator($registry_config->domain->registration->extra_fields);
$errors = $DataForm->Validate($_POST["add_fields"]);
if ($errors)
foreach ($errors as $_errmsg) $exception->AddMessage($_errmsg);
}
else
$display["add_fields"] = false;
if ($exception->hasMessages())
throw $exception;
$full_dmn_name = "{$_SESSION["domaininfo"]["name"]}.{$_SESSION["domaininfo"]["extension"]}";
if ($_POST["enable_managed_dns"])
{
示例2: testDataFormValidation
function testDataFormValidation()
{
$xmlstr = <<<XML
<fields>
\t<field iseditable="1" description="Phone" type="phone" registry_format="+[2].[4-16]" name="Phone" required="1" />
\t<field iseditable="1" type="select" name="asia_identform" description="Form of Identity" required="0">
\t\t<values>
\t\t\t<value name="Certificate of Incorp" value="certificate"/>
\t\t\t<value name="Charter" value="legislation"/>
\t\t\t<value name="Societies Registry" value="societyRegistry"/>
\t\t\t<value name="Political Party Registry" value="politicalPartyRegistry"/>
\t\t\t<value name="Passport/Citizenship ID" value="passport"/>
\t\t\t<value name="Other" value="other"/>
\t\t</values>
\t</field>
\t<!-- required if asia_identform=other -->
\t<field iseditable="1" type="text" name="asia_otheridentform" description="Other Identification Form" required="0" note="Required when form of identity is 'Other'"/>
</fields>\t\t
XML;
$manifest = simplexml_load_string($xmlstr);
$dform = new DataForm();
$dform->AppendFromXML($manifest);
$dform->AddXMLValidator($manifest);
$dform->AddValidator(create_function('$name, $value, $data', 'if (!$data["asia_identform"] && !$value) return "identform or otheridentform must be set";'), "asia_otheridentform");
$err = $dform->Validate(array());
var_dump($err);
return;
$manifest = simplexml_load_string('<fields><field iseditable="0" description="Full name" type="text" name="name" required="1" minlength="3" maxlength="255" /></fields>');
$err = $dform->ValidateOverManifest($manifest, array("name" => "ma"));
var_dump($err);
$dform->Bind(array("name" => "vv"));
$err = $dform->ValidateOverManifest($manifest, array("name" => "ma"));
var_dump($err);
}
示例3: array
else
{
// Empty extra
$extra_data = array();
}
// Merge extra fields with std POST fields
$extra_data = array_merge($extra_data, $_POST);
$extra_data = array_map('trim', $extra_data);
$XmlConfig = $Registry->GetManifest()->GetSectionConfig();
$trnFields = $XmlConfig->domain->transfer->fields;
if ($trnFields->children())
{
$DataForm = new DataForm();
$DataForm->AddXMLValidator($trnFields);
$errors = $DataForm->Validate($extra_data);
if ($errors)
foreach ($errors as $_errmsg) $err[] = $_errmsg;
}
//var_dump($err);
//var_dump($post_add_data);
//die();
if (!$err)
{
if ($transfer_contacts)
{
foreach($transfer_contacts as $v)
{
示例4: PostExtra
protected function PostExtra()
{
$DForm = new DataForm();
$Validator = new DOMDocument("1.0");
$Validator->appendChild($Validator->createElement("validator"));
$Factory = RegistryModuleFactory::GetInstance();
$tlds = $this->GetTLDs();
$extra_flatten = array();
foreach ($tlds as $tld) {
$Registry = $Factory->GetRegistryByExtension($tld);
$ConfigXml = $Registry->GetManifest()->GetSectionConfig();
$fields = $ConfigXml->domain->registration->extra_fields->xpath("field");
if (count($fields)) {
foreach ($fields as $field) {
$F = dom_import_simplexml($field);
$F = $Validator->importNode($F, true);
$name = "{$tld}-{$field->attributes()->name}";
$F->setAttribute("name", $name);
$extra_flatten[$name] = $this->attr["extra"][$tld][(string) $field->attributes()->name];
$Validator->documentElement->appendChild($F);
}
}
}
$manifest = simplexml_import_dom($Validator->documentElement);
$DForm->AddXMLValidator($manifest);
$err = $DForm->Validate($extra_flatten);
if (!$err) {
$k = "extra";
$this->{$k} = $this->attr[$k];
} else {
$ErrList = new ErrorList();
foreach ($err as $msg) {
$ErrList->AddMessage($msg);
}
throw $ErrList;
}
}