<?php echo "<?xml version='1.0'?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <style type="text/css">
    body  { font-family: arial; font-size: 12px; }
  </style>
 </head>
<body>


  <!-- STEP1: Load Record List (Paste this above other steps) -->
    <?php
      require_once "../lib/viewer_functions.php";
      $searchOptions = array();
      $searchOptions['keywords'] = @$FORM['q'];
      $searchOptions['perPage']  = "10";
      $searchOptions['debugSql'] = "0";

      $searchTables = array();
      $searchTables['news'] = array(
        'viewerUrl'       => 'newsPage.php',
        'titleField'      => 'title',
        'summaryField'    => 'summary',
        'searchFields'    =>  array('title','summary','content'),
      );

      $searchTables['quotes'] = array(
        'viewerUrl'       => 'quotesPage.php',
        'titleField'      => 'name',
        'summaryField'    => 'quote',
        'searchFields'    =>  array('name','pullQuote','quote'),
      );

      list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);
    ?>
  <!-- /STEP1: Load Record List -->

    <h1>Search Viewer</h1>

<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<input type="text" name="q" value="<?php echo htmlspecialchars(@$FORM['q']); ?>" size="50">
<input type="submit" name="" value="Search"><br/><br/>

<table border=0 cellpadding=2 cellspacing=0 width=100%>
 <tr>
  <td bgcolor="#EEEEEE"><font size=2 class="maintext">Search results for <b><?php echo htmlspecialchars(@$FORM['q']); ?></b></font></td>
  <td bgcolor="#EEEEEE" align="right"><font size=2 class="maintext">Results
    <b><?php echo htmlspecialchars(@$searchDetails['pageResultsStart']); ?></b> to
    <b><?php echo htmlspecialchars(@$searchDetails['pageResultsEnd']); ?></b> of
    <b><?php echo htmlspecialchars(@$searchDetails['totalRecords']); ?></b>.</font></td>
 </tr>
</table><br/>

<!-- show errors -->
    <?php if ($searchDetails['invalidPageNum']): ?>
      Results page '<?php echo $searchDetails['page']?>' not found, <a href="<?php echo $searchDetails['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/>
    <?php elseif ($searchOptions['keywords'] && $searchDetails['noRecordsFound']): ?>
      No records matched search query!<br/><br/>
    <?php elseif ($searchOptions['keywords'] == ""): ?>
      Enter a keyword to search.<br/><br/>
    <?php endif ?>

<!-- STEP2: Display Record List -->
  <?php foreach ($searchRows as $record): ?>
     <a href="<?php echo $record['_link'] ?>"><?php echo $record['_title'] ?></a><br/>
     <?php if ($record['_summary']): ?>
       <?php echo $record['_summary'] ?><br/>
      <?php else: ?>
        No description available for page.<br/>
      <?php endif ?>
     <a href="<?php echo $record['_link'] ?>" style="color: #008000"><?php echo $record['_link'] ?></a><br/><br/>
  <?php endforeach ?>
  <!-- /STEP2: Display Record List -->




  <!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
    <?php if ($searchDetails['prevPage']): ?>
      <a href="<?php echo $searchDetails['prevPageLink'] ?>">&lt;&lt; prev</a>
    <?php else: ?>
      &lt;&lt; prev
    <?php endif ?>

    - page <?php echo $searchDetails['page'] ?> of <?php echo $searchDetails['totalPages'] ?> -

    <?php if ($searchDetails['nextPage']): ?>
      <a href="<?php echo $searchDetails['nextPageLink'] ?>">next &gt;&gt;</a>
    <?php else: ?>
      next &gt;&gt;
    <?php endif ?>
  <!-- /STEP3: Display Page Links -->

</form>
</body>
</html>
