Scid  4.6.5
pinfo.tcl
Go to the documentation of this file.
1 
2 ####################
3 # Player Info window
4 
5 namespace eval pinfo {
6 set playerInfoName ""
7 
8 # the following icons are used as buttons with PND as input, this has
9 # to be handled specially and they involve some technicalities. All
10 # other icons and link resolvers come from the config file
11 image create photo wikiplnk -data {
12  R0lGODlhEAAQAIQQAAQCBBkYGSgoKDw6PEhHSFdYV2lqaXp7eoSDhJiYmKmoqbm6ucjHyNjZ2Ono
13  6fz9/P///////////////////////////////////////////////////////////////yH+EUNy
14  ZWF0ZWQgd2l0aCBHSU1QACH5BAEKABAALAAAAAAQABAAAAV24COOZGmeaDouBbE8CnE0z1E0jVE8
15  iPA+BEHDgUg8HAZjI2BwPBIBBcMgQo4KAcajEUQoRIsvOIAQJQC7I+InIhBojQFB1DiUEIBv3Pc0
16  lgQFDgoGA1QITncDBwp1AgllJgoCAl8Lk1onbjQPBgIpC5hbbConIQA7
17 }
18 image create photo dnblnk -data {
19  R0lGODlhFAAUALMAAAAAAGZmZld/u8zMzP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
20  AAAAACH5BAEAAAQALAAAAAAUABQAAARkkMg5BaA4SxHs1RknjB5YdSQJfCGapismvjRLzDTM4vkI
21  BB9e7ze4CHPEIsDT8wUGUAsHuKw9o8YAIUCFXQeWzbNQ4K4s37BkOSCTzWkb4dx2x0F0N9a0ZhfA
22  ciZnanwYMSARAAA7
23 }
24 image create photo seealsolnk -data {
25  R0lGODlhFQAVAMZ5AAAAAAEBAAICAQQGAhEXCSEtECMwESouJjw8PDJFGEJcH0xpJGFhYVRuMVV1
26  KF6CLH2IbmuVM4+Pj5SUlHysO4imYYGwQYK0PaKiooa6QIe7QKioqIi8Qoq9RIq9RYu9R4y+SI2+
27  SY2+SqysrI/ATZDAT62urK6urpHBUJLBUa+vr7GxsZXDVrKyspXEV5bEWJfEWrOzs7W1tZrGX7a2
28  tre3t57IZbm5ubq6uru7u6TLbry8vL29vajOdanOdsDAwMHBwavQecLCwqzQe63QfMPDw8TExLDS
29  gbDSgsXFxbHTg8bGxsfHx7LUhbTUh8jIyLXVicnJycrKyrfWjcvLy8zMzM3Nzc7OztDQ0L/bmdHR
30  0dLS0sbfpNbW1s/ks9bovdbovtrqxNrqxdvqxd3syN3syeLv0ePv0ubx1+jy2urz3fL46vP47Pf3
31  9/T57vb68Pn89vv7+/r8+Pz9+v3++/3+/P7+/f7+/v///v///////////////////////////yH+
32  EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAFQAVAAAH/oAjKi00Nzs/QEJFi4tAPzw3NC0qJy01O0BJ
33  T1RWV55XVlVRS0A7NS0rNDt5rK15LxqxsrE7NDE3QHlsRCIcJTaws7JCODI8S3k+GmJzaEMvIXJ5
34  cB+ySzw1P1J5HhpsrS9NrUeyUkA3RVZ5KRooUF5sL2R5aXljsldFOUtYeWHssTq4qENnhh06JGJp
35  WbKDiRZWdc5wgaEBhD0NZfJMibWFScMtrvKs0eAhDxINSvKY4fjkYx4dYNyYOKAhCKs4NfLgYaFh
36  S0uHeXq8sDCAgJM3XzQ4CAAhT5aeTPb1Y9UFAAMqVCpEiGAAwAQ1GhaiU8fqDgIAaNOmvaDhipFs
37  TdtatcEgocGCuwUAJMigwZwxZCFfxXogYG+sa7dyBQ5GQQHfWMRSrVosTFatSqoyReH0CZQoUqZa
38  CCJkCJEiRkUcQZKkYoPr17Bjyw4EADs=
39 }
40 
41 proc setupDefaultResolvers { } {
42  set optionF ""
43  if {[catch {open [scidConfigFile resolvers] w} optionF]} {
44  tk_messageBox -title "Scid: Unable to write file" -type ok -icon warning \
45  -message "Unable to write options file: [scidConfigFile resolvers]\n$optionF"
46  } else {
47  puts $optionF "# Scid resolver configuration"
48  puts $optionF "# Version: $::scidVersion, $::scidVersionDate"
49  puts $optionF "# This file contains commands in the Tcl language format."
50  puts $optionF "# If you edit this file, you must preserve valid Tcl"
51  puts $optionF "# format or it will not set your Scid options properly."
52  puts $optionF "#"
53  puts $optionF "# Define how to interpret IDs stored in ssp files. Each ID has to"
54  puts $optionF "# have a unique page to link to. It is currently not possible to link"
55  puts $optionF "# to more than one page by means of a single ID, or to get more"
56  puts $optionF "# than one button by any ID. Therefore, PND is handled specially"
57  puts $optionF "# and within pinfo.tcl"
58  puts $optionF "#"
59  puts $optionF "# Syntax of the following array's list entries:"
60  puts $optionF "#"
61  puts $optionF "# IDName: the tag to search for e.g. VIAF searches for"
62  puts $optionF "# %Bio VIAF-lines and so on"
63  puts $optionF "# link target url: %ID% is replaced by the ID"
64  puts $optionF "# icon name: the icons are specified below as base64 encoded images"
65  puts $optionF "# They must not live in ::pinfo-namespace!"
66  puts $optionF "# Link text: what to display in pinfo window"
67  puts $optionF "set ::pinfo::idlink(0) {{VIAF} {http://viaf.org/%ID%} {viaflnk} {VIAF}}"
68  puts $optionF "set ::pinfo::idlink(1) {{FIDEID} {http://ratings.fide.com/card.phtml?event=%ID%} {fidelnk} {FIDE}}"
69  puts $optionF "set ::pinfo::idlink(2) {{ICCFID} {http://www.iccf-webchess.com/PlayerDetails.aspx?id=%ID%} {iccflnk} {ICCF}}"
70  puts $optionF "set ::pinfo::idlink(3) {{DSB} {http://www.schachbund.de/dwz/db/spieler.html?zps=%ID%} {dsblnk} {DSB}}"
71  puts $optionF "set ::pinfo::idlink(4) {{BCF} {http://grading.bcfservices.org.uk/getref.php?ref=%ID%} {bcflnk} {BCF}}"
72  puts $optionF "set ::pinfo::idlink(5) {{SchemingMind} {http://www.schemingmind.com/plyrprofile.aspx?profile_id=%ID%} {smlnk} {SchemingMind}}"
73  puts $optionF "#"
74  puts $optionF "# Icons for the icons defined here MUST NOT live in ::pinfo namespace"
75  puts $optionF "#"
76  puts $optionF "image create photo fidelnk -data {"
77  puts $optionF " R0lGODlhEAAQAOecACIxWSY0XSc2XSg2YCc3Xig3Xik3Xyk4Xyo4Xyo4YCo5Xyo5YCs5Xyo6Xys6"
78  puts $optionF " YCs6YSw6YCw6YSw7YSw7Yi07Yi48Yi48Yy88Yi89YzA+ZDE/ZDE/ZTI/ZTJAZTJBZjNBZTNBZjRB"
79  puts $optionF " ZjNCZTRCZjZEaDdEaThEaThGaTlGaTpIazxKbT1KbT9MbkBNb0NQc0VRc0ZScUZUdEhUdEdVdkhV"
80  puts $optionF " dElVdEpXdk1ZeE5ZeFRef1NgfVRgf1dgf1hhf11nhGFsh2JsiGFtiGJtiGNtiGZyi2lzjWt3kHB4"
81  puts $optionF " kHN+lnqEm36GnYCJnYmSo4qTpZWbrpWcq5eerZeer5qgrp6ltaGns6asuKesuqetvK60wrC1wLa6"
82  puts $optionF " xra8x7i9xLu/x7vAyb3CyMvO1MzP09DS2tDT2dHU2dHV2tLV2dPV29PX29fZ3tna3dna3tra3tzd"
83  puts $optionF " 4d3d4dze4Nze4d3e4d3e4tzf4d3f4d3f497f4d7f5N/g4d7h497h5t/h5ODi5OHi5eHj5eLj5eLk"
84  puts $optionF " 5uPl6OTm6efn6eXo6ejq6+rq6+rq7Orr7Ors6+vs7ezt7+3u7+/w8vDw8O/x8fDx8vHx8vHy9PHz"
85  puts $optionF " 9PX19fb29vf39/j4+fr6+/v6+/z9/f39/v//////////////////////////////////////////"
86  puts $optionF " ////////////////////////////////////////////////////////////////////////////"
87  puts $optionF " ////////////////////////////////////////////////////////////////////////////"
88  puts $optionF " ////////////////////////////////////////////////////////////////////////////"
89  puts $optionF " ////////////////////////////////////////////////////////////////////////////"
90  puts $optionF " /////////////////////////////////////////////////////yH+EUNyZWF0ZWQgd2l0aCBH"
91  puts $optionF " SU1QACH5BAEKAP8ALAAAAAAQABAAAAjbAEEIHEiwoMGDBz1IGGDhhIkKBhx0IBhiAgUjWMSYiXRH"
92  puts $optionF " C5IPC0YIfLBji51KV1wESWPpT5chCUBggDGH06UsACYE0DFIEqdGPSBsKIMojxwgRFg84MGmzh5B"
93  puts $optionF " elbccATp0SNGVjgIWBKpUCJFjH7gcPOGDh8yFzAISGLID6A+f4SQCMQIzhovJVqouDFGTZtDk15Q"
94  puts $optionF " 8EEI0yZKVGrIgCJJU6ZFRxiAQFAEDR4wVXLYkBImzhklCgY2ENEkChMuX55McYLiQMEOBSCkiEFj"
95  puts $optionF " RgQCGhCC6JCht+7fAwMCADs="
96  puts $optionF "}"
97  puts $optionF "image create photo iccflnk -data {"
98  puts $optionF " R0lGODlhEAAQAMZqAAAA/wEB/wMD/wQE/wUF/wYG/wcH/wgI/woK/wsL/wwM/xAQ/xER/xIS/xMT"
99  puts $optionF " /xQU/xYW/xcX/xgY/xkZ/xoa/xsb/x4e/yEh/yIi/yUl/yYm/ycn/ykp/zIy/zQ0/zY2/zc3/zo6"
100  puts $optionF " /zs7/zw8/z09/0ZG/0lJ/01N/1hY/1lZ/1pa/1tb/1xc/2Nj/2Vl/2lp/2pq/3R0/3V1/3Z2/3d3"
101  puts $optionF " /3h4/3t7/3x8/39//4SE/4WF/4uL/42N/4+P/5CQ/5KS/5OT/5SU/5WV/5aW/5eX/5iY/5ub/5+f"
102  puts $optionF " /6Cg/6Gh/6en/6mp/6qq/66u/6+v/7S0/7i4/7u7/729/7+//8DA/8LC/8PD/8rK/8zM/83N/87O"
103  puts $optionF " /9PT/9fX/9jY/+Pj/+Tk/+bm/+jo/+vr/+zs//Hx//Ly//T0//b2//j4//z8////////////////"
104  puts $optionF " /////////////////////////////////////////////////////////////////////////yH+"
105  puts $optionF " EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAH8ALAAAAAAQABAAAAfjgFJTaF86R2dpXjlIZ2JQUFIV"
106  puts $optionF " GGMnAAVFaCaWRlQKCRULE1cGBwIgWwQIASFSAAAMDBJKAC4XEEwALRcWTwAUKAwTQwA0GQs9ADIZ"
107  puts $optionF " Dk0ALGmhw8ULPAAzGgvNK2nBQtYjHNUxJBxOABw/3dZcW0YANl1bUa4eod40aWlHADf5rQAegkmT"
108  puts $optionF " 8QIIgBozXvQqoUWgNWM7kmVg0EwFtAlFiE30kWxDA23cJiwBAAODBFwvdvXaFsvKgAcGQGQJEGGA"
109  puts $optionF " iFYsJYT5ACBAEDMdAAggMi9FGiVMzmhhcYNMGiwrcJQBk6RKmkAAOw=="
110  puts $optionF "}"
111  puts $optionF "image create photo viaflnk -data {"
112  puts $optionF " R0lGODlhEAAQAIQaAP8AAP8ICP8QEP8YGP8hIf8pKf8xMf85Of9CQv9SUv9aWv9jY/9zc/97e/+E"
113  puts $optionF " hP+MjP+UlP+cnP+lpf+trf+1tf/Gxv/Ozv/W1v/e3v/v7////////////////////////yH+EUNy"
114  puts $optionF " ZWF0ZWQgd2l0aCBHSU1QACH5BAEKAB8ALAAAAAAQABAAAAWDoCZm1lVp1ZVhqSWOSnBpEJNlynC+"
115  puts $optionF " tCA2LwODJ4IENI+M6AKYESWACuXlIBBFFADwVdgSK9bRBCC5ajBOTYYiNWumIguFPSdmledA42JJ"
116  puts $optionF " 8DIHABhYghoqPAxZTgsEEQwTPBILDFEiAhBIeIYOhgBTd0QZCEpZEBcJA2lLFyolKayqGiEAOw=="
117  puts $optionF "}"
118  puts $optionF ""
119  puts $optionF "image create photo smlnk -data {"
120  puts $optionF " R0lGODlhEAAQAOMNAAAAABgYITE5OVJSUmNja3Nzc4SEjJycpbW1tcbOztbW3ufn5+/39///////"
121  puts $optionF " /////yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAEAAQAAAEl7AVZEprawCSmkJLQy2HwCiFJgzK"
122  puts $optionF " 1RyAUBBKMhjBEAgGchSFWOGAahACh8GNsEDkBhaPStA6SAA7gytRMHQ8GQFCYcWEMK4DsoNwoS+L"
123  puts $optionF " hIAwUnxA8Iv6N0gYBDkdDC5KCF0JCAQEgw0MIQxiBD0GTQRdUSETfQcHCAgCADEIjJwgY2N/VIw1"
124  puts $optionF " lJ0vnTEKISEGRAOeuAhfLhEAOw=="
125  puts $optionF "}"
126  puts $optionF ""
127  puts $optionF "image create photo bcflnk -data {"
128  puts $optionF " R0lGODlhEAAQAIQRAAAAAAAAIAAAQAAgYCAgIDAwMABAgEBAQGBgYDBvbwCAgD9/fzCQkH9/f2Cg"
129  puts $optionF " oDCvr4/Pz////////////////////////////////////////////////////////////yH+EUNy"
130  puts $optionF " ZWF0ZWQgd2l0aCBHSU1QACwAAAAAEAAQAAAFWmCBjGRZEgixFE3kqqwbHUjCGK1r4zJdGINc5Bfs"
131  puts $optionF " IRrIpFJJkzUAUCcU0HQ9o9ZpNXIFSKE0mFBs3AnNRqJQbVy6k9uuE/IIxKdOh0Jwx3IDAlQEB4SF"
132  puts $optionF " hoYEIQA7"
133  puts $optionF "}"
134  puts $optionF ""
135  puts $optionF "image create photo dsblnk -data {"
136  puts $optionF " R0lGODlhEAAQAMZMABIRERYVFDsQDUoTDyMiInUfGWclIDQzM3QmF4QiG0A3G0A3HU47OU49O0VE"
137  puts $optionF " RE9FI1BNTFFNTFFOTVFOTlJOTlJQT1JRUVJSUVNSUlRTU1VUVFZVVds5LMw+Mto7Kds7L80/NF1d"
138  puts $optionF " XNs9Mdo/K9s+Mts+M9pAK9xAM9xANNtBNW9iNtxDN9xDONpGLNxFOdlIK9lILH5tN9xQRXh3d458"
139  puts $optionF " P4iIiK2XTJmZmb2lU6qqqru7u9zAYszMzOzNZuzNZ+zOZ+zOaOzOae3Qbe3Qbu7Rce3Sc93d3e7u"
140  puts $optionF " 7vn39/v5+fz6+v37+///////////////////////////////////////////////////////////"
141  puts $optionF " ////////////////////////////////////////////////////////////////////////////"
142  puts $optionF " /////////////////////////////////////////////////////////////////////////yH+"
143  puts $optionF " EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAEAAQAAAHs4BMghAUIi5CPT2Ci4sVEgwpJkGJjI0SDSgv"
144  puts $optionF " lJWLExUiIj49RZyCGBMyJCk9Q6WCS0sCBSM7Kg41gg66OUxIIScGNDG4NTdMDkxHB0xKFxwgCjYb"
145  puts $optionF " N0aCBDUzM0xJEyIfCz1GNw7GBzo6DkZIqAkID9VHyMhMMzqwAQMdOAsOBzxMAHRp0xBhAosTQBS5"
146  puts $optionF " YmIhQoYTHn4odBUhgowSLSQuzDABwooTMIAAIeKKYzcUMnokZBQIADs="
147  puts $optionF "}"
148  close $optionF
149  }
150 }
151 
152 # Resolve Wikipedias language sites by means of the Wikipedia API
153 proc WikipNLS { LinkList } {
154 
155  # set WikiPediaAPI "http://de.wikipedia.org/w/api.php?action=query"
156 
157  set WikiPLL "&prop=langlinks"
158  set WikiPTI "&titles="
159  set lang $::language
160  set langlink [lindex $LinkList 3]
161 
162  # translate Scid's internal single letter language representation by
163  # a more common two letter one; the same is used by WP
164  switch $lang {
165  B {set wplanguage pt}
166  C {set wplanguage cs}
167  D {set wplanguage de}
168  F {set wplanguage fr}
169  G {set wplanguage gr}
170  H {set wplanguage hu}
171  I {set wplanguage it}
172  K {set wplanguage ca}
173  N {set wplanguage nl}
174  O {set wplanguage no}
175  P {set wplanguage pl}
176  R {set wplanguage ru}
177  S {set wplanguage es}
178  W {set wplanguage sv}
179  Y {set wplanguage sr}
180  default {set wplanguage en}
181  }
182 
183  set Title [lindex $LinkList 3]
184  regsub -all {.*/} $Title "" Title
185 
186  # Spaces etc in URLs are bad, especially for TCL.
187  # Use poor mans urlencoding:
188  regsub -all { } $Title "%20" Title
189 
190  # collect all languages in $fullresult, each page contains a
191  # llcontinue item linking to the following languages
192  set fullresult ""
193  set llcontinue ""
194 
195  # start out here:
196  set WPfetchURL "$::pinfo::wikipAPI$WikiPLL$WikiPTI$Title"
197 
198  set token [::http::geturl $WPfetchURL]
199  set xmlresult [::http::data $token]
200  ::http::cleanup $token
201 
202  # avoid requirement of tDOM and use simple regexping here as the
203  # XML structure returned is simple enough
204 
205  # for more than 10 translations, a continue url is returned.
206  # Extract it
207  regsub -all {.*<langlinks llcontinue=} $xmlresult "" llcontinue
208  regsub -all {/>.*} $llcontinue "" llcontinue
209  regsub -all {\|} $llcontinue "%7C" llcontinue
210  regsub -all {\"} $llcontinue "" llcontinue
211 
212  # check if more langlinks exist, if so set the watermark, otherwise
213  # it has to be emptied.
214  if {[string match "*llcontinue*" $xmlresult]} {
215  # keep only the langlinks-section of the XML
216  regsub -all {.*<langlinks>} $xmlresult "" xmlresult
217  regsub -all {</langlinks>.*} $xmlresult "" xmlresult
218  regsub -all {</ll>} $xmlresult "</ll>\n" xmlresult
219  } else {
220  set llcontinue ""
221  }
222  set fullresult $xmlresult
223 
224  while { $llcontinue != "" } {
225 
226  set WPfetchURL "$::pinfo::wikipAPI$WikiPLL$WikiPTI$Title&llcontinue=$llcontinue"
227  regsub -all { } $WPfetchURL "" WPfetchURL
228 
229  set token [::http::geturl $WPfetchURL]
230  set xmlresult [::http::data $token]
231  ::http::cleanup $token
232 
233  if {[string match "*llcontinue*" $xmlresult]} {
234  regsub -all {.*<langlinks llcontinue=} $xmlresult "" llcontinue
235  regsub -all {/>.*} $llcontinue "" llcontinue
236  regsub -all {\|} $llcontinue "%7C" llcontinue
237  regsub -all {\"} $llcontinue "" llcontinue
238  } else {
239  set llcontinue ""
240  }
241 
242  regsub -all {.*<langlinks>} $xmlresult "" xmlresult
243  regsub -all {</langlinks>.*} $xmlresult "" xmlresult
244  regsub -all {</ll>} $xmlresult "</ll>\n" xmlresult
245  set fullresult "$fullresult$xmlresult"
246  }
247 
248  set langlist [split $fullresult "\n"]
249 
250  foreach ll $langlist {
251  # construct the NLS-enabled link to WP
252  if { [string match "*lang=\"$wplanguage\"*" $ll] } {
253  set baselink "http://$wplanguage.wikipedia.org/wiki/"
254  regsub -all {.*preserve">} $ll "" pagename
255  regsub -all {<.*} $pagename "" pagename
256  set langlink "$baselink$pagename"
257  }
258  }
259  openURL $langlink
260 }
261 
262 # Use the SeeAlso service hosted at Gemeinsamer Bibliotheks Verbund
263 # (Goettingen) to resolve the PND to german Wikipedia. SeeAlso might
264 # proove useful later for other services as they appear on SeeAlso
265 proc saPND2WP { pnd } {
266 
267  set SeeAlso "$::pinfo::SeeAlsoPND2WP$pnd"
268 
269  set token [::http::geturl $SeeAlso]
270 
271  set LinkList [::http::data $token]
272  regsub -all {\[} $LinkList "" LinkList
273  regsub -all {\]} $LinkList "" LinkList
274  regsub -all {\"} $LinkList "" LinkList
275  set LinkList [split $LinkList ,]
276 
277  WikipNLS $LinkList
278 }
279 
280 # Replace the ID-Tags by proper links
281 proc ReplaceIDTags { pinfo } {
282  # replace certain BIO lines by links to external media
283  regsub -all ".*PND " $pinfo "" pnd
284  regsub -all {<br>.*} $pnd "" pnd
285 
286  set pnd [string trim $pnd]
287 
288  switch $::language {
289  B {set wplanguage pt}
290  C {set wplanguage cs}
291  D {set wplanguage de}
292  F {set wplanguage fr}
293  H {set wplanguage hu}
294  I {set wplanguage it}
295  K {set wplanguage ca}
296  N {set wplanguage nl}
297  O {set wplanguage no}
298  P {set wplanguage pl}
299  R {set wplanguage ru}
300  S {set wplanguage es}
301  W {set wplanguage sv}
302  Y {set wplanguage sr}
303  default {set wplanguage en}
304  }
305 
306 
307  # the following three resolvers hook up with PND and need special
308  # treatment as additional functions need to be called
309  set wikiplink "<run openURL $::pinfo::wikipurl/$wplanguage/$pnd; ::windows::stats::Refresh><button wikiplnk -command openURL $::pinfo::wikipurl/$wplanguage/$pnd;><blue>WP</blue></run>"
310 
311  # As we have direct linkage to WikiPedia SeeAlso is currently
312  # obsolete. It might become of interest again if it offers other
313  # services to connect to.
314  ### set seealsolink "<run ::pinfo::saPND2WP $pnd; ::windows::stats::Refresh><button seealsolnk -command ::pinfo::saPND2WP $pnd><blue>SeeAlso</blue></run>"
315  set seealsolink ""
316 
317  set dnblink "<run openURL $::pinfo::dnburl/$pnd; ::windows::stats::Refresh><button dnblnk -command openURL $::pinfo::dnburl/$pnd><blue>DNB</blue></run>"
318 
319  # Handle all id definitions and link resolvers from the config file
320  foreach index [array names ::pinfo::idlink] {
321  set federation $::pinfo::idlink($index)
322  set searchterm [lindex $federation 0]
323  set link [lindex $federation 1]
324  set icon [lindex $federation 2]
325  set str [lindex $federation 3]
326 
327  # extract the ID
328  regsub -all ".*$searchterm " $pinfo "" id
329  regsub -all {<br>.*} $id "" id
330  set id [string trim $id]
331 
332  if {$id != ""} {
333  regsub -all "%ID%" $link $id link
334  set btn "<run openURL $link; ::windows::stats::Refresh><button $icon -command openURL $link><blue>$str</blue></run>"
335  regsub -all "$searchterm $id<br>" $pinfo $btn pinfo
336  }
337  }
338 
339  # Replace PND by all services linked to that ID
340  regsub -all "PND $pnd<br>" $pinfo "$seealsolink $wikiplink $dnblink" pinfo
341  regsub -all "</run> <run" $pinfo "</run> <run" pinfo
342 
343  return $pinfo
344 }
345 
346 
347 proc playerInfo {{player ""}} {
348  global playerInfoName
349  if {$player == ""} { set player $playerInfoName}
350  if {[catch {sc_name info -htext $player} pinfo]} { return}
351  set playerInfoName $player
352  set ::rgraph(player) $player
353  set w .playerInfoWin
354  if {! [winfo exists $w]} {
355  toplevel $w
356  setWinLocation $w
357  wm title $w "Scid: [tr ToolsPInfo]"
358  wm minsize $w 40 5
359  pack [frame $w.b2] -side bottom -fill x
360  pack [frame $w.b] -side bottom -fill x
361  button $w.b.graph -text [tr ToolsRating] \
362  -command {::tools::graphs::rating::Refresh player $playerInfoName}
363  button $w.b.edit -text $::tr(PInfoEditRatings) -command {
364  makeNameEditor
365  setNameEditorType rating
366  set editName $playerInfoName
367  set editNameSelect crosstable
368  }
369  button $w.b2.report -text [tr ToolsPlayerReport] \
370  -command {::preport::preportDlg $playerInfoName}
371  dialogbutton $w.b2.help -textvar ::tr(Help) -command {helpWindow PInfo}
372  dialogbutton $w.b2.update -textvar ::tr(Update) -command {::pinfo::playerInfo $playerInfoName}
373  dialogbutton $w.b2.close -textvar ::tr(Close) -command "focus .; destroy $w"
374  packbuttons right $w.b2.close $w.b2.update $w.b2.help
375  packbuttons left $w.b.graph $w.b.edit
376  packbuttons left $w.b2.report
377 
378  autoscrollframe $w.frame text $w.text -font font_Regular -background white \
379  -width $::winWidth($w) -height $::winHeight($w) -setgrid 1 -wrap none
380  #scrollbar $w.ybar -command "$w.text yview"
381  #pack $w.ybar -side right -fill y
382  #text $w.text -font font_Regular -background white \
383  # -width $::winWidth($w) -height $::winHeight($w) \
384  # -setgrid 1 -wrap none -yscrollcommand "$w.ybar set"
385  label $w.photo -background white
386  #pack $w.text -side top -fill both -expand yes
387  pack $w.frame -side top -fill both -expand yes
388  bind $w <Escape> "focus .; destroy $w"
389  ::htext::init $w.text
390  ::htext::updateRate $w.text 0
391  bind $w <Escape> "focus .; destroy $w"
392  bind $w <F1> {helpWindow PInfo}
393  bind $w <Configure> "recordWinSize $w"
395  }
396  set player [trimEngineName $player]
397  set imgdata [getphoto $player]
398  if {$imgdata != ""} {
399  image create photo photoPInfo -data $imgdata
400  $w.photo configure -image photoPInfo -anchor ne
401  place $w.photo -in $w.text -relx 1.0 -x -1 -rely 0.0 -y 1 -anchor ne
402  } else {
403  place forget $w.photo
404  }
405  $w.text configure -state normal
406  $w.text delete 1.0 end
407 
408  set pinfo [::pinfo::ReplaceIDTags $pinfo]
409 
410  # Display the player info
411  ::htext::display $w.text $pinfo
412 
413  $w.text configure -state disabled
416  #raiseWin $w
417 }
418 
419 # Call in the idlink config file.
420  if {[catch {source [scidConfigFile resolvers]}]} {
421  ::splash::add "No configuration for link resolvers found. Creating default..."
423  if {[catch {source [scidConfigFile resolvers]}]} {
424  ::splash::add "Oops there is something wrong with the resolvers file..."
425  } else {
426  ::splash::add "Default resolvers created and loaded."
427  }
428  } else {
429  ::splash::add "ID resolvers found, extended player info available."
430  }
431 }