- Publicity: Public Only All
revision-procs.tcl
Tcl API for adding file content to the database and for sending file content to back to the client.
- Location:
- packages/acs-content-repository/tcl/revision-procs.tcl
- Created:
- 2004-05-28
Procedures in this file
- cr_check_mime_type (public)
- cr_create_mime_type (private)
- cr_filename_to_mime_type (public)
- cr_import_content (public)
- cr_registered_type_for_mime_type (private)
- cr_set_imported_content_live (public)
- cr_write_content (public)
- cr_write_content-file (private)
- cr_write_content-lob (private)
- cr_write_content-text (private)
Detailed information
cr_check_mime_type (public)
cr_check_mime_type [ -mime_type mime_type ] [ -filename filename ] \ [ -file file ]
Check whether the mimetype is registered. If not, check whether it can be guessed from the filename. If guessed mimetype is not registered optionally insert it.
- Switches:
- -mime_type (optional)
- param The mime type
- -filename (optional)
- the filename
- -file (optional)
- the actual file being saved. This option currently doesn't have any effect, but in the future would be better to inspect the actual file content instead of trusting the user.
- Returns:
- the mapped mimetype
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- xotcl_core_tutorial_4, test_cr_items
cr_create_mime_type (private)
cr_create_mime_type -mime_type mime_type [ -extension extension ] \ [ -description description ]
Creates a mime type if it does not exist. Also maps extension to mime_type (unless the extension is already mapped to another mime type or extension is empty).
- Switches:
- -mime_type (required)
- the mime_type to create
- -extension (optional)
- the default extension for the given mime type
- -description (optional)
- a plain text description of the mime type (< 200 characters)
- Author:
- Jeff Davis <davis@xarg.net>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
cr_filename_to_mime_type (public)
cr_filename_to_mime_type [ -create ] filename
given a filename, returns the mime type. If the -create flag is given the mime type will be created; this assumes there is some other way such as ns_guesstype to find the filename
- Switches:
- -create (optional, boolean)
- flag whether to create the mime type the routine picks for filename
- Parameters:
- filename (required)
- the filename to try to guess a mime type for (the file need not exist, the routine does not attempt to access the file in any way)
- Returns:
- mimetype (or */* of unknown)
- Author:
- Jeff Davis <davis@xarg.net>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- auth_authenticate
cr_import_content (public)
cr_import_content [ -storage_type storage_type ] \ [ -creation_user creation_user ] [ -creation_ip creation_ip ] \ [ -image_only ] [ -image_type image_type ] \ [ -other_type other_type ] [ -title title ] \ [ -description description ] [ -package_id package_id ] \ [ -item_id item_id ] parent_id tmp_filename tmp_size mime_type \ object_name
Import an uploaded file into the content repository.
- Switches:
- -storage_type (optional, defaults to
"file"
)- Where to store the content (lob or file), defaults to "file" (later a system-wide parameter)
- -creation_user (optional)
- The creating user (defaults to current user)
- -creation_ip (optional)
- The creating ip (defaults to peeraddr)
- -image_only (optional, boolean)
- Only allow images
- -image_type (optional, defaults to
"image"
)- The type of content item to create if the file contains an image
- -other_type (optional, defaults to
"content_revision"
)- The type of content item to create for a non-image file
- -title (optional)
- The title given to the new revision
- -description (optional)
- The description of the new revision
- -package_id (optional)
- Package ID of the package that created the item
- -item_id (optional)
- If present, make a new revision of this item, otherwise, make a new item
- Parameters:
- parent_id (required)
- The parent of the content item we create
- tmp_filename (required)
- The name of the temporary file holding the uploaded content
- tmp_size (required)
- The size of tmp_file
- mime_type (required)
- The uploaded file's mime type
- object_name (required)
- The name to give the result content item and revision This procedure handles all mime_type details, creating a new item of the appropriate type and stuffing the content into either the filesystem or the database depending on "storage_type". The new revision is set live, and its item_id is returned to the caller. image_type and other_type should be supplied when the client package has extended the image and content_revision types to hold package-specific information. Checking is done to ensure that image_type has been inherited from image, and that other_type has been inherited from content_revision. Is up to the caller to do any checking on size limitations, etc.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- fs_add_delete_copy, fs_add_file_to_folder, oacs_dav_put
cr_registered_type_for_mime_type (private)
cr_registered_type_for_mime_type mime_type
Return the type registered for this mime type.
- Parameters:
- mime_type (required)
- param The mime type
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
cr_set_imported_content_live (public)
cr_set_imported_content_live [ -image_sql image_sql ] \ [ -other_sql other_sql ] mime_type revision_id
- Switches:
- -image_sql (optional)
- Optional SQL to extend the base image type
- -other_sql (optional)
- Optional SQL to extend the base content revision type
- Parameters:
- mime_type (required)
- Mime type of the new revision
- revision_id (required)
- The revision we're setting live If provided execute the appropriate SQL in the caller's context, then set the given revision live. The idea is to give the caller a clean way of setting the additional information needed for its private type. This is a hack. Executing this SQL can't be done within cr_import_content because the caller can't see the new revision's key...
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
cr_write_content (public)
cr_write_content [ -string ] [ -item_id item_id ] \ [ -revision_id revision_id ]
Write out the specified content to the current HTTP connection or return it to the caller by using the -string flag. Only one of item_id and revision_id should be passed to this procedure. If item_id is provided the item's live revision will be written, otherwise the specified revision. This routine was written to centralize the downloading of data from the content repository. Previously, similar code was scattered among various packages, not all of which were written to handle both in-database and in-filesystem storage of content items. Though this routine is written to be fully general in terms of a content item's storage type, typically those stored as text aren't simply dumped to the user in raw form, but rather ran through the templating system in order to surround the content with decorative HTML.
- Switches:
- -string (optional, boolean)
- specifies whether the content should be returned as a string or (the default) be written to the HTML connection (ola@polyxena.net)
- -item_id (optional)
- the item to write
- -revision_id (optional)
- revision to write
- Author:
- Don Baccus <dhogaza@pacifier.com>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- content_revision
cr_write_content-file (private)
cr_write_content-file [ -string ] [ -item_id item_id ] \ [ -revision_id revision_id ] [ -mime_type mime_type ] \ [ -content content ] [ -content_length content_length ] \ [ -storage_area_key storage_area_key ]
- Switches:
- -string (optional, boolean)
- -item_id (optional)
- -revision_id (optional)
- -mime_type (optional)
- -content (optional)
- -content_length (optional)
- -storage_area_key (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
cr_write_content-lob (private)
cr_write_content-lob [ -string ] [ -item_id item_id ] \ [ -revision_id revision_id ] [ -mime_type mime_type ] \ [ -content content ] [ -content_length content_length ] \ [ -storage_area_key storage_area_key ]
- Switches:
- -string (optional, boolean)
- -item_id (optional)
- -revision_id (optional)
- -mime_type (optional)
- -content (optional)
- -content_length (optional)
- -storage_area_key (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
cr_write_content-text (private)
cr_write_content-text [ -string ] [ -item_id item_id ] \ [ -revision_id revision_id ] [ -mime_type mime_type ] \ [ -content content ] [ -content_length content_length ] \ [ -storage_area_key storage_area_key ]
- Switches:
- -string (optional, boolean)
- -item_id (optional)
- -revision_id (optional)
- -mime_type (optional)
- -content (optional)
- -content_length (optional)
- -storage_area_key (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.