Index: openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl,v diff -u -r1.11 -r1.11.2.1 --- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 30 Jul 2003 04:56:41 -0000 1.11 +++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 31 Jan 2004 11:12:21 -0000 1.11.2.1 @@ -122,11 +122,13 @@ ad_proc -public classified-ads::ads::get_assigned_ads_by_category { {-category_id ""} + {-limit 0} } { Gets all the ads assigned to a category (or all categories in a package.) @param category_id The system returns all ads mapped to these categories, or all ads if no category is passed. + @param limit The limit of rows to return. 0 means return all rows. @author Roberto Mello } { @@ -140,6 +142,12 @@ set category_id [classified-ads::categories::get_package_keyword_id] } + if { $limit == 0 } { + set limit_clause "" + } else { + set limit_clause "LIMIT $limit" + } + # # Get custom fields for this category. # @@ -159,10 +167,13 @@ ad_proc -public classified-ads::ads::get_unassigned_ads_by_category { {-category_id_list ""} + {-limit 0} } { Gets all the ads NOT assigned to the categories passed. - @param container_id_list A list of category ids. The system returns all ads not mapped to these categories. + @param container_id_list A list of category ids. The system returns all + ads not mapped to these categories. + @param limit The limit of rows to return. 0 means return all rows. } { # DEDS: FIXME - this uses a subselect. this will get inefficient @@ -175,6 +186,12 @@ set parent_id [classified-ads::get_folder_id -package_id [ad_conn package_id]] + if { $limit == 0 } { + set limit_clause "" + } else { + set limit_clause "LIMIT $limit" + } + return [db_list_of_ns_sets select_ads {}] } Index: openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql,v diff -u -r1.6.2.1 -r1.6.2.2 --- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql 18 Jan 2004 10:36:42 -0000 1.6.2.1 +++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql 31 Jan 2004 11:12:21 -0000 1.6.2.2 @@ -25,6 +25,7 @@ ci.latest_revision = ads.ad_id order by cm.keyword_id asc, cr.title asc + $limit_clause @@ -45,6 +46,7 @@ ci.parent_id = :parent_id and ci.content_type = 'ca_ad' order by cr.title asc + $limit_clause Index: openacs-4/contrib/packages/classified-ads/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/index.adp,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/contrib/packages/classified-ads/www/index.adp 18 Jan 2004 10:36:42 -0000 1.1.2.1 +++ openacs-4/contrib/packages/classified-ads/www/index.adp 31 Jan 2004 11:12:21 -0000 1.1.2.2 @@ -1,135 +1,17 @@ -@title@ -@context@ +@title;noquote@ +@context;noquote@ - -

- Create a new top-level category -

- - - - - - - - -
- - Categories - -
- - - - - - - - - - - - - - - - - - -
NameSubcategoriesAction
-  @categories.heading@ - - @categories.children_count@ - - edit - -  | delete - -
-
- +

+ +

+

Categories

+

+ +

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Ads Under This Category (place new) - -
TitlePublished onAction
-  @assigned_ads.title@ - -  @assigned_ads.pretty_publish_date@ - - Remove -
- No ads assigned to this category. -
- Ads Not Assigned to Any Category - -
TitlePublished onAction
-  @unassigned_ads.title@ - -  @unassigned_ads.pretty_publish_date@ - - Assign -
- No unassigned ads. -
+
+ Index: openacs-4/contrib/packages/classified-ads/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/index.tcl,v diff -u -r1.5.2.1 -r1.5.2.2 --- openacs-4/contrib/packages/classified-ads/www/index.tcl 18 Jan 2004 03:04:07 -0000 1.5.2.1 +++ openacs-4/contrib/packages/classified-ads/www/index.tcl 31 Jan 2004 11:12:21 -0000 1.5.2.2 @@ -15,44 +15,99 @@ set root_folder_id [classified-ads::get_root_folder_id] set package_category_id [classified-ads::categories::get_package_keyword_id] set package_category_p 0 -set title "Categories" +set package_id [ad_conn package_id] +set title "Most Recent Ads" +# RBM: FIXME: Remove "50" hard-coded number +set ads_to_display 50 if {$keyword_id == 0} { + # + # If no category was selected, let's use the main package category + # set keyword_id $package_category_id set package_category_p 1 + set ads_to_display [parameter::get -package_id $package_id -parameter ads_to_display] + set actions "" + + # + # Now get categories. + # RBM: FIXME: This query seems inneficient. + # FIXME: Bulk actions according to permissions. + # + db_multirow categories select_categories {} + set parent_id $keyword_id + + template::list::create \ + -name categories \ + -multirow categories \ + -key keyword_id \ + -actions [list "Create top-level category" \ + [export_vars -base admin/category-new {parent_id return_url}] \ + "Create category"] \ + -bulk_actions { + "Edit" "admin/category-edit" "Edit checked categories" + "Delete" "admin/category-delete" "Delete checked categories" + } \ + -bulk_action_export_vars { + keyword_id + return_url + } \ + -row_pretty_plural "Categories" \ + -elements { + heading { + label "Name" + link_url_eval "index?keyword_id=$keyword_id" + link_html { title "View ads under this category" } + } + description { + label "Description" + link_url_eval "index?keyword_id=$keyword_id" + link_html { title "View ads under this category" } + } + children_count { + label "Number of subcategories" + } + } + } elseif {[string equal [classified-ads::get_main_keyword_id] $keyword_id]} { + # + # If the selected category is the top-level keyword_id, throw error + # ad_return_complaint 1 "
  • No access to the root id" ad_script_abort + } else { - # Select info for this category + # + # Select info for the selected category + # classified-ads::categories::get -keyword_id $keyword_id -array category_info set title $category_info(heading) + set actions [list "Place Ad" [export_vars -base ad-one {keyword_id}] "Place an Ad"] } +# RBM: FIXME - How should we deal with "unassigned" ads? +# +#template::util::list_of_ns_sets_to_multirow \ +# -rows [classified-ads::ads::get_unassigned_ads_by_category -category_id_list [list $keyword_id]] \ +# -var_name unassigned_ads + # # Get custom fields and set to be the list-builder spec # set custom_fields_list [util_memoize "classified-ads::categories::get_custom_fields -keyword_id $keyword_id"] -set list_builder_spec "" -foreach field $custom_fields_list { - append list_builder_spec "\t[lindex $field 0] { - label \"[lindex $field 1]\" - }" -} - -db_multirow categories select_categories {} - template::util::list_of_ns_sets_to_multirow \ - -rows [classified-ads::ads::get_assigned_ads_by_category -category_id $keyword_id] \ + -rows [classified-ads::ads::get_assigned_ads_by_category \ + -category_id $keyword_id \ + -limit $ads_to_display] \ -var_name assigned_ads template::list::create \ -name assigned_ads \ -multirow assigned_ads \ -key ad_id \ - -actions [list "Place Ad" [export_vars -base ad-one {keyword_id}] "Place an Ad"] \ + -actions $actions \ -row_pretty_plural "Ads" \ -elements { title { @@ -63,6 +118,9 @@ link_url_eval "ad-one?ad_id=$item_id" link_html { title "View this ad" } } + pretty_publish_date { + label "Date Posted" + } } set return_url "[ad_conn url]?[ad_conn query]"