Пример #1
0
 static function processField($field)
 {
     global $admin, $bigtree, $cms;
     // Check if the field type is stored in an extension
     if (strpos($field["type"], "*") !== false) {
         list($extension, $field_type) = explode("*", $field["type"]);
         $field_type_path = SERVER_ROOT . "extensions/{$extension}/field-types/{$field_type}/process.php";
     } else {
         $field_type_path = BigTree::path("admin/form-field-types/process/" . $field["type"] . ".php");
     }
     // If we have a customized handler for this data type, run it.
     if (file_exists($field_type_path)) {
         include $field_type_path;
         // If it's explicitly ignored return null
         if ($field["ignore"]) {
             return null;
         } else {
             $output = $field["output"];
         }
         // Fall back to default handling
     } else {
         if (is_array($field["input"])) {
             $output = $field["input"];
         } else {
             $output = BigTree::safeEncode($field["input"]);
         }
     }
     // Check validation
     if (!BigTreeAutoModule::validate($output, $field["options"]["validation"])) {
         $error = $field["options"]["error_message"] ? $field["options"]["error_message"] : BigTreeAutoModule::validationErrorMessage($output, $field["options"]["validation"]);
         $bigtree["errors"][] = array("field" => $field["title"], "error" => $error);
     }
     // Translation of internal links
     if (is_array($output)) {
         $output = BigTree::translateArray($output);
     } else {
         $output = $admin->autoIPL($output);
     }
     return $output;
 }
Пример #2
0
    // If we have a customized handler for this data type, run it, otherwise, it's simply the post value.
    $field_type_path = BigTree::path("admin/form-field-types/process/" . $resource["type"] . ".php");
    if (file_exists($field_type_path)) {
        include $field_type_path;
    } else {
        if (is_array($bigtree["post_data"][$field["key"]])) {
            $field["output"] = $bigtree["post_data"][$field["key"]];
        } else {
            $field["output"] = BigTree::safeEncode($bigtree["post_data"][$field["key"]]);
        }
    }
    // Backwards compatibility with older custom field types
    if (!isset($field["output"]) && isset($value)) {
        $field["output"] = $value;
    }
    if (!BigTreeAutoModule::validate($field["output"], $field["options"]["validation"])) {
        $error = $field["options"]["error_message"] ? $field["options"]["error_message"] : BigTreeAutoModule::validationErrorMessage($field["output"], $field["options"]["validation"]);
        $bigtree["errors"][] = array("field" => $field["options"]["title"], "error" => $error);
    }
    if (!$field["ignore"]) {
        // Translate internal link information to relative links.
        if (is_array($field["output"])) {
            $field["output"] = BigTree::translateArray($field["output"]);
        } else {
            $field["output"] = $admin->autoIPL($field["output"]);
        }
        $bigtree["entry"][$field["key"]] = $field["output"];
    }
}
// See if we added anything in pre-processing that wasn't a field in the form.
if (is_array($bigtree["preprocessed"])) {