/** * Gets all the files in the current directory, with exclusion of * .svn, .htaccess, .htpasswd etc. * Does not iterate to deeper levels. * @param \System\Collection\Vector extensions to include in the search. * @return \System\Collection\Vector A Vector with File objects. */ public final function getFiles(\System\Collection\Vector $extensions = null) { $list = new \System\Collection\Vector(); //list all the files $handle = opendir($this->path); while (($file = readdir($handle)) !== false) { //get the full path $filePath = self::getPath($this->path . self::getSeparator() . $file); //no current or upper folders should be considered and the target should exist. if ($file != '.' && $file != '..' && mb_substr($file, 0, 1) != '.' && file_exists($filePath) && !is_dir($filePath)) { $file = new \System\IO\File($filePath); if ($extensions != null) { if ($extensions->contains($file->getExtension())) { $list[] = $file; } } else { $list[] = $file; } } } closedir($handle); return $list; }
/** * Gets the error/notice value from the errormap and the missingvector. * First we check if the given formField occurs in the errormap, if not the missingvector is queried. * If nothing is found an empty string is returned. * This function is language independant using the 'form_notpresent', 'form_invalidrange', 'form_invalidvalue' definitions * @param string The field to look for. * @param \System\Collection\Map The Errormap * @param \System\Collection\Vector The missing field vector */ public static final function getErrorNotice($formField, \System\Collection\Map $errorMap, \System\Collection\Vector $missingFields) { $errorNotice = ''; switch (true) { case $missingFields->contains($formField): $errorNotice = \System\Internationalization\Language::getSentence('form_notpresent'); break; case isset($errorMap->{$formField}) && $errorMap->{$formField} == \System\Security\ValidateResult::VALIDATE_RANGE: $errorNotice = \System\Internationalization\Language::getSentence('form_invalidrange'); break; case isset($errorMap->{$formField}) && $errorMap->{$formField} == \System\Security\ValidateResult::VALIDATE_INVALIDVALUE: case isset($errorMap->{$formField}): $errorNotice = \System\Internationalization\Language::getSentence('form_invalidvalue'); break; default: //we ignore this case and output no error } return $errorNotice; }
/** * Checks if the given value exists in the range of the given $matchValues. This is done by strict matching each entry. * @param mixed The value to check * @param string The name of the field * @param \System\Collection\Vector The values to match against. * @param boolean Whether or not the value must be set * @return integer The result of the filter */ public final function inValueRange($value, $fieldName, \System\Collection\Vector $matchValues, $required = false) { $this->checkDuplicateFilter($fieldName); if (!$this->checkRequired($value, $fieldName, $required)) { return \System\Security\ValidateResult::VALIDATE_NOTPRESENT; } if (empty($value) && !$required) { //add the filtered data to the filtered set $this->filtered[$fieldName] = $value; return \System\Security\ValidateResult::VALIDATE_OK; } if ($matchValues->contains($value, true)) { //add the filtered data to the filtered set $this->filtered[$fieldName] = $value; return \System\Security\ValidateResult::VALIDATE_OK; } $this->errors[$fieldName] = \System\Security\ValidateResult::VALIDATE_INVALIDVALUE; return \System\Security\ValidateResult::VALIDATE_INVALIDVALUE; }