function createNewObject($object_type, $post_vars, $system_data_classes, $object_save = 0) { if (!$object_type) { return false; } if (!in_array($object_type, $system_data_classes)) { return false; } switch ($object_type) { case "page": $object = new page("new page"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->createContent(); $object->save(); } break; case "process": $object = new process("new process"); $object->update_document_props($post_vars); $object->update_design_props($post_vars); if ($object_save == 1) { $object->save(); } break; case "section": $object = new section("new section"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->createContent(); $object->save(); } break; case "image": $object = new image("new image"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->save(); } break; case "file": $object = new file("new file"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->save(); } break; default: break; } return $object; }