• 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

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):
%3 test_test_cr_items test_cr_items (test xotcl-core) cr_check_mime_type cr_check_mime_type test_test_cr_items->cr_check_mime_type test_xotcl_core_tutorial_4 xotcl_core_tutorial_4 (test xotcl-core) test_xotcl_core_tutorial_4->cr_check_mime_type cr_filename_to_mime_type cr_filename_to_mime_type (public) cr_check_mime_type->cr_filename_to_mime_type db_0or1row db_0or1row (public) cr_check_mime_type->db_0or1row parameter::get parameter::get (public) cr_check_mime_type->parameter::get content::item::new content::item::new (public) content::item::new->cr_check_mime_type content::revision::new content::revision::new (public) content::revision::new->cr_check_mime_type fs::add_file fs::add_file (public) fs::add_file->cr_check_mime_type fs::add_version fs::add_version (public) fs::add_version->cr_check_mime_type xo::db::CrItem instproc save xo::db::CrItem instproc save (public) xo::db::CrItem instproc save->cr_check_mime_type

Testcases:
xotcl_core_tutorial_4, test_cr_items

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):
%3 test_auth_authenticate auth_authenticate (test acs-authentication) cr_filename_to_mime_type cr_filename_to_mime_type test_auth_authenticate->cr_filename_to_mime_type cr_create_mime_type cr_create_mime_type (private) cr_filename_to_mime_type->cr_create_mime_type db_0or1row db_0or1row (public) cr_filename_to_mime_type->db_0or1row acs_mail_lite::send_immediately acs_mail_lite::send_immediately (private) acs_mail_lite::send_immediately->cr_filename_to_mime_type cr_check_mime_type cr_check_mime_type (public) cr_check_mime_type->cr_filename_to_mime_type download_insert_revision download_insert_revision (public) download_insert_revision->cr_filename_to_mime_type email_image::edit_email_image email_image::edit_email_image (public) email_image::edit_email_image->cr_filename_to_mime_type email_image::new_item email_image::new_item (public) email_image::new_item->cr_filename_to_mime_type

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):
%3 test_fs_add_delete_copy fs_add_delete_copy (test file-storage) cr_import_content cr_import_content test_fs_add_delete_copy->cr_import_content test_fs_add_file_to_folder fs_add_file_to_folder (test file-storage) test_fs_add_file_to_folder->cr_import_content test_oacs_dav_put oacs_dav_put (test oacs-dav) test_oacs_dav_put->cr_import_content ad_conn ad_conn (public) cr_import_content->ad_conn content::revision::update_content content::revision::update_content (private) cr_import_content->content::revision::update_content db_0or1row db_0or1row (public) cr_import_content->db_0or1row db_dml db_dml (public) cr_import_content->db_dml db_exec_plsql db_exec_plsql (public) cr_import_content->db_exec_plsql content::item::upload_file content::item::upload_file (public) content::item::upload_file->cr_import_content fs::add_version fs::add_version (public) fs::add_version->cr_import_content oacs_dav::impl::content_revision::put oacs_dav::impl::content_revision::put (private) oacs_dav::impl::content_revision::put->cr_import_content text_templates::store_final_document text_templates::store_final_document (public) text_templates::store_final_document->cr_import_content

Testcases:
fs_add_delete_copy, fs_add_file_to_folder, oacs_dav_put

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):
%3 cr_registered_type_for_mime_type cr_registered_type_for_mime_type (private) db_exec_plsql db_exec_plsql (public) cr_set_imported_content_live cr_set_imported_content_live cr_set_imported_content_live->cr_registered_type_for_mime_type cr_set_imported_content_live->db_exec_plsql

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):
%3 test_content_revision content_revision (test acs-content-repository) cr_write_content cr_write_content test_content_revision->cr_write_content db_0or1row db_0or1row (public) cr_write_content->db_0or1row download_file_downloader download_file_downloader (public) download_file_downloader->cr_write_content oacs_dav::impl::content_revision::get oacs_dav::impl::content_revision::get (private) oacs_dav::impl::content_revision::get->cr_write_content oacs_dav::impl::content_revision::head oacs_dav::impl::content_revision::head (private) oacs_dav::impl::content_revision::head->cr_write_content packages/acs-subsite/www/shared/email-image-bits.tcl packages/acs-subsite/ www/shared/email-image-bits.tcl packages/acs-subsite/www/shared/email-image-bits.tcl->cr_write_content packages/acs-subsite/www/shared/portrait-bits.tcl packages/acs-subsite/ www/shared/portrait-bits.tcl packages/acs-subsite/www/shared/portrait-bits.tcl->cr_write_content

Testcases:
content_revision
[ show source ]