Index: openacs-4/packages/news/www/preview.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/www/preview.tcl,v diff -u -r1.38 -r1.39 --- openacs-4/packages/news/www/preview.tcl 19 Jun 2018 10:08:24 -0000 1.38 +++ openacs-4/packages/news/www/preview.tcl 3 Sep 2024 15:37:39 -0000 1.39 @@ -1,11 +1,10 @@ -# /packages/news/www/preview.tcl ad_page_contract { This page previews the input from item-create or admin/revision-add - + @author stefan@arsdigita.com @creation-date 2000-12-18 @cvs-id $Id$ - + } { {item_id:naturalnum ""} action:notnull,trim @@ -14,13 +13,11 @@ {publish_body:allhtml,trim ""} publish_body.format:path,notnull {revision_log ""} - {publish_date:array ""} - {archive_date:array ""} - {permanent_p:boolean "f"} - publish_date_ansi:optional - archive_date_ansi:optional + {publish_date:clock(%Y-%m-%d) ""} + {archive_date:clock(%Y-%m-%d) ""} + {permanent_p:boolean,notnull "f"} imgfile:optional - + } -errors { publish_title:notnull "[_ news.lt_Please_supply_the_tit]" @@ -30,10 +27,10 @@ } -validate { check_revision_log -requires {action revision_log} { - if { $action eq "News Item" && $revision_log eq ""} { - ad_complain "[_ news.lt_You_must_supply_a_rev]" - return - } + if { $action eq "News Item" && $revision_log eq ""} { + ad_complain "[_ news.lt_You_must_supply_a_rev]" + return + } } } -properties { @@ -48,7 +45,7 @@ hidden_vars:onevalue permanent_p:onevalue html_p:onevalue - news_admin_p:onevalue + news_admin_p:onevalue form_action:onevalue image_url:onevalue edit_action:onevalue @@ -78,54 +75,27 @@ } set context [list $title] -# DRB: not sure about the accuracy of this comment so am leaving this. -# if we've come back from the image page, set up dates again -if {[info exists publish_date_ansi] && [info exists archive_date_ansi]} { - set exp {([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})} - if { ![regexp $exp $publish_date_ansi match \ - publish_date(year) publish_date(month) publish_date(day)] - || ![regexp $exp $archive_date_ansi match \ - archive_date(year) archive_date(month) archive_date(day)] } { - ad_return_complaint 1 [_ news.Publish_archive_dates_incorrect] - ad_script_abort - } -} # deal with Dates, granularity is 'day' # with news_admin privilege fill in publish and archive dates -if { $news_admin_p == 1 || [parameter::get -parameter ApprovalPolicy] eq "open" } { +if { $news_admin_p || [parameter::get -parameter ApprovalPolicy] eq "open" } { - if { [info exists publish_date(year)] && [info exists publish_date(month)] && [info exists publish_date(day)] } { - set publish_date_ansi "$publish_date(year)-$publish_date(month)-$publish_date(day)" - } else { - set publish_date_ansi "" - } - if { [info exists archive_date(year)] && [info exists archive_date(month)] && [info exists archive_date(day)] } { - set archive_date_ansi "$archive_date(year)-$archive_date(month)-$archive_date(day)" - } else { - set archive_date_ansi "" - } + set publish_date_pretty [lc_time_fmt $publish_date "%Q"] + set archive_date_pretty [lc_time_fmt $archive_date "%Q"] - if { ![template::util::date::validate $publish_date_ansi ""] } { - set publish_date_pretty [lc_time_fmt $publish_date_ansi "%Q"] - } - if { ![template::util::date::validate $archive_date_ansi ""] } { - set archive_date_pretty [lc_time_fmt $archive_date_ansi "%Q"] - } - - if { [dt_interval_check $archive_date_ansi $publish_date_ansi] >= 0 } { - ad_return_error \ + if { [dt_interval_check $archive_date $publish_date] >= 0 } { + ad_return_error \ [_ news.Scheduling_Error] \ [_ news.lt_The_archive_date_must] - ad_script_abort + ad_script_abort } } if { ${publish_body.format} eq "text/html" || ${publish_body.format} eq "text/enhanced" } { # close any open HTML tags in any case set publish_body [util_close_html_tags $publish_body] - + # Note: this is the *only* check against disallowed HTML tags in the # news posting system. Currently, each path for creating or revising # a news items passes through this preview script, so it's safe. But if @@ -144,12 +114,12 @@ # form variables for confirmation step set hidden_vars [export_vars -form { - publish_title publish_lead publish_body publish_body.format - publish_date_ansi archive_date_ansi html_p permanent_p imgfile + publish_title publish_lead publish_body publish_body.format + publish_date archive_date html_p permanent_p imgfile }] set image_vars [export_vars -form { publish_title publish_lead publish_body publish_body.format - publish_date_ansi archive_date_ansi html_p permanent_p action + publish_date archive_date html_p permanent_p action }] set form_action "
" set edit_action "" @@ -159,20 +129,20 @@ # Form vars to carry through Confirmation Page set hidden_vars [export_vars -form { item_id revision_log publish_title publish_lead publish_body publish_body.format - publish_date_ansi archive_date_ansi permanent_p html_p imgfile + publish_date archive_date permanent_p html_p imgfile }] set image_vars [export_vars -form { - publish_title publish_lead publish_body publish_body.format - publish_date_ansi archive_date_ansi html_p permanent_p action item_id revision_log + publish_title publish_lead publish_body publish_body.format + publish_date archive_date html_p permanent_p action item_id revision_log }] set form_action "" set edit_action "" } -# creator link +# creator link set creator_name [db_string creator { - select first_names || ' ' || last_name - from cc_users + select first_names || ' ' || last_name + from cc_users where user_id = :user_id }] set creator_link "[ns_quotehtml $creator_name]" @@ -181,8 +151,6 @@ -style ".news-item-preview { color: inherit; background-color: #eeeeee; margin: 1em 4em 1em 4em; padding: 1em; }" \ -media screen -ad_return_template - # Local variables: # mode: tcl # tcl-indent-level: 4