// Use WebFormWriter.nui Use WebSessionVariables.nui // Web session variables for ASP pages Use LanguageDictionary.nui // cLanguageDictionary class and translate_value function class cFormWriter is a cObject // Objects of this class must - like the class itself - be stateless (no memory between calls) procedure construct_object forward send construct_object object oCssStyle is a WebFormCss set phInheritObject to (oWebFormBaseCss(self)) end_object property integer phCssStyler public (oCssStyle(self)) object oContainerStack is a cStack end_object //> Specifies a prefix to be added to all CSS class names for this WebForm property string psCssClassPrefix public "wf1" property integer priv.phCurrentForm public 0 property integer priv.phCurrentContainer public 0 end_procedure procedure PushCurrentContainer integer lhContainer send push.i of oContainerStack (priv.phCurrentContainer(self)) set priv.phCurrentContainer to lhContainer end_procedure procedure PopCurrentContainer integer lhContainer get iPop of oContainerStack to lhContainer set priv.phCurrentContainer to lhContainer end_procedure procedure DoWriteGrid integer lhInput integer lhController end_procedure procedure DoWriteButtonArray integer lhControl integer liRow liMax lhButtons lbDisabled string lsName lsLabel lsToolTip lsLink string lsInputNamePrefix get sInputNamePrefix of lhControl to lsInputNamePrefix // (Delegates to wForm object) move (oButtons(lhControl)) to lhButtons get row_count of lhButtons to liMax decrement liMax for liRow from 0 to liMax get psLabel.i of lhButtons liRow to lsLabel get translate_value lsLabel to lsLabel if gbLngUpdate set psLabel.i of lhButtons liRow to gsLngValue get psName.i of lhButtons liRow to lsName //get pbDisabled.i of lhButtons liRow to lbDisabled get button_disabled of lhControl liRow to lbDisabled get psToolTip.i of lhButtons liRow to lsToolTip if (pbHref.i(lhButtons,liRow)) begin send XHTML_Add_Closed_Element "button" (HtmlEncodeNoCrLf(lsLabel)) send XHTML_Add_Attribute "type" "button" get button_href_value of lhControl liRow to lsLink if (pbWindowOpen.i(lhButtons,liRow)) send XHTML_Add_Attribute "onclick" ("window.open('"+lsLink+"')") else send XHTML_Add_Attribute "onclick" ("window.location='"+lsLink+"'") if lbDisabled send XHTML_Add_Attribute "disabled" "disabled" if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end else begin send XHTML_Add_Closed_Element "input" "" // Add an input for detecting name of form send XHTML_Add_Attribute "type" "submit" send XHTML_Add_Attribute "name" (lsInputNamePrefix+lsName) send XHTML_Add_Attribute "value" (HtmlEncodeNoCrLf(lsLabel)) if lbDisabled send XHTML_Add_Attribute "disabled" "disabled" if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end // loop end_procedure // This function is used to control whether the label of the // control (value at WFIP_LABEL) should be written in its own // table cell or in the same cell as the control itself. function bShouldWriteSeparateLabelCell integer liType returns integer if (liType=WFIT_CHECKBOX) function_return FALSE if (liType=WFIT_TEXTONLY) function_return FALSE if (liType=WFIT_BUTTON) function_return FALSE if (liType=WFIT_BUTTON_ARRAY) function_return FALSE if (liType=WFIT_GRID) function_return FALSE function_return TRUE end_function procedure OnStyleControl integer lhControl integer liWhat end_procedure procedure DoStyle_Control integer lhControl integer liWhat // 0:Label 1:Input 2:ExtraInfo 3:ErrorText integer lhStyler get phCssStyler to lhStyler if lhStyler begin send OnStyleControl lhControl liWhat send OnStyle of lhControl liWhat lhStyler end end_procedure procedure DoWriteControl integer lhControl integer liWhat // 0:Label 1:Input 2:ExtraInfo 3:ErrorText integer liInputType lbChecked liTable liRecnum integer lbReadOnly lbTransparant lhServer string lsValue lsLabel lsTrueValue lsErrorText lsToolTip lsLink lsFormName string lsInputName send DoStyle_Control lhControl liWhat if (pbSelfHtmlWriter(lhControl)=TRUE and liWhat=1) send DoWriteHtml of lhControl liWhat else begin get value of lhControl WFIP_INPUT_TYPE to liInputType get value of lhControl WFIP_ERROR_TEXT to lsErrorText get value of lhControl WFIP_READONLY to lbReadOnly if lbReadOnly get value of lhControl WFIP_TRANSPARENT to lbTransparant else move 0 to lbTransparant if (liWhat=0) begin // Label if (bShouldWriteSeparateLabelCell(self,liInputType)) begin get value of lhControl WFIP_LABEL to lsLabel if (lsLabel<>"") begin get translate_value lsLabel to lsLabel if gbLngUpdate set value of lhControl WFIP_LABEL to gsLngValue // Update language symbol to optimized value move "" to lsLink //if (integer(value(lhControl,WFIP_LABEL_AUTO_LINK))) begin if (bAutoLink(lhControl)) begin get value of lhControl WFIP_DB_FILE to liTable get server of lhControl to lhServer if lhServer get Data_Set of lhServer liTable to lhServer if (liTable and lhServer) begin get current_record of lhServer to liRecnum if liRecnum get QryString_RecordEditLink liTable liRecnum to lsLink end end if (lsLink="") begin send XHTML_Add_Closed_Element "span" lsLabel end else begin send XHTML_Add_Closed_Element "a" lsLabel send XHTML_Add_Attribute "href" lsLink end send add_attribute_class "" "inputlabel" // X send add_attribute_style CSS_FORM_INPUTLABEL end end end if (liWhat=1) begin // Control (alias widget) get sInputNamePrefix of lhControl to lsInputName // (Delegation) move (lsInputName+value(lhControl,WFIP_NAME)) to lsInputName get value of lhControl WFIP_TOOLTIP to lsToolTip if (liInputType=WFIT_PASSWORD) begin send XHTML_Add_Closed_Element "input" "" send add_attribute_class "" "input" send XHTML_Add_Attribute "type" "password" send XHTML_Add_Attribute "name" lsInputName // (value(lhControl,WFIP_NAME)) if (value(lhControl,WFIP_SIZE)<>"") send XHTML_Add_Attribute "size" (value(lhControl,WFIP_SIZE)) send XHTML_Add_Attribute "value" (value(lhControl,WFIP_VALUE)) if (integer(value(lhControl,WFIP_MAXLENGTH))) send XHTML_Add_Attribute "maxlength" (value(lhControl,WFIP_MAXLENGTH)) if lbReadOnly send XHTML_Add_Attribute "readonly" "readonly" if lbTransparant send XHTML_Add_Attribute "style" "background-color: transparent" if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end if (liInputType=WFIT_SIMPLE) begin send XHTML_Add_Closed_Element "input" "" send add_attribute_class "" "input" send XHTML_Add_Attribute "type" "text" send XHTML_Add_Attribute "name" lsInputName // (value(lhControl,WFIP_NAME)) if (value(lhControl,WFIP_SIZE)<>"") send XHTML_Add_Attribute "size" (value(lhControl,WFIP_SIZE)) send XHTML_Add_Attribute "value" (value(lhControl,WFIP_VALUE)) if (integer(value(lhControl,WFIP_MAXLENGTH))) send XHTML_Add_Attribute "maxlength" (value(lhControl,WFIP_MAXLENGTH)) if lbReadOnly send XHTML_Add_Attribute "readonly" "readonly" if lbTransparant send XHTML_Add_Attribute "style" "background-color: transparent" if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end if (liInputType=WFIT_TEXTAREA) begin get value of lhControl WFIP_VALUE to lsValue send XHTML_Add_Closed_Element "textarea" lsValue send add_attribute_class "" "textarea" send XHTML_Add_Attribute "name" lsInputName // (value(lhControl,WFIP_NAME)) send XHTML_Add_Attribute "cols" (value(lhControl,WFIP_COLS)) send XHTML_Add_Attribute "rows" (value(lhControl,WFIP_ROWS)) if lbReadOnly send XHTML_Add_Attribute "readonly" "readonly" if lbTransparant send XHTML_Add_Attribute "style" "background-color: transparent" if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end if (liInputType=WFIT_TEXTONLY) begin get value of lhControl WFIP_LABEL to lsValue get translate_value lsLabel to lsLabel if gbLngUpdate set value of lhControl WFIP_LABEL to gsLngValue // Update language symbol to optimized value send XHTML_Add_Closed_Element "span" lsValue send add_attribute_class "" "textonly" end if (liInputType=WFIT_RADIO) begin send DoWriteHtmlOptions of (phSelectOptions(lhControl)) WFIT_RADIO lsInputName (value(lhControl,WFIP_VALUE)) 1 "radiooption" (integer(value(lhControl,WFIP_READONLY))) lsToolTip end if (liInputType=WFIT_CHECKBOX) begin send XHTML_Add_Closed_Element "input" "" send XHTML_Add_Attribute "type" "checkbox" send XHTML_Add_Attribute "name" lsInputName // (value(lhControl,WFIP_NAME)) get value of lhControl WFIP_DB_TRUE_VALUE to lsTrueValue if (lsTrueValue<>"") move (value(lhControl,WFIP_VALUE)=lsTrueValue) to lbChecked else move (integer(value(lhControl,WFIP_VALUE))) to lbChecked if lbChecked send XHTML_Add_Attribute "checked" "checked" if lbReadOnly send XHTML_Add_Attribute "disabled" "disabled" if lbTransparant send XHTML_Add_Attribute "style" "background-color: transparent" // A checkbox allways outputs it label to the immediate right of the box send XHTML_Add_Closed_Element "span" (value(lhControl,WFIP_LABEL)) send add_attribute_class "" "label" // X send add_attribute_style CSS_FORM_INPUTLABEL if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end if (liInputType=WFIT_DROPDOWN) begin send XHTML_Add_Open_Element "select" send add_attribute_class "" "select" send XHTML_Add_Attribute "name" lsInputName // (value(lhControl,WFIP_NAME)) send XHTML_Add_Attribute "size" "1" // Setting this to anything over 1 (the default) is really defeating the purpose of having the options hidden away if (integer(value(lhControl,WFIP_AUTO_SUBMIT))) begin // Autimatically submit the form if the selection is changed send XHTML_Add_Attribute "onchange" ("autoSubmit(this,'"+lsInputName+"')") end if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip if lbReadOnly send XHTML_Add_Attribute "disabled" "disabled" if lbTransparant send XHTML_Add_Attribute "style" "background-color: transparent" send DoWriteHtmlOptions of (phSelectOptions(lhControl)) WFIT_DROPDOWN "" (value(lhControl,WFIP_VALUE)) 0 "" lsToolTip send XHTML_Close_Element end if (liInputType=WFIT_BUTTON) begin send XHTML_Add_Closed_Element "input" "" // Add an input for detecting name of form send XHTML_Add_Attribute "type" "submit" send XHTML_Add_Attribute "name" (value(lhControl,WFIP_SUBMIT_DETECT)) send XHTML_Add_Attribute "value" (HtmlEncodeNoCrLf(value(lhControl,WFIP_LABEL))) if (integer(value(lhControl,WFIP_READONLY))) send XHTML_Add_Attribute "disabled" "disabled" // send add_attribute_class (psClass(self)) "formbutton" // X send add_attribute_style CSS_FORM_BUTTON // get psStyle to lsStyle // if (lsStyle<>"") send XHTML_Add_Attribute "style" lsStyle get value WFIP_TOOLTIP to lsToolTip if (lsToolTip<>"") send XHTML_Add_Attribute "title" lsToolTip end if (liInputType=WFIT_BUTTON_ARRAY) begin send DoWriteButtonArray lhControl end if (liInputType=WFIT_GRID) begin send DoWriteGrid lhControl end end if (liWhat=2) begin // Extra info send XHTML_Add_Closed_Element "div" (value(lhControl,WFIP_EXTRA_INFO)) send add_attribute_class "" "extrainfo" // X send add_attribute_style CSS_FORM_INPUTINFO end if (liWhat=3) begin // Error text send XHTML_Add_Closed_Element "div" (value(lhControl,WFIP_ERROR_TEXT)) send add_attribute_class "" "errortext" // X send add_attribute_style CSS_FORM_INPUTERROR end end end_procedure procedure DoWriteControlCell string lsLabel integer liAux integer liTableRow integer liTableCol integer lhInput liRow integer liChainNextInput // If more inputs are written to the same cell this will be <>0 integer lhContainer move liAux to liRow get priv.phCurrentContainer to lhContainer get hChildObject of lhContainer liRow to lhInput if (bContentEnabled(lhInput)) begin // DoWriteControlCell get priv.ChainNextInput.i of (oChildren(lhContainer)) liRow to liChainNextInput // hm hm! if (lsLabel="label") begin send DoWriteControl lhInput 0 // Label end if (lsLabel="input") begin send DoWriteControl lhInput 1 // Input if liChainNextInput begin if (liChainNextInput=1) begin // Right send XHTML_Add_HorizontalSpace 3 end if (liChainNextInput=2) begin // Right+Space send XHTML_Add_HorizontalSpace 12 end send DoWriteControlCell "label" (liRow+1) liTableRow liTableCol send DoWriteControlCell "input" (liRow+1) liTableRow liTableCol end end if (lsLabel="extrainfo") begin send DoWriteControl lhInput 2 // Extra info end if (lsLabel="errortext") begin send DoWriteControl lhInput 3 // Error text if liChainNextInput begin send DoWriteControlCell "errortext" (liRow+1) liTableRow liTableCol end end if (lsLabel="freestyle") begin send DoWriteHtml of lhInput end end end_procedure register_function SiteAdmUserCommentLinkValue integer lhForm returns string procedure DoWriteUiContainerCell string lsLabel integer liAux integer liRow integer liCol integer lhObj lhForm lhContainer lhSiteAdmin string lsValue lsLink get priv.phCurrentForm to lhForm get priv.phCurrentContainer to lhContainer if (lsLabel="formtitle") begin send XHTML_Add_Closed_Element "h2" (psFormTitle(lhForm)) send add_attribute_class "" "formtitle" send add_attribute_style CSS_FORM_FORMTITLE end else if (lsLabel="directions") begin send XHTML_Add_Closed_Element "div" (psFormDirections(lhForm)) send add_attribute_class "" "directions" send add_attribute_style CSS_FORM_DIRECTIONS end else if (lsLabel="messagearea") begin if (pbMessageLine(lhForm)) begin get message_area_value of oWebFormSubmitErrors lhForm to lsValue //get waf_user_message to lsValue if (lsValue="") move "ÿ" to lsValue send XHTML_Add_Closed_Element "div" lsValue send add_attribute_class "" "messagearea" send add_attribute_style CSS_FORM_MESSAGEAREA end end else if (lsLabel="sitecomments") begin if (pbAllowCommentState(lhForm)) begin get WafModuleObject "siteadmin" to lhSiteAdmin if lhSiteAdmin begin // If siteadmin module os available get SiteAdmUserCommentLinkValue of lhSiteAdmin lhForm to lsLink send XHTML_Add_Closed_Element "a" "Comment this form" send XHTML_Add_Attribute "href" lsLink send XHTML_Add_Attribute "title" "Submit comments to site developers about the function of the form" send XHTML_Add_Attribute "target" "_blank" // Open in new browser end end end else begin // It must be a child container get hFindChildContainer of lhContainer lsLabel to lhObj if lhObj send DoWriteHtml of lhObj end end_procedure procedure DoWriteContainerCell string lsLabel integer liAux integer liRow integer liCol integer lhObj lhForm lhContainer string lsTitle get priv.phCurrentContainer to lhContainer if (lsLabel="title") begin get value of lhContainer WFCP_TITLE to lsTitle if (lsTitle<>"") begin send XHTML_Add_Closed_Element "h2" lsTitle send add_attribute_class "" "formtitle" send add_attribute_style CSS_FORM_FORMTITLE end end get hFindChildContainer of lhContainer lsLabel to lhObj if lhObj send DoWriteHtml of lhObj end_procedure //procedure DoWriteGridContainerCell string lsLabel integer liAux integer liRow integer liCol // integer lhContainer lhGridObject // get priv.phCurrentContainer to lhContainer // get phGridController of lhContainer to lhGridObject // if (lsLabel="grid") begin // if lhGridObject send DoWriteHtml of lhGridObject // end // if (lsLabel="buttons") begin // end //end_procedure procedure DoWriteContainer integer lhForm integer lhContainer integer lhLayout // Layout object of this container integer liEncElem // Encapsulating element mode integer lbFieldset // Should we draw a fieldset element around this container? integer liContainerClass // Class of the container integer lbPopupState integer lbTabPage // Is it a tab page container? integer lbTempDisplay // Difficult to give a sensible name integer lbDisplayMode // 0=Don't 1=Normal 2=Hidden integer liCssElement // Indicates the CSS style to be used with the encapsulating element of this container integer lhPopupContainer // Handle to child popup container (if any) string lsPopupId // Our own popup setting string lsParentPopupId // Our parent containers popup setting string lsEncWidth // If an encapsulating element should be drawn (liEncElem), the width is this string lsLabel // Visible label of container string lsInputNamePrefix if (bContentEnabled(lhContainer)) begin // If the container isn't enabled we shall not write a thing send DoStyle_Container lhContainer set priv.phCurrentForm to lhForm send PushCurrentContainer lhContainer get piContainerClass of lhContainer to liContainerClass get sInputNamePrefix of lhForm to lsInputNamePrefix // ---- Write a hidden input with our own lsPopupId: get psPopupID of lhContainer to lsPopupId // If this is non blank, it points to the WFCP_ID of one of its children if (lsPopupId<>"" and bControlContainer(lhContainer)=0) begin // If there is a popup value and we're not a controls container if (liContainerClass=WFCC_UI) send XHTML_Add_Open_Element "div" // It we're the WFCC_UI container, we need to have an extra DIV send DoWriteHiddenInput (lsInputNamePrefix+lowercase(value(lhContainer,WFCP_ID)+"__popupid")) lsPopupId if (liContainerClass=WFCC_UI) send XHTML_Close_Element // div end // ---- get psPopupID of (parent(lhContainer)) to lsParentPopupId // Get parents popup ID get value of lhContainer WFCP_POPUP_STATE to lbPopupState // Is popup state set on this container? move (liContainerClass=WFCC_TAB_PAGE) to lbTabPage // Is the container a tab page? move (lsParentPopupId="" or lsParentPopupId=value(lhContainer,WFCP_ID)) to lbTempDisplay // Does the container comply with the parent popup indicator (regardless of popup state) if (liContainerClass=WFCC_UI) begin // If outermost container, we must always display normal. move 1 to lbDisplayMode // Display normal end else begin if lbTabPage begin if lbTempDisplay move 1 to lbDisplayMode // Normal display else move 2 to lbDisplayMode // Hidden end else begin if lbPopupState begin // If the container is marked as a popup container if lbTempDisplay move 1 to lbDisplayMode // Display normal else move 0 to lbDisplayMode // Don't end else begin if lbTempDisplay move 1 to lbDisplayMode // Display normal else move 2 to lbDisplayMode // Hidden end end end if lbDisplayMode begin // 0=Don't 1=Normal 2=Hidden if (integer(value(lhContainer,WFCP_HIDDEN_STATE))) move 2 to lbDisplayMode if (lbDisplayMode=2) begin // Hide it send XHTML_Add_Open_Element "div" send XHTML_Add_Attribute "style" "display:none" // Hide all the fieldsets except the popped up one. end else begin // we only do all the encapsulating stuff, if the container is not hidden get value of lhContainer WFCP_ENC_ELEM to liEncElem if liEncElem begin if (liEncElem=1) send XHTML_Add_Open_Element "div" if (liEncElem=2) send XHTML_Add_Open_Element "span" /// get value of lhContainer WFCP_ENC_WIDTH to lsEncWidth get piCssElement of lhContainer to liCssElement if (liCssElement<>-1) send add_attribute_style liCssElement end get value of lhContainer WFCP_FIELDSET_ELEM to lbFieldset if lbFieldset begin send XHTML_Add_Open_Element "fieldset" send add_attribute_class "" "fieldset" send add_attribute_style CSS_FORM_FIELDSET get value of lhContainer WFCP_TITLE to lsLabel if (lsLabel<>"") begin send XHTML_Add_Closed_Element "legend" lsLabel send add_attribute_class "" "fieldsetlegend" send add_attribute_style CSS_FORM_FIELDSETLEGEND end end end get phLayout of lhContainer to lhLayout if lhLayout begin if (bControlContainer(lhContainer)) begin send DoWriteHtml of lhLayout MSG_DoWriteControlCell self end else begin // if (lsPopupId<>"") begin // If a popup id has been specified, we look for it and ask that to paint itself get hFindChildContainer of lhContainer lsPopupId to lhPopupContainer if lhPopupContainer send DoWriteHtml of lhPopupContainer else send XHTML_Add_Closed_Element "div" ("Popup container not found ("+lsPopupId+")") //send XHTML_Add_Open_Element "span" //send XHTML_Add_Attribute "style" "display:none" // Hide all the fieldsets except the popped up one. send DoWriteHtmlAllNonPopup of lhContainer //send XHTML_Close_Element end else begin // If no popup indication we use the normal layout object if (liContainerClass=WFCC_UI) send DoWriteHtml of lhLayout MSG_DoWriteUiContainerCell self else send DoWriteHtml of lhLayout MSG_DoWriteContainerCell self end end end else send OnWriteHtml of lhContainer // If it doesn't have a layout it'll just have to do by itself if (lbDisplayMode=2) begin send XHTML_Close_Element // div (end hide it) end else begin if liEncElem send XHTML_Close_Element // fieldset if lbFieldset send XHTML_Close_Element // div or span end end // send PopCurrentContainer end // bContentEnabled end_procedure // DoWriteContainer procedure OnStyle_Container integer lhContainer // Sent only if phCssStyler is set // integer lhStyler // get phCssStyler to lhStyler // In here you may manipulate elements: // CSS_FORM_FORM // CSS_FORM_FORM_ENCAP // CSS_FORM_FORMTITLE // CSS_FORM_DIRECTIONS // CSS_FORM_MESSAGEAREA end_procedure procedure DoStyle_Container integer lhContainer integer lhStyler liEncElem liEncapHorAdjust string lsEncapWidth lsColor lsBorder get phCssStyler to lhStyler if lhStyler begin // Apply styles according to properties: // 1. Handle capsulating element (if piEncapElement is set) get value of lhContainer WFCP_ENC_ELEM to liEncElem if liEncElem begin get value of lhContainer WFCP_ENC_WIDTH to lsEncapWidth get value of lhContainer WFCP_ENC_COLOR to lsColor get value of lhContainer WFCP_ENC_BORDER_STYLE to lsBorder if (lsEncapWidth<>"") set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_DIMEN_WIDTH to lsEncapWidth if (lsColor<>"") set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BACKGROUND_COLOR to lsColor if (lsBorder<>"") begin set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_STYLE to lsBorder set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_WIDTH to "1px" set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_COLOR to "#000000" end else begin set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_STYLE to "none" set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_WIDTH to "0px" set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_BORDER_COLOR to "#000000" end if (liEncElem=1) begin // div //get piEncapHorAdjust to liEncapHorAdjust // 0=left, 1=center, 2=right //if (liEncapHorAdjust=0) begin // set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_LEFT to "0px" // set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_RIGHT to "auto" //end if (liEncapHorAdjust=1) begin set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_LEFT to "auto" set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_RIGHT to "auto" end //if (liEncapHorAdjust=2) begin // set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_LEFT to "auto" // set Property_Value of lhStyler CSS_FORM_FORM_ENCAP CSSPS_MARGIN_RIGHT to "0px" //end end end // liEncElem send OnStyle_Container lhContainer send OnStyle of lhContainer lhStyler end end_procedure procedure DoWriteHiddenInput string lsName string lsValue send XHTML_Add_Closed_Element "input" "" // Add an input for detecting name of form send XHTML_Add_Attribute "type" "hidden" send XHTML_Add_Attribute "name" lsName send XHTML_Add_Attribute "value" lsValue end_procedure procedure DoWriteHiddenInputInclPrefix string lsName string lsValue integer lhForm string lsInputNamePrefix get priv.phCurrentForm to lhForm get sInputNamePrefix of lhForm to lsInputNamePrefix send DoWriteHiddenInput (lsInputNamePrefix+lsName) lsValue end_procedure procedure DoWriteHiddenRowIdHelp integer lhDD integer liTable integer lhConnectedToDD // wForm integer lhForm string lsParam get priv.phCurrentForm to lhForm get sHiddenRecnumFieldName of lhForm liTable to lsParam send DoWriteHiddenInput lsParam (current_record(lhDD)) end_procedure procedure OnStyle_Form integer lhForm end_procedure procedure DoStyle_Form integer lhForm integer lhStyler get phCssStyler to lhStyler if lhStyler begin // Instert stand stuff here send OnStyle_Form lhForm send OnStyle of lhForm lhStyler end end_procedure procedure DoWriteForm integer lhForm // cFormWriter integer lhServer lhUiContainer lhStyler string lsInputNamePrefix set priv.phCurrentForm to lhForm get server of lhForm to lhServer get phUiContainer of lhForm to lhUiContainer get phCssStyler to lhStyler if lhStyler begin send DoReset of lhStyler send DoStyle_Form lhForm end get sInputNamePrefix of lhForm to lsInputNamePrefix send XHTML_Add_Open_Element "form" send add_attribute_class "" "form" // X send add_attribute_style CSS_FORM_FORM send XHTML_Add_Attribute "action" (sFormAction(lhForm)) send XHTML_Add_Attribute "method" "post" send XHTML_Add_Attribute "onsubmit" "SetChangedStates(this)" send XHTML_Add_Open_Element "div" // The only purpose of this DIV is to make the page XHTML 1.0 STRICT compliant send DoWriteHiddenInput "htmlform_name" (psFormName(lhForm)) send DoWriteHiddenInput "htmlform_collection" (psFormCollection(lhForm)) send DoWriteHiddenInput "AutoSubmitter" "" send DoWriteHiddenInput "ChangedStates" "" if lhServer begin // Write hidden inputs with record identifiers send DoWriteHiddenRowIdHelp lhServer (main_file(lhServer)) 0 send DDO_CallbackReset // Up Recursive ParentFirst ExclVisited send DDO_Callback lhServer TRUE TRUE FALSE TRUE MSG_DoWriteHiddenRowIdHelp self // Write Row Id's from DDOs end send DoWriteHiddenInput (lsInputNamePrefix+"AlreadyChangedStates") (sAlreadyChangedStates(lhForm)) send DoWriteBackgroundForm of lhForm send XHTML_Close_Element // div End of STRICT compliancy //send DoStyle_Container lhUiContainer // Calculate in-line CSS send DoWriteHtml of lhUiContainer send XHTML_Close_Element // form end_procedure // DoWriteForm procedure DoWriteFormHidden integer lhForm integer lhServer lhUiContainer string lsInputNamePrefix send XHTML_Add_Open_Element "div" send XHTML_Add_Attribute "style" "display:none" // Hide the lot set priv.phCurrentForm to lhForm get server of lhForm to lhServer get phUiContainer of lhForm to lhUiContainer get sInputNamePrefix of lhForm to lsInputNamePrefix if lhServer begin // Write hidden inputs with record identifiers send DoWriteHiddenRowIdHelp lhServer (main_file(lhServer)) 0 send DDO_CallbackReset // Up Recursive ParentFirst ExclVisited send DDO_Callback lhServer TRUE TRUE FALSE TRUE MSG_DoWriteHiddenRowIdHelp self // Write Row Id's from DDOs (hidden version) end send DoWriteHiddenInput (lsInputNamePrefix+"AlreadyChangedStates") (sAlreadyChangedStates(lhForm)) send DoWriteBackgroundForm of lhForm //send DoStyle_Container lhUiContainer // Calculate in-line CSS send DoWriteHtml of lhUiContainer send XHTML_Close_Element // div end_procedure function ContainerLayoutColumnCount integer lhContainer returns integer // cFormWriter integer liMax liRow liColumn liMaxColumn liLocation lbFirst liSpan integer lhChildren integer lhChildContainer move (oChildren(lhContainer)) to lhChildren move 0 to liMaxColumn move 0 to liColumn move TRUE to lbFirst get row_count of lhChildren to liMax decrement liMax for liRow from 0 to liMax get phObject.i of lhChildren liRow to lhChildContainer ifnot (integer(value(lhChildContainer,WFCP_POPUP_STATE))) begin get value of lhChildContainer WFCP_LOCATION to liLocation // 0=Below 1=Right get value of lhChildContainer WFCP_LOCATION_SPAN to liSpan // 0=no span, x=span x colums, -1 span to max column if lbFirst begin move 0 to liLocation // In case of a rubbish setting (you can't set the first object to the right of anything) move FALSE to lbFirst end if (liSpan=-1) move TRUE to lbFirst // The first component after a span-to-end needs to be confined if (liLocation=0) begin // Below if (liColumn>liMaxColumn) move liColumn to liMaxColumn if (liSpan<1) move 1 to liSpan move liSpan to liColumn end if (liLocation=1) begin // Right if (liSpan<1) move 1 to liSpan move (liColumn+liSpan) to liColumn end end loop if (liColumn>liMaxColumn) move liColumn to liMaxColumn function_return liMaxColumn end_function // ContainerLayoutColumnCount function hCreateLayoutObject returns integer integer lhLayout object oLayout is a WebLayoutTable // Form layout move self to lhLayout set psBorder to 0 set psCellSpacing to 0 set psCellPadding to 0 set psWidth to "" end_object function_return lhLayout end_function procedure DoLayoutContainers integer lhContainer integer lhLayout // Handle to layout being created integer liMaxColumn // Number of columns in the layout. Calculated before anything. integer liTableRow // Current table row of the layout we are generating. integer liTableColumn // Current table column of the layout we are generating. integer lhChildContainer // Handle to child container(s) integer liLocation // Location setting of child container integer liRow liMax // Counter and boundary of child containers integer lbFirst integer lhStyler liSpan lhChildren integer liClass integer lbComments // TRUE if site commenting feature has been switched on string lsTitle string lsDirections string lsId string lsPrefix string lsStyle get phLayout of lhContainer to lhLayout ifnot lhLayout begin get hCreateLayoutObject to lhLayout set phLayout of lhContainer to lhLayout get ContainerLayoutColumnCount lhContainer to liMaxColumn move -1 to liTableRow get psCssClassPrefix to lsPrefix send DoReset of lhLayout set piPurpose of lhLayout to LAYOUTPURPOSE_FORM if (lsPrefix<>"") begin set psTableClass of lhLayout to (lsPrefix+"formtable") end get phCssStyler to lhStyler if lhStyler begin get sInLineStyle of lhStyler CSS_FORM_FORMTABLE to lsStyle end set psTableStyle of lhLayout to lsStyle send begin_cells of lhLayout get piContainerClass of lhContainer to liClass if (liClass=WFCC_UI) begin // If outermost container we create some special cells: get psFormTitle of lhContainer to lsTitle // These are queries of the form object but get psFormDirections of lhContainer to lsDirections // we rely on delegation to solve that if (lsTitle<>"") begin increment liTableRow send add_cell of lhLayout liTableRow 0 0 0 "formtitle" 0 if (liMaxColumn>1) set span_values of lhLayout to 1 liMaxColumn end if (lsDirections<>"") begin increment liTableRow send add_cell of lhLayout liTableRow 0 0 0 "directions" 0 if (liMaxColumn>1) set span_values of lhLayout to 1 liMaxColumn end increment liTableRow send add_cell of lhLayout liTableRow 0 0 0 "messagearea" 0 if (liMaxColumn>1) set span_values of lhLayout to 1 liMaxColumn end move TRUE to lbFirst // Go through all the children move (oChildren(lhContainer)) to lhChildren get row_count of lhChildren to liMax decrement liMax move 0 to liTableColumn for liRow from 0 to liMax get phObject.i of lhChildren liRow to lhChildContainer get value of lhChildContainer WFCP_ID to lsId if (lsId="") begin // Set psComponentLabel if it hasn't already been set move ("fs"+string(liRow)) to lsId set value of lhChildContainer WFCP_ID to lsId end ifnot (integer(value(lhChildContainer,WFCP_POPUP_STATE))) begin get value of lhChildContainer WFCP_LOCATION to liLocation // 0=Below 1=Right get value of lhChildContainer WFCP_LOCATION_SPAN to liSpan // 0=no span, x=span x colums, -1 span to max column if lbFirst begin move 0 to liLocation // Just in case of a rubbish setting (you can't set the first object to the right of anything) move FALSE to lbFirst end if (liSpan=-1) move TRUE to lbFirst // The first component after a span-to-end needs to be confined if (liLocation=0) begin // Below increment liTableRow move 0 to liTableColumn send add_cell of lhLayout liTableRow liTableColumn 0 0 lsId 0 end if (liLocation=1) begin // Right increment liTableColumn send add_cell of lhLayout liTableRow liTableColumn 0 0 lsId 0 end if (liSpan>1) set span_values of lhLayout to 1 liSpan if (liSpan=-1) begin // Span to max column move (liMaxColumn-liTableColumn) to liSpan set span_values of lhLayout to 1 liSpan end end loop if (liClass=WFCC_UI) begin // If outermost container we create some special cells: get pbAllowCommentState of lhContainer to lbComments // Will be resolved through delegation if lbComments begin get value of oBaseSessionVariables WSV_COMMENTS_ON to lbComments move 1 to lbComments if lbComments begin increment liTableRow send add_cell of lhLayout liTableRow 0 0 0 "sitecomments" 0 if (liMaxColumn>1) set span_values of lhLayout to 1 liMaxColumn end end end send end_cells of lhLayout end end_procedure // DoLayoutContainers // Note that function ControlsLayoutColumnCount returns the actual table column // count divided by two. The reason is that each column is a label column plus a // a input column. function ControlsLayoutColumnCount integer lhContainer returns integer integer lhChildren liMax liRow liCurrentColumn liMaxColumn liLocation lhInput move (oChildren(lhContainer)) to lhChildren get row_count of lhChildren to liMax decrement liMax move 0 to liMaxColumn move 0 to liCurrentColumn for liRow from 0 to liMax get phObject.i of lhChildren liRow to lhInput get value of lhInput WFIP_LOCATION to liLocation // 0:New line, 1:Right (same cell), 2:Right (new cell) if (liRow=0 or liLocation=0) move 1 to liCurrentColumn else if (liLocation=2) increment liCurrentColumn if (liCurrentColumn>liMaxColumn) move liCurrentColumn to liMaxColumn loop function_return liMaxColumn end_function procedure DoLayoutControls integer lhContainer integer lhLayout integer liMax liRow integer lhInput integer liTableRow integer lhStyler integer liExtraInfoMode integer liErrorTextMode integer liLocation integer liMaxColumnSet integer liColumnSet integer lhChildren integer lbSpan integer liPreviousTableRow string lsPrefix lsStyle get phLayout of lhContainer to lhLayout ifnot lhLayout begin get hCreateLayoutObject to lhLayout set phLayout of lhContainer to lhLayout get phCssStyler to lhStyler get psCssClassPrefix to lsPrefix send DoReset of lhLayout set piPurpose of lhLayout to LAYOUTPURPOSE_FIELDSET set psTableClass of lhLayout to (lsPrefix+"fieldsettable") get ControlsLayoutColumnCount lhContainer to liMaxColumnSet decrement liMaxColumnSet for liColumnSet from 0 to liMaxColumnSet send add_column of lhLayout (liColumnSet*2+0) (lsPrefix+"fieldsetlabelcolumn") "" send add_column of lhLayout (liColumnSet*2+1) (lsPrefix+"fieldsetdatacolumn") "" loop set psTableStyle of lhLayout to "" set psBorder of lhLayout to 0 set psCellSpacing of lhLayout to 0 set psCellPadding of lhLayout to 0 set psWidth of lhLayout to "" set psTableStyle of lhLayout to "" get value of lhContainer WFCP_EXTRA_INFO_MODE to liExtraInfoMode // 1:Extra info in widget cell // 2:Extra info in spanned cells, get value of lhContainer WFCP_ERROR_TEXT_MODE to liErrorTextMode // 1:Error in widget cell // 2:Error in spanned cells // 3:Error in widget cell (after field) // 4:Error in spanned cells (after field) send begin_cells of lhLayout move (oChildren(lhContainer)) to lhChildren get row_count of lhChildren to liMax decrement liMax move 0 to liTableRow move 0 to liColumnSet for liRow from 0 to liMax get phObject.i of lhChildren liRow to lhInput get value of lhInput WFIP_LOCATION to liLocation // 0:New line, 1:Right (same cell), 2:Right (new cell) if (liLocation=1 and liRow>0) begin set priv.ChainNextInput.i of lhChildren (liRow-1) to liLocation end else begin if (liLocation=2 and liRow>0) begin // Right, new cell move liPreviousTableRow to liTableRow increment liColumnSet end else begin // New table row move liTableRow to liPreviousTableRow move 0 to liColumnSet end if liExtraInfoMode begin // We must add a row for extra info if lhStyler begin send OnStyleTableCell of lhInput lhStyler 2 // 2 means ExtraInfo get sInLineStyle of lhStyler CSS_FORM_EXTRAINFOCELL to lsStyle end else move "" to lsStyle if (liExtraInfoMode=1) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "filler" liRow send add_cell of lhLayout liTableRow (liColumnSet*2+1) 0 0 "extrainfo" liRow set class_and_style of lhLayout to (lsPrefix+"extrainfocell") lsStyle increment liTableRow end if (liExtraInfoMode=2) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "extrainfo" liRow set span_values of lhLayout to 0 2 set class_and_style of lhLayout to (lsPrefix+"extrainfocell") lsStyle increment liTableRow end end if liErrorTextMode begin // We must add a row for error text if lhStyler begin send OnStyleTableCell of lhInput lhStyler 3 // 3 means ErrorText get sInLineStyle of lhStyler CSS_FORM_ERRORTEXTCELL to lsStyle end else move "" to lsStyle if (liErrorTextMode=1) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "filler" liRow send add_cell of lhLayout liTableRow (liColumnSet*2+1) 0 0 "errortext" liRow set class_and_style of lhLayout to (lsPrefix+"errortextcell") lsStyle increment liTableRow end if (liErrorTextMode=2) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "errortext" liRow set span_values of lhLayout to 0 2 set class_and_style of lhLayout to (lsPrefix+"errortextcell") lsStyle increment liTableRow end end get value of lhInput WFIP_SPAN to lbSpan ifnot lbSpan begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "label" liRow if lhStyler begin send OnStyleTableCell of lhInput lhStyler 0 // 0 means Label get sInLineStyle of lhStyler CSS_FORM_LABELCELL to lsStyle end else move "" to lsStyle set class_and_style of lhLayout to (lsPrefix+"labelcell") lsStyle send add_cell of lhLayout liTableRow (liColumnSet*2+1) 0 0 "input" liRow if lhStyler begin send OnStyleTableCell of lhInput lhStyler 1 // 1 means Control get sInLineStyle of lhStyler CSS_FORM_INPUTCELL to lsStyle end set class_and_style of lhLayout to (lsPrefix+"inputcell") lsStyle end else begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "input" liRow if (lbSpan=1) set span_values of lhLayout to 0 2 if (lbSpan=2) set span_values of lhLayout to 0 (liMaxColumnSet+1*2) if lhStyler begin send OnStyleTableCell of lhInput lhStyler 1 // 1 means Control get sInLineStyle of lhStyler CSS_FORM_INPUTCELL to lsStyle end else move "" to lsStyle set class_and_style of lhLayout to (lsPrefix+"inputcell") lsStyle end increment liTableRow if liErrorTextMode begin // We must add a row for error text if lhStyler begin // send OnStyleTableCell of lhInput lhStyler 3 // 3 means ErrorText (We do not need to send that from here. It's already been sent further up in this procedure) get sInLineStyle of lhStyler CSS_FORM_ERRORTEXTCELL to lsStyle end else move "" to lsStyle if (liErrorTextMode=3) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "filler" liRow send add_cell of lhLayout liTableRow (liColumnSet*2+1) 0 0 "errortext" liRow set class_and_style of lhLayout to (lsPrefix+"errortextcell") lsStyle increment liTableRow end if (liErrorTextMode=4) begin send add_cell of lhLayout liTableRow (liColumnSet*2+0) 0 0 "errortext" liRow set span_values of lhLayout to 0 2 set class_and_style of lhLayout to (lsPrefix+"errortextcell") lsStyle increment liTableRow end end end //if (liObjectType=2) begin // SelList // send add_cell of lhLayout liTableRow 0 0 0 "input" liRow // set span_values of lhLayout to 0 2 //end //if (liObjectType=3) begin // Free style cell // if (pbFullWidth(lhInput)) begin // send add_cell of lhLayout liTableRow 0 0 0 "freestyle" liRow // set span_values of lhLayout to 0 2 // end // else begin // send add_cell of lhLayout liTableRow 0 0 0 "filler" liRow // send add_cell of lhLayout liTableRow 1 0 0 "freestyle" liRow // end // increment liTableRow //end loop send end_cells of lhLayout end end_procedure procedure DoLayoutTabDialog integer lhContainer integer lhLayout get phLayout of lhContainer to lhLayout ifnot lhLayout begin get hCreateLayoutObject to lhLayout set phLayout of lhContainer to lhLayout send begin_cells of lhLayout send add_cell of lhLayout 0 0 0 0 "buttons" 0 send add_cell of lhLayout 1 0 0 0 "page" 0 send end_cells of lhLayout end end_procedure // DoLayoutControls //procedure DoLayoutGridContainer integer lhContainer // integer lhLayout // get phLayout of lhContainer to lhLayout // ifnot lhLayout begin // get hCreateLayoutObject to lhLayout // set phLayout of lhContainer to lhLayout // send begin_cells of lhLayout // send add_cell of lhLayout 0 0 0 0 "title" 0 // send add_cell of lhLayout 1 0 0 0 "grid" 0 // send add_cell of lhLayout 2 0 0 0 "buttons" 0 // send end_cells of lhLayout // end //end_procedure procedure DoLayout integer lhContainer integer liClass if (piType(lhContainer)=0) begin //Container get piContainerClass of lhContainer to liClass if (liClass=WFCC_GROUP or liClass=WFCC_TAB_PAGE or liClass=WFCC_UI) begin if (bControlContainer(lhContainer)) send DoLayoutControls lhContainer else send DoLayoutContainers lhContainer end if (liClass=WFCC_TAB_DIALOG) begin send DoLayoutTabDialog lhContainer end if (liClass=WFCC_FREESTYLE) begin end //if (liClass=WFCC_GRID) begin // send DoLayoutGridContainer lhContainer //end end else begin // Control end end_procedure procedure InitializeLayouter integer lhStyler get phCssStyler to lhStyler if lhStyler send DoReset of lhStyler end_procedure procedure add_attribute_class string lsClass string lsDefaultClass string lsPreFix if (lsClass<>"") send XHTML_Add_Attribute "class" lsClass else begin get psCssClassPrefix to lsPrefix if (lsPrefix<>"") send XHTML_Add_Attribute "class" (lsPrefix+lsDefaultClass) end end_procedure procedure add_attribute_style integer liIndex integer lhStyler string lsStyle get phCssStyler to lhStyler if lhStyler begin // If there is a styler object at all get sInlineStyle of lhStyler liIndex to lsStyle if (lsStyle<>"") send XHTML_Add_Attribute "style" lsStyle end end_procedure end_class // cFormWriter object oStandardFormWriter is a cFormWriter end_object