Exemple #1
0
 public function getEvents()
 {
     $dataReader = new DataReader();
     $data = $dataReader->getDataFromHtml($this->endpoint);
     $xpath = new DOMXPath($data);
     $items = $xpath->query("//div[contains(@class, 'conference-listing')]/ol/li[position() <= 3]/h4/a");
     if (0 === count($items)) {
         return '';
     }
     $output = '<p>You may also remember me from such events as ';
     $numItems = $items->length;
     $doneItems = 0;
     for ($i = $numItems - 1; $i >= 0; $i--) {
         $item = $items->item($i);
         $doneItems++;
         $joiner = '.';
         if ($doneItems < $numItems - 1) {
             $joiner = ', ';
         } else {
             if ($doneItems < $numItems) {
                 $joiner = ' and ';
             }
         }
         $text = $item->nodeValue;
         $url = $item->attributes->getNamedItem('href')->nodeValue;
         $output .= "<a href='http://lanyrd.com{$url}'>{$text}</a>{$joiner}";
     }
     $output .= '</p>';
     return $output;
 }
 /**
  * DataReader factory
  * Executes a SQL statement (with optional parameters) and returns a new DataReader ready for iteration
  *
  * @param string $sql
  * @param array  $parameters
  * @param \PDO   $connection
  * @param int    $fetchMode
  *
  * @return DataReader|bool
  */
 public static function create($sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC)
 {
     $_reader = new DataReader(Sql::createStatement($sql, $connection, $fetchMode));
     if (false === ($_result = $_reader->execute($parameters))) {
         //	Don't be wasteful
         unset($_reader);
         return false;
     }
     return $_reader;
 }
Exemple #3
0
function getHtmlForStream($stream, $url, $maxItems = 100)
{
    $dataReader = new DataReader();
    $data = $dataReader->getDataFromFeed($url);
    $backlog = array();
    $output = '';
    $numItems = 0;
    foreach ($data->channel->item as $item) {
        if ($numItems >= $maxItems) {
            continue;
        }
        $output .= getHtmlForEntry($item, $stream, $backlog, !(bool) $numItems);
        $numItems++;
    }
    if (sizeof($backlog) > 0) {
        $output .= getHtmlForEntry($item, $stream, $backlog);
    }
    if ('' == $output) {
        error_log('returning early');
        return $output;
    }
    return "<ol>{$output}</ol>";
}
Exemple #4
0
 /**
  * Creates and returns an optionally parameter-bound \PDOStatement object suitable for iteration
  *
  * @param string $sql
  * @param array  $parameters
  * @param \PDO   $connection
  * @param int    $fetchMode Set to false to not touch fetch mode
  *
  * @return DataReader
  */
 public static function query($sql, $parameters = null, &$connection = null, $fetchMode = \PDO::FETCH_ASSOC)
 {
     return DataReader::create($sql, $parameters, $connection, $fetchMode);
 }
Exemple #5
0
<?php

/* This module contains the HTML for the header of the page.
 */
require_once "../data_reader.php";
require_once "../front_viewers.php";
?>
<header>
  <div id="title">
    <?php 
echo DataReader::readConfigFile()['title'];
?>
  </div>
  <div id="login-area">
    <?php 
if (validLoginCode()) {
    // User is logged in, so we show the login identifier
    echo FrontViewers::getLoginIdentifier();
} else {
    // User isn't logged in, so we show the login form.
    echo FrontViewers::getLoginForm();
}
?>
  </div>
</header>