ad_library { API for integrating bw with q-wiki @creation-date 17 Jul 2012 @cs-id $Id: } ad_proc -public qwbw_page_create { instance_id page_id model_ref spec1ref spec1default spec2ref spec2default spec3ref spec3default image_name image_width image_height thumbnail_name thumbnail_width thumbnail_height price dimensions ship_wt actual_wt unit } { Creates extension to wiki page. returns page_id, or 0 if error. instance_id is usually package_id } { # $template_id $page_id $model_ref $spec1ref $spec1default $spec2ref $spec2default $spec3ref $spec3default $image_name $image_width $image_height $thumbnail_name $thumbnail_width $thumbnail_height $price $dimensions $ship_wt $actual_wt $unit if { $instance_id eq "" } { # set instance_id package_id set instance_id [ad_conn package_id] } set page_id_exists [db_0or1row qwbw_get_page_id "select page_id as page_id_fra_db from qwbw_catalog where instance_id = :instance_id and page_id = :page_id" ] if { $page_id_exists } { db_dml qwbw_wiki_page_update { update qwbw_catalog set model_ref = :model_ref, spec1ref =:spec1ref, spec1default=:spec1default, spec2ref =:spec2ref, spec2default=:spec2default, spec3ref =:spec3ref, spec3default =:spec3default, image_name =:image_name, image_width=:image_width, image_height=:image_height, thumbnail_name=:thumbnail_name, thumbnail_width=:thumbnail_width, thumbnail_height=:thumbnail_height, price=:price, dimensions=:dimensions, ship_wt=:ship_wt, actual_wt=:actual_wt, unit=:unit where instance_id = :instance_id and page_id = :page_id } } else { db_dml qwbw_wiki_page_create { insert into qwbw_catalog (instance_id, page_id, model_ref, spec1ref, spec1default, spec2ref, spec2default, spec3ref, spec3default, image_name, image_width, image_height, thumbnail_name, thumbnail_width, thumbnail_height, price, dimensions, ship_wt, actual_wt, unit) values (:instance_id,:page_id,:model_ref,:spec1ref,:spec1default,:spec2ref,:spec2default,:spec3ref,:spec3default,:image_name,:image_width,:image_height,:thumbnail_name,:thumbnail_width,:thumbnail_height,:price,:dimensions,:ship_wt,:actual_wt,:unit ) } } return 1 } ad_proc -public qwbw_page_read { page_id {instance_id ""} } { Returns page contents of page_id. Returns page as list of attribute values: model_ref, spec1ref, spec1default, spec2ref, spec2default, spec3ref, spec3default, image_name, image_width, image_height, thumbnail_name, thumbnail_width, thumbnail_height, price, dimensions, ship_wt, actual_wt, unit } { #set page_bw_list \[qwbw_page_read $page_id \] # $model_ref $spec1ref $spec1default $spec2ref $spec2default $spec3ref $spec3default $image_name $image_width $image_height $thumbnail_name $thumbnail_width $thumbnail_height $price $dimensions $ship_wt $actual_wt $unit if { $instance_id eq "" } { # set instance_id package_id set instance_id [ad_conn package_id] } set return_list_of_lists [db_list_of_lists qwbw_wiki_page_get { select model_ref, spec1ref, spec1default, spec2ref, spec2default, spec3ref, spec3default, image_name, image_width, image_height, thumbnail_name, thumbnail_width, thumbnail_height, price, dimensions, ship_wt, actual_wt, unit from qwbw_catalog where page_id = :page_id and instance_id = :instance_id } ] # convert return_lists_of_lists to return_list set return_list [lindex $return_list_of_lists 0] return $return_list } ad_proc -public qwbw_page_write { instance_id page_id model_ref spec1ref spec1default spec2ref spec2default spec3ref spec3default image_name image_width image_height thumbnail_name thumbnail_width thumbnail_height price dimensions ship_wt actual_wt unit } { Creates extension to wiki page. returns page_id, or 0 if error. instance_id is usually package_id } { # $template_id $page_id $model_ref $spec1ref $spec1default $spec2ref $spec2default $spec3ref $spec3default $image_name $image_width $image_height $thumbnail_name $thumbnail_width $thumbnail_height $price $dimensions $ship_wt $actual_wt $unit if { $instance_id eq "" } { # set instance_id package_id set instance_id [ad_conn package_id] } set page_id_exists [db_0or1row qwbw_get_page_id "select page_id as page_id_fra_db from qwbw_catalog where instance_id = :instance_id and page_id = :page_id" ] if { $page_id_exists } { db_dml qwbw_wiki_page_update { update qwbw_catalog set model_ref = :model_ref, spec1ref =:spec1ref, spec1default=:spec1default, spec2ref =:spec2ref, spec2default=:spec2default, spec3ref =:spec3ref, spec3default =:spec3default, image_name =:image_name, image_width=:image_width, image_height=:image_height, thumbnail_name=:thumbnail_name, thumbnail_width=:thumbnail_width, thumbnail_height=:thumbnail_height, price=:price, dimensions=:dimensions, ship_wt=:ship_wt, actual_wt=:actual_wt, unit=:unit where instance_id = :instance_id and page_id = :page_id } } else { db_dml qwbw_wiki_page_create { insert into qwbw_catalog (instance_id, page_id, model_ref, spec1ref, spec1default, spec2ref, spec2default, spec3ref, spec3default, image_name, image_width, image_height, thumbnail_name, thumbnail_width, thumbnail_height, price, dimensions, ship_wt, actual_wt, unit) values (:instance_id,:page_id,:model_ref,:spec1ref,:spec1default,:spec2ref,:spec2default,:spec3ref,:spec3default,:image_name,:image_width,:image_height,:thumbnail_name,:thumbnail_width,:thumbnail_height,:price,:dimensions,:ship_wt,:actual_wt,:unit ) } } return 1 }