//> Use WebQueryString.nui // Functions for constructing valid links Use Base.nui // Item_Property command, Various macros (FOR_EX...), cArray, cSet and cStack classes (No User Interface) Use Strings.nui // String manipulation for VDF and 3.2 (No User Interface) Use WebGlobalFunctions.nui // WafGetHtmlFormValue and WafGetQueryString functions //> The cTablePages class holds the identification of max 1 module/page combination per table. class cTablePages is a cArray // item_property_list item_property string psModuleName.i item_property string psPageName.i end_item_property_list cTablePages procedure add_page integer liTable string lsModule string lsPage set psModuleName.i liTable to lsModule set psPageName.i liTable to lsPage end_procedure end_class // cTablePages object oRecordEditPages is a cTablePages // These are pages meant for editing records end_object procedure set RecordEditPage integer liTable string lsModule string lsPage send add_page of oRecordEditPages liTable lsModule lsPage end_procedure object oWebQueryStringConstructer is a cArray property string psUrl public "" item_property_list item_property string psName.i item_property string psValue.i end_item_property_list procedure add_parameter string lsName string lsValue integer liRow if (lsValue<>"") begin get row_count to liRow set psName.i liRow to lsName set psValue.i liRow to lsValue end end_procedure function link_value returns string integer liMax liRow string lsRval lsName lsValue get psUrl to lsRval get row_count to liMax decrement liMax for liRow from 0 to liMax if liRow move (lsRval+"&") to lsRval else move (lsRval+"?") to lsRval get psName.i liRow to lsName get psValue.i liRow to lsValue move (lsRval+lsName+"="+lsValue) to lsRval loop function_return lsRval end_function procedure add_query_string string lsQryString integer liMax liItem string lsValueSet lsName lsValue get HowManyWords lsQryString "&" to liMax for liItem from 1 to liMax get ExtractWord lsQryString "&" liItem to lsValueSet get ExtractWord lsValueSet "=" 1 to lsName get ExtractWord lsValueSet "=" 2 to lsValue if (lsName<>"") send add_parameter lsName lsValue loop end_procedure function iFindRow string lsName returns integer integer liMax liRow get row_count to liMax decrement liMax for liRow from 0 to liMax if (lsName=psName.i(self,liRow)) function_return liRow loop function_return (liMax+1) end_function procedure add_parameter_protected string lsName string lsValue integer liRow if (lsValue<>"") begin get iFindRow lsName to liRow set psName.i liRow to lsName set psValue.i liRow to lsValue end end_procedure end_object //> Call this procedure as the first thing when constructing a new query string procedure QryString_Prepare global string lsRootUrl send delete_data of oWebQueryStringConstructer set psUrl of oWebQueryStringConstructer to lsRootUrl end_procedure procedure QryString_AddQryString global string lsQryString send add_query_string of oWebQueryStringConstructer lsQryString end_procedure procedure QryString_AddParam global string lsName string lsValue send add_parameter of oWebQueryStringConstructer lsName lsValue end_procedure // "Protected" means that parameter lsName is replaced if already present // in the query string currently being built. procedure QryString_AddParamProtected global string lsName string lsValue send add_parameter_protected of oWebQueryStringConstructer lsName lsValue end_procedure procedure QryString_AddRecordParam global integer liFile integer liRecnum string lsValue get_attribute DF_FILE_LOGICAL_NAME of liFile to lsValue send QryString_AddParam (lowercase(lsValue+"_rid")) liRecnum end_procedure procedure QryString_PrepareModulePage global string lsModule string lsPage string lsAction get waf_config_value WACFG_ASP_FILE to lsAction send QryString_Prepare lsAction send QryString_AddParam "m" lsModule send QryString_AddParam "p" lsPage end_procedure procedure QryString_PrepareUrlAndQueryStr string lsRootUrl string lsQryString send QryString_Prepare lsRootUrl send QryString_AddQryString lsQryString end_procedure function QryString_Value global returns string string lsValue get link_value of oWebQueryStringConstructer to lsValue function_return lsValue end_function //> This function returns a link to the standard editing page of table liTable (appended with the //> value of lsRecId as the record identifier). function QryString_RecordEditLink global integer liTable string lsRecId returns string string lsModule lsPage get psModuleName.i of oRecordEditPages liTable to lsModule get psPageName.i of oRecordEditPages liTable to lsPage if ((lsPage+lsModule)<>"") begin send QryString_PrepareModulePage lsModule lsPage send QryString_AddRecordParam liTable lsRecId function_return (QryString_Value()) end function_return "" end_function //> This function returns a link to the standard editing page of table liTable appended with the //> record identifyers of the parent tables (as postulated by the mandatory lhDD object). function QryString_RecordCreateLink global integer liTable integer lhDD returns string integer lhServerDD liMax liItm liParentTable string lsModule lsPage lsParentId if lhDD begin get psModuleName.i of oRecordEditPages liTable to lsModule get psPageName.i of oRecordEditPages liTable to lsPage if ((lsPage+lsModule)<>"") begin send QryString_PrepareModulePage lsModule lsPage get Data_Set_Server_Count of lhDD to liMax decrement liMax for liItm from 0 to liMax get Data_Set_Server of lhDD item liItm to lhServerDD get main_file of lhServerDD to liParentTable get current_record of lhServerDD to lsParentId send QryString_AddRecordParam liParentTable lsParentId loop function_return (QryString_Value()) end end function_return "" end_function //hejsa function QryString_BackLink global returns string string lsUrl lsQueryStr get value of oBaseSessionVariables WSV_CURRENT_URL to lsUrl get value of oBaseSessionVariables WSV_CURRENT_QRYSTR to lsQueryStr function_return (lsUrl+"?"+lsQueryStr) end_function