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]"