コード例 #1
0
 /**
  * Validate a CAS text field.
  * @param array $errors the errors array that validation is assembling.
  * @param string $value the submitted value validate.
  * @param string $fieldname the name of the field add any errors to.
  * @param string $savesession the array key to save the session to in $this->validationcasstrings.
  * @return array updated $errors array.
  */
 protected function validate_cas_text($errors, $value, $fieldname, $fixingdollars, $session = null)
 {
     if (!$fixingdollars && strpos($value, '$$') !== false) {
         $errors[$fieldname][] = stack_string('forbiddendoubledollars');
     }
     $castext = new stack_cas_text($value, $session, $this->seed, 't');
     if (!$castext->get_valid()) {
         $errors[$fieldname][] = $castext->get_errors();
         return $errors;
     }
     // Validate any [[facts:...]] tags.
     $unrecognisedtags = stack_fact_sheets::get_unrecognised_tags($value);
     if ($unrecognisedtags) {
         $errors[$fieldname][] = stack_string('unrecognisedfactstags', array('tags' => implode(', ', $unrecognisedtags)));
         return $errors;
     }
     if ($session) {
         $display = $castext->get_display_castext();
         if ($castext->get_errors()) {
             $errors[$fieldname][] = $castext->get_errors();
             return $errors;
         }
     }
     return $errors;
 }
コード例 #2
0
 public function test_trap_bad_fact_sheet_names()
 {
     $this->assertEquals(array(0 => 'bad_hint', 1 => 'badder_hint'), stack_fact_sheets::get_unrecognised_tags("This is some CAStext with a [[facts:bad_hint]] " . "and yet another [[facts:badder_hint]]"));
 }