Index: openacs-4/packages/edit-this-page/Changes
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/Changes,v
diff -u
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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):
+ - attribute_name
+
- pretty_name
+
- pretty_plural
+
- datatype (must be one of the entries in acs_datatypes:
+ string, boolean, number, integer, date, etc.)
+
- html (a string containing html attributes for the input
+ control. useful attributes are "size=X" to specify
+ the size of standard input controls, and "rows=X cols=X"
+ to specify the size of a textarea. Textareas will be
+ used only if the datatype is string and html specifies
+ rows or cols.)
+
- default_value (can either be a string denoting a single default
+ value, or the name of a callback function you've
+ defined in the etp namespace which is used to
+ provide values for select lists).
+
+ # 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:
+
+ - item_id
+
- name
+
- revision_id
+
- title
+
- context_bar
+
- description
+
- publish_date
+
- content
+
- extended attributes, if any, defined by etp::make_content_type
+
+} {
+ # 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:
+
+ - name
+
- url (use this to generate a link to this item)
+
- title
+
- description
+
- object_type
+
- publish_date
+
- item_id
+
+
+ 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:
+ - name
+
- title
+
- description
+
+
+} {
+ 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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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:
+
+
+-
+@content_items.title@
+
+
+
+
+
+
+Questions and Answers:
+
+
+
+-
+Q: @content_items.title@
+
+A:
+@content_items.content@
+
+
+
+
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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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@
+
+