Ejemplo n.º 1
0
<?php

require_once 'PackageConfig.php';
PackageConfig::addPackage('pinhole', 'work-gauthierm');
PackageConfig::addPackage('swat', 'work-gauthierm');
PackageConfig::addPackage('site', 'work-gauthierm');
require_once 'MDB2.php';
require_once 'SwatDB/SwatDB.php';
require_once 'Pinhole/PinholeTagFactory.php';
$dsn = 'pgsql://php@192.168.0.26/gallery?sslmode=disable';
$connection = MDB2::connect($dsn);
$instance = new PinholeInstance();
$instance->setDatabase($connection);
$instance->load(1);
PinholeTagFactory::setDefaultDatabase($connection);
PinholeTagFactory::setDefaultInstance($instance);
function test_tag($string)
{
    $tag = PinholeTagFactory::get($string);
    if ($tag) {
        echo "=> ", $tag, ': "', $tag->getTitle(), "\"\n";
        echo "   Photos: ";
        foreach ($tag->getPhotos() as $photo) {
            echo $photo->id, ' ';
        }
        echo "\n";
        if ($tag instanceof PinholeIterableTag) {
            echo "   Iterable: ", $tag->prev()->getTitle(), " <=> ", $tag->next()->getTitle(), "\n";
        }
    } else {
        echo "=> {$string}: *** error loading tag ***\n";