<?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="search" on-deadlock-retry="3" decor="wiki_decor.vspx" style="wiki_style.xsl" xmlns:v="http://www.openlinksw.com/vspx/" xmlns:vm="http://www.openlinksw.com/vspx/macro">
	<!--	<v:on-init>
	    set isolation='committed';
	</v:on-init> -->
	<vm:pagewrapper>
		<vm:variables>
			<v:variable name="url" type="varchar" default="null" persist="0"/>
			<v:variable name="search_word" type="varchar" default="'Wiki'" persist="0"/>
			<v:variable persist="temp" name="cnt" type="integer" default="0"/>
		</vm:variables>
		<vm:pagetitle>Search</vm:pagetitle>
		<vm:pagebody>
			<div class="wiki_search">
				<v:form name="search_form" type="simple" method="POST" action="/wikix/search.vspx">
					<v:before-data-bind>
						self.search_word := coalesce ({?'searchtext_t'}, self.searchtext.ufl_value);
					</v:before-data-bind>

					<div class="wiki_search_row">
						<span>
							<v:text name="searchtext" format="%s" value="--coalesce (self.searchtext.ufl_value, {?'searchtext_t'})"/>
						</span>
						<span>
							<v:button xhtml_class="button" action="simple" name="Search" value="Search Again">
								<v:on-post><![CDATA[
									self.search_word := self.searchtext.ufl_value;
									self.s_result.vc_data_bind (e);
								]]></v:on-post>
							</v:button>
						</span>
					</div>
				</v:form>
				<table class="wikitable">
					<v:template name="search_res_t1" type="simple">
						<v:data-set name="s_result" sql="select RES_ID, RES_NAME, length (RES_CONTENT) as RES_LEN, &quot;WV&quot;.&quot;Wiki&quot;.&quot;Date&quot; (RES_CR_TIME) as RES_CR_TIME_STR,RES_PERMS, RES_FULL_PATH
                            from WS.WS.SYS_DAV_RES
                            where
                             contains (RES_CONTENT, :search_word_param)
                             and RES_FULL_PATH like '/DAV/VAD/wiki/%.txt'" nrows="10" scrollable="1" edit="0" width="80%">
							<v:param name="search_word_param" value="self.search_word"/>
							<v:template name="pages_header" type="simple" name-to-remove="table" set-to-remove="bottom">
								<tr>
									<th align="left" width="20%">
										<v:label name="label1" value="Name" format="%s"/>
									</th>
									<th align="left" width="10%">
										<v:label name="label2" value="Size" format="%s"/>
									</th>
									<th align="left" width="10%">
										<v:label name="label3" value="Date" format="%s"/>
									</th>
								</tr>
							</v:template>
							<v:template name="pages_repeat" type="repeat" name-to-remove="" set-to-remove="">
						      	        <v:template name="no_rows" type="if-not-exists">
						                	<tr><td colspan="7">No files found</td></tr>
						        	</v:template>
								<v:template name="pages_browse" type="browse" name-to-remove="table" set-to-remove="both">
									<?vsp self.cnt := self.cnt + 1; ?>

									<tr>
										<td width="20%">
											<v:button xhtml_class="button" action="simple" name="link" style="url" value="--&quot;WV&quot;.&quot;Wiki&quot;.&quot;TopicName&quot; ((control.vc_parent as vspx_row_template).te_rowset[0])"/>
											<v:on-post><![CDATA[
										  declare _topic WV.WIKI.TOPICINFO;
										  _topic := WV.WIKI.TOPICINFO ();
										  _topic.ti_id := (select "TopicId" from WV.WIKI.TOPIC where "ResId" =(control as vspx_row_template).te_rowset[0]);
										  _topic.ti_find_metadata_by_id ();
											self.vc_redirect ('/wiki/' || _topic.ti_cluster_name || '/' || _topic.ti_local_name);
										]]></v:on-post>
										</td>
										<td width="10%">
											<v:label name="label6" value="--(control.vc_parent as
                           vspx_row_template).te_rowset[2]" format="%d"/>
										</td>
										<td width="10%">
											<v:label name="label7" value="--(control.vc_parent as
                           vspx_row_template).te_rowset[3]" format="%s"/>
										</td>
									</tr>
								</v:template>
							</v:template>
							<v:template name="pages_footer" type="simple" name-to-remove="table" set-to-remove="bottom">
							</v:template>

						</v:data-set>
					</v:template>
					<tr> <td> <?vsp http_value (self.cnt); ?> found </td> </tr>
				</table>
			</div>
		</vm:pagebody>
	</vm:pagewrapper>
</v:page>
