Index: openacs-4/packages/lars-blogger/www/category-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/category-delete.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/lars-blogger/www/category-delete.tcl 29 Sep 2003 08:05:42 -0000 1.1
+++ openacs-4/packages/lars-blogger/www/category-delete.tcl 29 Sep 2003 19:41:23 -0000 1.2
@@ -5,7 +5,7 @@
permission::require_permission -object_id [ad_conn package_id] -privilege write
-db_exec_plsql delete { *SQL* }
+db_exec_plsql delete {}
ad_returnredirect $return_url
Index: openacs-4/packages/lars-blogger/www/category-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/category-edit.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/lars-blogger/www/category-edit.adp 29 Sep 2003 13:51:46 -0000 1.2
+++ openacs-4/packages/lars-blogger/www/category-edit.adp 29 Sep 2003 19:41:23 -0000 1.3
@@ -5,19 +5,6 @@
+
-
-
- -
- @categories.name@ − @categories.short_name@
- (edit
- |
- delete)
-
-
-
-
-Add new category
-
-
Index: openacs-4/packages/lars-blogger/www/category-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/category-edit.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/lars-blogger/www/category-edit.tcl 29 Sep 2003 13:56:48 -0000 1.2
+++ openacs-4/packages/lars-blogger/www/category-edit.tcl 29 Sep 2003 19:41:23 -0000 1.3
@@ -1,12 +1,20 @@
-ad_page_contract {} {
- {category_id:integer ""}
+ad_page_contract {
+ View and edit blogger categories.
+
+ @author Steffen Christensen (steffen@refresh.dk)
+ @cvs-id $Id$
+} {
+ category_id:integer,optional
{return_url ""}
{name:allhtml ""}
{short_name:allhtml ""}
}
+set page_title "Manage Categories"
+set context [list $page_title]
+
# Must be logged in
-ad_maybe_redirect_for_registration
+auth::require_login
# Must have write privilege
permission::require_permission -object_id [ad_conn package_id] -privilege write
@@ -15,102 +23,108 @@
if { [lars_blog_categories_p -package_id $package_id] != 1} {
ad_return_error "No category support" "Categories are not supported. Modify the package parameters to add support."
- return
+ ad_script_abort
}
-db_multirow categories categories { *SQL* }
-
-if { [string length $return_url]==0 } {
- set return_url category-edit
+if { [empty_string_p $return_url] } {
+ set return_url [ad_conn url]
}
-form create category -cancel_url [ad_decode $return_url "" "." $return_url]
+#####
+#
+# Add/edit form
+#
+#####
-element create category name -label "Category" -datatype text -html { size 50 }
-
-element create category short_name \
- -label "Category Short Name" \
- -datatype text \
- -html { size 20 } \
- -optional \
- -help_text "This is used to provide a pretty URL for viewing postings in this category"
-
-element create category category_id -widget hidden -datatype text
-element create category return_url -widget hidden -datatype text -value $return_url
-
-if { [form is_request category] } {
-
- if { [empty_string_p $category_id] } {
- set insert_or_update insert
- set category_id [db_nextval "acs_object_id_seq"]
-
- # Prefill title and content with supplied values
- foreach element { name short_name } {
- if { [exists_and_not_null $element] } {
- element set_value entry $element [set $element]
- }
- }
- } else {
- set insert_or_update update
- db_1row category { *SQL* }
-
- element set_value category name $name
- element set_value category short_name $short_name
+ad_form -name category -cancel_url $return_url -form {
+ {category_id:key}
+ {name:text
+ {label "Category"}
+ {html { size 50 }}
}
+ {short_name:text,optional
+ {label "Category Short Name"}
+ {html { size 20 }}
+ {help_text "This is used to provide a pretty URL for viewing postings in this category"}
+ }
+ {return_url:text(hidden),optional}
+} -new_request {
- element set_properties category category_id -value $category_id
-}
+} -edit_request {
+ db_1row category {}
-if { [form is_valid category] } {
- set category_id [element get_value category category_id]
- set name [element get_value category name]
- set short_name [element get_value category short_name]
-
- set return_url [element get_value category return_url]
-
- if { [string length $short_name]==0 } {
+} -on_submit {
+
+ if { [empty_string_p $short_name] } {
set existing_short_names [db_list short_names {}]
- set short_name [util_text_to_url -existing_urls $existing_short_names -text $name]
+ set short_name [util_text_to_url -existing_urls $existing_short_names -text $name]
} else {
db_1row short_name_exists { *SQL* }
if { $short_name_exists > 0 } {
- ad_return_error "Category short name exists" "The specified Category Short Name is already being used − please select another one."
- return
+ form set_error category short_name "This short name is already used by another category"
+ break
}
}
-
- db_1row category_exists { *SQL* }
- if { $category_exists == 0 } {
- set insert_or_update insert
- set creation_user [ad_conn user_id]
- set creation_ip [ns_conn peeraddr]
- db_exec_plsql insert_category { *SQL* }
- } else {
- set insert_or_update update
- db_dml update_category { *SQL* }
- }
+} -new_data {
+
+ set creation_user [ad_conn user_id]
+ set creation_ip [ns_conn peeraddr]
+
+ db_exec_plsql insert_category {}
- if { [empty_string_p $return_url] } {
- set return_url "[ad_conn package_url]admin"
- }
+} -edit_data {
+
+ db_dml update_category {}
+
ad_returnredirect $return_url
ad_script_abort
}
-if { ![form is_request category] && ![form is_valid category] } {
- set insert_or_update [element get_value category insert_or_update]
-}
-switch -- $insert_or_update {
- insert {
- set page_title "Add Blog Category"
+
+#####
+#
+# Category list
+#
+#####
+
+template::list::create \
+ -name categories \
+ -multirow categories \
+ -actions {
+ "Add category" "category-edit" "Add new category"
+ } -elements {
+ edit {
+ label {}
+ display_template {}
+ link_url_eval {[export_vars -base [ad_conn url] { category_id }]}
+ link_html { title "Edit category" }
+ sub_class narrow
+ }
+ name {
+ label {Name}
+ link_url_eval {[ad_conn package_url]cat/$short_name/}
+ }
+ short_name {
+ label {Short Name}
+ }
+ num_entries {
+ label {\# Entries}
+ html { align right }
+ display_col num_entries_pretty
+ }
+ delete {
+ label {}
+ display_template {}
+ link_url_eval {[export_vars -base "category-delete" { category_id { return_url [ad_return_url] } }]}
+ link_html { title "Delete category" }
+ sub_class narrow
+ }
}
- update {
- set page_title "Edit Blog Category"
- }
-}
-set context [list $page_title]
+db_multirow -extend { num_entries_pretty } categories categories {} {
+ set num_entries_pretty [lc_numeric $num_entries]
+}
Index: openacs-4/packages/lars-blogger/www/category-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/category-edit.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/lars-blogger/www/category-edit.xql 29 Sep 2003 08:05:42 -0000 1.1
+++ openacs-4/packages/lars-blogger/www/category-edit.xql 29 Sep 2003 19:41:23 -0000 1.2
@@ -4,9 +4,15 @@
- select *
- from pinds_blog_categories
- where package_id = :package_id
+ select c.category_id,
+ c.name,
+ c.short_name,
+ (select count(*)
+ from pinds_blog_entries e
+ where e.category_id = c.category_id) as num_entries
+ from pinds_blog_categories c
+ where c.package_id = :package_id
+ order by upper(c.name), c.name
Index: openacs-4/packages/lars-blogger/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/index.adp,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/lars-blogger/www/index.adp 29 Sep 2003 11:32:53 -0000 1.18
+++ openacs-4/packages/lars-blogger/www/index.adp 29 Sep 2003 19:41:23 -0000 1.19
@@ -11,7 +11,7 @@
-@context_bar;noquote@
+@context;noquote@
Index: openacs-4/packages/lars-blogger/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/index.tcl,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/lars-blogger/www/index.tcl 29 Sep 2003 11:03:31 -0000 1.11
+++ openacs-4/packages/lars-blogger/www/index.tcl 29 Sep 2003 19:41:23 -0000 1.12
@@ -18,25 +18,25 @@
set package_url [ad_conn package_url]
set package_url_with_extras $package_url
-set l_context_bar [list]
+set context [list]
set context_base_url [ad_conn package_url]
if { ![empty_string_p $screen_name] } {
# Show Screen Name in context bar
append context_base_url /user/$screen_name
- lappend l_context_bar [list $context_base_url $screen_name]
+ lappend context [list $context_base_url $screen_name]
append package_url_with_extras user/$screen_name/
}
if { ![empty_string_p $category_short_name] } {
- if { ![db_0or1row get_category_from_short_name { *SQL* }] } {
+ if { ![db_0or1row get_category_from_short_name {}] } {
ad_return_error "Category doesn't exist" "The specified category wasn't valid."
return
}
# Show Category in context bar
append context_base_url /category/$category_short_name
- lappend l_context_bar [list $context_base_url $category_name]
+ lappend context [list $context_base_url $category_name]
} else {
set category_id ""
}
@@ -62,7 +62,7 @@
set display_bloggers_p 1
- db_multirow bloggers bloggers { *SQL* }
+ db_multirow bloggers bloggers {}
set user_has_blog_p 0
multirow foreach bloggers {
@@ -97,23 +97,23 @@
# Show Archive, Year and Month i context
append context_base_url /archive
- lappend l_context_bar [list $context_base_url Archive]
+ lappend context [list $context_base_url Archive]
append context_base_url /$year
- lappend l_context_bar [list $context_base_url $year]
+ lappend context [list $context_base_url $year]
append context_base_url /$month
- lappend l_context_bar [list $context_base_url $month]
+ lappend context [list $context_base_url $month]
if { [exists_and_not_null day] } {
set interval "day"
- db_1row archive_date_month_day { *SQL* }
+ db_1row archive_date_month_day {}
# Day in context
append context_base_url /$day
- lappend l_context_bar [list $context_base_url $day]
+ lappend context [list $context_base_url $day]
} else {
set interval "month"
- db_1row archive_date_month { *SQL* }
+ db_1row archive_date_month {}
}
append page_title " Archive"
@@ -127,13 +127,13 @@
set archive_date ""
}
-db_multirow categories categories { *SQL* }
+db_multirow categories categories {}
# Cut the URL off the last item in the context bar
-set l_context_bar [lreplace $l_context_bar end end [lindex [lindex $l_context_bar end] end]]
-eval "set context_bar \[ad_context_bar $l_context_bar\]"
+if { [llength $context] > 0 } {
+ set context [lreplace $context end end [lindex [lindex $context end] end]]
+}
# Load the StylesheetURL into $stylesheet_url
regsub \% [lars_blog_stylesheet_url] $package_url stylesheet_url
-ad_return_template
Index: openacs-4/packages/lars-blogger/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/admin/index.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/lars-blogger/www/admin/index.tcl 29 Sep 2003 08:05:42 -0000 1.7
+++ openacs-4/packages/lars-blogger/www/admin/index.tcl 29 Sep 2003 19:41:23 -0000 1.8
@@ -11,7 +11,7 @@
set title [db_string package_name { *SQL* }]
-set parameters_url "/admin/site-map/parameter-set?[export_vars { package_id }]"
+set parameters_url [export_vars -base "/shared/parameters" { package_id { return_url [ad_return_url] } }]
set arrow_url "[lars_blog_public_package_url -package_id $package_id]graphics/arrow-box.gif"