<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $basketElements = $em->getRepository('BasketElement')->findByBasket($request->get('basket'));
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>ELEMENT LIST FOR BASKET WITH ID <?php 
echo $request->get('basket');
?>
</h1>
        <?php 
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $query = $em->getRepository('Record')->search(array('query' => 'all', 'offset_start' => $request->get('offset', 0), 'per_page' => 10));
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>SEARCH FOR RECORDS</h1>
        <?php 
if (null !== $errMsg) {
    echo $errMsg;
} else {
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $databoxCollection = $em->getRepository('DataboxCollection')->findByDatabox($request->get('databox'));
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>COLLECTIONs LIST FOR DATABOX WITH ID <?php 
echo $request->get('databox');
?>
</h1>
        <?php 
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $databoxes = $em->getRepository('Databox')->findAll();
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>DATABOXES LIST</h1>
        <?php 
if (null !== $errMsg) {
    echo $errMsg;
} else {
    echo '<a href="./">back</a><br/>';
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $feeds = $em->getRepository('Feed')->findAll();
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>FEEDS LIST</h1>
        <?php 
if (null !== $errMsg) {
    echo $errMsg;
} else {
    echo '<a href="./">back</a><br/>';
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$offsetStart = $request->get('offset_start', 0);
$perPage = $request->get('per_page', 5);
$totalEntries = $request->get('total_entries');
$errMsg = null;
try {
    $entries = $em->getRepository('Entry')->findByFeed($request->get('feed'), $offsetStart, $perPage);
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>FEED ENTRIES FOR FEED WITH ID <?php 
echo $request->get('feed');
<?php

use PhraseanetSDK\Tools\Entity\Manager;
use PhraseanetSDK\Exception\NotFoundException;
use PhraseanetSDK\Exception\ExceptionInterface;
$client = (require __DIR__ . '/../src/common/client.php');
/* @var $client \PhraseanetSDK\Client */
if (null === $client->getAccessToken()) {
    header(sprintf('Location: %s', $CONF['authentication-uri']));
}
$em = new Manager($client);
$errMsg = null;
try {
    $baskets = $em->getRepository('Basket')->findAll();
} catch (NotFoundException $e) {
    $errMsg = $e->getMessage();
} catch (ExceptionInterface $e) {
    $errMsg = $e->getMessage();
}
?>
<html>
    <head>

    </head>
    <body>
        <h1>BASKETS LIST</h1>
        <?php 
if (null !== $errMsg) {
    echo $errMsg;
} else {
    echo '<a href="./">back</a><br/>';