form = array("title" => (object)array("value" => "", "label" => "Title"), "name" => (object)array("value" => "", "label" => "Name"), "description" => (object)array("value" => "", "label" => "Description"), "slug" => (object)array("value" => "", "label" => "Internet Address")); // @todo add sort column sort order fields $form->errors = array("title" => "", "name" => "", "description" => "", "slug" => ""); if ($type != "album" && $add_form) { $form->form["image_file"] = (object)array("value" => "", "label" => "Image File"); $form->errors["image_file"] = ""; } if (empty($path) && !$add_form) { $form->form["name"]->readonly = $form->form["slug"]->readonly = "readonly"; } if ($data) { foreach (array_keys($form->form) as $field) { if (isset($data->$field)) { $form->form[$field]->value = $data->$field; } } } return $form; } static function format_response($type, $path, $form, $result) { $json = (object)array("result" => $result); if ($result != "success") { $json->form = new View("edit.html"); $json->form->title = "Update " . ucwords($type); $json->form->path = $path; $json->form->type = $type; $json->form->form = (object)$form->form; $json->form->errors = (object)$form->errors; $json->form = (string)$json->form; } else { $json->path = $path; $json->type = $type; } return json_encode($json); } }