Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.156 -r1.157 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 25 Jul 2007 23:59:24 -0000 1.156 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 26 Jul 2007 17:37:39 -0000 1.157 @@ -250,59 +250,6 @@ # Operations on the whole instance # - Page ad_proc select_query { - {-select_attributes ""} - {-orderby ""} - {-where_clause ""} - {-count:boolean false} - {-folder_id} - {-page_size 20} - {-page_number ""} - {-extra_where_clause ""} - {-extra_from_clause ""} - } { - returns the SQL-query to select the xowiki pages of the specified folder - @select_attributes attributes for the sql query to be retrieved, in addion - to ci.item_id acs_objects.object_type, which are always returned - @param orderby clause for ordering the solution set - @param where_clause clause for restricting the answer set - @param count return the query for counting the solutions - @param folder_id parent_id - @return sql query - } { - my instvar object_type_key - #if {![info exists folder_id]} {my instvar folder_id} - - set attributes [list ci.item_id ci.name p.page_id] - foreach a $select_attributes { - if {$a eq "title"} {set a p.title} - lappend attributes $a - } - if {$count} { - set attribute_selection "count(*)" - set orderby "" ;# no need to order when we count - set page_number "" ;# no pagination when count is used - } else { - set attribute_selection [join $attributes ,] - } - - if {$where_clause ne ""} {set where_clause "and $where_clause "} - if {$page_number ne ""} { - set pagination "offset [expr {$page_size*($page_number-1)}] limit $page_size" - } else { - set pagination "" - } - set outer_join [expr {[string first s. $attribute_selection] > -1 ? - "left outer join syndication s on s.object_id = p.revision_id" : ""}] - set order_clause [expr {$orderby ne "" ? "ORDER BY $orderby" : ""}] - set sql "select $attribute_selection from xowiki_pagei p $outer_join, cr_items ci \ - $extra_from_clause \ - where ci.parent_id = $folder_id and ci.item_id = p.item_id and \ - ci.live_revision = p.page_id $where_clause $extra_where_clause $order_clause $pagination" - #my log "--SQL=$sql" - return $sql - } - # # Page marshall/demarshall # @@ -1057,14 +1004,8 @@ } PageTemplate instproc count_usages {} { return [::xowiki::PageTemplate count_usages -item_id [my item_id]] - #set sql [::xowiki::PageInstance instance_select_query \ - # -count true \ - # -with_subtypes true \ - # -from_clause ", xowiki_page_instance p" \ - # -where_clause " p.page_template=[my item_id] and p.page_instance_id=cr.revision_id " \ - # -folder_id [[my package_id] folder_id]] - #return [db_list [my qn count] $sql] } + PageTemplate proc count_usages {-item_id:required} { set count [db_string [my qn count_usages] \ "select count(page_instance_id) from xowiki_page_instance, cr_items i \ Index: openacs-4/packages/xowiki/www/admin/test.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/admin/Attic/test.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/xowiki/www/admin/test.tcl 14 Jul 2007 18:02:33 -0000 1.7 +++ openacs-4/packages/xowiki/www/admin/test.tcl 26 Jul 2007 17:37:39 -0000 1.8 @@ -150,8 +150,7 @@ ? {::$folder_id parent_id} $folder_id "parent_id of folder object is folder_id" ? {expr {[::$folder_id item_id]>0}} 1 "item_id given" ? {expr {[::$folder_id revision_id]>0}} 1 "revision_id given" -? {db_string count [::xowiki::Page select_query \ - -folder_id $folder_id -count true]} 1 \ +? {db_string count "select count(*) from cr_items where parent_id = $folder_id"} 1 \ "folder contains the folder object" test subsection "Create and Render Index Page" @@ -173,8 +172,7 @@ ? {expr {$content_length > 1000}} 1 \ "page rendered, content-length $content_length > 1000" ? {string first Error $content} -1 "page contains no error" -? {db_string count [::xowiki::Page select_query \ - -folder_id $folder_id -count true]} 2 \ +? {db_string count "select count(*) from cr_items where parent_id = $folder_id"} 2 \ "folder contains the folder object and the index page" #test code [$page_item_id serialize] @@ -238,8 +236,7 @@ ? {::$folder_id parent_id} $folder_id "parent_id of folder object is folder_id" ? {expr {[::$folder_id item_id]>0}} 1 "item_id given" ? {expr {[::$folder_id revision_id]>0}} 1 "revision_id given" -? {db_string count [::xowiki::Page select_query \ - -folder_id $folder_id -count true]} 2 \ +? {db_string count "select count(*) from cr_items where parent_id = $folder_id"} 2 \ "folder contains the folder object and index" test subsection "Render Index Page (2nd)" @@ -278,6 +275,7 @@ ? {$package_id package_url} /$instance_name/ "package_url" ? {$package_id url} /$instance_name/weblog "url" ? {$package_id id} $package_id "the id of the package object = package_id" +set folder_id [::$package_id folder_id] test subsection "Create and Render Weblog" set content [::$package_id invoke -method $m] @@ -286,9 +284,7 @@ "page rendered, content-length $content_length > 1000" ? {string first Error $content} -1 "page contains no error" -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 5 \ +? {db_string count "select count(*) from cr_items where parent_id = $folder_id"} 5 \ "folder contains: folder object, index and weblog page (+2 includelets)" @@ -349,9 +345,7 @@ "SWA sees the delete link" ? {expr {[::$package_id make_link -privilege admin -link admin/ $package_id {} {}] ne ""}} 1 \ "SWA sees admin link" -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 5 \ +? {db_string count "select count(*) from cr_items where parent_id=[$package_id folder_id]"} 5 \ "folder contains: folder object, index and weblog page (+2 includelets)" @@ -369,9 +363,7 @@ ? {::xo::cc exists __continuation} 1 "continuation exists" ? {::xo::cc set __continuation} "ad_returnredirect /$instance_name/" \ "redirect to main instance" -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 4 \ +? {db_string count "select count(*) from cr_items where parent_id=[$package_id folder_id]"} 4 \ "folder contains: folder object, index and weblog page (+1 includelet)" test subsection "Create a test page named hello" @@ -388,9 +380,7 @@ $page set_content [string trim [$page text] " \n"] $page initialize_loaded_object $page save_new -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 5 \ +? {db_string count "select count(*) from cr_items where parent_id=[$package_id folder_id]"} 5 \ "folder contains: folder object, index and weblog, hello page (+1 includelet)" ? {expr {[$page revision_id]>0}} 1 "revision_id given" ? {expr {[$page item_id]>0}} 1 "item_id given" @@ -399,9 +389,7 @@ $page append title "- V.2" $page save -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 5 \ +? {db_string count "select count(*) from cr_items where parent_id=[$package_id folder_id]"} 5 \ "still 5 pages" ? {expr {[$page revision_id]>$revision_id1}} 1 "revision_id > old revision_id" ? {expr {[$page item_id] == $item_id1}} 1 "item id the same" @@ -422,9 +410,7 @@ ? {expr {$content_length > 1000}} 1 \ "page rendered, content-length $content_length > 1000" ? {string first Error $content} -1 "page contains no error" -? {db_string count [::xowiki::Page select_query \ - -folder_id [$package_id folder_id] \ - -count true]} 6 \ +? {db_string count "select count(*) from cr_items where parent_id=[$package_id folder_id]"} 6 \ "again, 6 pages"