Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-core
Commits
d2334086
Commit
d2334086
authored
May 15, 2023
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added auxiliary function for cosine CSV export in FinancialDocumentListPage
parent
75c71bd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
intranet-csv-procs.tcl
tcl/intranet-csv-procs.tcl
+97
-0
No files found.
tcl/intranet-csv-procs.tcl
View file @
d2334086
...
...
@@ -428,3 +428,100 @@ ad_proc im_csv_guess_separator { file } {
}
# ------------------------------------------------------------------
# CSV output helpers
# ------------------------------------------------------------------
ad_proc im_cvs_output_findoc_clean_cell
{
-value:required
}
{
Removes HTML tags from cells in order to return the alphanumeric
value suitable for a CSV
(
Excel
)
format
}
{
ns_log Notice
"im_cvs_output_findoc_clean_cell: in: val='
$value
'"
regsub -all
{[
\n\t\r
]}
$value
" "
value
set value
[
string
trim
$value
]
ns_log Notice
"im_cvs_output_findoc_clean_cell: whitespace: val='
$value
'"
# Empty value => empty value
if
{
""
eq
$value
}
{
return
$value
}
ns_log Notice
"im_cvs_output_findoc_clean_cell: work: val='
$value
'"
# Remove enclosing tags
(
always in <tag ...>xxx</tag> structure
)
set new_value
""
while
{
$value
ne
$new
_value
}
{
set new_value
$value
set value
[
im_cvs_output_strip_outer_tag -value
$new
_value
]
}
ns_log Notice
"im_cvs_output_findoc_clean_cell: nowrap: val='
$value
'"
# Single tag? Replace with tag...
if
{[
regexp
{
^
\<
(
\w
+
)[
^
\>
]
*
\>
$
}
$value
match tag
]}
{
ns_log Notice
"im_cvs_output_findoc_clean_cell: single tag: tag=
$tag
, val='
$value
'"
set value
$tag
}
# <option ...>value</option> list? Return the
"selected"
option.
set value
[
im_csv_output_strip_option_list -value
$value
]
set value
[
string
trim
$value
]
ns_log Notice
"im_cvs_output_findoc_clean_cell: out: val='
$value
'"
return
$value
}
ad_proc im_cvs_output_strip_outer_tag
{
-value:required
}
{
ns_log Notice
"im_cvs_output_strip_outer_tag: value=
$value
"
if
{[
regexp
{
^
\<
(
\w
+
)[
^
\>
]
*
\>
(
.*
)
$
}
$value
match start_tag rest
]}
{
# Found a starting tag
ns_log Notice
"im_cvs_output_strip_outer_tag: value=
$value
, start_tag=
$start
_tag, rest=
$rest
"
if
{[
regexp
{
^
(
.*
)
\<
/
(
\w
+
)
\>
$
}
$rest
match content end_tag
]}
{
# Found an end tag
ns_log Notice
"im_cvs_output_strip_outer_tag: value=
$value
, start_tag=
$start
_tag, end_tag=
$end
_tag content=
$content
"
if
{[
string
tolower
$start
_tag
]
eq
[
string
tolower
$end
_tag
]}
{
ns_log Notice
"im_cvs_output_strip_outer_tag: return=
$content
"
return
$content
}
}
}
return
$value
;
# unchanged
}
ad_proc im_csv_output_strip_option_list
{
-value:required
}
{
set org_value
[
string
trim
$value
]
# Skip if not starting with <option...>
if
{
!
[
regexp
-nocase
{
^
\<
option
[
^
\>
]
*
\>
}
$org
_value
]}
{
return
$org
_value
}
ns_log Notice
"im_cvs_output_strip_option_list: in: value=
$value
"
regsub -all -nocase
{
\<\/
option
\>
}
$value
"
\n
"
value
ns_log Notice
"im_cvs_output_strip_option_list: subs: value=
$value
"
set option_list
[
split
$value
"
\n
"
]
ns_log Notice
"im_cvs_output_strip_option_list: option_list=
$option
_list"
# Search for
"<option selected>..."
set result
""
foreach option
$option
_list
{
set option
[
string
trim
$option
]
ns_log Notice
"im_cvs_output_strip_option_list: option=
$option
"
if
{[
regexp
{
\<
option
[
^
\>
]
*selected
[
^
\>
]
*
\>
(
.*
)
$
}
$option
match result
]}
{
return
$result
}
}
return
$org
_value
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment