Index: openacs-4/packages/photo-album/lib/one-photo.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/lib/one-photo.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/photo-album/lib/one-photo.adp 26 Jul 2004 13:07:42 -0000 1.1 @@ -0,0 +1,24 @@ + + Display one photo. + + @author Jeff Davis davis@xarg.net + @cvs-id $Id: one-photo.adp,v 1.1 2004/07/26 13:07:42 jeffd Exp $ + + @param photo array of values as returned from photo_album::photo::get + @param style string (either "feed" or "display" -- default is display) + @param base_url url to the package (ok for this to be empty if in the package, trailing / expected) + + +

@photo.title@

+

@photo.description@

+ +

@photo.caption@

+

@photo.story@

+

by @photo.username@

+
+ +

@photo.description@

+

@photo.caption@

+

@photo.story@

+

by @photo.username@

+
\ No newline at end of file Index: openacs-4/packages/photo-album/lib/one-photo.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/lib/one-photo.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/photo-album/lib/one-photo.tcl 26 Jul 2004 13:07:42 -0000 1.1 @@ -0,0 +1,4 @@ +if {![info exists photo(user_url)]} { + set photo(user_url) [acs_community_member_url -user_id $photo(user_id)] +} + Index: openacs-4/packages/photo-album/tcl/photo-album-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/tcl/photo-album-procs-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/photo-album/tcl/photo-album-procs-postgresql.xql 26 Jun 2003 02:45:09 -0000 1.3 +++ openacs-4/packages/photo-album/tcl/photo-album-procs-postgresql.xql 26 Jul 2004 13:07:42 -0000 1.4 @@ -177,4 +177,33 @@ + + + SELECT + ci.item_id as photo_id, + u.user_id, + u.first_names || ' ' || u.last_name as username, + pp.caption, + pp.story, + cr.title, + cr.description, + ci.parent_id as album_id, + to_char(o.creation_date,'YYYY-MM-DD HH24:MI:SS') as created_ansi, + case when acs_permission__permission_p(ci.item_id, :user_id, 'admin') ='t' then 1 else 0 end as admin_p, + case when acs_permission__permission_p(ci.item_id, :user_id, 'write') = 't' then 1 else 0 end as write_p, + case when acs_permission__permission_p(ci.parent_id, :user_id, 'write') = 't' then 1 else 0 end as album_write_p, + case when acs_permission__permission_p(ci.item_id, :user_id, 'delete') = 't' then 1 else 0 end as photo_delete_p + FROM cr_items ci, + cr_revisions cr, + pa_photos pp, + acs_objects o, + acs_users_all u + WHERE cr.revision_id = pp.pa_photo_id + and ci.live_revision = cr.revision_id + and o.object_id = ci.item_id + and u.user_id = o.creation_user + and ci.item_id = :photo_id + + + Index: openacs-4/packages/photo-album/tcl/photo-album-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/tcl/photo-album-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/photo-album/tcl/photo-album-procs.tcl 29 Jun 2004 10:18:45 -0000 1.10 +++ openacs-4/packages/photo-album/tcl/photo-album-procs.tcl 26 Jul 2004 13:07:42 -0000 1.11 @@ -1192,4 +1192,86 @@ } } - +# JCD -- support procs for searching and such + +namespace eval photo_album {} +namespace eval photo_album::photo {} +namespace eval photo_album::album {} + +ad_proc -public photo_album::photo::get { + -photo_id:required + -array:required + {-user_id {}} +} { + return an array with the photo data. + + elements are: + + photo_delete_p + admin_p + write_p + album_write_p + + album_id + caption + description + photo_id + story + title + + image_types (list of available related images "base" "viewer" "thumb") + + For each image type there is (eg viewer here): + + viewer_content + viewer_content_length + viewer_height + + viewer_image_id + viewer_latest_revision + viewer_live_revision + viewer_name + viewer_relation_tag + viewer_width +} { + upvar $array row + + if {[empty_string_p $user_id]} { + if {[ad_conn isconnected]} { + set user_id [ad_conn user_id] + } else { + set user_id 0 + } + } + + db_1row basic {} -column_array row + + db_foreach images {} -column_set img { + set rel [ns_set iget $img relation_tag] + lappend row(image_types) $rel + for { set i 0 } { $i < [ns_set size $img] } { incr i } { + set row(${rel}_[ns_set key $img $i]) [ns_set value $img $i] + } + } +} + +ad_proc -public photo_album::photo::package_url { + -photo_id +} { + given a photo_id (can be an item or revision_id) + return the package_url for the corresponding photo. + + does not include the site part just the path. +} { + db_0or1row package { + SELECT n.node_id, i1.item_id + FROM cr_items i1, cr_items i2, pa_package_root_folder_map m, site_nodes n + WHERE m.folder_id = i2.item_id + and i1.item_id = coalesce((select item_id from cr_revisions where revision_id = :photo_id),:photo_id) + and n.object_id = m.package_id + and i1.tree_sortkey between i2.tree_sortkey and tree_right(i2.tree_sortkey) + limit 1 + } + + return [site_node::get_element -node_id $node_id -element url] +} \ No newline at end of file Index: openacs-4/packages/photo-album/tcl/photo-album-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/tcl/photo-album-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/photo-album/tcl/photo-album-procs.xql 18 Nov 2003 18:55:29 -0000 1.3 +++ openacs-4/packages/photo-album/tcl/photo-album-procs.xql 26 Jul 2004 13:07:42 -0000 1.4 @@ -34,5 +34,20 @@ + + + SELECT ccr.relation_tag, image_items.name, image_items.live_revision, image_items.latest_revision, i.*, image_revs.content, image_revs.content_length + FROM cr_items photo, + cr_items image_items, + cr_revisions image_revs, + cr_child_rels ccr, + images i + WHERE ccr.parent_id = photo.item_id + and image_items.item_id = ccr.child_id + and image_items.live_revision = i.image_id + and image_revs.revision_id = image_items.live_revision + and photo.item_id = :photo_id; + + Index: openacs-4/packages/photo-album/tcl/photo-album-search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/tcl/photo-album-search-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/photo-album/tcl/photo-album-search-procs.tcl 1 Jun 2004 19:13:05 -0000 1.1 +++ openacs-4/packages/photo-album/tcl/photo-album-search-procs.tcl 26 Jul 2004 13:07:42 -0000 1.2 @@ -46,16 +46,16 @@ @creation-date 2004-06-01 @author Jeff Davis davis@xarg.net } { - set node [db_string package { - SELECT n.node_id + db_0or1row package { + SELECT n.node_id, i1.item_id FROM cr_items i1, cr_items i2, pa_package_root_folder_map m, site_nodes n WHERE m.folder_id = i2.item_id - and i1.item_id = :album_id + and i1.item_id = coalesce((select item_id from cr_revisions where revision_id = :album_id),:album_id) and n.object_id = m.package_id and i1.tree_sortkey between i2.tree_sortkey and tree_right(i2.tree_sortkey) - }] + } - return "[ad_url][site_node::get_element -node_id $node -element url]album?album_id=$album_id" + return "[ad_url][site_node::get_element -node_id $node_id -element url]album?album_id=$item_id" } @@ -79,23 +79,40 @@ @creation-date 2004-06-01 @author Jeff Davis davis@xarg.net } { - # get the best revision to show if it's an item_id otherwise assume we got a pa_album revision. - set revision_id [db_string best_revision {select coalesce(live_revision, latest_revision) from cr_items where item_id = :photo_id} -default $photo_id] + # get the item_id if we got a revision_id + set item_id [db_string item_id {select item_id from cr_revisions where revision_id = :photo_id} -default $photo_id] - db_0or1row album_datasource { - select r.title, - r.title || ' ' || r.description || ' caption: ' || p.caption || ' story: ' || p.story || ' filename: ' || p.user_filename as content, - 'text/html' as mime, - '' as keywords, - 'text' as storage_type - from cr_revisions r, pa_photos p - where r.revision_id = :revision_id - and p.pa_photo_id = r.revision_id - } -column_array datasource + photo_album::photo::get -photo_id $item_id -array photo - set datasource(object_id) $photo_id + # get the base url + set base [photo_album::photo::package_url -photo_id $item_id] + set full "[ad_url]$base" - return [array get datasource] + set ::lev [info level] + namespace eval ::template { + variable parse_level + lappend parse_level $::lev + } + set body [template::adp_include /packages/photo-album/lib/one-photo [list &photo "photo" base $base style feed]] + namespace eval ::template { + variable parse_level + template::util::lpop parse_level + } + + + return [list object_id $photo_id \ + title $photo(title) \ + mime "text/html" \ + keywords {} \ + storage_type text \ + content $body \ + syndication [list link "${full}photo/photo_id=$item_id" \ + description "$photo(description) $photo(caption)" \ + author $photo(username) \ + category photos \ + guid "[ad_url]/o/$item_id" \ + pubDate $photo(created_ansi)] \ + ] } ad_proc -private photo_album::search::photo::url { photo_id } { @@ -106,16 +123,16 @@ @creation-date 2004-06-01 @author Jeff Davis davis@xarg.net } { - set node [db_string package { - SELECT n.node_id + db_0or1row package { + SELECT n.node_id, i1.item_id FROM cr_items i1, cr_items i2, pa_package_root_folder_map m, site_nodes n WHERE m.folder_id = i2.item_id - and i1.item_id = :photo_id + and i1.item_id = coalesce((select item_id from cr_revisions where revision_id = :photo_id),:photo_id) and n.object_id = m.package_id and i1.tree_sortkey between i2.tree_sortkey and tree_right(i2.tree_sortkey) - }] + } - return "[ad_url][site_node::get_element -node_id $node -element url]photo?photo_id=$photo_id" + return "[ad_url][site_node::get_element -node_id $node_id -element url]photo?photo_id=$item_id" } Index: openacs-4/packages/photo-album/www/photo.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/www/photo.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/photo-album/www/photo.xql 3 May 2004 13:13:56 -0000 1.4 +++ openacs-4/packages/photo-album/www/photo.xql 26 Jul 2004 13:07:42 -0000 1.5 @@ -33,27 +33,6 @@ - - - select - cr.title, - i.height as height, - i.width as width, - i.image_id as image_id - from cr_items ci, - cr_revisions cr, - cr_items ci2, - cr_child_rels ccr2, - images i - where ci.live_revision = cr.revision_id - and ci.item_id = ccr2.parent_id - and ccr2.child_id = ci2.item_id - and ccr2.relation_tag = 'viewer' - and ci2.live_revision = i.image_id - and ci.item_id = 3059 - - - select rel_id from cr_child_rels