<?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('/home/toledoh/public_html/clubsite/','','../','../../','../../../');
  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 records
  list($eventsRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'events',
  ));

  # team filter must accept records with no teams specified (i.e. a "public record") 
  $team_filter = "membership = ''"; 
   
  # team filter must also accept records with any single team which is also listed in $CURRENT_USER['team'] 
  foreach (explode("\t", trim($CURRENT_USER['membership'])) as $team_num) { 
    $team_filter .= mysql_escapef(" OR membership LIKE ?", "%\t$team_num\t%"); 
  } 
   
  list($eventsRecords, $eventsMetaData) = getRecords(array(
    'tableName'   => 'events',
    'where'         => $team_filter, 
  ));

?>
<!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 List 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> (Most list pages only have title and link fields.)</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 Records (Paste this where you want your records to be listed) -->
    <h1>Events - List Page Viewer</h1>
    <?php foreach ($eventsRecords as $record): ?>
      Record Number: <?php echo $record['num'] ?><br/>
      Title: <?php echo $record['title'] ?><br/>
      membership: <?php echo join(', ', getListLabels('events', 'membership', $record['membership'])); ?><br/>
      Start Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['start_date'])) ?><br/>
      <!-- For date formatting codes see: http://www.php.net/date -->
      End Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['end_date'])) ?><br/>
      <!-- For date formatting codes see: http://www.php.net/date -->
      Monday: <?php echo $record['monday'] ?><br/>
      Tuesday: <?php echo $record['tuesday'] ?><br/>
      Wednesday: <?php echo $record['wednesday'] ?><br/>
      Thursday: <?php echo $record['thursday'] ?><br/>
      Friday: <?php echo $record['friday'] ?><br/>
      Saturday: <?php echo $record['saturday'] ?><br/>
      Sunday: <?php echo $record['sunday'] ?><br/>
      Location: <?php echo $record['location'] ?><br/>
      Content: <?php echo $record['content'] ?><br/>
      _link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

      <hr/>
    <?php endforeach ?>

    <?php if (!$eventsRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->

</body>
</html>
