Index: openacs-4/packages/edit-this-page/Changes =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/Changes,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/Changes 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,14 @@ +Edit This Page version history + +24 September 2001 +ETP code checked in to the anonymous CVS server at openacs.org, and tagged +as version 1.01. We changed the package internal name from editthispage +to edit-this-page, which is more standard. Unfortunately, the design of +the APM tables prevents you from changing the package name in an existing +database, so you'll need to reinstall the package and recreate any content +items you may have. + +30 August 2001 +Version 1.0 released at http://etp.museatech.net/download/editthispage-1.0.apm. + + Index: openacs-4/packages/edit-this-page/edit-this-page.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/edit-this-page.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/edit-this-page.info 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,106 @@ + + + + + Edit This Page + Edit This Page + f + f + + + + postgresql + + Luke Pond + An easy-to-use content management system. + nothing yet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/edit-this-page/sql/postgresql/etp-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/sql/postgresql/Attic/etp-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/sql/postgresql/etp-create.sql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,455 @@ +-- etp-create.sql +-- @author Luke Pond (dlpond@pobox.com) +-- @creation-date 2001-05-31 +-- + +create sequence t_etp_auto_page_number_seq; +create view etp_auto_page_number_seq as +select nextval('t_etp_auto_page_number_seq') as nextval; + +create function etp_get_attribute_value (integer, integer) +returns varchar as ' +declare + p_object_id alias for $1; + p_attribute_id alias for $2; + v_value varchar; +begin + select attr_value + into v_value + from acs_attribute_values + where object_id = p_object_id + and attribute_id = p_attribute_id; + + if not found then + v_value := ''''; + end if; + + return v_value; +end; +' language 'plpgsql'; + + + +create function etp_create_page(integer, varchar, varchar, varchar) +returns integer as ' +declare + p_package_id alias for $1; + p_name alias for $2; + p_title alias for $3; + p_content_type alias for $4; -- default null -> use content_revision + v_item_id integer; + v_revision_id integer; + v_content_type varchar; + v_folder_id integer; +begin + v_item_id := acs_object__new(null, ''content_item'', now(), null, null, p_package_id); + + v_folder_id := etp_get_folder_id(p_package_id); + + insert into cr_items ( + item_id, parent_id, name, content_type + ) values ( + v_item_id, v_folder_id, p_name, v_content_type + ); + + -- would like to use p_content_type here, but since there''s + -- no table that corresponds to it, we get an error from + -- the dynamic sql in acs_object__delete. so just use content_revision. + + v_content_type := ''content_revision''; + v_revision_id := acs_object__new(null, v_content_type); + + insert into cr_revisions (revision_id, item_id, title, + publish_date, mime_type) + values (v_revision_id, v_item_id, p_title, now(), ''text/html''); + + update cr_items set live_revision = v_revision_id + where item_id = v_item_id; + + return 1; +end; +' language 'plpgsql'; + +create function etp_create_extlink(integer, varchar, varchar, varchar) +returns integer as ' +declare + p_package_id alias for $1; + p_url alias for $2; + p_title alias for $3; + p_description alias for $4; + v_item_id integer; + v_folder_id integer; +begin + v_item_id := acs_object__new(null, ''content_extlink''); + v_folder_id := etp_get_folder_id(p_package_id); + + insert into cr_items ( + item_id, parent_id, name, content_type + ) values ( + v_item_id, v_folder_id, ''extlink '' || etp_auto_page_number_seq.nextval, ''content_extlink'' + ); + + insert into cr_extlinks + (extlink_id, url, label, description) + values + (v_item_id, p_url, p_title, p_description); + + return 1; +end; +' language 'plpgsql'; + +create function etp_create_symlink(integer, integer) +returns integer as ' +declare + p_package_id alias for $1; + p_target_id alias for $2; + v_item_id integer; + v_folder_id integer; +begin + v_item_id := acs_object__new(null, ''content_symlink''); + v_folder_id := etp_get_folder_id(p_package_id); + + insert into cr_items ( + item_id, parent_id, name, content_type + ) values ( + v_item_id, v_folder_id, ''symlink '' || etp_auto_page_number_seq.nextval, ''content_symlink'' + ); + + insert into cr_symlinks + (symlink_id, target_id) + values + (v_item_id, p_target_id); + + return 1; +end; +' language 'plpgsql'; + +create function etp_create_new_revision(integer, varchar, integer) +returns integer as ' +declare + p_package_id alias for $1; + p_name alias for $2; + p_user_id alias for $3; + v_revision_id integer; + v_new_revision_id integer; + v_content_type varchar; +begin + + select max(r.revision_id) + into v_revision_id + from cr_revisions r, cr_items i + where i.name = p_name + and i.parent_id = etp_get_folder_id(p_package_id) + and r.item_id = i.item_id; + + select object_type + into v_content_type + from acs_objects + where object_id = v_revision_id; + + -- cannot use acs_object__new because it creates attributes with their + -- default values, which is not what we want. + + select acs_object_id_seq.nextval + into v_new_revision_id from dual; + + insert into acs_objects (object_id, object_type, creation_date, creation_user) + values (v_new_revision_id, v_content_type, now(), p_user_id); + + insert into cr_revisions (revision_id, item_id, title, description, content, mime_type) + select v_new_revision_id, item_id, title, description, content, mime_type + from cr_revisions r + where r.revision_id = v_revision_id; + + -- copy extended attributes to the new revision, if there are any + insert into acs_attribute_values (object_id, attribute_id, attr_value) + select v_new_revision_id as object_id, attribute_id, attr_value + from acs_attribute_values + where object_id = v_revision_id; + + return 1; +end; +' language 'plpgsql'; + + + +alter table cr_folders +add package_id integer references apm_packages; + +create function etp_get_folder_id (integer) +returns integer as ' +declare + p_package_id alias for $1; + v_folder_id integer; +begin + select folder_id into v_folder_id + from cr_folders + where package_id = p_package_id; + if not found then + v_folder_id := content_item_globals.c_root_folder_id; + end if; + + return v_folder_id; +end; +' language 'plpgsql'; + + +create function etp_get_relative_url(integer, varchar) +returns varchar as ' +declare + p_item_id alias for $1; + p_name alias for $2; + v_url varchar(400); + v_object_type varchar; + v_link_rec record; +begin + + select object_type into v_object_type + from acs_objects + where object_id = p_item_id; + + if v_object_type = ''content_item'' then + return p_name; + end if; + + if v_object_type = ''content_folder'' then + return p_name || ''/''; + end if; + + if v_object_type = ''content_extlink'' then + select url into v_url + from cr_extlinks + where extlink_id = p_item_id; + return v_url; + end if; + + if v_object_type = ''content_symlink'' then + select target_id into p_item_id + from cr_symlinks + where symlink_id = p_item_id; + + select f.package_id, i.name + into v_link_rec + from cr_items i, cr_folders f + where i.item_id = p_item_id + and i.parent_id = f.folder_id; + + select site_node__url(s.node_id) into v_url + from site_nodes s + where s.object_id = v_link_rec.package_id; + + return v_url || v_link_rec.name; + + end if; + + return null; + +end; +' language 'plpgsql'; + +create function etp_get_title(integer, varchar) +returns varchar as ' +declare + p_item_id alias for $1; + p_revision_title alias for $2; + v_title varchar(400); + v_object_type varchar; +begin + if p_revision_title is not null then + return p_revision_title; + end if; + + select object_type from acs_objects into v_object_type + where object_id = p_item_id; + + if v_object_type = ''content_folder'' then + select r.title + into v_title + from cr_items i, cr_revisions r + where i.parent_id = p_item_id + and i.name = ''index'' + and i.live_revision = r.revision_id; + return v_title; + end if; + + if v_object_type = ''content_extlink'' then + select label into v_title + from cr_extlinks + where extlink_id = p_item_id; + return v_title; + end if; + + if v_object_type = ''content_symlink'' then + select target_id into p_item_id + from cr_symlinks + where symlink_id = p_item_id; + return etp_get_title(p_item_id, null); + end if; + + if v_object_type = ''content_item'' then + select r.title into v_title + from cr_items i, cr_revisions r + where i.item_id = p_item_id + and i.live_revision = r.revision_id; + return v_title; + end if; + + return null; + +end; +' language 'plpgsql'; + +create function etp_get_description(integer, varchar) +returns varchar as ' +declare + p_item_id alias for $1; + p_revision_description alias for $2; + v_description varchar(400); + v_object_type varchar; +begin + if p_revision_description is not null then + return p_revision_description; + end if; + + select object_type from acs_objects into v_object_type + where object_id = p_item_id; + + if v_object_type = ''content_folder'' then + select r.description + into v_description + from cr_items i, cr_revisions r + where i.parent_id = p_item_id + and i.name = ''index'' + and i.live_revision = r.revision_id + and i.item_id = r.item_id; + return v_description; + end if; + + if v_object_type = ''content_extlink'' then + select description into v_description + from cr_extlinks + where extlink_id = p_item_id; + return v_description; + end if; + + if v_object_type = ''content_symlink'' then + select target_id into p_item_id + from cr_symlinks + where symlink_id = p_item_id; + return etp_get_description(p_item_id, null); + end if; + + if v_object_type = ''content_item'' then + select r.description into v_description + from cr_items i, cr_revisions r + where i.item_id = p_item_id + and i.live_revision = r.revision_id; + return v_description; + end if; + + return null; + +end; +' language 'plpgsql'; + + + + + +-- this is a workaround for a bug in postgresql 7.1 +-- that causes the cr_revision__delete function to +-- trigger a "data change violation" as a result of +-- a row being inserted and then deleted from the +-- cr_item_publish_audit table in the same transaction. +-- see http://openacs.org/bboard/q-and-a-fetch-msg.tcl?msg_id=0001x3&topic_id=12&topic=OpenACS%204%2e0%20Design + +-- this effectively drops all constraints (foreign key and otherwise) +-- from the audit table. + +create table cr_audit_temp as select * from cr_item_publish_audit; +drop table cr_item_publish_audit; +create table cr_item_publish_audit as select * from cr_audit_temp; +drop table cr_audit_temp; + + + +-- add the ETP parameters to the acs-subsite package so that +-- we can serve the site's home page and top level pages. + +create function inline_0 () +returns integer as ' +declare + ss_package_id integer; + cur_val record; +begin + perform apm__register_parameter( + NULL, + ''acs-subsite'', + ''application'', + ''Name of the ETP application to use (default, faq, wiki, or create your own with the etp::define_applicaton procedure)'', + ''string'', + ''default'', + ''EditThisPage'', + ''1'', + ''1'' + ); + perform apm__register_parameter( + NULL, + ''acs-subsite'', + ''subtopic_application'', + ''Name of the ETP application to use when creating a subtopic'', + ''string'', + ''default'', + ''EditThisPage'', + ''1'', + ''1'' + ); + + select package_id into ss_package_id + from apm_packages + where package_key = ''acs-subsite''; + + for cur_val in select parameter_id, default_value + from apm_parameters + where package_key = ''acs-subsite'' + and section_name = ''EditThisPage'' + loop + perform apm_parameter_value__new( + null, + ss_package_id, + cur_val.parameter_id, + cur_val.default_value + ); + end loop; + + return 0; +end; +' language 'plpgsql'; + +select inline_0 (); +drop function inline_0 (); + + +-- create a folder with magic folder_id of -400 where we +-- will put all deleted content items so they'll be recoverable. + +create function inline_1 () +returns integer as ' +begin +perform content_folder__new ( + ''trash'', + ''Trash'', + ''Deleted content items get put here'', + 0, + null, + -400, + now(), + null, + null + ); +return 0; +end; +' language 'plpgsql'; + +select inline_1 (); +drop function inline_1 (); Index: openacs-4/packages/edit-this-page/tcl/etp-gc.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-gc.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-gc.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,84 @@ +# etp-gc.tcl + +ad_library { + Demo for using general comments with ETP + + @cvs-id $Id: etp-gc.tcl,v 1.1 2001/09/24 17:24:13 lukep Exp $ + @author Pat Colgan pat@museatech.net + @date 20 June 2001 +} + +namespace eval etp { + +ad_proc -public get_gc_link { } { + Called from rotisserie questions template to present comment link + taking out permission checking for now + @author Pat Colgan pat@museatech.net + @creation-date 4-17-01 +} { + + # get object_id + # check permissions + # return link + + # We only show the link here if the_public has + # general_comments_create privilege on the page. Why the_public + # rather than the current user? Because we don't want admins to + # be seeing "Add a comment" links on non-commentable pages. + # + set item_id $pa.item_id + set object_name [etp::get_name] + set comment_link "" + + append comment_link "
+ [general_comments_create_link -object_name $object_name $item_id ] +
" + + append comment_link "[general_comments_get_comments -print_content_p 1 $item_id ]" + return $comment_link +} +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/edit-this-page/tcl/etp-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-init.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-init.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,90 @@ +# etp-init.tcl + +ad_library { + Registers content types used by Edit This Page templates + + @cvs-id $Id: etp-init.tcl,v 1.1 2001/09/24 17:24:13 lukep Exp $ + @author Luke Pond dlpond@pobox.com + @date 31 May 2001 +} + +# Definitions of the attributes that belong to special content types + +etp::define_content_type journal_issue "Journal Issue" "Journal Issues" { + { publication_date "Publication Date" "Publication Dates" string "size=60" "" } + { issue_name "Issue name" "Issue names" string "size=60" "" } +} + + +etp::define_content_type journal_article "Journal Article" "Journal Articles" { + { section Section Sections string "" "" } + { byline Byline Bylines string "" "" } + { abstract Abstract Abstracts string "rows=24 cols=80" "" } + { citation Citation Citations string "rows=4 cols=80" "" } +} + + +etp::define_content_type news_item "News Item" "News Items" { + { location "Location" "Location" string "size=80" "" } + { subtitle "Subtitle" "Subtitle" string "rows=4 cols=80" "" } + { release_date "Release Date" "Release Dates" string "size=60" "" } + { archive_date "Archive Date" "Archive Dates" string "size=60" "" } +} + +# Definitions of ETP "applications". One of these must be chosen for +# each package instance of ETP, thereby determining the behavior and +# appearance of the package and the admin pages. + +# Note: when defining your own application, you can specify +# whichever of these parameters you want to change; those you leave +# unspecified will be looked up from the "default" application. + +etp::define_application default { + index_template packages/edit-this-page/templates/article-index + index_content_type content_revision + index_object_name "subtopic" + index_title_attr_name "Title" + index_description_attr_name "Description" + index_content_attr_name "Content" + + content_template packages/edit-this-page/templates/article-content + content_content_type content_revision + content_object_name "page" + content_title_attr_name "Title" + content_description_attr_name "Description" + content_content_attr_name "Content" + + allow_subtopics t + allow_extlinks t + allow_symlinks t + + auto_page_name "" +} + + +etp::define_application faq { + index_template packages/edit-this-page/templates/faq-index + index_object_name "FAQ" + + content_template packages/edit-this-page/templates/faq-content + content_object_name "question" + content_title_attr_name "Question" + content_content_attr_name "Answer" + + allow_subtopics f + allow_extlinks f + allow_symlinks f + auto_page_name "number" +} + + +etp::define_application news { + index_template packages/edit-this-page/templates/news-index + content_template packages/edit-this-page/templates/news-content + content_content_type news_item + content_object_name "news item" + allow_subtopics f + allow_extlinks f + allow_symlinks f + auto_page_name "number" +} Index: openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-procs-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,67 @@ + + + oracle8.1.6 + + + + begin + acs_object_type.create_type ( + :content_type, + :pretty_name, + :pretty_plural, + 'content_revision', + :content_type, + :content_type, + null, + 'f', + null, + null + ); + end; + + + + + + begin + :1 := acs_attribute.create_attribute ( + :content_type, + :a_name, + :a_datatype, + :a_pretty_name, + :a_pretty_plural, + null, + null, + :a_default, + 1, + 1, + null, + 'generic', + 'f' + ); + end; + + + + + + begin + etp_create_page( + :package_id, + :name, + :title, + :content_type + ); + end; + + + + + + select object_id as package_id + from site_nodes + where node_id = site_node.node_id(:url_stub, null) + + + + Index: openacs-4/packages/edit-this-page/tcl/etp-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-procs-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-procs-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,61 @@ + + + postgresql7.1 + + + + select acs_object_type__create_type ( + :content_type, + :pretty_name, + :pretty_plural, + 'content_revision', + :content_type, + :content_type, + null, + 'f', + null, + null + ) + + + + + + select acs_attribute__create_attribute ( + :content_type, + :a_name, + :a_datatype, + :a_pretty_name, + :a_pretty_plural, + null, + null, + :a_default, + 1, + 1, + null, + 'generic', + 'f' + ) + + + + + + select etp_create_page( + :package_id, + :name, + :title, + :content_type + ) + + + + + + select object_id as package_id + from site_nodes + where node_id = site_node__node_id(:url_stub, null) + + + + Index: openacs-4/packages/edit-this-page/tcl/etp-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-procs.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,651 @@ +# etp-procs.tcl + +ad_library { + Helper procedures for Edit This Page + + @cvs-id $Id: etp-procs.tcl,v 1.1 2001/09/24 17:24:13 lukep Exp $ + @author Luke Pond dlpond@pobox.com + @date 31 May 2001 +} + +namespace eval etp { + +set standard_attributes { + {title Title Titles string {size="60"} "Untitled" -1} + {description Description Descriptions string {rows=24 cols=80} "" -1} + {content Content Content string {rows=24 cols=80} "" -1} +} + +ad_proc -public make_content_type { content_type pretty_name pretty_plural attribute_metadata } { + obsolete name; use define_content_type instead +} { + return [define_content_type $content_type $pretty_name $pretty_plural $attribute_metadata] +} + +ad_proc -public define_content_type { content_type pretty_name pretty_plural attribute_metadata } { + + Call this at server startup time to register the + extended page attributes for a particular content type. + It ensures that there is a corresponding entry in + acs_object_types for the content type, and that for + each of the extended page attributes given there is + an appropriate entry in acs_attributes. Also, a + namespace variable stores all extended page attributes + in memory data structure for quick retrieval. +

+ Extended page attribute values are stored in + the acs_attribute_values table (so-called "generic" storage) + to prevent the necessity of creating a table for each + content type. This is the reason we're not using the + attribute procs defined in the acs-subsite package, as + they only support type-specific storage. +

+ NOTE: get the attribute metadata right the first time. + If you decide to add a new attribute to an existing object type, + the procedure will create it for you. But it won't + process updates to existing attributes or remove them. + You'll have to do that by hand. + + @author Luke Pond + @creation-date 2001-05-31 + + @param content_type The content type you're registering. This name + must be unique across all pages that must store + extended page attributes. + @param pretty_name The display name for the content type + @param pretty_plural The plural form of the display name + @param attribute_metadata A list of records describing each extended + page attribute. Each record is a list containing the following + values (in sequence):

+ # TODO: other features are needed such as making an attribute optional + # and also specifying options for select lists. +} { + variable content_types + if {![info exists content_types]} { + array set content_types [list] + } + + # ensure an entry in acs_object_types + if { ![db_0or1row object_type_exists ""] } { + db_exec_plsql object_type_create "" + } + + set attribute_metadata_with_ids [list] + + # for each attribute, ensure an entry in acs_attributes + foreach attribute $attribute_metadata { + if {[llength $attribute] != 6} { + ns_log Error "etp::make_content_type ($content_type) failed: + attribute_metadata record has incorrect format" + return + } + + set a_name [lindex $attribute 0] + set a_pretty_name [lindex $attribute 1] + set a_pretty_plural [lindex $attribute 2] + set a_datatype [lindex $attribute 3] + set a_html [lindex $attribute 4] + set a_default [lindex $attribute 5] + + if { ![db_0or1row attribute_exists ""] } { + set attribute_id [db_exec_plsql attribute_create ""] + } + lappend attribute $attribute_id + lappend attribute_metadata_with_ids $attribute + } + + set content_types($content_type) $attribute_metadata_with_ids +} + + +ad_proc -public define_application { name params } { + TODO: Need documentation + TODO: Check the parameters passed in +} { + variable application_params + if {![info exists application_params]} { + array set application_params [list] + } + set application_params($name) $params + ns_log Notice "ETP application $name is $application_params($name)" +} + +ad_proc -public modify_application { name params } { + TODO: Need documentation + TODO: Check the parameters passed in +} { + variable application_params + array set param_array $application_params($name) + array set param_array $params + set application_params($name) [array get param_array] + ns_log Notice "ETP application $name is modified to $application_params($name)" +} + +ad_proc -public get_defined_applications { } { + returns a list of all defined applications +} { + variable application_params + return [lsort [array names application_params]] +} + +ad_proc -public get_application_param { param_name {app ""} } { + NYI: Need documentation +} { + array set params [get_application_params $app] + + if { [info exists params($param_name)] } { + return $params($param_name) + } else { + return "" + } +} + +ad_proc -public get_application_params { {app ""} } { + NYI: Need documentation +} { + variable application_params + + if { [empty_string_p $app] } { + set app [ad_parameter application "default"] + } + + array set params $application_params(default) + + if { [info exists application_params($app)] } { + array set params $application_params($app) + } + + return [array get params] +} + + +ad_proc -public make_page { name {title "Untitled"} } { + @author Luke Pond + @creation-date 2001-05-31 + @param name the name of the page you wish to create + in the current package + + Creates a new page (content item) with the given name + by inserting a row into the cr_items table, and creates + an initial revision by inserting a row into the cr_revisions + table. + +} { + set package_id [ad_conn package_id] + + set content_type [etp::get_content_type $name] + + # ensure an entry in cr_items for this (package_id, name) combination + + if { ![db_0or1row page_exists ""] } { + db_exec_plsql page_create "" + } +} + +ad_proc -public get_content_type { {name ""} } { + @param name specify "index" to get the index_content_type parameter. + otherwise returns the content_type parameter. + + Returns the content_type specified in the package parameters. +} { + if { $name == "index" } { + set content_type [etp::get_application_param index_content_type] + } else { + set content_type [etp::get_application_param content_content_type] + } + return $content_type +} + + +ad_proc -public get_page_attributes { } { + @author Luke Pond + @creation-date 2001-05-31 + @param Optionally may specify an object type containing + extended page attributes to be returned. + @return Creates the pa variable in the caller's context. + + Creates an array variable called pa in the caller's stack frame, + containing all attributes necessary to render the current page. + These attributes include the standard elements from the cr_revisions + table such as title, description, and content. If the content_type + parameter is provided, any extended page attributes that + correspond to it will be included. See docs for etp::make_content_type + to learn how this works. +

+ Two database accesses are required to create the array variable. + Once created, subsequent calls to this method will find the variable + in a cache, unless a) any of the page attributes are changed, or b) + the page has been flushed from the cache. (flush details TBD). +

+ The complete list of standard attributes in the pa array is as follows: +

+} { + # TODO: I have no idea if ns_cache automatically flushes + # items that are out of date. Must find out or risk + # running out of memory + + set max_age [ad_parameter cache_max_age edit-this-page] + + set name [etp::get_name] + set content_type [etp::get_content_type $name] + + upvar pa pa + + if { [catch { + if {[empty_string_p [ad_conn -get revision_id]]} { + # asking for the live published revision + set code "etp::get_pa [ad_conn package_id] $name $content_type" + array set pa [util_memoize $code $max_age] + } else { + # an admin is browsing other revisions - do not use caching. + array set pa [etp::get_pa [ad_conn package_id] $name $content_type] + } + } errmsg] } { + ns_log Notice "Error from etp::get_pa was:\n $errmsg" + + # Page not found. Redirect admins to setup page; + # otherwise report 404 error. + if { $name == "index" && + [ad_permission_p [ad_conn package_id] admin] } { + # set up the new content section + ad_returnredirect "etp-setup-2" + } else { + ns_returnnotfound + } + # we're done responding to this request, so do no + # further processing on this page + ad_script_abort + } +} + + +ad_proc -private get_pa { package_id name {content_type ""} } { + @author Luke Pond + @creation-date 2001-05-31 + @param package_id The package_id for the current request + + @param name The page name of the current request. + @return The tcl array (in list form) of page attributes. + + Does the real work of setting up the page-attribute array, + which is then fed to the cache. The (package_id name) + combination uniquely identifies a page. +} { + + set extended_attributes [get_ext_attribute_columns $content_type] + + set revision_id [ad_conn revision_id] + if {[empty_string_p $revision_id]} { + # this will throw an error if the page does not exist + db_1row get_page_attributes "" -column_array pa + } else { + # revision_id was set by index.vuh + db_1row get_page_attributes_other_revision "" -column_array pa + } + + # add in the context bar + if { $name == "index" } { + set cb [ad_context_bar] + } else { + set cb [ad_context_bar $pa(title)] + } + # remove the "Your Workspace" link, so we can cache this context + # bar and it will work for everyone + + regsub {^Your Workspace : } $cb "" cb + + if {[lindex $cb 1] == "Your Workspace"} { + set cb [lreplace $cb 0 1] + } + set pa(context_bar) $cb + + return [array get pa] +} + +ad_proc -public get_ext_attribute_columns { content_type } { + Constructs some dynamic SQL to get each + of the extended page attributes. note + that the attribute values are stored for + each *revision*, so we look them up based + on the live revision id, not on the item id. +} { + set extended_attributes "" + if { ![empty_string_p $content_type] && + ![string equal $content_type "content_revision"] } { + variable content_types + + set attributes $content_types($content_type) + + foreach attribute_desc $attributes { + set lookup_sql [etp::get_attribute_lookup_sql $attribute_desc] + append extended_attributes ",\n $lookup_sql" + } + } + return $extended_attributes +} + +ad_proc -public get_attribute_descriptors { content_type } { + returns a list of attribute descriptors for the given content_type. + this includes standard attributes as well as extended attributes. +} { + variable standard_attributes + variable content_types + + if {[info exists content_types($content_type)]} { + return [concat $standard_attributes $content_types($content_type)] + } + + return $standard_attributes +} + +ad_proc -public get_attribute_desc { name content_type } { + returns the attribute descriptor for the given attribute. + works for extended attributes defined by the given content_type + as well as for the standard attributes (title, description, and content). + (the documentation for etp_make_content_type explains what's in an + attribute descriptor contains) +} { + # check for standard attributes first + + variable standard_attributes + + foreach std_desc $standard_attributes { + if { $name == [lindex $std_desc 0] } { + return $std_desc + } + } + + variable content_types + if {[info exists content_types($content_type)]} { + set extended_attributes $content_types($content_type) + foreach ext_desc $extended_attributes { + if { $name == [lindex $ext_desc 0] } { + return $ext_desc + } + } + } + + return "" +} + +ad_proc -public get_attribute_id { attribute_desc } { +} { + return [lindex $attribute_desc end] +} + +ad_proc -public get_attribute_name { attribute_desc } { +} { + return [lindex $attribute_desc 0] +} + +ad_proc -public get_attribute_pretty_name { attribute_desc {page_name ""} } { +} { + set pretty_name [lindex $attribute_desc 1] + + # handle customized standard attribute names + # which are set up with etp application parameters + set attr_name [lindex $attribute_desc 0] + if { [lsearch -exact { title description content } $attr_name] != -1 } { + if { $page_name == "index" } { + set param_name "index_${attr_name}_attr_name" + } else { + set param_name "content_${attr_name}_attr_name" + } + + ns_log Notice "Asking for $param_name" + set pretty_name [etp::get_application_param $param_name] + } + + return $pretty_name +} + +ad_proc -public get_attribute_data_type { attribute_desc } { +} { + return [lindex $attribute_desc 3] +} + +ad_proc -public get_attribute_html { attribute_desc } { +} { + return [lindex $attribute_desc 4] +} + +ad_proc -public get_attribute_default { attribute_desc } { +} { + return [lindex $attribute_desc 5] +} + +ad_proc -public get_attribute_lookup_sql { attribute_desc } { +} { + set attribute_id [etp::get_attribute_id $attribute_desc] + set attribute_name [etp::get_attribute_name $attribute_desc] + set default [etp::get_attribute_default $attribute_desc] + + set lookup_sql "etp_get_attribute_value(r.revision_id, $attribute_id)" + + # see if a select-list callback function was specified + if { [info commands $default] != "" } { + set transformed_lookup_sql [eval $default transform_during_query $attribute_id {$lookup_sql}] + + if {$transformed_lookup_sql != ""} { + set lookup_sql $transformed_lookup_sql + } + } + return "$lookup_sql as $attribute_name" +} + +ad_proc -public get_etp_link { } { + @author Luke Pond + @creation-date 2001-05-31 + + If the current package is an instance of Edit This Page, + and the user has write access, returns + the html "Edit This Page" link which should be + displayed at the bottom of the page. +

+ This may be called either from your master template, + or from individual pages that are used within an ETP + package instance. It incurs 1 database hit to + do the permissions check. The package type is acquired + via the in-memory copy of the site-nodes layout. + +} { + set url_stub [ns_conn url] + array set site_node [site_node $url_stub] + set urlc [regexp -all "/" $url_stub] + if { ($site_node(package_key) == "edit-this-page" || + ($site_node(package_key) == "acs-subsite" && $urlc == 1)) && + [ad_permission_p [ad_conn package_id] write] } { + + set name [etp::get_name] + + if { ![regexp "^etp" $name] } { + return "Edit This Page\n" + } + } + return "" +} + +ad_proc -public get_name { } { + @author Luke Pond + @creation-date 2001-06-10 + + Returns the canonical page name for the current request. +} { + set url_stub [ad_conn url] + if { [string index $url_stub end] == "/" } { + set name index + } else { + set name [file rootname [file tail $url_stub]] + } + return $name +} + +ad_proc -public get_latest_revision_id { package_id name } { + @author Luke Pond + @creation-date 2001-06-10 + + Returns the latest revision id for the given content item. +} { + db_1row get_latest_revision_id "" + return $revision_id +} + +ad_proc -public get_live_revision_id { package_id name } { + @author Luke Pond + @creation-date 2001-06-10 + + Returns the published ("live") revision id for the given content item. +} { + db_1row get_live_revision_id "" + return $revision_id +} + +ad_proc -public get_content_items { args } { + @author Luke Pond + @creation-date 2001-06-10 + @param -orderby - what should appear in the ORDER BY clause + @param -where - additional query restrictions to follow the WHERE clause + @param -package_id - package_id to use (by default uses [ad_conn package_id]) + @param args - all remaining parameters are taken to be additional page attributes to return + Creates a variable named "content_items" in the caller's context. + This is a multirow result set suitable for passing to an index template, + containing all the structured data necessary to present a list of + links to content pages/folders/extlinks/symlinks. + + Each row always contains values for the following page attributes: +

+ + Additionally, you may name additional attributes that will be + returned, either from the standard page attributes stored in + cr_revisions, or extended page attributes defined with + etp::make_content_type. +

+ The content_items variable is created with a single db query, + and currently is never cached. + +} { + set package_id [ad_conn package_id] + set content_type [etp::get_content_type] + + set orderby "attributes.sort_order" + set extra_where_clauses "1 = 1" + set columns "i.item_id, i.name, tree_sortkey as sort_order, + to_char(r.publish_date, 'Mon DD, YYYY') as publish_date, + (select object_type from acs_objects + where object_id = i.item_id) as object_type, + etp_get_relative_url(i.item_id, i.name) as url, + etp_get_title(i.item_id, r.title) as title, + etp_get_description(i.item_id, r.description) as description + " + + for {set i 0} {$i < [llength $args]} {incr i} { + set arg [lindex $args $i] + + if { $arg == "-package_id" } { + incr i + set package_id [lindex $args $i] + } + + if { $arg == "-orderby" } { + incr i + set orderby [lindex $args $i] + continue + } + + if { $arg == "-where" } { + incr i + set extra_where_clauses [lindex $args $i] + continue + } + + if { [lsearch -exact { item_id revision_id content publish_date } $arg] != -1 } { + append columns ",\n r.$arg" + } else { + ns_log Notice "extended attribute named $arg" + set attr_desc [etp::get_attribute_desc $arg $content_type] + if { ![empty_string_p $attr_desc] } { + ns_log Notice "adding it" + set lookup_sql [etp::get_attribute_lookup_sql $attr_desc] + append columns ",\n $lookup_sql" + } + } + } + + upvar content_items content_items + + db_multirow content_items get_content_items "" +} + +ad_proc -public get_subtopics {} { + @author Luke Pond + @creation-date 2001-06-13 + + Creates a variable named "subtopics" in the caller's context. + This is a multirow result set suitable for passing to an index template, + containing all the structured data necessary to present a list of + links to subtopics. + + The columns in the "subtopics" query are:

+ +} { + set package_id [ad_conn package_id] + upvar subtopics subtopics + db_multirow subtopics get_subtopics "" +} + + +ad_proc -public check_write_access {} { + @author Luke Pond + @creation-date 2001-08-29 + Designed to be used at the top of every ETP admin page. + Returns an HTTP 403 Access Denied and aborts page processing + if the user doesn't have "write" permission for the current + package. +} { + if { ![ad_permission_p [ad_conn package_id] write] } { + ad_return_forbidden "Access Denied" "Sorry, you haven't been + given permission to work on this area of the website. Please + contact your webmaster if you believe this to be in error." + ad_script_abort + } +} + +} \ No newline at end of file Index: openacs-4/packages/edit-this-page/tcl/etp-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/tcl/etp-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/tcl/etp-procs.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,101 @@ + + + + + + select 1 from acs_object_types + where object_type = :content_type + + + + + + select attribute_id from acs_attributes + where object_type = :content_type + and attribute_name = :a_name + + + + + + select 1 from cr_items + where parent_id = etp_get_folder_id(:package_id) + and name = :name + + + + + + select i.item_id, i.name, r.revision_id, r.title, + r.description, r.publish_date, r.content $extended_attributes + from cr_items i, cr_revisions r + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = i.live_revision + + + + + + select i.item_id, i.name, r.revision_id, r.title, + r.description, r.publish_date, r.content $extended_attributes + from cr_items i, cr_revisions r + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = :revision_id + + + + + + select max(revision_id) as revision_id + from cr_revisions r, cr_items i + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + + + + + + select live_revision as revision_id + from cr_items i + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + + + + + + select * from ( + select $columns + from cr_items i + left join + cr_revisions r + on (i.live_revision = r.revision_id) + where i.parent_id = etp_get_folder_id(:package_id) + and i.name != 'index' + ) as attributes + where $extra_where_clauses + order by $orderby + + + + + + +select child.name, child.node_id, child.object_id as package_id, + etp_package_title(child.object_id) as title, + etp_package_description(child.object_id) as description + from site_nodes parent, site_nodes child, apm_packages p + where parent.object_id = :package_id + and child.parent_id = parent.node_id + and child.object_id = p.package_id + and p.package_key = 'editthispage' + + + + + Index: openacs-4/packages/edit-this-page/templates/article-content.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/article-content.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/article-content.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,5 @@ + +@pa.title@ +@pa.context_bar@ + +@pa.content@ \ No newline at end of file Index: openacs-4/packages/edit-this-page/templates/article-content.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/article-content.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/article-content.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ +# /packages/edit-this-page/templates/article-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This is the default page used to display content pages + for an Edit This Page package instance. It assumes a + content type with no extended attributes, and presents + the content item with a standard article layout. +

+ If you want to use some other page instead, specify it with + the content_template package parameter. + +} { +} -properties { + pa:onerow +} + +etp::get_page_attributes + Index: openacs-4/packages/edit-this-page/templates/article-index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/article-index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/article-index.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,19 @@ + +@pa.title@ +@pa.context_bar@ + + +@pa.content@ + + +

+ + +@content_items.title@ + + - @content_items.description@ + +

+
+ +
Index: openacs-4/packages/edit-this-page/templates/article-index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/article-index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/article-index.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,22 @@ +# /packages/edit-this-page/templates/article-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This is the default page used to display an index listing + for an Edit This Page package instance. It assumes a + content type with no extended attributes, and presents + a listing of all content pages belonging to this package. +

+ If you want to use some other page instead, specify it with + the index_template package parameter. + +} { +} -properties { + pa:onerow + content_pages:multirow +} + +etp::get_page_attributes +etp::get_content_items Index: openacs-4/packages/edit-this-page/templates/faq-content.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/faq-content.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/faq-content.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,10 @@ + +@pa.title@ +@pa.context_bar@ + +

+Q: @pa.title@ +

+A: +@pa.content@ +

Index: openacs-4/packages/edit-this-page/templates/faq-content.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/faq-content.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/faq-content.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,17 @@ +# /packages/edit-this-page/templates/faq-content.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-07-05 + + This page can be used to display a single question from a FAQ. + However, the faq-index page displays all questions and answers + without linking to an individual question, so you'll have to + come up with some other way to use it (search engine results, perhaps) +} { +} -properties { + pa:onerow +} + +etp::get_page_attributes + Index: openacs-4/packages/edit-this-page/templates/faq-index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/faq-index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/faq-index.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,35 @@ + +@pa.title@ +@pa.context_bar@ + +

+ + +@pa.content@ +

+ + +Frequently Asked Questions: +

    + +
  1. +@content_items.title@ +
  2. +
    +
+
+

+ +Questions and Answers: +

    + + +
  1. +Q: @content_items.title@ +

    +A: +@content_items.content@ +

    +

  2. +
    +
Index: openacs-4/packages/edit-this-page/templates/faq-index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/faq-index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/faq-index.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ +# /packages/edit-this-page/templates/article-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This is an interface for a list of Frequently Asked Questions. + We assume you want to see all the questions on a single page, + so there are no links to pages that display individual questions. + + This template uses no extended page attributes. The question + is stored in the page title, and the answer is stored in the content + field. +} { +} -properties { + pa:onerow + content_pages:multirow +} + +etp::get_page_attributes +etp::get_content_items content Index: openacs-4/packages/edit-this-page/templates/journal-article.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/journal-article.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/journal-article.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,5 @@ + +@pa.title@ +@pa.context_bar@ + +@pa.content@ Index: openacs-4/packages/edit-this-page/templates/journal-article.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/journal-article.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/journal-article.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ +# /packages/edit-this-page/templates/article-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This is the default page used to display content pages + for an Edit This Page package instance. It assumes a + content type with no extended attributes, and presents + the content item with a standard article layout. +

+ If you want to use some other page instead, specify it with + the content_template package parameter. + +} { +} -properties { + pa:onerow +} + +etp::get_page_attributes + Index: openacs-4/packages/edit-this-page/templates/journal-issue.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/journal-issue.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/journal-issue.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ + +@pa.title@ +@pa.context_bar@ + + +@pa.content@ + + +

+ + +@content_items.section@ +

+ +@content_items.title@
+@content_items.byline@ +
+
+
+

+ Index: openacs-4/packages/edit-this-page/templates/journal-issue.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/journal-issue.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/journal-issue.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,23 @@ +# /packages/edit-this-page/templates/article-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This is the default page used to display an index listing + for an Edit This Page package instance. It assumes a + content type with no extended attributes, and presents + a listing of all content pages belonging to this package. +

+ If you want to use some other page instead, specify it with + the index_template package parameter. + +} { +} -properties { + pa:onerow + content_pages:multirow +} + +etp::get_page_attributes +etp::get_content_items byline section -orderby section + Index: openacs-4/packages/edit-this-page/templates/news-content.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/news-content.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/news-content.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,24 @@ + +@pa.title@ +@pa.context_bar@ + + +

@pa.subtitle@
+ + +

+ + + + + +@pa.location@ - + + +@pa.release_date@ - + + + +@pa.content@ + +

\ No newline at end of file Index: openacs-4/packages/edit-this-page/templates/news-content.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/news-content.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/news-content.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,15 @@ +# /packages/edit-this-page/templates/news-content.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-08-30 + + Displays a single news item. + +} { +} -properties { + pa:onerow +} + +etp::get_page_attributes + Index: openacs-4/packages/edit-this-page/templates/news-index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/news-index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/news-index.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ + +@pa.title@ +@pa.context_bar@ + + +@pa.content@ + + + +There are no current news items + + +

+ +If you're looking for an old news article, check the expired news. Index: openacs-4/packages/edit-this-page/templates/news-index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/templates/news-index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/templates/news-index.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,31 @@ +# /packages/edit-this-page/templates/news-index.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-08-30 + + This is an example of using extended attributes in an ETP template. + + Displays all news items for which the release date is in + the past and the archive date is in the future. + + If "archive_p=t" is in the url, displays all news items for + which the release date is in the past. + +} { + {archive_p "f"} +} -properties { + pa:onerow + content_pages:multirow +} + +if { $archive_p == "f" } { + set where "sysdate() between to_date(attributes.release_date, 'YYYY-MM-DD') and to_date(attributes.archive_date, 'YYYY-MM-DD')" +} else { + set where "sysdate() >= to_date(attributes.archive_date, 'YYYY-MM-DD')" +} + +set orderby "to_date(attributes.release_date, 'YYYY-MM-DD') desc" + +etp::get_page_attributes +etp::get_content_items -where $where -orderby $orderby release_date archive_date Index: openacs-4/packages/edit-this-page/www/etp-create-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-create-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-create-2.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-10 + + Handles the form submission and creates a new content page + +} { + name + title +} + +etp::check_write_access + +if { [regexp {[^a-zA-Z0-9\-_]} $name] } { + ad_return_complaint 1 "The subtopic name must be a short identifier + containing no spaces. It will be the final part of the URL that + identifies this subtopic." +} else { + etp::make_page $name $title + ad_returnredirect "etp?[export_url_vars name]" +} Index: openacs-4/packages/edit-this-page/www/etp-create-extlink.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-create-extlink.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-create-extlink.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,42 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-07-10 + + Presents a simple form for creating or editing an external link. + +} { + { url "" } + { title "" } + { item_id "" } + { confirmed "f" } +} -properties { + page_title:onevalue + context_bar:onevalue + form_vars:onevalue +} + +if { $confirmed == "t" } { + if { [empty_string_p $subtopic_name] || + [regexp {[^a-zA-Z0-9\-_]} $subtopic_name] } { + ad_return_complaint 1 "The subtopic name must be a short identifier + containing no spaces. It will be the final part of the URL that + identifies this subtopic." + } else { + set new_package_id [subsite::auto_mount_application \ + -instance_name $subtopic_name \ + -pretty_name $subtopic_title "edit-this-page"] + set curr_package_id [ad_conn package_id] + db_foreach old_package_parameters "" { + db_dml copy_parameter "" + } + set title $subtopic_title + ad_returnredirect "$subtopic_name/etp-setup-2?[export_url_vars title]" + } + ad_script_abort +} else { + set confirmed "t" + set form_vars [export_form_vars confirmed] +} + +set page_title "Create a new subtopic" +set context_bar [ad_context_bar [list "etp" "Edit"] "New subtopic"] Index: openacs-4/packages/edit-this-page/www/etp-create.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-create.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-create.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,30 @@ + +@page_title@ +@context_bar@ + +
+ + + + + + +
+Page name + + + +This must be a short identifier containing +no spaces. It will be the final name in the URL that identifies this page. +Depending on the auto_page_name parameter, the page name be +be pre-filled with a unique number or with a number representing today's date. +
+Page title + + + +You may change the title later if you like. +
+ +
+

Index: openacs-4/packages/edit-this-page/www/etp-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-create.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-create.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,29 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-10 + + Presents a simple form for creating a new content page + +} { +} -properties { + new_page_name + page_title + context_bar +} + +etp::check_write_access + +set auto_page_name [etp::get_application_param auto_page_name] + +if {$auto_page_name == "number"} { + set new_page_name [db_string next_page_number { + select etp_auto_page_number_seq.nextval from dual + }] +} elseif {$auto_page_name =="date"} { + set new_page_name [ns_fmttime [ns_time] "%Y%m%d"] +} else { + set new_page_name "" +} + +set page_title "Create a new content page" +set context_bar [ad_context_bar [list "etp" "Edit"] "New page"] Index: openacs-4/packages/edit-this-page/www/etp-delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-delete-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-delete-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,13 @@ + + + oracle8.1.6 + + + +begin + content_item.delete(:revision_id) +end; + + + + Index: openacs-4/packages/edit-this-page/www/etp-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-delete-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-delete-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,11 @@ + + + postgresql7.1 + + + +select content_item__delete(:item_id); + + + + Index: openacs-4/packages/edit-this-page/www/etp-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-delete.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-delete.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,10 @@ + +Confirm delete operation for @name@ +Are you sure you want to delete the page "@title@" at @page_url@ ? +This operation cannot be undone. +

+ +@form_vars@ + +

+ Index: openacs-4/packages/edit-this-page/www/etp-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-delete.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,39 @@ +# /packages/edit-this-page/www/etp-delete.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-13 + + Asks for confirmation before deleting the whole page + +} { + name + { confirmed f } +} -properties { + page_url:onevalue + title:onevalue + form_vars:onevalue +} + +etp::check_write_access + +set package_id [ad_conn package_id] + +if { $confirmed == "t" } { + # TODO: the clear_revisions statement below should be unnecessary. + # It's there because content_item__delete was throwing an error + # (possibly due to the data-change violation, basically a postgresql bug) + db_1row get_item_id "" + db_dml clear_revisions "" + db_exec_plsql delete_page "" + ad_returnredirect "etp" + ad_script_abort +} else { + set confirmed "t" + set form_vars [export_form_vars name confirmed] + set page_url "[file dirname [ad_conn url]]/$name" + db_0or1row get_title "" + if {![info exists title]} { + set title "Unknown title" + } +} \ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-delete.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-delete.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + + select title + from cr_revisions r, cr_items i + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and r.item_id = i.item_id + and r.revision_id = i.live_revision + + + + + + select item_id + from cr_items + where parent_id = etp_get_folder_id(:package_id) + and name = :name + + + + + +update cr_items set live_revision=null, latest_revision=null +where item_id = :item_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-edit-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp-edit-2-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit-2-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,13 @@ + + + oracle8.1.6 + + + +begin + etp_create_new_revision(:package_id, :name, :user_id) from dual; +end; + + + + Index: openacs-4/packages/edit-this-page/www/etp-edit-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp-edit-2-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit-2-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,11 @@ + + + postgresql7.1 + + + +select etp_create_new_revision(:package_id, :name, :user_id); + + + + Index: openacs-4/packages/edit-this-page/www/etp-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp-edit-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit-2.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,66 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-10 + + Handles updating the value for a single page attribute + +} { + name + attribute +} -properties { + page_title:onevalue + attribute_title:onevalue + widget:onevalue +} + +etp::check_write_access + +set form [ns_getform] +if { [empty_string_p $form] || [ns_set find $form $attribute] == -1 } { + ad_return_error "This is a bug" "Form must provide value for $attribute" + ad_script_abort +} +set value [ns_set get $form $attribute] + +# TODO: validate the html that was given to us + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +set latest_revision_id [etp::get_latest_revision_id $package_id $name] +set live_revision_id [etp::get_live_revision_id $package_id $name] + +if { $latest_revision_id == $live_revision_id } { + # This is the first edit performed on this page since it was last + # published. Now's the time to make a new revision to store the changes. + + db_exec_plsql create_new_revision "" + set latest_revision_id [etp::get_latest_revision_id $package_id $name] +} + +set content_type [etp::get_content_type $name] +set attribute_desc [etp::get_attribute_desc $attribute $content_type] +set attribute_id [etp::get_attribute_id $attribute_desc] +if { $attribute_id == -1} { + # standard attribute + db_dml update_attribute "" +} else { + # extended_attribute + db_transaction { + db_dml delete_ext_attribute "" + db_dml insert_ext_attribute "" + } +} + +# As a convenience, if you change the Title of an index page, +# we also update the package instance name so that the context bar +# reflects the new title. Note this is something you can't do through +# the Site Map UI. + +if { $name == "index" && $attribute == "title" } { + db_dml update_package_instance_name "" + +} + + +ad_returnredirect "etp?[export_url_vars name]" Index: openacs-4/packages/edit-this-page/www/etp-edit-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp-edit-2.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit-2.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,35 @@ + + + + + +update cr_revisions +set $attribute = :value +where revision_id = :latest_revision_id + + + + + +delete from acs_attribute_values +where object_id = :latest_revision_id +and attribute_id = :attribute_id + + + + + +insert into acs_attribute_values (object_id, attribute_id, attr_value) +values (:latest_revision_id, :attribute_id, :value) + + + + + +update apm_packages +set instance_name = :value +where package_id = :package_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,15 @@ + +@page_title@ +@context_bar@ + +
+@form_vars@ + + + +
+@widget@ +
+ +
+
\ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,80 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-10 + + Presents a form for editing a single page attribute + +} { + name + attribute +} -properties { + page_title:onevalue + context_bar:onevalue + attribute_title:onevalue + widget:onevalue + form_vars:onevalue +} + +etp::check_write_access + +set package_id [ad_conn package_id] +set revision_id [etp::get_latest_revision_id $package_id $name] +set content_type [etp::get_content_type $name] +set attribute_desc [etp::get_attribute_desc $attribute $content_type] + +ns_log Notice "etp-edit: attr_desc is $attribute_desc" +set attribute_title [etp::get_attribute_pretty_name $attribute_desc $name] + +# figure out the attribute's value + +if { [lsearch -exact {title description content} $attribute] >= 0 } { + # value is stored in cr_revisions table + + db_1row get_standard_attribute "" + +} else { + # value is stored in acs_attribute_values + set attribute_id [etp::get_attribute_id $attribute_desc] + db_1row get_extended_attribute "" +} + + +# TODO: need to implement select lists also +# TODO: what about default values? + +set type [etp::get_attribute_data_type $attribute_desc] +set html [etp::get_attribute_html $attribute_desc] +set default [etp::get_attribute_default $attribute_desc] + +ns_log Notice "default is $default; [info commands $default]" + +# see if a select-list callback function was specified +if { [info commands $default] != "" } { + set query_results [eval $default option_list $attribute_id] + set widget "\n" +} elseif {$type == "string" && [regexp -nocase {(rows|cols)} $html]} { + set widget "\n" +} else { + set widget "\n" +} + +set form_vars [export_form_vars name attribute] + +set page_title "$attribute_title for page \"$page_title\"" + +if {$name == "index"} { + set context_bar [ad_context_bar [list "etp?[export_url_vars name]" Edit] $attribute_title] +} else { + set context_bar [ad_context_bar [list $name $name] [list "etp?[export_url_vars name]" Edit] $attribute_title] +} + + + Index: openacs-4/packages/edit-this-page/www/etp-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-edit.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-edit.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,27 @@ + + + + + + select $attribute as value, r.title as page_title + from cr_revisions r, cr_items i + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = :revision_id + + + + + + select etp_get_attribute_value(r.revision_id, :attribute_id) as value, + r.title as page_title + from cr_items i, cr_revisions r + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = :revision_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-extlink.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-extlink.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-extlink.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,36 @@ + +@page_title@ +@context_bar@ + +
+@form_vars@ + + + + + + + +
+External URL + + + +This is the url of the link destination. If the link is to another site, +it must be fully qualified beginning with http://. +
+Title + + + +This is the text of the link that will be generated. +
+Description + + +
+ +
+

Index: openacs-4/packages/edit-this-page/www/etp-extlink.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-extlink.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-extlink.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,59 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-07-10 + + Presents a simple form for creating or editing an external link. + +} { + { url "" } + { label "" } + { description "" } + { item_id "" } + { confirmed "f" } +} -properties { + page_title:onevalue + context_bar:onevalue + form_vars:onevalue +} + +etp::check_write_access + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +if { $confirmed == "t" } { + if { [empty_string_p $url] || [empty_string_p $label] } { + ad_return_complaint 1 "You must fill out all fields in this form." + } else { + if { [empty_string_p $item_id] } { + db_exec_plsql create_extlink { + select etp_create_extlink(:package_id, :url, :label, :description); + } + } else { + db_dml update_extlink { + update cr_extlinks + set url = :url, label = :label, description = :description + where extlink_id = :item_id + } + } + ad_returnredirect "etp" + } + ad_script_abort +} else { + set confirmed "t" + set form_vars [export_form_vars item_id confirmed] + + if {![empty_string_p $item_id]} { + db_1row get_extlink_info { + select url, label, description + from cr_extlinks + where extlink_id = :item_id + } + set page_title "Edit an external link" + set context_bar [ad_context_bar [list "etp" "Edit"] "Edit external link"] + } else { + set page_title "Create a new external link" + set context_bar [ad_context_bar [list "etp" "Edit"] "New external link"] + } +} + Index: openacs-4/packages/edit-this-page/www/etp-history-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-history-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-history-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,26 @@ + + + postgresql7.1 + + + + +select o.creation_user as creation_user_id, + person__name(o.creation_user) as creation_user_name, + to_char(o.creation_date, 'Mon DD') as creation_date, + o.modifying_user as publish_user_id, + person__name(o.modifying_user) as publish_user_name, + to_char(r.publish_date, 'Mon DD') as publish_date, + r.revision_id, + content_revision__get_number(r.revision_id) as version_number +from cr_revisions r, cr_items i, acs_objects o +where r.item_id = i.item_id +and o.object_id = r.revision_id +and i.parent_id = etp_get_folder_id(:package_id) +and i.name = :name +order by r.revision_id + + + + + Index: openacs-4/packages/edit-this-page/www/etp-history.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-history.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-history.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,43 @@ + +@page_title@ +@context_bar@ + + + + + + + + + + + + + +
Version +Created +Published + +
@revisions.version_number@ + + + + +@revisions.creation_user_name@ on + +@revisions.creation_date@ + + + + +@revisions.publish_user_name@ on + +@revisions.publish_date@ + + +view + + | revert + + +
\ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-history.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-history.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-history.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,36 @@ +# /packages/edit-this-page/www/etp-history.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-13 + + Displays the revision history for a page, allowing you + to revert to a previous revision. + +} { + name +} -properties { + page_title:onevalue + context_bar:onevalue + name:onevalue + live_revision_id:onevalue + revisions:multirow +} + +etp::check_write_access + +set package_id [ad_conn package_id] + +set live_revision_id [etp::get_live_revision_id $package_id $name] + +set page_title "Revision history for $name" + +if {$name == "index"} { + set context_bar [ad_context_bar [list "etp?[export_url_vars name]" Edit] "History"] +} else { + set context_bar [ad_context_bar [list $name $name] [list "etp?[export_url_vars name]" Edit] "History"] +} + + +db_multirow revisions get_revisions "" + Index: openacs-4/packages/edit-this-page/www/etp-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-master.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-master.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,24 @@ + + +@title@ + + + +

@title@

+@context_bar@ +
+ + + +
+ + + + + + + +
@signatory@
@etp_link@
+ + + \ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-master.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-master.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,20 @@ +# /packages/edit-this-page/www/master.tcl + +# Ensures variables needed by master.adp are defined + +if { ![info exists title] } { + set title [ad_system_name] +} +if { ![info exists context_bar] } { + set context_bar "" +} +if { ![info exists signatory] } { + set signatory [ad_system_owner] +} + +set filename [file tail [ad_conn url]] +if { [string compare $filename "etp*"] != 0 } { + set etp_link [etp::get_etp_link] +} else { + set etp_link "" +} Index: openacs-4/packages/edit-this-page/www/etp-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,19 @@ + + + oracle8.1.6 + + + + select i.item_id, i.name, r.revision_id, r.title, + content_revision.get_number(r.revision_id) as latest_revision, + content_revision.get_number(r.live_revision) as live_revision, + r.description, r.publish_date, r.content $extended_attributes + from cr_items i, cr_revisions r + where i.parent_id = :package_id + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = :revision_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,19 @@ + + + postgresql7.1 + + + + select i.item_id, i.name, r.revision_id, r.title, + content_revision__get_number(r.revision_id) as latest_revision, + content_revision__get_number(i.live_revision) as live_revision, + r.description, r.publish_date, r.content $extended_attributes + from cr_items i, cr_revisions r + where i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and i.item_id = r.item_id + and r.revision_id = :revision_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-publish.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-publish.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-publish.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,32 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-04 + + Displays all options for editing a page + +} { + name +} + +etp::check_write_access + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +set latest_revision_id [etp::get_latest_revision_id $package_id $name] +set live_revision_id [etp::get_live_revision_id $package_id $name] + +if { $latest_revision_id > $live_revision_id } { + db_transaction { + db_dml publish_latest_revision "" + db_dml set_publish_date "" + db_dml set_audit_info "" + } + # Invalidate the cache used by etp::get_page_attributes + set key "etp::get_pa $package_id $name [etp::get_content_type $name]" + ns_log Notice "etp-publish: invalidating cache for $key" + util_memoize_flush $key +} + +ad_returnredirect "etp?[export_url_vars name]" + Index: openacs-4/packages/edit-this-page/www/etp-publish.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-publish.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-publish.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,30 @@ + + + + + +update cr_items +set live_revision = :latest_revision_id +where live_revision = :live_revision_id + + + + + +update cr_revisions +set publish_date = now() +where revision_id = :latest_revision_id + + + + + +update acs_objects +set modifying_user = :user_id, + last_modified = now() +where object_id = :latest_revision_id + + + + + Index: openacs-4/packages/edit-this-page/www/etp-revert-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-revert-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-revert-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,13 @@ + + + oracle8.1.6 + + + +begin + content_revision.delete(:revision_id); +end; + + + + Index: openacs-4/packages/edit-this-page/www/etp-revert-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-revert-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-revert-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,13 @@ + + + postgresql7.1 + + + + +select content_revision__delete(:revision_id) + + + + + Index: openacs-4/packages/edit-this-page/www/etp-revert.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-revert.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-revert.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,17 @@ + +Confirm revert operation for @name@ +Are you sure you want to go back to version @version_number@? +In order to do so, the + +most recent version + + +@revision_count@ more recent versions + +will be deleted. +

+ +@form_vars@ + +

+ Index: openacs-4/packages/edit-this-page/www/etp-revert.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-revert.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-revert.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,46 @@ +# /packages/edit-this-page/www/etp-revert.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-13 + + Asks for confirmation before deleting revisions + +} { + name + revision_id:integer + version_number:integer + { confirmed "f" } +} -properties { + name:onevalue + revision_count:onevalue + version_number:onevalue + revision_id:onevalue + form_vars:onevalue +} + +etp::check_write_access + +set package_id [ad_conn package_id] + +if { $confirmed == "t" } { + db_transaction { + db_1row get_item_id "" + + db_dml set_live_revision "" + set revision_list [db_list revisions_to_delete ""] + + foreach revision_id $revision_list { + db_exec_plsql delete_revision "" + } + } + ad_returnredirect "etp?[export_url_vars name]" + ad_script_abort + +} else { + + db_1row get_revision_count "" + + set confirmed "t" + set form_vars [export_form_vars name revision_id version_number confirmed] +} \ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-revert.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-revert.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-revert.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,42 @@ + + + + + + select item_id + from cr_items + where parent_id = etp_get_folder_id(:package_id) + and name = :name + + + + + + update cr_items + set live_revision = :revision_id, latest_revision = :revision_id + where item_id = :item_id + + + + + + select revision_id + from cr_revisions + where item_id = :item_id + and revision_id > :revision_id + order by revision_id + + + + + + select count(1) as revision_count + from cr_revisions r, cr_items i + where r.item_id = i.item_id + and i.parent_id = etp_get_folder_id(:package_id) + and i.name = :name + and r.revision_id > :revision_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-setup-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-2-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup-2-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,17 @@ + + + postgresql7.1 + + + +select content_folder__new(:name, :title, '', etp_get_folder_id(:parent_package_id)); + + + + + +select acs_object__name(:package_id) as title + + + + Index: openacs-4/packages/edit-this-page/www/etp-setup-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-2.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup-2.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,48 @@ +# /packages/edit-this-page/www/etp-setup-2.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + Creates the initial index page and the entry in cr_folders + for a new content section. + +} { +} + +etp::check_write_access + +set package_id [ad_conn package_id] +set node_id [ad_conn node_id] +db_1row get_section_name "" + +set site_node_url [file dirname [ad_conn url]] + +if { $site_node_url == "/" } { + # -100 is the magic number for the "root folder". + set folder_id -100 + db_transaction { + db_dml set_folder_package "" + etp::make_page "index" $title + } + +} else { + set name [db_string site_node_name ""] + set parent_url [file dirname $site_node_url] + + array set parent_site_node [site_node $parent_url] + set parent_package_id $parent_site_node(object_id) + +# set parent_package_id [site_node_closest_ancestor_package -url "$parent_url" "edit-this-page"] +# if {[empty_string_p $parent_package_id]} { +# set parent_package_id [site_node_closest_ancestor_package -url "$parent_url" "acs-subsite"] +# } + + db_transaction { + set folder_id [db_exec_plsql create_folder ""] + db_dml set_folder_package "" + etp::make_page "index" $title + } +} + +ad_returnredirect "etp" Index: openacs-4/packages/edit-this-page/www/etp-setup-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-2.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup-2.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,25 @@ + + + + + + + select name + from site_nodes + where node_id = :node_id + + + + + + + + update cr_folders + set package_id = :package_id + where folder_id = :folder_id + + + + + + Index: openacs-4/packages/edit-this-page/www/etp-setup-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup-oracle.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,11 @@ + + + oracle8.1.6 + + + +select acs_object.name(:package_id) as title from dual + + + + Index: openacs-4/packages/edit-this-page/www/etp-setup-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,11 @@ + + + postgresql7.1 + + + +select acs_object__name(:package_id) as title + + + + Index: openacs-4/packages/edit-this-page/www/etp-setup.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,35 @@ + +@page_title@ +@context_bar@ + +The ETP application in use for a content section determines the +appearance and content of its pages. You may also specify the +application that should be used when a subtopic is created within +this content section. + +

+

+
+ + + + + + + + + + +
Application: + +
Subtopic Application: + +

+

+ +
+
+
+

+ + Index: openacs-4/packages/edit-this-page/www/etp-setup.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-setup.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,61 @@ +# /packages/edit-this-page/www/etp-setup.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + This page allows admins to perform initial setup + of a new content section. + +} { + {page_title ""} + {confirmed "f"} + {app ""} + {subtopic_app ""} +} -properties { + app_options:onevalue + subtopic_app_options:onevalue + context_bar:onevalue +} + +etp::check_write_access + +set package_id [ad_conn package_id] + +if { $confirmed == "f" } { + set app [ad_parameter application "default"] + set subtopic_app [ad_parameter subtopic_application "default"] + + set app_options "" + set subtopic_app_options "" + + set apps [etp::get_defined_applications] + + foreach app_name $apps { + + if { $app == $app_name } { + append app_options "\n" + } else { + append app_options "\n" + } + + if { $subtopic_app == $app_name } { + append subtopic_app_options "\n" + } else { + append subtopic_app_options "\n" + } + } + set page_title "Change ETP application in use for content section \"$page_title\"" + set context_bar [ad_context_bar {"etp" "Edit"} "Setup"] + + ad_return_template + +} else { + db_dml set_app_param "" + db_dml set_subtopic_app_param "" + apm_parameter_sync edit-this-page $package_id + ad_returnredirect "etp" + ad_script_abort +} + + Index: openacs-4/packages/edit-this-page/www/etp-setup.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp-setup.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-setup.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,36 @@ + + + + + + + update apm_parameter_values + set attr_value = :app + where package_id = :package_id + and parameter_id = (select parameter_id + from apm_parameters + where package_key=(select package_key + from apm_packages + where package_id = :package_id) + and parameter_name = 'application') + + + + + + + + update apm_parameter_values + set attr_value = :subtopic_app + where package_id = :package_id + and parameter_id = (select parameter_id + from apm_parameters p + where package_key=(select package_key + from apm_packages + where package_id = :package_id) + and parameter_name = 'subtopic_application') + + + + + Index: openacs-4/packages/edit-this-page/www/etp-subtopic-create.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-subtopic-create.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-subtopic-create.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,30 @@ + +@page_title@ +@context_bar@ + +

+@form_vars@ + + + + + + +
+Subtopic name + + + +This must be a short identifier containing no spaces. It will be the +final part of the URL that identifies this subtopic. +
+Subtopic title + + + +This will be the title of the top-level page in this subtopic. You +may change it later if you like. +
+ +
+

Index: openacs-4/packages/edit-this-page/www/etp-subtopic-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-subtopic-create.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-subtopic-create.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,52 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-07-06 + + Presents a simple form for creating a new subtopic. + Prevents us from having to use the confusing site-map interface. + +} { + { subtopic_name "" } + { subtopic_title "" } + { confirmed f } +} -properties { + page_title:onevalue + context_bar:onevalue + form_vars:onevalue +} + +etp::check_write_access + +if { $confirmed == "t" } { + if { [empty_string_p $subtopic_name] || + [regexp {[^a-zA-Z0-9\-_]} $subtopic_name] } { + ad_return_complaint 1 "The subtopic name must be a short identifier + containing no spaces. It will be the final part of the URL that + identifies this subtopic." + } else { + set new_package_id [subsite::auto_mount_application \ + -instance_name $subtopic_name \ + -pretty_name $subtopic_title "edit-this-page"] + set curr_package_id [ad_conn package_id] + +# this parameter-copying code predates the use of ETP applications +# db_foreach old_package_parameters "" { +# db_dml copy_parameter "" +# } + + db_1row get_subtopic_application "" + db_1row get_application_parameter_id "" + db_dml set_subtopic_application "" + + apm_parameter_sync "edit-this-page" $new_package_id + set title $subtopic_title + ad_returnredirect "$subtopic_name/etp-setup-2?[export_url_vars title]" + } + ad_script_abort +} else { + set confirmed "t" + set form_vars [export_form_vars confirmed] +} + +set page_title "Create a new subtopic" +set context_bar [ad_context_bar [list "etp" "Edit"] "New subtopic"] Index: openacs-4/packages/edit-this-page/www/etp-subtopic-create.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-subtopic-create.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-subtopic-create.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,60 @@ + + + + + + +select attr_value, parameter_id + from apm_parameter_values + where package_id = :curr_package_id + + + + + + + +update apm_parameter_values +set attr_value = :attr_value +where package_id = :new_package_id +and parameter_id = :parameter_id + + + + + + + + +select v.attr_value as subtopic_application + from apm_parameter_values v, apm_parameters p + where v.parameter_id = p.parameter_id + and v.package_id = :curr_package_id + and p.parameter_name = 'subtopic_application' + + + + + + + +select parameter_id + from apm_parameters p + where p.parameter_name = 'application' + and package_key = 'editthispage' + + + + + + + +update apm_parameter_values +set attr_value = :subtopic_application +where package_id = :new_package_id +and parameter_id = :parameter_id + + + + + Index: openacs-4/packages/edit-this-page/www/etp-swap-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-swap-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-swap-postgresql.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,32 @@ + + + postgresql7.1 + + + + select tree_sortkey, item_id + from cr_items + where parent_id = etp_get_folder_id(:package_id) + and tree_sortkey < :sort_key + order by tree_sortkey desc + + + + + + select tree_sortkey, item_id + from cr_items + where tree_sortkey >= :prev_sort_key + order by tree_sortkey + + + + + + update cr_items + set tree_sortkey = :new_sortkey + where item_id = :item_id + + + + Index: openacs-4/packages/edit-this-page/www/etp-swap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-swap.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-swap.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,46 @@ +# /packages/edit-this-page/www/etp-setup.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + Swaps the page with the given sort order + with the one preceding it. + +} { + sort_order +} + +etp::check_write_access + +set sort_key $sort_order + +set package_id [ad_conn package_id] + +db_foreach get_prev_key "" { + set prev_sort_key $tree_sortkey + break; +} + +db_transaction { + +db_foreach get_all_keys "" { + + if {[regsub "^$prev_sort_key" $tree_sortkey $sort_key new_sortkey] || + [regsub "^$sort_key" $tree_sortkey $prev_sort_key new_sortkey]} { + + # fortunately tree_sortkey is not unique, so it doesn't matter + # if we temporarily have two rows with the same key here. + + db_dml update_key "" + + } else { + # because of how we ordered the select, we're done. + # db_foreach will flush the remaining result rows. + break + } +} + +} + +ad_returnredirect "etp" \ No newline at end of file Index: openacs-4/packages/edit-this-page/www/etp-symlink.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-symlink.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-symlink.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,15 @@ + +@page_title@ +@context_bar@ + + +@all_pages.indent@ + +@all_pages.title@
+
+ +@all_pages.title@
+
+
+ +

Index: openacs-4/packages/edit-this-page/www/etp-symlink.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-symlink.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-symlink.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,77 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-07-10 + + Presents a simple form for creating or editing a symbolic link + (which is a link to another page or folder in the CMS) + +} { + { target_id "" } + { item_id "" } +} -properties { + page_title:onevalue + context_bar:onevalue + item_id:onevalue + all_pages:multirow +} + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +if { ![empty_string_p $target_id] } { + + # if the target is a folder, find the item_id for its index page + if { [db_string get_object_type { + select object_type from acs_objects + where object_id = :target_id + }] == "content_folder" } { + set target_id [db_string get_index_id { + select item_id from cr_items + where parent_id = :target_id + and name = 'index' + }] + } + + if { [empty_string_p $item_id] } { + db_exec_plsql create_symlink { + select etp_create_symlink(:package_id, :target_id); + } + } else { + db_dml update_symlink { + update cr_symlinks + set target_id = :target_id + where symlink_id = :item_id + } + } + ad_returnredirect "etp" + ad_script_abort +} else { + + if {![empty_string_p $item_id]} { + db_1row get_symlink_info { + select target_id + from cr_symlinks + where symlink_id = :item_id + } + set page_title "Edit a link to local content" + set context_bar [ad_context_bar [list "etp" "Edit"] "Edit internal link"] + } else { + set page_title "Create a link to local content" + set context_bar [ad_context_bar [list "etp" "Edit"] "New internal link"] + } + + db_multirow all_pages all_pages { + select i.item_id, i.name, etp_get_title(i.item_id, null) as title, + repeat(' ',(tree_level(i.tree_sortkey) - 1) * 4) as indent + from cr_items i, acs_objects o + where i.item_id = o.object_id + and o.object_type in ('content_item', 'content_folder') + and i.name != 'index' + and i.tree_sortkey not like (select tree_sortkey + from cr_items + where item_id = -400) || '%' + order by i.tree_sortkey + } + +} + Index: openacs-4/packages/edit-this-page/www/etp-trash.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-trash.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-trash.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,27 @@ +# /packages/edit-this-page/www/etp-trash.tcl + +ad_page_contract { + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-07-25 + + Moves the item to the "Trash" folder so we can + recover it later if necessary. There is no annoying + confirmation message. + +} { + item_id:integer +} + +etp::check_write_access + +set package_id [ad_conn package_id] + +if {[db_0or1row get_node_id ""]} { + site_map_unmount_application -delete_p "t" $node_id +} + +db_dml trash_item "" + +ad_returnredirect "etp" +ad_script_abort + Index: openacs-4/packages/edit-this-page/www/etp-trash.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp-trash.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp-trash.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + + select node_id + from site_nodes sn, cr_folders f + where f.folder_id = :item_id + and sn.object_id = f.package_id + + + + + + + update cr_items + set parent_id = -400 + where item_id = :item_id + + + + + Index: openacs-4/packages/edit-this-page/www/etp.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp.adp 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,127 @@ + +@page_title@ +@context_bar@ + + +
+@page_url@ + +version @pa.latest_revision@ +(live version is @pa.live_revision@) + + +Edit parent page + +
+

+ +

All editable attributes

+ + + + + + + + + + + +
@page_attributes.pretty_name@ +@page_attributes.value@ +edit +
+ +

+ + + + + + + + + +
+

Publishing options

+ +
+ +

Configuration of this content section

+
+ +

+ + +

Content items in this section

+ + + + + + + + + + + + +
+Create a new +@application_params.content_object_name@ + +or +@subtopic_object_name@ + + +or +external link + + +or +internal link + + +
@content_items.title@ + + + +(page) +edit + + + +(subtopic) +edit + + +(external ref) +edit + + +(internal ref) +edit + + + + +| delete + + +| move up + +
+ + Index: openacs-4/packages/edit-this-page/www/etp.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/etp.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp.tcl 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,88 @@ +ad_page_contract { + @author Luke Pond (dlpond@museatech.net) + @creation-date 2001-06-04 + + Displays all options for editing a page + +} { + { name "index" } +} -properties { + pa:onerow + application_params:onerow + subtopic_object_name:onevalue + page_attributes:multirow + page_url:onevalue + content_pages:multirow + page_title:onevalue + context_bar:onevalue + subtopics:multirow +} + +etp::check_write_access + +array set application_params [etp::get_application_params] +set subtopic_object_name [etp::get_application_param index_object_name [ad_parameter subtopic_application "default"]] + +set package_id [ad_conn package_id] +set content_type [etp::get_content_type $name] +set extended_attributes [etp::get_ext_attribute_columns $content_type] + +# as opposed to the typical use of etp::get_page_attributes, which +# gets the attributes of the live revision, these two queries get +# the attributes of the most recent revision, and +# the results aren't cached. + +set revision_id [etp::get_latest_revision_id $package_id $name] +db_1row get_current_page_attributes "" -column_array pa + +template::multirow create page_attributes name pretty_name value + +proc truncate {str} { + set str [ad_quotehtml $str] + if {[string length $str] > 100} { + set str "[string range $str 0 100]..." + } + return $str +} + +set attributes [etp::get_attribute_descriptors $content_type] + +foreach attribute $attributes { + set attribute_name [etp::get_attribute_name $attribute] + set attribute_pretty_name [etp::get_attribute_pretty_name $attribute $name] + template::multirow append page_attributes $attribute_name \ + $attribute_pretty_name [truncate $pa($attribute_name)] +} + + +set page_title "Attributes for page \"$pa(title)\"" +if { $name == "index" } { + set context_bar [ad_context_bar "Edit"] +} else { + set context_bar [ad_context_bar [list $name $name] "Edit"] +} + +set url_dir "[file dirname [ad_conn url]]" +if { $url_dir == "/" } { + set page_url "/$name" + set edit_parent_url "" +} else { + set page_url "$url_dir/$name" + + if { $name == "index" } { + regsub {/[^/]*/[^/]*$} $page_url "" parent_url + } else { + set parent_url $url_dir + } + set edit_parent_url "$parent_url/etp" +} + +if {$name == "index"} { + # Get the list of content items in this directory + etp::get_content_items + + #this custom query is no longer needed?? maybe it will be if we + #prevent newly-created pages from being displayed... + #db_multirow content_pages get_content_pages "" +} + Index: openacs-4/packages/edit-this-page/www/etp.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/Attic/etp.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/etp.xql 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,16 @@ + + + + + + select name, title, tree_sortkey as sort_order + from cr_items i, cr_revisions r + where i.parent_id = etp_get_folder_id(:package_id) + and i.name != 'index' + and i.item_id = r.item_id + and i.latest_revision = r.revision_id + order by tree_sortkey + + + + Index: openacs-4/packages/edit-this-page/www/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/www/index.vuh,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/edit-this-page/www/index.vuh 24 Sep 2001 17:24:13 -0000 1.1 @@ -0,0 +1,57 @@ +ad_page_contract { + packages/editthispage/www/index.vuh + + @author Luke Pond (dlpond@pobox.com) + @creation-date 2001-06-01 + + Virtual URL Handler to serve files from an + instance of the Edit This Page package. + + Helpful .vuh example at + http://www.arsdigita.com/bboard/q-and-a-fetch-msg?msg_id=000JTn +} { + {revision_id ""} +} + +ad_conn -set revision_id $revision_id + +# get the portion of the url following the package directory +set name [ad_conn path_info] + +ns_log Notice "index.vuh: request for $name" + +if { [string index $name end] == "/" } { + # it's in a subdirectory, and we know there's no + # other package mounted on that subdirectory. + ns_returnnotfound +} + +set server_root [file dirname [ns_info pageroot]] + +if {[empty_string_p $name] || $name == "index"} { + set path "$server_root/[etp::get_application_param index_template]" +} elseif {[string match "etp*" $name]} { + # this trickery is for serving pages from the top level, + # where the acs-subsite package is mounted rather than + # the editthispage package. normally the request processor + # finds these before invoking this file. + set path "$server_root/packages/editthispage/www/$name" +} else { + + set path "$server_root/[etp::get_application_param content_template]" + + # set up form variables so we can pass the "name" + # variable to the content page. + global _ns_form + set _ns_form [ns_set create] + ns_set put [ns_getform] "name" $name +} + +ns_log Notice "Edit This Page index.vuh: serving $path" + +rp_serve_abstract_file $path + + + + +