Example #1
2
include_once '../lib/classes/PhotoView.class.php';
// view
// set default value so page loads without passing params
$station = safeParam('station', '7adl');
if (!isset($TEMPLATE)) {
    $TITLE = 'GPS Station ' . strtoupper($station) . ' Photos';
    $NAVIGATION = true;
    $HEAD = '<link rel="stylesheet" href="' . $MOUNT_PATH . '/css/photos.css" />';
    $FOOT = '';
    include 'template.inc.php';
}
$db = new Db();
// Db query result: station details for selected station
$rsStation = $db->queryStation($station);
$station_exists = $rsStation->fetch();
if ($station_exists) {
    // Get a list of photos for selected station
    $dir = sprintf('%s/stations/%s.dir/%s/photos/screen', $DATA_DIR, substr($station, 0, 1), $station);
    $files = getDirContents($dir);
    // Add photos to collection
    $photoCollection = new PhotoCollection($station);
    foreach ($files as $file) {
        $photoModel = new Photo($file);
        $photoCollection->add($photoModel);
    }
    // Render HTML
    $view = new PhotoView($photoCollection);
    $view->render();
} else {
    print '<p class="alert error">ERROR: Station Not Found</p>';
}
 public function testIsEmpty()
 {
     $collection = new PhotoCollection();
     $this->assertTrue($collection->isEmpty());
     $collection->push(array('id' => 6374, 'storage' => 'local'));
     $this->assertFalse($collection->isEmpty());
 }
Example #3
0
 public function upload(PhotoCollection &$collection)
 {
     $items = $collection->getItems();
     $params = $this->extendParams(['items' => array_values(array_map(function ($item) {
         return ['file' => '@' . $item->getFilePath(), 'id' => $item->getId(), 'hash' => $item->getHash()];
     }, $collection->getItems()))]);
     $res = $this->makeRequest('upload', $params, self::HTTP_POST);
     return true;
 }