Index: openacs-4/contrib/packages/bcms-ui-base/resources/file-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms-ui-base/resources/file-form.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/bcms-ui-base/resources/file-form.tcl 4 Oct 2003 08:44:51 -0000 1.1
@@ -0,0 +1,110 @@
+ad_page_contract {
+ a form to create or edit a file
+
+ this file is meant to be included with the following parameters
+
+ folder_id - if you are creating a new file
+ file_id - if you are creating a new revision of a file
+ revision_id - if you are editing a file revision
+ return_url - requires a return_url, so after creating or editing a folder it redirect to this url
+
+} {
+ {file_name:optional ""}
+}
+
+# check if the parameters exists and set them to their defaults
+if {![info exists folder_id]} {
+ if {![info exists file_id] && ![info exists revision_id]} {
+ error "folder_id does not exists, please pass in the folder_id if you are creating a new file"
+ }
+ set folder_id ""
+}
+if {![info exists file_id]} {
+ if {![info exists folder_id] && ![info exists revision_id]} {
+ error "file_id does not exists, please pass in the file_id if you are creating a new revision"
+ }
+ set file_id ""
+}
+
+# lets get an existing file with name $file_name
+if {![string equal $file_name ""]} {
+ array set existing_file [bcms::item::get_item_by_url -root_id $folder_id -url $file_name]
+}
+
+ad_form -name simpleform -html {enctype multipart/form-data} -form {
+ revision_id:key
+}
+
+if {![string equal $folder_id ""] || [info exists revision_id]} {
+ ad_form -extend -name simpleform -form {
+ {file_name:text(text) {help_text {no spaces, no special characters}} {label "File Name"}}
+ } -validate {
+ {file_name
+ {([array size existing_file] == 0) || ([info exists file_id] && ($existing_file(item_id) == $file_id))}
+ "File Name already exists,
please use another File Name"
+ }
+ }
+}
+
+ad_form -extend -name simpleform -form {
+
+ {title:text(text) {label "Title"}}
+ {description:text(textarea),optional {html {rows 5 cols 80}} {label "Description"}}
+ {upload_file:file(file),optional {label "File"}}
+ {folder_id:integer(hidden),optional {value $folder_id}}
+ {file_id:integer(hidden),optional {value $file_id}}
+ {return_url:text(hidden) {value $return_url}}
+
+} -validate {
+ # require file only we are uploading a new file, otherwise it ok to just edit the other fields
+ {upload_file
+ {!$__new_p || [exists_and_not_null upload_file]}
+ "File is required"
+ }
+} -edit_request {
+
+ array set one_revision [bcms::revision::get_revision -revision_id $revision_id]
+ set file_id $one_revision(item_id)
+ set file_name $one_revision(name)
+ set title $one_revision(title)
+ set content $one_revision(content)
+ set description $one_revision(description)
+
+ ad_set_form_values file_id file_name title content description
+
+} -edit_data {
+
+ bcms::revision::set_revision -revision_id $revision_id \
+ -title $title -description $description
+ if {[info exists file_name]} {
+ bcms::item::set_item -item_id $file_id -name $file_name
+ # we have renamed the file, we need to redirect on the new name
+ set path [ns_set get [lindex [bcms::item::get_item_path -item_id $file_id -prepend_path [ad_conn package_url] -return_list -no_parent] 1] path]
+ ad_returnredirect $path
+ }
+
+} -new_data {
+
+ if {![string equal $file_id ""]} {
+ # just create the revision the file is existing
+# set revision_id [bcms::revision::add_revision -item_id $file_id \
+# -title $title -content $content -description $description \
+# -mime_type "text/html"]
+ } elseif {![string equal $folder_id ""] && ![string equal $file_name ""]} {
+ # if the file does not exists, create the file and revision
+ set file_id [bcms::upload_file -file_name $file_name -folder_id $folder_id \
+ -title $title -description $description -upload_file $upload_file]
+ } else {
+ ns_log notice "bcms: file not created"
+ }
+
+} -after_submit {
+
+ ad_returnredirect $return_url
+ ad_script_abort
+
+}
+
+ad_return_template "/packages/bcms-ui-base/resources/simple-form"
+
+
Index: openacs-4/contrib/packages/bcms-ui-base/resources/image-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms-ui-base/resources/image-form.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/bcms-ui-base/resources/image-form.tcl 4 Oct 2003 08:44:51 -0000 1.1
@@ -0,0 +1,131 @@
+ad_page_contract {
+ a form to create or edit a image
+
+ this image is meant to be included with the following parameters
+
+ folder_id - if you are creating a new image
+ image_id - if you are creating a new revision of a image
+ revision_id - if you are editing a image revision
+ return_url - requires a return_url, so after creating or editing a folder it redirect to this url
+
+} {
+ {image_name:optional ""}
+}
+
+# check if the parameters exists and set them to their defaults
+if {![info exists folder_id]} {
+ if {![info exists image_id] && ![info exists revision_id]} {
+ error "folder_id does not exists, please pass in the folder_id if you are creating a new image"
+ }
+ set folder_id ""
+}
+if {![info exists image_id]} {
+ if {![info exists folder_id] && ![info exists revision_id]} {
+ error "image_id does not exists, please pass in the image_id if you are creating a new revision"
+ }
+ set image_id ""
+}
+
+# lets get an existing image with name $image_name
+if {![string equal $image_name ""]} {
+ array set existing_image [bcms::item::get_item_by_url -root_id $folder_id -url $image_name]
+}
+
+ad_form -name simpleform -html {enctype multipart/form-data} -form {
+ revision_id:key
+}
+
+if {![string equal $folder_id ""] || [info exists revision_id]} {
+ ad_form -extend -name simpleform -form {
+ {image_name:text(text) {help_text {no spaces, no special characters}} {label "Image Name"}}
+ } -validate {
+ {image_name
+ {([array size existing_image] == 0) || ([info exists image_id] && ($existing_image(item_id) == $image_id))}
+ "Image Name already exists,
please use another Image Name"
+ }
+ }
+}
+
+ad_form -extend -name simpleform -form {
+
+ {title:text(text) {label "Title"}}
+ {description:text(textarea),optional {html {rows 5 cols 80}} {label "Description"}}
+ {width:integer(text) {label "Width"}}
+ {height:integer(text) {label "Height"}}
+ {upload_image:file(file),optional {label "Image"}}
+ {folder_id:integer(hidden),optional {value $folder_id}}
+ {image_id:integer(hidden),optional {value $image_id}}
+ {return_url:text(hidden) {value $return_url}}
+
+} -validate {
+ # require image only we are uploading a new image, otherwise it ok to just edit the other fields
+ {upload_image
+ {!$__new_p || [exists_and_not_null upload_image]}
+ "Image is required"
+ }
+} -edit_request {
+
+ array set one_revision [bcms::revision::get_revision -revision_id $revision_id]
+ set image_id $one_revision(item_id)
+ set image_name $one_revision(name)
+ set title $one_revision(title)
+ set content $one_revision(content)
+ set description $one_revision(description)
+
+ ad_set_form_values image_id image_name title content description
+
+} -edit_data {
+
+ bcms::revision::set_revision -revision_id $revision_id \
+ -title $title -description $description
+ if {[info exists image_name]} {
+ bcms::item::set_item -item_id $image_id -name $image_name
+ # we have renamed the image, we need to redirect on the new name
+ set path [ns_set get [lindex [bcms::item::get_item_path -item_id $image_id -prepend_path [ad_conn package_url] -return_list -no_parent] 1] path]
+ ad_returnredirect $path
+ }
+
+} -new_data {
+
+ if {![string equal $image_id ""]} {
+ # just create the revision the image is existing
+# set revision_id [bcms::revision::add_revision -item_id $image_id \
+# -title $title -content $content -description $description \
+# -mime_type "text/html"]
+ } elseif {![string equal $folder_id ""] && ![string equal $image_name ""]} {
+ # if the image does not exists, create the image and revision
+
+ if {![info exists creation_user_id]} { set creation_user_id [ad_conn user_id] }
+ if {![info exists creation_ip]} { set creation_ip [ad_conn peeraddr] }
+
+ # get the file properties
+ set upload_filename [template::util::file::get_property filename $upload_image]
+ set upload_tmpfile [template::util::file::get_property tmp_filename $upload_image]
+ set upload_mime_type [template::util::file::get_property mime_type $upload_image]
+
+ db_transaction {
+ set file_id [bcms::item::create_item -item_name $image_name -parent_id $folder_id -content_type image \
+ -storage_type file -creation_user_id $creation_user_id -creation_ip $creation_ip]
+
+ set revision_id [bcms::revision::upload_file_revision -item_id $file_id \
+ -title $title -description $description \
+ -upload_filename $upload_filename -upload_tmpfile $upload_tmpfile -mime_type $upload_mime_type \
+ -creation_user_id $creation_user_id -creation_ip $creation_ip -additional_properties "width $width height $height"]
+
+ }
+
+
+ } else {
+ ns_log notice "bcms: image not created"
+ }
+
+} -after_submit {
+
+ ad_returnredirect $return_url
+ ad_script_abort
+
+}
+
+ad_return_template "/packages/bcms-ui-base/resources/simple-form"
+
+
Index: openacs-4/contrib/packages/bcms-ui-base/resources/page-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms-ui-base/resources/page-form.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms-ui-base/resources/page-form.tcl 27 Aug 2003 17:33:49 -0000 1.1
+++ openacs-4/contrib/packages/bcms-ui-base/resources/page-form.tcl 4 Oct 2003 08:44:51 -0000 1.2
@@ -73,7 +73,7 @@
if {[info exists page_name]} {
bcms::item::set_item -item_id $page_id -name $page_name
# we have renamed the page, we need to redirect on the new name
- set path [ns_set get [lindex [bcms::item::get_item_path -item_id $page_id -prepend_path [ad_conn package_url] -return_list -no_parent] 0] path]
+ set path [ns_set get [lindex [bcms::item::get_item_path -item_id $page_id -prepend_path [ad_conn package_url] -return_list -no_parent] 1] path]
ad_returnredirect $path
}
Index: openacs-4/contrib/packages/bcms-ui-base/resources/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/bcms-ui-base/resources/search.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/bcms-ui-base/resources/search.tcl 22 Sep 2003 07:36:46 -0000 1.1
+++ openacs-4/contrib/packages/bcms-ui-base/resources/search.tcl 4 Oct 2003 08:44:51 -0000 1.2
@@ -1,8 +1,7 @@
ad_page_contract {
display search results
-
-} {
+ supply the following vars:
name_search:optional
title_search:optional
content_search:optional
@@ -12,8 +11,24 @@
{bulk_action_export_vars:optional ""}
{orderby:optional}
{page:optional}
+
+
+} {
}
+if {[info exists name_search] && [empty_string_p $name_search]} {
+ unset name_search
+}
+if {[info exists title_search] && [empty_string_p $title_search]} {
+ unset title_search
+}
+if {[info exists content_search] && [empty_string_p $content_search]} {
+ unset content_search
+}
+if {[info exists content_type_search] && [empty_string_p $content_type_search]} {
+ unset content_type_search
+}
+
if {$display_search_results} {
set root_folder_id [parameter::get -parameter root_folder_id]
@@ -107,8 +122,8 @@
orderby last_modified
}
} \
- -page_size 5 \
- -page_groupsize 2 \
+ -page_size 10 \
+ -page_groupsize 10 \
-page_flush_p 1 \
-page_query_name get_results_page_query