function _createInsertAddressRuleset($fieldset_list) { $xml_file = './files/ruleset/ncart_insertAddress.xml'; $buff = '<?xml version="1.0" encoding="utf-8"?>' . '<ruleset version="1.5.0">' . '<customrules>' . '</customrules>' . '<fields>%s</fields>' . '</ruleset>'; $fields = array(); $fields[] = '<field name="member_srl" required="true" rule="number" />'; $fields[] = '<field name="opt" required="true" />'; $fields[] = '<field name="title" required="true" />'; $fields[] = '<field name="address" required="true" />'; if (count($fieldset_list)) { foreach ($fieldset_list as $fieldset) { foreach ($fieldset->fields as $field) { if ($field->required == 'Y') { switch ($field->column_type) { case 'tel': case 'kr_zip': $fields[] = sprintf('<field name="%s[]" required="true" />', $field->column_name); break; case 'email_address': $fields[] = sprintf('<field name="%s" required="true" rule="email"/>', $field->column_name); break; case 'user_id': $fields[] = sprintf('<field name="%s" required="true" rule="userid" length="3:20" />', $field->column_name); break; default: $fields[] = sprintf('<field name="%s" required="true" />', $field->column_name); break; } } } } } $xml_buff = sprintf($buff, implode('', $fields)); FileHandler::writeFile($xml_file, $xml_buff); unset($xml_buff); $validator = new Validator($xml_file); $validator->setCacheDir('files/cache'); $validator->getJsPath(); }
/** * @brief create insert item ruleset **/ function _createInsertItemRuleset($extra_vars) { $xml_file = './files/ruleset/nproduct_insertItem.xml'; $buff = '<?xml version="1.0" encoding="utf-8"?>' . '<ruleset version="1.5.0">' . '<customrules>' . '</customrules>' . '<fields>%s</fields>' . '</ruleset>'; $fields = array(); $fields[] = '<field name="module_srl" required="true" />'; $fields[] = '<field name="item_name" required="true" length="1:60" />'; $fields[] = '<field name="document_srl" required="true" rule="number" />'; $fields[] = '<field name="price" required="true" rule="number" />'; $fields[] = '<field name="description" required="true" />'; if (count($extra_vars)) { foreach ($extra_vars as $formInfo) { if ($formInfo->required == 'Y') { if ($formInfo->type == 'tel' || $formInfo->type == 'kr_zip') { $fields[] = sprintf('<field name="%s[]" required="true" />', $formInfo->column_name); } else { if ($formInfo->type == 'email_address') { $fields[] = sprintf('<field name="%s" required="true" rule="email"/>', $formInfo->column_name); } else { if ($formInfo->type == 'user_id') { $fields[] = sprintf('<field name="%s" required="true" rule="userid" length="3:20" />', $formInfo->column_name); } else { $fields[] = sprintf('<field name="%s" required="true" />', $formInfo->column_name); } } } } } } $xml_buff = sprintf($buff, implode('', $fields)); FileHandler::writeFile($xml_file, $xml_buff); unset($xml_buff); $validator = new Validator($xml_file); $validator->setCacheDir('files/cache'); $validator->getJsPath(); }
/** * Add the js file * * @deprecated * @param string $file File name with path * @param string $optimized optimized (That seems to not use) * @param string $targetie target IE * @param string $index index * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) * @param bool $isRuleset Use ruleset * @param string $autoPath If path not readed, set the path automatically. * @return void */ public static function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null) { if ($isRuleset) { if (strpos($file, '#') !== FALSE) { $file = str_replace('#', '', $file); if (!is_readable($file)) { $file = $autoPath; } } $validator = new Validator($file); $validator->setCacheDir('files/cache'); $file = $validator->getJsPath(); } self::$_instance->oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index)); }
/** * Create ruleset file of find account * @param string $identifier (login identifier) * @return void */ function _createFindAccountByQuestion($identifier) { $xml_file = './files/ruleset/find_member_account_by_question.xml'; $buff = '<?xml version="1.0" encoding="utf-8"?>' . '<ruleset version="1.5.0">' . '<customrules>' . '</customrules>' . '<fields>%s</fields>' . '</ruleset>'; $fields = array(); if ($identifier == 'user_id') { $fields[] = '<field name="user_id" required="true" rule="userid" />'; } $fields[] = '<field name="email_address" required="true" rule="email" />'; $fields[] = '<field name="find_account_question" required="true" />'; $fields[] = '<field name="find_account_answer" required="true" length=":250"/>'; $xml_buff = sprintf($buff, implode('', $fields)); Filehandler::writeFile($xml_file, $xml_buff); $validator = new Validator($xml_file); $validator->setCacheDir('files/cache'); $validator->getJsPath(); }
/** * Add the js file * * @deprecated * @param string $file File name with path * @param string $optimized optimized (That seems to not use) * @param string $targetie target IE * @param string $index index * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) * @param bool $isRuleset Use ruleset * @param string $autoPath If path not readed, set the path automatically. * @return void */ function addJsFile($file, $optimized = false, $targetie = '', $index = 0, $type = 'head', $isRuleset = false, $autoPath = null) { if ($isRuleset) { if (strpos($file, '#') !== false) { $file = str_replace('#', '', $file); if (!is_readable($file)) { $file = $autoPath; } } $validator = new Validator($file); $validator->setCacheDir('files/cache'); $file = $validator->getJsPath(); } is_a($this, 'Context') ? $self =& $this : ($self =& Context::getInstance()); $self->oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index)); }
public function testConditionXml() { $vd = new Validator(dirname(__FILE__) . '/condition.xml'); $data = array('greeting1' => 'hello'); $this->assertTrue($vd->validate($data)); // Change the value of greeting1. Greeting2 is required now $data['greeting1'] = 'Hello'; $this->assertFalse($vd->validate($data)); $data['greeting2'] = 'World'; $this->assertTrue($vd->validate($data)); // javascript $vd->setCacheDir(dirname(__FILE__)); $js = $vd->getJsPath(); $this->assertFileEquals($js, dirname(__FILE__) . '/condition.en.js'); }