1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369
|
<?xml version="1.0"?>
<!--
-
- $Id$
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-->
<v:page name="main"
xmlns:v="http://www.openlinksw.com/vspx/" doctype="-//W3C//DTD XHTML 1.0 Transitional//EN"
style="/DAV/VAD/blog2/widgets/main.xsl"
xmlns:vm="http://www.openlinksw.com/vspx/weblog/"
xmlns:ods="http://www.openlinksw.com/vspx/ods/"
>
<html>
<head>
<title>Weblogs Advanced Search</title>
<link rel="stylesheet" type="text/css" href="/weblog/public/css/default.css"/>
<?vsp if (length (self.ds_data)) { ?>
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?V self.qurl ?>xml" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="<?V self.qurl ?>atom" />
<link rel="meta" title="RDF" type="application/rdf+xml" href="<?V self.qurl ?>rdf" />
<?vsp } ?>
</head>
<v:variable name="blogid" type="varchar" default="null" param-name="blogid"/>
<v:variable name="title" type="varchar" default="''"/>
<v:variable name="copy" type="varchar" default="''"/>
<v:variable name="disc" type="varchar" default="''"/>
<v:variable name="email" type="varchar" default="''"/>
<v:variable name="owner" type="varchar" default="''"/>
<v:variable name="about" type="varchar" default="''"/>
<v:variable name="home" type="varchar" default="''"/>
<v:variable name="phome" type="varchar" default="''"/>
<v:variable name="ds_data" type="any" default="null"/>
<v:variable name="ds_meta" type="any" default="null"/>
<v:variable name="opts" type="any" default="null"/>
<v:variable name="output" type="varchar" default="'html'" param-name="output"/>
<v:variable name="qry" type="varchar" default="null" param-name="q"/>
<v:variable name="postid" type="varchar" default="null" param-name="postid"/>
<v:variable name="sqry" type="varchar" default="null" param-name="output"/>
<v:variable name="qtype" type="varchar" default="'text'" param-name="type"/>
<v:variable name="qurl" type="any" default="''"/>
<v:variable name="gurl" type="any" default="''"/>
<v:variable name="details" type="int" default="1" param-name="details"/>
<v:variable name="rowcnt" type="int" default="10" param-name="cnt"/>
<v:variable name="pageno" type="int" default="1" param-name="page"/>
<v:variable name="start_offset" type="int" default="null" param-name="start-index"/>
<v:variable name="total" type="int" default="0" />
<v:variable name="osrch" type="int" default="0" param-name="OpenSearch" />
<v:variable name="opensearch" type="varchar" default="null" param-name="OpenSearch"/>
<v:variable name="kwds" type="varchar" default="''"/>
<v:variable name="author" type="varchar" default="''"/>
<v:variable name="pkwd" type="varchar" default="null" param-name="kwds"/>
<v:variable name="hit_words" type="any" default="null"/>
<v:variable name="have_comunity_blog" type="any" default="null" />
<v:variable name="filt" type="varchar" default="'*default*'"/>
<v:variable name="d_before" type="datetime" default="null" param-name="from" />
<v:variable name="d_after" type="datetime" default="null" param-name="to" />
<v:variable name="s_cat" type="varchar" default="null" param-name="cat" />
<v:variable name="s_tag" type="varchar" default="null" param-name="tags" />
<v:variable name="upar" type="varchar" default="''" persist="temp" />
<v:variable name="atomver" type="varchar" default="'0.3'" persist="temp" />
<v:variable name="refpage" type="varchar" default="''" />
<v:variable name="backlink" type="varchar" default="''" />
<v:variable name="stock_img_loc" type="varchar" default="'/weblog/public/images/'"/>
<v:variable name="custom_img_loc" type="varchar" default="null"/>
<v:variable name="last_date" type="date" default="null" persist="temp"/>
<v:variable name="score_ratio" type="float" default="1" />
<v:variable name="s_tag_is_qry" type="int" default="0" param-name="tag-is-qry"/>
<v:variable name="blog_iri" type="varchar" default="null" persist="temp" />
<v:variable name="chost" type="varchar" default="''"/> <!-- CNAME of the host -->
<v:variable name="owner_name" type="varchar" default="null" persist="temp" />
<v:variable name="inst_name" type="varchar" default="null"/>
<v:before-render>
<![CDATA[
if (length (self.sid) and BLOG.DBA.IS_REGULAR_FEED ())
{
declare vars any;
vars := coalesce ((select deserialize (blob_to_string(VS_STATE)) from VSPX_SESSION where VS_SID = self.sid), NULL);
--dbg_obj_print ('connection_vars_set', self.sid);
connection_vars_set (vars);
connection_set('uid', connection_get('vspx_user'));
}
]]>
</v:before-render>
<v:on-init>
<![CDATA[
declare refr, ht, pars any;
set isolation = 'committed';
set http_charset='utf-8';
declare _cookie_vec any;
_cookie_vec := vsp_ua_get_cookie_vec(lines);
self.sid := coalesce(get_keyword('sid', params), get_keyword('sid', _cookie_vec));
self.realm := get_keyword('realm', params, 'wa');
self.chost := wa_cname ();
refr := http_request_header (lines, 'Referer');
if (refr <> 0)
{
ht := WS.WS.PARSE_URI (refr);
if (not e.ve_is_post)
self.refpage := ht[2];
pars := split_and_decode (ht[4]);
if (not isarray (pars))
pars := vector ();
self.backlink := get_keyword ('page', pars, 'index');
}
whenever not found goto nfi;
select BI_TITLE,
BI_HOME,
BI_P_HOME,
coalesce(BI_COPYRIGHTS,''),
coalesce(BI_DISCLAIMER,''),
coalesce(BI_ABOUT, ''),
coalesce (BI_E_MAIL, U_E_MAIL),
deserialize (blob_to_string (BI_OPTIONS)),
BI_OWNER,
BI_KEYWORDS,
U_FULL_NAME,
BI_FILTER,
BI_HAVE_COMUNITY_BLOG,
U_NAME,
BI_WAI_NAME
into
self.title,
self.home,
self.phome,
self.copy,
self.disc,
self.about,
self.email,
self.opts,
self.owner,
self.kwds,
self.author,
self.filt,
self.have_comunity_blog,
self.owner_name,
self.inst_name
from BLOG.DBA.SYS_BLOG_INFO, DB.DBA.SYS_USERS
where BI_BLOG_ID = self.blogid and U_ID = BI_OWNER
with (prefetch 1);
goto runit;
nfi:;
signal ('22023', 'The selected blog does not exist');
runit:;
if (self.opts is null)
self.opts := vector ();
if (self.ds_data is null)
{
self.ds_data := vector ();
self.ds_meta := vector ();
self.qt.ufl_value := self.qtype;
}
self.atomver := get_keyword ('AtomFeedVer', self.opts, '0.3');
self.blog_iri := sprintf ('http://%s/dataspace/%U/weblog/%U', self.chost, self.owner_name, self.inst_name);
if (ODS.DBA.search_do_rdf (self.qry, null, self.vc_event.ve_lines, 100, self.blog_iri))
{
self.vc_enabled := 0;
return;
}
]]>
</v:on-init>
<v:after-data-bind>
<![CDATA[
if (self.qry is null)
return;
self.expr.ufl_value := self.qry;
self.qt.ufl_value := self.qtype;
if (not e.ve_is_post)
self.do_search (e);
]]>
</v:after-data-bind>
<v:method name="enable_it" arglist="in what varchar, in flag int">
<![CDATA[
declare rc int;
if ((self.qry is null and self.qt.ufl_value = what) or (self.qry is not null and self.qtype = what))
rc := flag;
else if (self.qry is null and self.qt.ufl_value is null
and get_keyword ('type', self.vc_event.ve_params) = what)
rc := flag;
else
rc := case when flag then 0 else 1 end;
return rc;
]]>
</v:method>
<v:method name="score_to_length" arglist="in s numeric">
<![CDATA[
s := s * self.score_ratio;
if (s > 300)
return 300;
if (s < 0)
return 0;
return s;
]]>
</v:method>
<v:method name="do_search" arglist="inout e vspx_event">
<![CDATA[
declare xmldoc, ses, arr, res, qes, ftcond, tag_qry any;
declare i, l, max1 int;
declare url any;
declare inx, s_off, e_off int;
declare d1, d2, cats, tags, qry, stat, msg, dta, mdta, h, pars, dexp, catw, atb, twhere any;
tag_qry := null;
max1 := atoi (self.maxhit.ufl_value);
s_off := (self.pageno - 1) * self.rowcnt;
if (self.start_offset is not null and isinteger (self.start_offset) and self.start_offset > 0)
s_off := self.start_offset - 1;
e_off := s_off + self.rowcnt;
declare exit handler for sqlstate '*'
{
self.vc_is_valid := 0;
self.vc_error_message := __SQL_MESSAGE;
return;
};
if (self.sqry is not null)
{
d1 := self.d_before;
d2 := self.d_after;
catw := self.s_cat;
tags := self.s_tag;
if (d1 is not null)
self.upar := self.upar||sprintf ('&from=%d-%d-%d', year (d1), month (d1), dayofmonth (d1));
if (d2 is not null)
self.upar := self.upar||sprintf ('&to=%d-%d-%d', year (d2), month (d2), dayofmonth (d2));
}
else
{
d1 := null;
d2 := null;
catw := trim (self.catw.ufl_value);
tags := trim (self.tagw.ufl_value);
}
if (length (self.dataad.ufl_value))
{
declare exit handler for sqlstate '22007'
{
self.vc_is_valid := 0;
self.vc_error_message := 'Please specify correct date for date before.';
return;
};
d1 := stringdate (self.dataay.ufl_value||'-'||self.dataam.ufl_value||'-'||self.dataad.ufl_value);
self.upar := self.upar||sprintf ('&from=%s-%s-%s',self.dataay.ufl_value,self.dataam.ufl_value, self.dataad.ufl_value);
}
if (length (self.databd.ufl_value))
{
declare exit handler for sqlstate '22007'
{
self.vc_is_valid := 0;
self.vc_error_message := 'Please specify correct date for date after.';
return;
};
d2 := stringdate (self.databy.ufl_value||'-'||self.databm.ufl_value||'-'||self.databd.ufl_value);
self.upar := self.upar||sprintf ('&to=%s-%s-%s',self.databy.ufl_value,self.databm.ufl_value, self.databd.ufl_value);
}
if (length (catw))
self.upar := self.upar||sprintf ('&cat=%U',catw);
if (length (tags))
self.upar := self.upar||sprintf ('&tags=%U',tags);
self.ds_data := vector ();
if (length (self.expr.ufl_value) < 2 and 0 = length (catw) and 0 = length (tags) and d1 is null and d2 is null and self.postid is null)
{
self.expr.vc_error_message := 'No expression entered';
self.vc_is_valid := 0;
return;
}
res := vector ();
if (self.qt.ufl_value = 'text' or length (self.expr.ufl_value) = 0)
{
declare str varchar;
declare vt, war, word2 any;
self.qt.ufl_value := 'text';
self.hit_words := vector ();
pars := vector (self.blog_iri, self.blogid, self.blogid);
ftcond := '';
if (length (self.expr.ufl_value))
{
vt := vt_batch ();
vt_batch_feed (vt, self.expr.ufl_value, 0, 0, 'x-any');
war := vt_batch_strings_array (vt);
foreach (any word1 in war) do
{
if (isstring (word1) and word1 not in ('AND','NOT','NEAR','OR') and not vt_is_noise (word1, 'utf-8', 'x-any'))
self.hit_words := vector_concat (self.hit_words, vector (word1));
}
if (length (self.hit_words) > 9)
self.hit_words := subseq (self.hit_words, 0, 9);
str := FTI_MAKE_SEARCH_STRING (self.expr.ufl_value);
{
declare exit handler for sqlstate '*'
{
self.vc_is_valid := 0;
self.vc_error_message := 'Invalid keyword string entered';
return;
};
vt_parse ('[__lang \'x-ViDoc\' __enc \'UTF-8\'] ' || str);
}
ftcond := ' and contains (B_CONTENT, ?) ';
pars := vector_concat (pars, vector (
concat (
'[__lang \'x-ViDoc\' __enc \'UTF-8\'] ',
str)
));
}
inx := 0;
dexp := '';
if (d1 is not null)
{
dexp := ' and B_TS >= ? ';
pars := vector_concat (pars, vector (d1));
}
if (d2 is not null)
{
dexp := dexp || ' and B_TS <= ? ';
pars := vector_concat (pars, vector (d2));
}
if (length (catw))
{
dexp := dexp || ' and exists (select 1 from BLOG..MTYPE_BLOG_CATEGORY, BLOG..MTYPE_CATEGORIES
where MTB_CID = MTC_ID and MTC_BLOG_ID = MTB_BLOG_ID and MTB_POST_ID = B_POST_ID and
strcasestr (MTC_NAME, ?) is not null)';
pars := vector_concat (pars, vector (catw));
}
if (length (self.postid))
{
dexp := dexp || ' and B_POST_ID = ? ';
pars := vector_concat (pars, vector (self.postid));
}
atb := '';
twhere := '';
if (length (tags))
{
declare blog_cond any;
if (self.have_comunity_blog is null or self.have_comunity_blog = 0)
blog_cond := 'and b'||replace(self.blogid, '-', '_');
else
blog_cond := '';
if (self.s_tag_is_qry)
tag_qry := tags;
else
tag_qry := FTI_MAKE_SEARCH_STRING (tags);
atb := ' BLOG..BLOG_TAG a, ';
twhere := sprintf (' contains (BT_TAGS, ''[__lang "x-ViDoc"] %s %s'', offband, BT_POST_ID) and BT_POST_ID = B_POST_ID and BT_BLOG_ID = BA_C_BLOG_ID and ', tag_qry, blog_cond);
}
qry := 'select top 1000 NULL, concat (?,\'/\', B_POST_ID), B_TITLE,
B_USER_ID, B_TS, B_MODIFIED, ' || case when ftcond = '' then '0' else 'b.SCORE' end || ', B_POST_ID, B_VER
from ' || atb || ' BLOG..SYS_BLOGS b,
(select BI_BLOG_ID as BA_C_BLOG_ID, BI_BLOG_ID as BA_M_BLOG_ID
from BLOG..SYS_BLOG_INFO where BI_BLOG_ID = ? union all
select * from (select BA_C_BLOG_ID, BA_M_BLOG_ID
from BLOG.DBA.SYS_BLOG_ATTACHES where BA_M_BLOG_ID = ?) name1) name2
where ' || twhere || 'B_BLOG_ID = BA_C_BLOG_ID ' || ftcond || dexp || '
order by ';
if (self.date_ord.ufl_selected or ftcond = '')
{
qry := qry || ' b.B_TS ' || case when self.ord_type.ufl_selected = 0 then 'asc' else 'desc' end;
self.date_ord.ufl_selected := 1;
}
else
{
qry := qry || ' b.SCORE desc'; --|| case when self.ord_type.ufl_selected = 0 then 'asc' else 'desc' end;
}
--dbg_obj_print (qry, pars);
stat := '00000';
exec (qry, stat, msg, pars, 0, null, null, h);
if (stat <> '00000')
signal (stat, msg);
while (0 = exec_next (h, null, null, dta))
{
if (not self.osrch)
goto addit;
if (inx >= e_off)
;
else if (inx >= s_off)
{
addit:
res := vector_concat (res, vector (dta));
}
inx := inx + 1;
}
exec_close (h);
self.total := inx;
goto retres1;
}
if (self.qt.ufl_value not in ('xpath', 'xquery'))
{
self.vc_is_valid := 0;
self.vc_error_message := 'Invalid query type.';
return;
}
if (get_keyword ('XtendedSearchMax', self.opts, -1) > 0 and max1 > get_keyword ('XtendedSearchMax', self.opts, -1))
{
self.maxhit.vc_error_message := 'Maximum results setting is too large (must be <' ||
cast(get_keyword ('XtendedSearchMax', self.opts, -1) as varchar) || ')';
self.vc_is_valid := 0;
return;
}
inx := 0;
qry := sprintf ('select B_CONTENT, B_TITLE, B_POST_ID, B_USER_ID, B_TS, B_MODIFIED
from BLOG..SYS_BLOGS, (select BI_BLOG_ID as BA_C_BLOG_ID, BI_BLOG_ID as BA_M_BLOG_ID from BLOG..SYS_BLOG_INFO where BI_BLOG_ID = ? union all select * from (select BA_C_BLOG_ID, BA_M_BLOG_ID from BLOG.DBA.SYS_BLOG_ATTACHES where BA_M_BLOG_ID = ?) name1) name2 where B_BLOG_ID = BA_C_BLOG_ID');
pars := vector (self.blogid, self.blogid);
dexp := '';
if (d1 is not null)
{
dexp := ' and B_TS >= ? ';
pars := vector_concat (pars, vector (d1));
}
if (d2 is not null)
{
dexp := dexp || ' and B_TS <= ? ';
pars := vector_concat (pars, vector (d2));
}
if (length (catw))
{
dexp := dexp || ' and exists (select 1 from BLOG..MTYPE_BLOG_CATEGORY, BLOG..MTYPE_CATEGORIES
where MTB_CID = MTC_ID and MTC_BLOG_ID = MTB_BLOG_ID and MTB_POST_ID = B_POST_ID and
strcasestr (MTC_NAME, ?) is not null)';
pars := vector_concat (pars, vector (catw));
}
qry := qry || dexp;
if (self.date_ord.ufl_selected)
{
qry := qry || ' order by B_TS ' || case when self.ord_type.ufl_selected = 0 then 'asc' else 'desc' end;
self.date_ord.ufl_selected := 1;
}
exec (qry, stat, msg, pars, 0, null, null, h);
if (isstring (stat) and stat <> '00000')
signal (stat, msg);
while (0 = exec_next (h, null, null, dta))
{
declare xp, postid, modified, posted, userid, title any;
xp := xtree_doc (dta[0], 2, '', 'UTF-8');
title := dta[1];
postid := dta[2];
userid := dta[3];
posted := dta[4];
modified := dta[5];
url := concat (self.home,'?id=',postid);
declare exit handler for sqlstate '42000'
{
self.vc_is_valid := 0;
self.vc_error_message := 'The query path or query document referenced in this query is non existent.';
return;
};
declare exit handler for sqlstate '37000'
{
self.vc_is_valid := 0;
self.vc_error_message := 'Invalid query expression.';
return;
};
if (self.qt.ufl_value = 'xpath')
arr := xpath_eval (self.expr.ufl_value, xp, 0);
else if (self.qt.ufl_value = 'xquery')
{
arr := xquery_eval (self.expr.ufl_value, xp);
if (isentity (arr))
arr := vector (arr);
}
if (isarray(arr))
{
i := 0;
l := length (arr);
while (i < l)
{
if (not isinteger (arr[i]))
{
if (not self.osrch)
goto addit1;
if (inx >= e_off)
;
else if (inx >= s_off)
{
addit1:
res := vector_concat (res, vector (vector (serialize_to_UTF8_xml (arr[i]),
url, title, userid, posted, modified, 0, postid)));
}
max1 := max1 - 1;
inx := inx + 1;
self.total := inx;
if (max1 <= 0)
{
goto retres;
}
}
i := i + 1;
}
}
nextr:;
}
retres:
exec_close (h);
retres1:
--if (self.output1.ufl_value in ('xml', 'rdf' , 'atom', 'xbel'))
-- self.output := self.output1.ufl_value;
qes := string_output ();
http_escape (self.expr.ufl_value, 8, qes);
qes := string_output_string (qes);
self.qurl := sprintf ('/weblog/public/search.vspx?blogid=%s&q=%s&type=%s%s&output=', self.blogid, qes, self.qt.ufl_value, self.upar);
if (BLOG.DBA.IS_REGULAR_FEED ())
{
self.gurl := sprintf ('/GData/%U/', self.blogid);
if (length (tag_qry))
{
declare arr, ses, tag_str any;
ses := string_output ();
arr := vt_parse (tag_qry);
self.gdata_cat_str (arr, ses);
tag_str := string_output_string (ses);
self.gurl := self.gurl || '-' || tag_str;
}
if (length (self.expr.ufl_value))
{
self.gurl := self.gurl || sprintf ('?q=%s', qes);
}
}
else
{
self.gurl := connection_get ('GData_URI');
}
self.ds_data := res;
if (self.output in ('xml' , 'rdf' , 'atom', 'xbel'))
return;
if (self.qt.ufl_value = 'text')
{
self.dst.vc_enabled := 1;
self.dst.vc_data_bind (e);
self.dst.vc_enabled := 1;
}
else
{
self.ds.vc_enabled := 1;
self.ds.vc_data_bind (e);
self.ds.vc_enabled := 1;
}
return;
]]>
</v:method>
<!-- the fti_make_search_string make ANDs -->
<v:method name="gdata_cat_str" arglist="inout arr any, inout ses any"><![CDATA[
if (isarray (arr) and length (arr) = 3 and arr[0] = 1)
{
http ('/', ses);
http (arr[2], ses);
return;
}
else if (not isarray (arr))
{
return;
}
foreach (any elm in arr) do
{
self.gdata_cat_str (elm, ses);
}
return;
]]></v:method>
<body>
<script type="text/javascript">
function show_hide_order (f, fl)
{
var o = f['ord_type'];
if (fl.checked == true)
o.disabled = false;
else
o.disabled = true;
}
</script>
<v:form name="form1" type="simple" method="POST">
<v:on-post>
<![CDATA[
declare tab vspx_tab;
declare tmpl vspx_control;
tab := self.help1;
tmpl := tab.vc_find_control(self.qt.ufl_value||'_help');
tab.tb_active := tmpl;
if (e.ve_button = control)
{
self.expr.ufl_value := '';
self.ds_data := vector ();
self.ds.ds_rows_offs := 0;
self.ds.vc_enabled := 0;
self.dst.vc_enabled := 0;
}
]]>
</v:on-post>
<ods:ods-bar app_type="WEBLOG2"/>
<table id="pagecontainer" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td colspan="3">
<table id="header" cellpadding="0" cellspacing="0">
<tr>
<td>
<h1>
<v:url name="tit1" value="--self.title" url="--self.home" xhtml_class="title_link"/>
</h1>
</td>
<td class="right">
</td>
</tr>
<tr>
<td>
<h2>
<v:label name="tit2" value="Advanced Search (XQuery, XPath, Free Text)"/>
</h2>
</td>
<td class="right">
</td>
</tr>
</table>
<div id="navbartop">
<div> </div>
</div>
</td>
</tr>
<tr>
<v:template name="leftt" type="simple" enabled="--case when self.sqry is null then 1 else 0 end">
<td class="box" id="left">
<div class="box">
<h2>Query Type</h2>
<div class="roll">
<v:select-list name="qt" auto-submit="1">
<v:item name="Text" value="text"/>
<v:item name="XPath" value="xpath"/>
<v:item name="XQuery" value="xquery"/>
<v:after-data-bind>
<![CDATA[
if (not get_keyword ('EnableXtendedSearch',self.opts, 1))
{
control.vsl_items := vector ('Text');
control.vsl_item_values := vector ('text');
}
]]>
</v:after-data-bind>
</v:select-list>
</div>
<!--h2>Results As</h2>
<div class="roll">
<v:select-list name="output1">
<v:item name="HTML" value="html"/>
<v:item name="XML - RSS 2.0" value="xml"/>
<v:item name="XML - Atom" value="atom"/>
<v:item name="XML - RDF" value="rdf"/>
<v:item name="XML - XBEL" value="xbel"/>
</v:select-list>
</div-->
<h2>Example</h2>
<div class="roll">
<v:tab name="help1" initial-active="text_help">
<v:template name="text_help" type="simple">
To perform Full-Text search,<br/>
enter a word or phrase:<br/>
<b>ODBC DRIVER</b><br/>
or<br/>
<b>"exact phrase"</b>
</v:template>
<v:template name="xpath_help" type="simple">
<v:select-list name="xp" xhtml_onchange="javascript: document.form1.expr.value = this.value">
<v:item value="" name="* select an example *"/>
<v:item value="//p[a]" name="paragraph with link(s)"/>
<v:item value="//p[contains(.,\'Virtuoso\')]" name="about Virtuoso"/>
<v:item value="//a[@href]/@href" name="link targets"/>
<v:item value="//a/text()" name="link titles"/>
<v:item value="//a[@name or @id]" name="link references"/>
<v:item value="//b" name="text in bold"/>
<v:item value="//i" name="text in italic"/>
<v:item value="//p[b or i or u or s or small or big]/*" name="formatting"/>
<v:item value="//p[b or i or u or s or small or big]/ancestor::*" name="section with formatting"/>
<v:item value="//*[@class]" name="css formatted sections"/>
<v:item value="//table[.//tr/td]" name="tables"/>
<v:item value="//img[@src]" name="images"/>
<v:item value="//p[img[@src]]" name="sections with images"/>
<v:item value="//p[a/@href[contains(.,\'.xml\')]]" name="about XML"/>
</v:select-list>
</v:template>
<v:template name="xquery_help" type="simple">
<v:select-list name="xq" xhtml_onchange="javascript: document.form1.expr.value = this.value">
<v:item value="" name="* select an example *"/>
<v:item value="for $i in node()//table return $i" name="all tables"/>
<v:item value="for $t in node()//table return <ul> {for $i in $t//tr return <li>{$i/td/text()}</li> }</ul>" name="table to list"/>
<v:item value="for $i in node()//a return <p>{ string($i/@href) }</p>" name="list of links"/>
<v:item value="for $i in node() return <p>{ .//text() }</p>" name="text nodes"/>
<v:item value="for $i in node()//p[contains(.,\'Virtuoso\')] return <p>{ string($i) }</p>" name="about Virtuoso"/>
</v:select-list>
</v:template>
</v:tab>
</div>
<div class="roll">
<v:url name="home1" value="Back" url="--sprintf('%sindex.vspx?page=%s&sid=%s&realm=%s', self.home, self.backlink, self.sid, self.realm)"/>
</div>
</div>
</td>
</v:template>
<td id="texttd">
<?vsp if (self.refpage = '/weblog/public/search.vspx') { ?>
<div>
<a href="javascript: void(0)" value="Close" onclick="if (opener != null) { opener.focus (); window.close() }"><img src="/weblog/public/images/close_16.gif" hspace="1" border="0" />Close</a>
</div>
<?vsp } ?>
<div id="text">
<v:template name="sboxt" type="simple" enabled="--case when self.sqry is null then 1 else 0 end">
<h1>Search Expression</h1>
<div id="error_left"><v:error-summary /></div>
<table class="formdata">
<tr>
<td colspan="2">
<div>
<v:textarea name="expr" value="" xhtml_rows="15" xhtml_cols="70" error-glyph="*">
<v:before-render>
control.ufl_value := charset_recode (control.ufl_value, 'UTF-8', '_WIDE_');
</v:before-render>
</v:textarea>
</div>
</td>
</tr>
<tr>
<td><label for="catw">Category has word(s)</label></td>
<td>
<v:text name="catw" xhtml_id="catw" value="" xhtml_size="20" xhtml_class="textbox" />
</td>
</tr>
<tr>
<td><label for="tagw">With tags</label></td>
<td>
<v:text name="tagw" xhtml_id="tagw" value="" xhtml_size="20" xhtml_class="textbox" />
</td>
</tr>
<tr>
<td><label for="dataad">Date after</label></td>
<td>
<v:text name="dataad" value="" xhtml_size="2" xhtml_class="textbox" xhtml_id="dataad"/>.
<v:text name="dataam" value="" xhtml_size="2" xhtml_class="textbox" />.
<v:text name="dataay" value="" xhtml_size="4" xhtml_class="textbox" /> (DD-MM-YYYY)
</td>
</tr>
<tr>
<td><label for="databd">Date before</label></td>
<td>
<v:text name="databd" value="" xhtml_size="2" xhtml_class="textbox" xhtml_id="databd" />.
<v:text name="databm" value="" xhtml_size="2" xhtml_class="textbox" />.
<v:text name="databy" value="" xhtml_size="4" xhtml_class="textbox" /> (DD-MM-YYYY)
</td>
</tr>
<v:template type="simple">
<tr>
<td colspan="2">
<div><label for="maxhit">Max results</label>
<v:text name="maxhit" default_value="100" xhtml_size="5" error-glyph="*" xhtml_id="maxhit">
<v:validator name="vvnum1" test="regexp" regexp="^[0-9]+$" message="Only digits are allowed for setting "Max results"" runat="client"/>
</v:text>
</div>
</td>
</tr>
<v:before-render>
<![CDATA[
control.vc_enabled := case when self.qt.ufl_value = 'text' or self.qt.ufl_value is null then 0 else 1 end;
]]>
</v:before-render>
</v:template>
<tr>
<td colspan="2">
<v:check-box name="date_ord" value="1" xhtml_id="date_ord" xhtml_onclick="javascript: show_hide_order (this.form, this)">
<v:before-render>
if (length (self.expr.ufl_value) = 0
and (length (self.catw.ufl_value) or length (self.tagw.ufl_value)
or length (self.databd.ufl_value) or length (self.dataad.ufl_value)
))
control.ufl_selected := 1;
</v:before-render>
</v:check-box>
<label for="date_ord">Order by date</label></td>
</tr>
<tr>
<td colspan="2">
<v:check-box name="ord_type" value="1" xhtml_id="ord_type" initial-checked="1">
<v:before-render>
if (self.date_ord.ufl_selected = 0)
control.vc_add_attribute ('disabled', '1');
</v:before-render>
</v:check-box>
<label for="ord_type">Newest first</label></td>
</tr>
<tr>
<td COLSPAN="2">
<v:button xhtml_class="real_button" action="simple" name="post" value="Execute" xhtml_title="Execute" xhtml_alt="Execute">
<v:on-post>
<![CDATA[
self.ds.vc_reset ();
self.dst.vc_reset ();
self.do_search (e);
]]>
</v:on-post>
</v:button>
</td>
</tr>
<tr>
<td colspan="2">
<?vsp
if (length (self.ds_data))
{
?>
<a href="<?V self.qurl ?>html" target="_blank"><img src="/weblog/public/images/html401.gif" border="0" title="HTML" alt="HTML"/></a>
<a href="<?V self.qurl ?>xml" target="_blank"><img src="/weblog/public/images/rss-icon-16.gif" border="0" title="RSS" alt="RSS" hspace="3"/>RSS v2.0</a>
<a href="<?V self.qurl ?>atom" target="_blank"><img src="/weblog/public/images/atom-icon-16.gif" border="0" title="ATOM" alt="ATOM" hspace="3"/>Atom 1.0</a>
<a href="<?V self.qurl ?>rdf" target="_blank"><img src="/weblog/public/images/rdf-icon-16.gif" border="0" title="RDF" alt="RDF" hspace="3"/>RDF</a>
<a href="<?V self.qurl ?>xbel" target="_blank"><img src="/weblog/public/images/blue-icon-16.gif" border="0" title="XBEL" alt="XBEL" hspace="3"/>XBEL</a>
<a href="<?V sprintf ('search.vspx?blogid=%U&type=%s&kwds=%U&OpenSearch', self.blogid, self.qt.ufl_value, coalesce (self.expr.ufl_value, self.qry)) ?>" target="_blank"><img src="/weblog/public/images/blue-icon-16.gif" border="0" hspace="3"/>OpenSearch</a>
<a href="<?V self.gurl ?>" target="_blank"><img src="/weblog/public/images/blue-icon-16.gif" border="0" title="GData" alt="GData" hspace="3"/>GData</a>
<?vsp
}
?>
</td>
</tr>
</table>
</v:template>
<h2>Results
<v:label name="ct1" value="--length (self.ds_data)" format=" (%d)" render-only="1"/>
<v:template name="rest" type="simple" condition="length (self.sqry)">
from search by "<?V BLOG..blog_utf2wide(self.qry) ?>" <br />
<a href="<?V self.qurl ?>xml"><img src="/weblog/public/images/rss-icon-16.gif" border="0" hspace="3"/>RSS 2.0</a>
<a href="<?V self.qurl ?>atom"><img src="/weblog/public/images/atom-icon-16.gif" border="0" hspace="3"/>Atom 1.0</a>
<a href="<?V self.qurl ?>rdf"><img src="/weblog/public/images/rdf-icon-16.gif" border="0" hspace="3"/>RDF</a>
<a href="<?V self.qurl ?>xbel"><img src="/weblog/public/images/blue-icon-16.gif" border="0" title="XBEL" alt="XBEL" hspace="3"/>XBEL</a>
<a href="<?V sprintf ('search.vspx?blogid=%U&type=%s&kwds=%U&OpenSearch', self.blogid, self.qt.ufl_value, coalesce (self.expr.ufl_value, self.qry)) ?>"><img src="/weblog/public/images/blue-icon-16.gif" border="0" hspace="3"/>OpenSearch</a>
</v:template>
</h2>
<br />
<v:data-set name="ds" data="--self.ds_data" meta="--self.ds_meta" nrows="10" scrollable="1" instantiate="--self.enable_it ('text', 0)">
<v:template name="tmpl1" type="repeat">
<v:template name="tmpl7" type="if-not-exists">
<div class="message">No matches found</div>
</v:template>
<v:template name="tmpl4" type="browse">
<div class="message">
<div>
<span class="message_title">
<v:url name="l6" value="--(control.vc_parent as vspx_row_template).te_rowset[2]" url="--(control.vc_parent as vspx_row_template).te_rowset[1]" render-only="1" format="%s" is-local="1"/>
<?vsp
if (self.sid is not null and self.realm is not null)
{
?>
<v:url name="l7" value="[Edit]" url="--concat(self.home, 'index.vspx?page=edit_post&', 'editid=', (control.vc_parent as vspx_row_template).te_rowset[7])" render-only="0">
</v:url>
<v:url name="l8" value="[Log]" url="--concat(self.home, 'index.vspx?page=routing_queue&', 'post_id=', (control.vc_parent as vspx_row_template).te_rowset[7])" render-only="0">
</v:url>
<?vsp
}
?>
</span>
<v:label value="" format="%s">
<v:before-render>
<![CDATA[
set isolation = 'uncommitted';
declare tit, author, ref1, email, a_name any;
author := '';
ref1 := '';
whenever not found goto nfuser;
select U_FULL_NAME, BI_E_MAIL, BI_HOME, U_NAME into author, email, ref1, a_name
from BLOG.DBA.SYS_BLOG_INFO, SYS_USERS where
BI_OWNER = (control.vc_parent as vspx_row_template).te_rowset[3]
and U_ID = BI_OWNER;
if (author = '' or author is null)
author := email;
if (self.have_comunity_blog and length (self.sid))
{
declare url vspx_url;
url := control.vc_parent.vc_find_control ('l7');
url.vu_url := replace (url.vu_url, self.home, ref1);
if (a_name <> coalesce (connection_get ('vspx_user'), ''))
{
url.vc_enabled := 0;
}
}
nfuser:
if (length (self.sid))
{
ref1 := ref1 || sprintf ('?sid=%U&realm=%U', self.sid, self.realm);
}
if (author <> '')
control.ufl_value := ' [<a href="' || ref1 || '">' || sprintf('%s', author) || '</a>]';
else
control.ufl_value := '';
]]>
</v:before-render>
</v:label>
<img src="/weblog/public/images/score.gif" height="5" width="<?V self.score_to_length (control.te_rowset[6]) ?>" />
</div>
<div class="desc">
<?vsp
http (control.te_rowset[0]);
?>
</div>
<div class="pubdate">posted on
<v:label value="--BLOG..blog_date_fmt ((control.vc_parent as vspx_row_template).te_rowset[4])" format="%s" render-only="1"/>
<v:label value="--BLOG..blog_date_fmt ((control.vc_parent as vspx_row_template).te_rowset[5])"
format=', modified on <span class="modified">%s</span>'
enabled="--datediff('second', (control.vc_parent as vspx_row_template).te_rowset[4], (control.vc_parent as vspx_row_template).te_rowset[5])"/>
</div>
</div>
</v:template>
</v:template>
<v:template name="tmpl3" type="simple">
<div align="center">
<vm:ds-navigation data-set="ds"/>
</div>
</v:template>
</v:data-set>
<table class="search_result">
<v:data-set name="dst" data="--self.ds_data"
meta="--self.ds_meta"
nrows="10" scrollable="1" instantiate="--self.enable_it ('text', 1)">
<v:before-render><![CDATA[
declare _max int;
declare len any;
len := length (self.ds_data);
_max := 0;
if (len > 0)
{
if (self.date_ord.ufl_selected)
{
declare data any;
data := self.ds_data;
foreach (any d in data) do
{
if (d[6] > _max)
_max := d[6];
}
}
else
{
_max := self.ds_data[0][6];
}
}
if (_max > 300)
{
self.score_ratio := cast ( ( 300.0 / _max ) as float);
}
]]></v:before-render>
<v:template name="tmplth1" type="simple">
<tr class="search_result_header">
<th>No</th>
<th>Title</th>
<?vsp if (self.have_comunity_blog) { ?>
<th>Author</th>
<?vsp } ?>
<th>Score</th>
</tr>
</v:template>
<v:template name="tmplt1" type="repeat">
<v:template name="tmplt7" type="if-not-exists">
<tr><td class="message" colspan="4">No matches found</td></tr>
</v:template>
<v:template name="tmplt4" type="browse">
<?vsp
declare curt any;
curt := control.te_rowset[4];
if (self.date_ord.ufl_selected and (self.last_date is null or BLOG..not_same_month (self.last_date, curt)))
{
self.last_date := curt;
http (sprintf ('<tr><td class="date_separator" colspan="3">%s, %d</td></tr>',
monthname (curt), year (curt)));
}
?>
<tr>
<td>
<v:label render-only="1" name="clt1" value="--(control.vc_parent as vspx_row_template).te_ctr+ self.dst.ds_rows_offs + 1" format="%d."/>
</td>
<td>
<v:url name="lt6" value="--BLOG..blog_utf2wide ((control.vc_parent as vspx_row_template).te_rowset[2])"
url="--(control.vc_parent as vspx_row_template).te_rowset[1]" render-only="1" is-local="1"/>
<?vsp
if (self.sid is not null and self.realm is not null)
{
?>
<v:url name="l27" value="[Edit]" url="--concat(self.home, 'index.vspx?page=edit_post&', 'editid=', (control.vc_parent as vspx_row_template).te_rowset[7])" render-only="0">
</v:url>
<v:url name="l28" value="[Log]" url="--concat(self.home, 'index.vspx?page=routing_queue&', 'post_id=', (control.vc_parent as vspx_row_template).te_rowset[7])" render-only="0">
</v:url>
<?vsp
}
?>
</td>
<?vsp if (self.have_comunity_blog) { ?>
<td>
<v:label value="" format="%s">
<v:before-render>
<![CDATA[
set isolation = 'uncommitted';
declare tit, author, ref1, email, a_name any;
author := ''; ref1 := '';
whenever not found goto nfuser;
select U_FULL_NAME, BI_E_MAIL, BI_HOME, U_NAME into author, email, ref1, a_name
from BLOG.DBA.SYS_BLOG_INFO, SYS_USERS where
BI_OWNER = (control.vc_parent as vspx_row_template).te_rowset[3]
and U_ID = BI_OWNER;
if (author = '' or author is null)
author := email;
if (self.have_comunity_blog and length (self.sid))
{
declare url vspx_url;
url := control.vc_parent.vc_find_control ('l27');
url.vu_url := replace (url.vu_url, self.home, ref1);
if (a_name <> coalesce (connection_get ('vspx_user'), ''))
{
url.vc_enabled := 0;
}
}
if (length (self.sid))
{
ref1 := ref1 || sprintf ('?sid=%U&realm=%U', self.sid, self.realm);
}
nfuser:
if (author <> '')
control.ufl_value := ' [<a href="' || ref1 || '">' || sprintf('%s', author) || '</a>]';
else
control.ufl_value := '';
]]>
</v:before-render>
</v:label>
</td>
<?vsp } ?>
<td>
<img src="/weblog/public/images/score.gif" height="5" width="<?V self.score_to_length (control.te_rowset[6]) ?>" xhtml_title="Score" xhtml_alt="Score"/>
</td>
</tr>
<tr>
<td colspan="<?V case when self.have_comunity_blog = 1 then 4 else 3 end ?>"><![CDATA[
<?vsp
if (length (self.hit_words) > 0)
{
declare post any;
post := (select blob_to_string (B_CONTENT) from BLOG..SYS_BLOGS where B_POST_ID = control.te_rowset[7]);
declare excerpt_samples any;
excerpt_samples := coalesce (search_excerpt (self.hit_words, post), '');
http (excerpt_samples);
}
?>]]>
</td>
</tr>
</v:template>
</v:template>
<v:template name="tmplt3" type="simple">
<tr>
<td colspan="<?V case when self.have_comunity_blog = 1 then 4 else 3 end ?>" align="center">
<?vsp
{
declare _prev, _next, _last, _first vspx_button;
declare d_prev, d_next, d_last, d_first, index_arr int;
d_prev := d_next := d_last := d_first := index_arr := 0;
_first := control.vc_find_control ('dst_first');
_last := control.vc_find_control ('dst_last');
_next := control.vc_find_control ('dst_next');
_prev := control.vc_find_control ('dst_prev');
if (_next is not null and not _next.vc_enabled and _prev is not null and not _prev.vc_enabled)
goto skipit;
index_arr := 1;
if (_next is not null and not _next.vc_enabled)
{
d_next := 1;
}
if (_prev is not null and not _prev.vc_enabled)
{
d_prev := 1;
}
skipit:;
?>
<?vsp
http(' ');
if (d_prev)
{
http ('<a href="#"><<</a>');
}
?>
<v:button name="dst_prev" action="simple" style="url" value="<<"
xhtml_alt="Previous" xhtml_title="Previous" text=" Previous">
</v:button>
<![CDATA[ ]]>
<![CDATA[ ]]>
<!-- an version of page numbering -->
<xsl:if test="not(@type) or @type = 'set'">
<v:text name="dst_offs" type="hidden" value="0" />
<?vsp
if (index_arr)
{
declare dsname, idx_offs, frm_name any;
declare frm vspx_control;
frm := control.vc_find_parent_form (control);
frm_name := '';
if (frm is not null)
frm_name := frm.vc_name;
-- this button is just to trigger the post, no render at all
if (0)
{
?>
<v:button name="dst_idx" action="simple" style="url" value="Submit">
<v:on-post><![CDATA[
declare ds vspx_data_set;
declare dss vspx_data_source;
declare offs int;
offs := atoi(get_keyword (replace (control.vc_name, '_idx', '_offs'), e.ve_params, '0'));
ds := control.vc_find_parent (control, 'vspx_data_set');
{
ds.ds_rows_offs := ds.ds_nrows * offs;
ds.vc_data_bind (e);
}
]]></v:on-post>
</v:button>
<?vsp
}
dsname := 'dst';
declare i, n, t, c, total_pages, to_page integer;
declare _class varchar;
declare dss vspx_data_source;
declare ds vspx_data_set;
ds := control.vc_parent;
dss := null;
i := 0;
-- rec. per page
n := ds.ds_nrows; -- 10
-- total rows
t := length (self.ds_data); -- ~1000
-- starting page no.
c := ds.ds_rows_offs / n; -- 0, 1, 2
--dbg_obj_print ('n=',n, ' t=',t,' c=', c);
total_pages := t/n;
if (c > 10)
i := c - 10;
to_page := c + 11;
if (to_page > total_pages)
to_page := total_pages;
while (t and i < to_page)
{
?>
| <a href="#" onclick="javascript: document.forms['<?V frm_name ?>'].<?V dsname ?>_offs.value = <?V i ?>; doPost ('<?V frm_name ?>', '<?V dsname ?>_idx'); return false"><?vsp http_value (i + 1, case when c = i then 'b' else null end); ?></a>
<?vsp
i := i + 1;
}
if (t and i > 0)
http (' | ');
}
?>
</xsl:if>
<![CDATA[ ]]>
<![CDATA[ ]]>
<?vsp
if (d_next)
{
http ('<a href="#">>></a>');
}
?>
<v:button name="dst_next" action="simple" style="url" value=">>"
xhtml_alt="Next" xhtml_title="Next" text=" Next">
</v:button>
<?vsp
}
?>
</td>
</tr>
</v:template>
</v:data-set>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="powered"><vm:powered-by/></div>
<div id="copy"><vm:copyright/></div>
<div id="disclaimer"><vm:disclaimer/></div>
</td>
</tr>
</table>
</v:form>
</body>
<?vsp<![CDATA[
if (self.output = 'xml' or self.output = 'rdf' or self.output = 'xbel' or self.output = 'atom')
{
declare dta any;
declare _u_f_name, _u_name, _u_e_mail varchar;
dta := self.ds_data;
http_rewrite ();
http_header ('Content-Type: text/xml; charset=UTF-8\r\n');
http ('<rss version="2.0" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:vi="http://www.openlinksw.com/weblog/">\r\n<channel>\r\n');
http ('<title>');
http (self.title);
http ('</title>');
http ('<link>');
if (BLOG.DBA.IS_REGULAR_FEED ())
{
http ('http://'); http(BLOG.DBA.BLOG_GET_HOST ()); http_value (self.qurl || 'html');
}
else
{
http (self.gurl);
}
http ('</link>');
http ('<pubDate>');
http_value (BLOG..date_rfc1123 (now ()));
http ('</pubDate>');
http ('<managingEditor>');
http_value (BLOG..blog_utf2wide (self.author));
http_value (sprintf ('<%s>', self.email));
http ('</managingEditor>');
http ('<description>About ');
http (trim(coalesce (self.qry, self.expr.ufl_value), ''' "'));
http ('</description>');
http (sprintf ('<openSearch:totalResults>%d</openSearch:totalResults>\r\n', self.total));
http (sprintf ('<openSearch:startIndex>%d</openSearch:startIndex>\r\n', ((self.pageno - 1)*self.rowcnt + 1)));
http (sprintf ('<openSearch:itemsPerPage>%d</openSearch:itemsPerPage>\r\n', self.rowcnt));
foreach (any elm in dta) do
{
http ('<item>');
if (self.details)
{
http ('<description>');
if (elm[0] is null)
{
declare post any;
post := (select blob_to_string (B_CONTENT) from BLOG..SYS_BLOGS where B_POST_ID = elm[7]);
http (sprintf ('<![%s[', 'CDATA'));
http (BLOG..BLOG2_POST_RENDER (post, self.filt));
http (']]' || '>');
}
else
http_value (elm[0]);
http ('</description>');
}
http ('<title>');
http_value (BLOG..blog_utf2wide(elm[2]));
http ('</title>');
http ('<link>');
if (elm[1] not like '%://%')
http (sprintf ('http://%s', BLOG.DBA.BLOG_GET_HOST ()));
http_value (elm[1]);
http ('</link>');
http ('<pubDate>');
http_value (BLOG..date_rfc1123 (elm[5]));
http ('</pubDate>');
if (length (elm) > 8)
{
http ('<vi:version>');
http_value (elm[8]);
http ('</vi:version>');
}
http ('<vi:modified>');
http_value (BLOG..date_iso8601 (elm[5]));
http ('</vi:modified>');
{
declare exit handler for not found;
select U_FULL_NAME, U_NAME, U_E_MAIL into _u_f_name, _u_name, _u_e_mail from SYS_USERS where U_ID = elm[3];
if (not length (_u_f_name))
_u_f_name := _u_name;
http ('<author>');
http (BLOG..blog_wide2utf (_u_f_name));
http (sprintf (' <%V>', _u_e_mail));
http ('</author>');
}
http ('</item>');
}
http ('</channel></rss>');
if (self.output = 'rdf')
http_xslt (BLOG..BLOG2_GET_PPATH_URL ('widgets/rss2rdf.xsl'));
else if (self.output = 'xbel')
http_xslt (BLOG..BLOG2_GET_PPATH_URL ('widgets/rss2xbel.xsl'));
else if (self.output = 'atom')
{
declare xsl any;
if (self.atomver = '1.0')
xsl := 'rss2atom.xsl';
else
xsl := 'rss2atom03.xsl';
--dbg_printf ('Atom_Self_URI=%s', connection_get ('Atom_Self_URI'));
http_xslt (BLOG..BLOG2_GET_PPATH_URL ('widgets/'||xsl), vector ('httpUrl', BLOG.DBA.GET_HTTP_URL (), 'isRegularFeed', BLOG.DBA.IS_REGULAR_FEED ()));
}
return;
}
if (self.opensearch is not null)
{
declare sho varchar;
if (not length (self.about))
self.about := self.title;
sho := regexp_match ('[[:alnum:]_]+', self.about);
http_header ('Content-Type: text/xml; charset=UTF-8\r\n');
declare host, title, about, copyr, home, name, descr, mail, author, discl, kwds, bid, welk, opts any;
bid := self.blogid;
welk := get_keyword ('WelcomeMessage', self.opts, '');
host := http_request_header (lines, 'Host');
if (self.pkwd is not null)
self.kwds := self.pkwd;
http_rewrite ();
http ('<?xml version="1.0" ?>'); ]]>
?><OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<Url type="text/html" template="http://<?V host ?>/weblog/public/search.vspx?blogid=<?V bid ?><?V sprintf ('&q={searchTerms}&cnt={count}&page={startPage}&type=%s', self.qt.ufl_value) ?>" />
<Url type="application/rss+xml" template="http://<?V host ?>/weblog/public/search.vspx?blogid=<?V bid ?><?V sprintf ('&q={searchTerms}&cnt={count}&page={startPage}&type=%s&output=xml', self.qt.ufl_value) ?>" />
<ShortName><?V sho ?></ShortName>
<LongName><?V BLOG..blog_utf2wide (self.title) ?></LongName>
<Description>About: <?V trim(self.kwds, ''' "') ?></Description>
<Tags><?V trim(self.kwds, ''' "') ?></Tags>
<Image height="16" width="16" type="image/png">http://<?V host ?>/ods/images/icons/ods_weblog_16.png</Image>
<Image height="64" width="64" type="image/gif">http://<?V host ?>/weblog/public/images/vbloglogo1.gif</Image>
<SampleSearch><?V self.kwds ?></SampleSearch>
<Developer><?V BLOG..blog_utf2wide (self.author) ?></Developer>
<Contact><?V self.email ?></Contact>
<Attribution><?V BLOG..blog_utf2wide (self.copy) ?></Attribution>
<SyndicationRight>open</SyndicationRight>
<AdultContent>false</AdultContent>
</OpenSearchDescription><?vsp
return;
}
?>
</html>
</v:page>
|