<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/hsphere/local/home/lyleandcindy/dunhamrealestateservices.com/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load record from 'listings'
  list($listingsRecords, $listingsMetaData) = getRecords(array(
    'tableName'   => 'listings',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $listingsRecord = @$listingsRecords[0]; // get first record
  if (!$listingsRecord) { dieWith404("Record not found!"); } // show error message if no record found

?><!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; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
  </style>
 </head>
<body>

  <!-- INSTRUCTIONS -->
    <div class="instructions">
      <b>Sample Detail Viewer - Instructions:</b>
      <ol>
        <?php /*><li style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
        <li><b>Remove any fields you don't want displayed.</b></li>
        <li>Rearrange remaining fields to suit your needs.</li>
        <li>Copy and paste code into previously designed page (or add design to this page).</li>
      </ol>
    </div>
  <!-- /INSTRUCTIONS -->

  <!-- STEP2: Display Record (Paste this where you want your record to appear) -->
    <h1>Property Listings - Detail Page Viewer</h1>
      Record Number: <?php echo htmlencode($listingsRecord['num']) ?><br/>
      Featured Property (value): <?php echo $listingsRecord['featured'] ?><br/>
      Featured Property (text):  <?php echo $listingsRecord['featured:text'] ?><br/>
      Banner Status (value): <?php echo $listingsRecord['banner_status'] ?><br/>
      Banner Status (label): <?php echo $listingsRecord['banner_status:label'] ?><br/>
      Listing Company (values): <?php echo join(', ', $listingsRecord['listing_company:values']); ?><br/>
      Listing Company (labels): <?php echo join(', ', $listingsRecord['listing_company:labels']); ?><br/>
      Property Title: <?php echo htmlencode($listingsRecord['title']) ?><br/>
      Subtitle: <?php echo htmlencode($listingsRecord['subtitle']) ?><br/>
      Property Type (values): <?php echo join(', ', $listingsRecord['property_type:values']); ?><br/>
      Property Type (labels): <?php echo join(', ', $listingsRecord['property_type:labels']); ?><br/>
      Price: <?php echo htmlencode($listingsRecord['price']) ?><br/>
      MLS #: <?php echo htmlencode($listingsRecord['mls']) ?><br/>
      Address: <?php echo htmlencode($listingsRecord['address']) ?><br/>
      City: <?php echo htmlencode($listingsRecord['city']) ?><br/>
      State (value): <?php echo $listingsRecord['state'] ?><br/>
      State (label): <?php echo $listingsRecord['state:label'] ?><br/>
      Summary: <?php echo htmlencode($listingsRecord['summary']) ?><br/>
      Description: <?php echo $listingsRecord['description']; ?><br/>
      _link : <a href="<?php echo $listingsRecord['_link'] ?>"><?php echo $listingsRecord['_link'] ?></a><br/>

      <!-- STEP 2a: Display Uploads for field 'pdf_file' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        PDF File:
        <blockquote>
        <?php foreach ($listingsRecord['pdf_file'] as $index => $upload): ?>
          Upload Url: <?php echo $upload['urlPath'] ?><br/>

          <!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.
<br/>
          Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

          Image Tags:<br/>
          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<br/>

          Extension: <?php echo $upload['extension'] ?><br/>
          isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          <hr/>
          // end uploads comment tag -->

        <?php endforeach ?>
        </blockquote>
      <!-- STEP2a: /Display Uploads -->


      <!-- STEP 2a: Display Uploads for field 'uploads' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        Uploads:
        <blockquote>
        <?php foreach ($listingsRecord['uploads'] as $index => $upload): ?>
          Upload Url: <?php echo $upload['urlPath'] ?><br/>

          <!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

          Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
          Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

          Image Tags:<br/>
          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
          <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

          info1 (Tags) : <?php echo htmlencode($upload['info1']) ?><br/>
          info2 (Title) : <?php echo htmlencode($upload['info2']) ?><br/>
          info3 (Caption) : <?php echo htmlencode($upload['info3']) ?><br/><br/>

          Extension: <?php echo $upload['extension'] ?><br/>
          isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          <hr/>
          // end uploads comment tag -->

        <?php endforeach ?>
        </blockquote>
      <!-- STEP2a: /Display Uploads -->

  <!-- /STEP2: Display Record -->
    <hr/>

  <a href="<?php echo $listingsMetaData['_listPage'] ?>">&lt;&lt; Back to list page</a>
  <a href="mailto:?subject=<?php echo urlencode(thisPageUrl()) ?>">Email this Page</a>

</body>
</html>
