mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
Implement RSSFeeds, fixed controllers implementation, fixed tests
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Admin;
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
use Repositories;
|
use Entities\Feed;
|
||||||
|
use Entities\FeedPublisher;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -47,9 +48,9 @@ class Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
|
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
|
||||||
|
|
||||||
$publisher = new \Entities\FeedPublisher($app['authentication']->getUser(), true);
|
$publisher = new FeedPublisher($app['authentication']->getUser(), true);
|
||||||
|
|
||||||
$feed = new \Entities\Feed($publisher, $request->request->get('title'), $request->request->get('subtitle'));
|
$feed = new Feed($publisher, $request->request->get('title'), $request->request->get('subtitle'));
|
||||||
|
|
||||||
if ($request->request->get('public') == '1') {
|
if ($request->request->get('public') == '1') {
|
||||||
$feed->setPublic(true);
|
$feed->setPublic(true);
|
||||||
@@ -178,7 +179,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app);
|
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app);
|
||||||
$feed = $app["EM"]->getRepository("Entities\Feed")->find($id);
|
$feed = $app["EM"]->getRepository("Entities\Feed")->find($id);
|
||||||
|
|
||||||
$publisher = new \Entities\FeedPublisher($user, false);
|
$publisher = new FeedPublisher($user, false);
|
||||||
$publisher->setFeed($feed);
|
$publisher->setFeed($feed);
|
||||||
|
|
||||||
$feed->addPublisher($publisher);
|
$feed->addPublisher($publisher);
|
||||||
|
|||||||
@@ -539,7 +539,8 @@ class Root implements ControllerProviderInterface
|
|||||||
private function getPublicationStartPage(Application $app)
|
private function getPublicationStartPage(Application $app)
|
||||||
{
|
{
|
||||||
return $app['twig']->render('client/home_inter_pub_basket.html.twig', array(
|
return $app['twig']->render('client/home_inter_pub_basket.html.twig', array(
|
||||||
'feeds' => \Feed_Collection::load_all($app, $app['authentication']->getUser()),
|
// 'feeds' => \Feed_Collection::load_all($app, $app['authentication']->getUser()),
|
||||||
|
'feeds' => $app['EM']->getRepository('Entities\Feed')->getAllforUser($app['authentication']->getUser()),
|
||||||
'image_size' => (int) $app['authentication']->getUser()->getPrefs('images_size')
|
'image_size' => (int) $app['authentication']->getUser()->getPrefs('images_size')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,13 +160,15 @@ class Lightbox implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) {
|
$controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) {
|
||||||
|
|
||||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $entry_id);
|
// $entry = \Feed_Entry_Adapter::load_from_id($app, $entry_id);
|
||||||
$item = new \Feed_Entry_Item($app['phraseanet.appbox'], $entry, $item_id);
|
$entry = $app['EM']->getRepository("Entities\FeedEntry")->find($entry_id);
|
||||||
|
// $item = new \Feed_Entry_Item($app['phraseanet.appbox'], $entry, $item_id);
|
||||||
|
$item = $entry->getItems()->getItem($item_id);
|
||||||
|
|
||||||
if ($app['browser']->isMobile()) {
|
if ($app['browser']->isMobile()) {
|
||||||
$output = $app['twig']->render('lightbox/feed_element.html.twig', array(
|
$output = $app['twig']->render('lightbox/feed_element.html.twig', array(
|
||||||
'feed_element' => $item,
|
'feed_element' => $item,
|
||||||
'module_name' => $item->get_record()->get_title()
|
'module_name' => $item->getRecord()->get_title()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -313,7 +315,8 @@ class Lightbox implements ControllerProviderInterface
|
|||||||
return $app->redirectPath('logout');
|
return $app->redirectPath('logout');
|
||||||
}
|
}
|
||||||
|
|
||||||
$feed_entry = \Feed_Entry_Adapter::load_from_id($app, $entry_id);
|
// $feed_entry = \Feed_Entry_Adapter::load_from_id($app, $entry_id);
|
||||||
|
$feed_entry = $app['EM']->getEntity("Entities\FeedEntry")->find($entry_id);
|
||||||
|
|
||||||
$template = 'lightbox/feed.html.twig';
|
$template = 'lightbox/feed.html.twig';
|
||||||
|
|
||||||
@@ -321,12 +324,12 @@ class Lightbox implements ControllerProviderInterface
|
|||||||
$template = 'lightbox/IE6/feed.html.twig';
|
$template = 'lightbox/IE6/feed.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $feed_entry->get_content();
|
$content = $feed_entry->getItems();
|
||||||
|
|
||||||
$output = $app['twig']->render($template, array(
|
$output = $app['twig']->render($template, array(
|
||||||
'feed_entry' => $feed_entry,
|
'feed_entry' => $feed_entry,
|
||||||
'first_item' => array_shift($content),
|
'first_item' => array_shift($content),
|
||||||
'local_title' => $feed_entry->get_title(),
|
'local_title' => $feed_entry->getTitle(),
|
||||||
'module' => 'lightbox',
|
'module' => 'lightbox',
|
||||||
'module_name' => _('admin::monitor: module validation')
|
'module_name' => _('admin::monitor: module validation')
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ use Alchemy\Phrasea\Feed\Aggregate;
|
|||||||
use Alchemy\Phrasea\Feed\AggregateLinkGenerator;
|
use Alchemy\Phrasea\Feed\AggregateLinkGenerator;
|
||||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
use Alchemy\Phrasea\Feed\LinkGenerator;
|
use Alchemy\Phrasea\Feed\LinkGenerator;
|
||||||
|
use Entities\FeedEntry;
|
||||||
|
use Entities\FeedItem;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -60,7 +62,7 @@ class Feed implements ControllerProviderInterface
|
|||||||
$author_name = $request->request->get('author_name');
|
$author_name = $request->request->get('author_name');
|
||||||
$author_email = $request->request->get('author_email');
|
$author_email = $request->request->get('author_email');
|
||||||
|
|
||||||
$entry = new \Entities\FeedEntry();
|
$entry = new FeedEntry();
|
||||||
$entry->setFeed($feed);
|
$entry->setFeed($feed);
|
||||||
$entry->setPublisher($publisher);
|
$entry->setPublisher($publisher);
|
||||||
$entry->setTitle($title);
|
$entry->setTitle($title);
|
||||||
@@ -72,7 +74,7 @@ class Feed implements ControllerProviderInterface
|
|||||||
|
|
||||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||||
foreach ($publishing as $record) {
|
foreach ($publishing as $record) {
|
||||||
$item = new \Entities\FeedItem();
|
$item = new FeedItem();
|
||||||
$item->setEntry($entry);
|
$item->setEntry($entry);
|
||||||
$item->setRecordId($record->get_record_id());
|
$item->setRecordId($record->get_record_id());
|
||||||
$item->setSbasId($record->get_sbas_id());
|
$item->setSbasId($record->get_sbas_id());
|
||||||
@@ -166,7 +168,7 @@ class Feed implements ControllerProviderInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = new \entities\FeedItem($entry, $item_sort_datas[0]);
|
$item = new FeedItem($entry, $item_sort_datas[0]);
|
||||||
$item->setEntry($entry);
|
$item->setEntry($entry);
|
||||||
$entry->addItem($item);
|
$entry->addItem($item);
|
||||||
$item->setOrd($item_sort_datas[1]);
|
$item->setOrd($item_sort_datas[1]);
|
||||||
@@ -262,11 +264,9 @@ class Feed implements ControllerProviderInterface
|
|||||||
|
|
||||||
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAll();
|
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAll();
|
||||||
|
|
||||||
$aggregateGenerator = new AggregateLinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
|
||||||
|
|
||||||
$aggregate = new Aggregate($app, $feeds);
|
$aggregate = new Aggregate($app, $feeds);
|
||||||
|
|
||||||
$link = $aggregateGenerator->generate($aggregate, $app['authentication']->getUser(), AggregateLinkGenerator::FORMAT_RSS, null, $renew);
|
$link = $app['feed.aggregate-link-generator']->generate($aggregate, $app['authentication']->getUser(), AggregateLinkGenerator::FORMAT_RSS, null, $renew);
|
||||||
|
|
||||||
$output = array(
|
$output = array(
|
||||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||||
@@ -283,9 +283,7 @@ class Feed implements ControllerProviderInterface
|
|||||||
|
|
||||||
$feed = $app["EM"]->getRepository("Entities\Feed")->loadWithUser($app, $app['authentication']->getUser(), $id);
|
$feed = $app["EM"]->getRepository("Entities\Feed")->loadWithUser($app, $app['authentication']->getUser(), $id);
|
||||||
|
|
||||||
$linkGenerator = new LinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
$link = $app['feed.user-link-generator']->generate($feed, $app['authentication']->getUser(), LinkGenerator::FORMAT_RSS, null, $renew);
|
||||||
|
|
||||||
$link = $linkGenerator->generate($feed, $app['authentication']->getUser(), LinkGenerator::FORMAT_RSS, null, $renew);
|
|
||||||
|
|
||||||
$output = array(
|
$output = array(
|
||||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use \Alchemy\Phrasea\Feed\Aggregate;
|
use Alchemy\Phrasea\Feed\Aggregate;
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Exception\SessionNotFound;
|
use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||||
use Silex\Application as SilexApplication;
|
use Silex\Application as SilexApplication;
|
||||||
@@ -75,8 +75,8 @@ class Root implements ControllerProviderInterface
|
|||||||
|
|
||||||
// $user_feeds = \Feed_Collection::load_all($app, $app['authentication']->getUser());
|
// $user_feeds = \Feed_Collection::load_all($app, $app['authentication']->getUser());
|
||||||
// $feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
// $feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
||||||
$user_feeds = $app["EM"]->getRepository("Entities\Feed")->getAllForUser($app['authentication']->getUser());
|
$feeds = $app["EM"]->getRepository("Entities\Feed")->getAllForUser($app['authentication']->getUser());
|
||||||
$aggregate = new Aggregate($app, $user_feeds);
|
// $aggregate = new Aggregate($app, $user_feeds);
|
||||||
|
|
||||||
$thjslist = "";
|
$thjslist = "";
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class Root implements ControllerProviderInterface
|
|||||||
'GV_thesaurus' => $app['phraseanet.registry']->get('GV_thesaurus'),
|
'GV_thesaurus' => $app['phraseanet.registry']->get('GV_thesaurus'),
|
||||||
'cgus_agreement' => \databox_cgu::askAgreement($app),
|
'cgus_agreement' => \databox_cgu::askAgreement($app),
|
||||||
'css' => $css,
|
'css' => $css,
|
||||||
'aggregate' => $aggregate,
|
'feeds' => $feeds,
|
||||||
'GV_google_api' => $app['phraseanet.registry']->get('GV_google_api'),
|
'GV_google_api' => $app['phraseanet.registry']->get('GV_google_api'),
|
||||||
'queries_topics' => $queries_topics,
|
'queries_topics' => $queries_topics,
|
||||||
'search_status' => \databox_status::getSearchStatus($app),
|
'search_status' => \databox_status::getSearchStatus($app),
|
||||||
|
|||||||
@@ -725,10 +725,7 @@ class Login implements ControllerProviderInterface
|
|||||||
$app->addFlash('error', _('login::erreur: No available connection - Please contact sys-admin'));
|
$app->addFlash('error', _('login::erreur: No available connection - Please contact sys-admin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$public_feeds = \Feed_Collection::load_public_feeds($app);
|
$feeds = $app['EM']->getRepository('Entities\Feed')->findAllPublic();
|
||||||
|
|
||||||
$feeds = $public_feeds->get_feeds();
|
|
||||||
array_unshift($feeds, $public_feeds->get_aggregate());
|
|
||||||
|
|
||||||
$form = $app->form(new PhraseaAuthenticationForm());
|
$form = $app->form(new PhraseaAuthenticationForm());
|
||||||
$form->setData(array(
|
$form->setData(array(
|
||||||
|
|||||||
@@ -32,15 +32,15 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
$perPage = 5;
|
$perPage = 5;
|
||||||
$entries = $feed->getEntries((($page - 1) * $perPage), $perPage);
|
$entries = $feed->getEntries((($page - 1) * $perPage), $perPage);
|
||||||
|
|
||||||
if ($format == \Entities\Feed::FORMAT_RSS) {
|
if ($format == 'rss') {
|
||||||
$content = new \Feed_XML_RSS();
|
$content = new \Feed_XML_RSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == \Entities\Feed::FORMAT_ATOM) {
|
if ($format == 'atom') {
|
||||||
$content = new \Feed_XML_Atom();
|
$content = new \Feed_XML_Atom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == \Entities\Feed::FORMAT_COOLIRIS) {
|
if ($format == 'cooliris') {
|
||||||
$content = new \Feed_XML_Cooliris();
|
$content = new \Feed_XML_Cooliris();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,6 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
};
|
};
|
||||||
|
|
||||||
$controllers->get('/feed/{id}/{format}/', function(Application $app, $id, $format) use ($display_feed) {
|
$controllers->get('/feed/{id}/{format}/', function(Application $app, $id, $format) use ($display_feed) {
|
||||||
// $feed = new \Feed_Adapter($app, $id);
|
|
||||||
$feed = $app["EM"]->getRepository("Entities\Feed")->find($id);
|
$feed = $app["EM"]->getRepository("Entities\Feed")->find($id);
|
||||||
|
|
||||||
if (!$feed->isPublic()) {
|
if (!$feed->isPublic()) {
|
||||||
@@ -112,7 +111,6 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/userfeed/aggregated/{token}/{format}/', function(Application $app, $token, $format) use ($display_feed) {
|
$controllers->get('/userfeed/aggregated/{token}/{format}/', function(Application $app, $token, $format) use ($display_feed) {
|
||||||
$token = $app["EM"]->getRepository("Entities\AggregateToken")->findBy(array("id" => $id));
|
$token = $app["EM"]->getRepository("Entities\AggregateToken")->findBy(array("id" => $id));
|
||||||
//$feed = $token->getFeed();
|
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
@@ -125,8 +123,6 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
->assert('format', '(rss|atom)');
|
->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/aggregated/{format}/', function(Application $app, $format) use ($display_feed) {
|
$controllers->get('/aggregated/{format}/', function(Application $app, $format) use ($display_feed) {
|
||||||
//$feeds = \Feed_Collection::load_public_feeds($app);
|
|
||||||
//$feed = $feeds->get_aggregate();
|
|
||||||
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAllPublic();
|
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAllPublic();
|
||||||
$feed = new Aggregate($app, $feeds);
|
$feed = new Aggregate($app, $feeds);
|
||||||
|
|
||||||
@@ -140,8 +136,6 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
->assert('format', '(rss|atom)');
|
->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/cooliris/', function(Application $app) use ($display_feed) {
|
$controllers->get('/cooliris/', function(Application $app) use ($display_feed) {
|
||||||
// $feeds = \Feed_Collection::load_public_feeds($app);
|
|
||||||
// $feed = $feeds->get_aggregate();
|
|
||||||
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAllPublic();
|
$feeds = $app["EM"]->getRepository("Entities\Feed")->findAllPublic();
|
||||||
$feed = new Aggregate($app, $feeds);
|
$feed = new Aggregate($app, $feeds);
|
||||||
|
|
||||||
@@ -149,7 +143,7 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, \Feed_Adapter::FORMAT_COOLIRIS, $page);
|
return $display_feed($app, $feed, 'cooliris', $page);
|
||||||
})
|
})
|
||||||
->bind('feed_public_cooliris');
|
->bind('feed_public_cooliris');
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class FeedServiceProvider implements ServiceProviderInterface
|
|||||||
$app['feed.user-link-generator'] = $app->share(function($app) {
|
$app['feed.user-link-generator'] = $app->share(function($app) {
|
||||||
return new LinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
return new LinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
||||||
});
|
});
|
||||||
$app['feed.aggreagate-link-generator'] = $app->share(function($app) {
|
$app['feed.aggregate-link-generator'] = $app->share(function($app) {
|
||||||
return new AggregateLinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
return new AggregateLinkGenerator($app['url_generator'], $app['EM'], $app['tokens']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,21 +28,55 @@ class AggregateLinkGenerator
|
|||||||
{
|
{
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case self::FORMAT_ATOM:
|
case self::FORMAT_ATOM:
|
||||||
|
$params = array('token' => $this->getAggregateToken($user, $renew)->getValue(),
|
||||||
|
'format' => 'atom');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
return new FeedLink(
|
return new FeedLink(
|
||||||
$this->generator->generate('feed_user_aggregated', array(
|
$this->generator->generate('feed_user_aggregated', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
'token' => $this->getAggregateToken($user, $renew)->getValue(),
|
|
||||||
'format' => 'atom',
|
|
||||||
), UrlGenerator::ABSOLUTE_URL),
|
|
||||||
sprintf('%s - %s', $aggregate->getTitle(), 'Atom'),
|
sprintf('%s - %s', $aggregate->getTitle(), 'Atom'),
|
||||||
'application/atom+xml'
|
'application/atom+xml'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::FORMAT_RSS:
|
case self::FORMAT_RSS:
|
||||||
|
$params = array('token' => $this->getAggregateToken($user, $renew)->getValue(),
|
||||||
|
'format' => 'rss');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
return new FeedLink(
|
return new FeedLink(
|
||||||
$this->generator->generate('feed_user_aggregated', array(
|
$this->generator->generate('feed_user_aggregated', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
'token' => $this->getAggregateToken($user, $renew)->getValue(),
|
sprintf('%s - %s', $aggregate->getTitle(), 'RSS'),
|
||||||
'format' => 'rss',
|
'application/rss+xml'
|
||||||
), UrlGenerator::ABSOLUTE_URL),
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException(sprintf('Format %s is not recognized.', $format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePublic(Aggregate $aggregate, $format, $page = null)
|
||||||
|
{
|
||||||
|
switch ($format) {
|
||||||
|
case self::FORMAT_ATOM:
|
||||||
|
$params = array('format' => 'atom');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
|
return new FeedLink(
|
||||||
|
$this->generator->generate('feed_user_aggregated', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
|
sprintf('%s - %s', $aggregate->getTitle(), 'Atom'),
|
||||||
|
'application/atom+xml'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case self::FORMAT_RSS:
|
||||||
|
$params = array('format' => 'rss');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
|
return new FeedLink(
|
||||||
|
$this->generator->generate('feed_user_aggregated', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
sprintf('%s - %s', $aggregate->getTitle(), 'RSS'),
|
sprintf('%s - %s', $aggregate->getTitle(), 'RSS'),
|
||||||
'application/rss+xml'
|
'application/rss+xml'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,23 +28,59 @@ class LinkGenerator
|
|||||||
{
|
{
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case self::FORMAT_ATOM:
|
case self::FORMAT_ATOM:
|
||||||
|
$params = array('token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
|
||||||
|
'id' => $feed->getId(),
|
||||||
|
'format' => 'atom');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
return new FeedLink(
|
return new FeedLink(
|
||||||
$this->generator->generate('feed_user', array(
|
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
|
|
||||||
'id' => $feed->getId(),
|
|
||||||
'format' => 'atom',
|
|
||||||
), UrlGenerator::ABSOLUTE_URL),
|
|
||||||
sprintf('%s - %s', $feed->getTitle(), 'Atom'),
|
sprintf('%s - %s', $feed->getTitle(), 'Atom'),
|
||||||
'application/atom+xml'
|
'application/atom+xml'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::FORMAT_RSS:
|
case self::FORMAT_RSS:
|
||||||
|
$params = array('token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
|
||||||
|
'id' => $feed->getId(),
|
||||||
|
'format' => 'rss');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
return new FeedLink(
|
return new FeedLink(
|
||||||
$this->generator->generate('feed_user', array(
|
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
|
sprintf('%s - %s', $feed->getTitle(), 'RSS'),
|
||||||
'id' => $feed->getId(),
|
'application/rss+xml'
|
||||||
'format' => 'rss',
|
);
|
||||||
), UrlGenerator::ABSOLUTE_URL),
|
break;
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException(sprintf('Format %s is not recognized.', $format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePublic(Feed $feed, $format, $page = null)
|
||||||
|
{
|
||||||
|
switch ($format) {
|
||||||
|
case self::FORMAT_ATOM:
|
||||||
|
$params = array('id' => $feed->getId(),
|
||||||
|
'format' => 'atom');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
|
return new FeedLink(
|
||||||
|
$this->generator->generate('feed_public', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
|
sprintf('%s - %s', $feed->getTitle(), 'Atom'),
|
||||||
|
'application/atom+xml'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case self::FORMAT_RSS:
|
||||||
|
$params = array('id' => $feed->getId(),
|
||||||
|
'format' => 'rss');
|
||||||
|
if (null !== $page) {
|
||||||
|
$params['page'] = $page;
|
||||||
|
}
|
||||||
|
return new FeedLink(
|
||||||
|
$this->generator->generate('feed_public', $params, UrlGenerator::ABSOLUTE_URL),
|
||||||
sprintf('%s - %s', $feed->getTitle(), 'RSS'),
|
sprintf('%s - %s', $feed->getTitle(), 'RSS'),
|
||||||
'application/rss+xml'
|
'application/rss+xml'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -424,4 +424,27 @@ class Feed implements FeedInterface
|
|||||||
{
|
{
|
||||||
return $this->tokens;
|
return $this->tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entries
|
||||||
|
*
|
||||||
|
* @param \Entities\FeedEntry $entries
|
||||||
|
* @return Feed
|
||||||
|
*/
|
||||||
|
public function addEntrie(\Entities\FeedEntry $entries)
|
||||||
|
{
|
||||||
|
$this->entries[] = $entries;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove entries
|
||||||
|
*
|
||||||
|
* @param \Entities\FeedEntry $entries
|
||||||
|
*/
|
||||||
|
public function removeEntrie(\Entities\FeedEntry $entries)
|
||||||
|
{
|
||||||
|
$this->entries->removeElement($entries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -66,11 +66,11 @@ class FeedEntry
|
|||||||
{
|
{
|
||||||
$this->items = new \Doctrine\Common\Collections\ArrayCollection();
|
$this->items = new \Doctrine\Common\Collections\ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
@@ -86,14 +86,14 @@ class FeedEntry
|
|||||||
public function setTitle($title)
|
public function setTitle($title)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title
|
* Get title
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
@@ -109,14 +109,14 @@ class FeedEntry
|
|||||||
public function setSubtitle($subtitle)
|
public function setSubtitle($subtitle)
|
||||||
{
|
{
|
||||||
$this->subtitle = $subtitle;
|
$this->subtitle = $subtitle;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subtitle
|
* Get subtitle
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSubtitle()
|
public function getSubtitle()
|
||||||
{
|
{
|
||||||
@@ -132,14 +132,14 @@ class FeedEntry
|
|||||||
public function setAuthorName($authorName)
|
public function setAuthorName($authorName)
|
||||||
{
|
{
|
||||||
$this->author_name = $authorName;
|
$this->author_name = $authorName;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get author_name
|
* Get author_name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAuthorName()
|
public function getAuthorName()
|
||||||
{
|
{
|
||||||
@@ -155,14 +155,14 @@ class FeedEntry
|
|||||||
public function setAuthorEmail($authorEmail)
|
public function setAuthorEmail($authorEmail)
|
||||||
{
|
{
|
||||||
$this->author_email = $authorEmail;
|
$this->author_email = $authorEmail;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get author_email
|
* Get author_email
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAuthorEmail()
|
public function getAuthorEmail()
|
||||||
{
|
{
|
||||||
@@ -178,14 +178,14 @@ class FeedEntry
|
|||||||
public function setCreatedOn($createdOn)
|
public function setCreatedOn($createdOn)
|
||||||
{
|
{
|
||||||
$this->created_on = $createdOn;
|
$this->created_on = $createdOn;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get created
|
* Get created
|
||||||
*
|
*
|
||||||
* @return \DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getCreatedOn()
|
public function getCreatedOn()
|
||||||
{
|
{
|
||||||
@@ -201,14 +201,14 @@ class FeedEntry
|
|||||||
public function setUpdatedOn($updatedOn)
|
public function setUpdatedOn($updatedOn)
|
||||||
{
|
{
|
||||||
$this->updated_on = $updatedOn;
|
$this->updated_on = $updatedOn;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get updated
|
* Get updated
|
||||||
*
|
*
|
||||||
* @return \DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getUpdatedOn()
|
public function getUpdatedOn()
|
||||||
{
|
{
|
||||||
@@ -224,7 +224,7 @@ class FeedEntry
|
|||||||
public function addItem(\Entities\FeedItem $items)
|
public function addItem(\Entities\FeedItem $items)
|
||||||
{
|
{
|
||||||
$this->items[] = $items;
|
$this->items[] = $items;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ class FeedEntry
|
|||||||
/**
|
/**
|
||||||
* Get items
|
* Get items
|
||||||
*
|
*
|
||||||
* @return \Doctrine\Common\Collections\Collection
|
* @return \Doctrine\Common\Collections\Collection
|
||||||
*/
|
*/
|
||||||
public function getItems()
|
public function getItems()
|
||||||
{
|
{
|
||||||
@@ -257,14 +257,14 @@ class FeedEntry
|
|||||||
public function setPublisher(\Entities\FeedPublisher $publisher = null)
|
public function setPublisher(\Entities\FeedPublisher $publisher = null)
|
||||||
{
|
{
|
||||||
$this->publisher = $publisher;
|
$this->publisher = $publisher;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get publisher
|
* Get publisher
|
||||||
*
|
*
|
||||||
* @return \Entities\FeedPublisher
|
* @return \Entities\FeedPublisher
|
||||||
*/
|
*/
|
||||||
public function getPublisher()
|
public function getPublisher()
|
||||||
{
|
{
|
||||||
@@ -280,27 +280,38 @@ class FeedEntry
|
|||||||
public function setFeed(\Entities\Feed $feed = null)
|
public function setFeed(\Entities\Feed $feed = null)
|
||||||
{
|
{
|
||||||
$this->feed = $feed;
|
$this->feed = $feed;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get feed
|
* Get feed
|
||||||
*
|
*
|
||||||
* @return \Entities\Feed
|
* @return \Entities\Feed
|
||||||
*/
|
*/
|
||||||
public function getFeed()
|
public function getFeed()
|
||||||
{
|
{
|
||||||
return $this->feed;
|
return $this->feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPublisher(\User_Adapter $user)
|
public function isPublisher(\User_Adapter $user)
|
||||||
{
|
{
|
||||||
if ($this->publisher) {
|
if ($this->publisher) {
|
||||||
if ($this->publisher->getUsrId() === $user->get_id())
|
if ($this->publisher->getUsrId() === $user->get_id())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getItem($id)
|
||||||
|
{
|
||||||
|
foreach ($this->items as $item) {
|
||||||
|
if ($item->getId() == $id) {
|
||||||
|
return ($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ class FeedItem
|
|||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
@@ -58,14 +58,14 @@ class FeedItem
|
|||||||
public function setRecordId($recordId)
|
public function setRecordId($recordId)
|
||||||
{
|
{
|
||||||
$this->record_id = $recordId;
|
$this->record_id = $recordId;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get record_id
|
* Get record_id
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getRecordId()
|
public function getRecordId()
|
||||||
{
|
{
|
||||||
@@ -81,14 +81,14 @@ class FeedItem
|
|||||||
public function setSbasId($sbasId)
|
public function setSbasId($sbasId)
|
||||||
{
|
{
|
||||||
$this->sbas_id = $sbasId;
|
$this->sbas_id = $sbasId;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sbas_id
|
* Get sbas_id
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getSbasId()
|
public function getSbasId()
|
||||||
{
|
{
|
||||||
@@ -104,21 +104,21 @@ class FeedItem
|
|||||||
public function setEntry(\Entities\FeedEntry $entry = null)
|
public function setEntry(\Entities\FeedEntry $entry = null)
|
||||||
{
|
{
|
||||||
$this->entry = $entry;
|
$this->entry = $entry;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get entry
|
* Get entry
|
||||||
*
|
*
|
||||||
* @return \Entities\FeedEntry
|
* @return \Entities\FeedEntry
|
||||||
*/
|
*/
|
||||||
public function getEntry()
|
public function getEntry()
|
||||||
{
|
{
|
||||||
return $this->entry;
|
return $this->entry;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $ord;
|
private $ord;
|
||||||
|
|
||||||
@@ -126,20 +126,20 @@ class FeedItem
|
|||||||
/**
|
/**
|
||||||
* Set ord
|
* Set ord
|
||||||
*
|
*
|
||||||
* @param \int $ord
|
* @param integer $ord
|
||||||
* @return FeedItem
|
* @return FeedItem
|
||||||
*/
|
*/
|
||||||
public function setOrd(\int $ord)
|
public function setOrd($ord)
|
||||||
{
|
{
|
||||||
$this->ord = $ord;
|
$this->ord = $ord;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ord
|
* Get ord
|
||||||
*
|
*
|
||||||
* @return \int
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getOrd()
|
public function getOrd()
|
||||||
{
|
{
|
||||||
@@ -155,14 +155,14 @@ class FeedItem
|
|||||||
public function setCreatedOn($createdOn)
|
public function setCreatedOn($createdOn)
|
||||||
{
|
{
|
||||||
$this->created_on = $createdOn;
|
$this->created_on = $createdOn;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get created_on
|
* Get created_on
|
||||||
*
|
*
|
||||||
* @return \DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getCreatedOn()
|
public function getCreatedOn()
|
||||||
{
|
{
|
||||||
@@ -178,17 +178,22 @@ class FeedItem
|
|||||||
public function setUpdatedOn($updatedOn)
|
public function setUpdatedOn($updatedOn)
|
||||||
{
|
{
|
||||||
$this->updated_on = $updatedOn;
|
$this->updated_on = $updatedOn;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get updated_on
|
* Get updated_on
|
||||||
*
|
*
|
||||||
* @return \DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getUpdatedOn()
|
public function getUpdatedOn()
|
||||||
{
|
{
|
||||||
return $this->updated_on;
|
return $this->updated_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setLastInFeedItem()
|
||||||
|
{
|
||||||
|
$this->setOrd($this->getEntry()->getItems()->count() + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
public function fire($event, $params, &$entry)
|
public function fire($event, $params, &$entry)
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
'entry_id' => $entry->get_id()
|
'entry_id' => $entry->getId()
|
||||||
);
|
);
|
||||||
|
|
||||||
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
@@ -72,13 +72,18 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
->include_templates(false)
|
->include_templates(false)
|
||||||
->email_not_null(true);
|
->email_not_null(true);
|
||||||
|
|
||||||
if ($entry->get_feed()->get_collection()) {
|
if ($entry->getFeed()->getCollection($this->app)) {
|
||||||
$Query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id()));
|
$Query->on_base_ids(array($entry->getFeed()->getCollection($this->app)->get_base_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = 0;
|
$start = 0;
|
||||||
$perLoop = 100;
|
$perLoop = 100;
|
||||||
|
|
||||||
|
$from = array(
|
||||||
|
'email' => $entry->getAuthorEmail(),
|
||||||
|
'name' => $entry->getAuthorName()
|
||||||
|
);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$results = $Query->limit($start, $perLoop)->execute()->get_results();
|
$results = $Query->limit($start, $perLoop)->execute()->get_results();
|
||||||
|
|
||||||
@@ -93,7 +98,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
\random::TYPE_FEED_ENTRY
|
\random::TYPE_FEED_ENTRY
|
||||||
, $user_to_notif->get_id()
|
, $user_to_notif->get_id()
|
||||||
, null
|
, null
|
||||||
, $entry->get_id()
|
, $entry->getId()
|
||||||
);
|
);
|
||||||
|
|
||||||
$url = $this->app->url('lightbox', array('LOG' => $token));
|
$url = $this->app->url('lightbox', array('LOG' => $token));
|
||||||
@@ -107,8 +112,8 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
if ($readyToSend) {
|
if ($readyToSend) {
|
||||||
$mail = MailInfoNewPublication::create($this->app, $receiver);
|
$mail = MailInfoNewPublication::create($this->app, $receiver);
|
||||||
$mail->setButtonUrl($url);
|
$mail->setButtonUrl($url);
|
||||||
$mail->setAuthor($entry->get_author_name());
|
$mail->setAuthor($entry->getAuthorName());
|
||||||
$mail->setTitle($entry->get_title());
|
$mail->setTitle($entry->getTitle());
|
||||||
|
|
||||||
$this->app['notification.deliverer']->deliver($mail);
|
$this->app['notification.deliverer']->deliver($mail);
|
||||||
$mailed = true;
|
$mailed = true;
|
||||||
@@ -116,6 +121,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
|
$this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
|
||||||
|
|
||||||
}
|
}
|
||||||
$start += $perLoop;
|
$start += $perLoop;
|
||||||
} while (count($results) > 0);
|
} while (count($results) > 0);
|
||||||
@@ -134,16 +140,20 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
|||||||
$sx = simplexml_load_string($datas);
|
$sx = simplexml_load_string($datas);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$entry = \Feed_Entry_Adapter::load_from_id($this->app, (int) $sx->entry_id);
|
$entry = $this->app['EM']->getRepository("Entities\FeedEntry")->find((int) $sx->entry_id);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $entry) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'text' => sprintf(
|
'text' => sprintf(
|
||||||
_('%1$s has published %2$s')
|
_('%1$s has published %2$s')
|
||||||
, $entry->get_author_name()
|
, $entry->getAuthorName()
|
||||||
, '<a href="/lightbox/feeds/entry/' . $entry->get_id() . '/" target="_blank">' . $entry->get_title() . '</a>'
|
, '<a href="/lightbox/feeds/entry/' . $entry->getId() . '/" target="_blank">' . $entry->getTitle() . '</a>'
|
||||||
)
|
)
|
||||||
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
|
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div>
|
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:left;width:auto;">
|
<td style="text-align:left;width:auto;">
|
||||||
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}">
|
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().getTitle|e}}{% endif %}">
|
||||||
{% if first_item %}{{first_item.get_record().get_title|raw}}{% endif %}
|
{% if first_item %}{{first_item.get_record().getTitle|raw}}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:right;width:230px;">
|
<td style="text-align:right;width:230px;">
|
||||||
@@ -43,9 +43,9 @@
|
|||||||
<div class="lightbox_container PNB record_display_box">
|
<div class="lightbox_container PNB record_display_box">
|
||||||
{% if first_item %}
|
{% if first_item %}
|
||||||
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %}
|
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %}
|
||||||
{% set bask_prev = first_item.get_record().get_preview() %}
|
{% set bask_prev = first_item.getRecord().get_preview() %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set bask_prev = first_item.get_record().get_thumbnail() %}
|
{% set bask_prev = first_item.getRecord().get_thumbnail() %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'', false, false)}}
|
{{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'', false, false)}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -60,8 +60,8 @@
|
|||||||
<div class="display_id"></div>
|
<div class="display_id"></div>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:left;width:auto;">
|
<td style="text-align:left;width:auto;">
|
||||||
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}">
|
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().get_title|e}}{% endif %}">
|
||||||
{% if first_item %}{{first_item.get_record().get_title}}{% endif %}
|
{% if first_item %}{{first_item.getRecord().get_title}}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:right;width:230px;">
|
<td style="text-align:right;width:230px;">
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<div class="lightbox_container PNB">
|
<div class="lightbox_container PNB">
|
||||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
|
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
|
||||||
{% if first_item %}
|
{% if first_item %}
|
||||||
{{caption.format_caption(first_item.get_record(), '', null, business)}}
|
{{caption.format_caption(first_item.getRecord(), '', null, business)}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
<div id="sc_container">
|
<div id="sc_container">
|
||||||
{% for element in feed_entry.get_content() %}
|
{% for element in feed_entry.get_content() %}
|
||||||
<div class="basket_element_wrapper">
|
<div class="basket_element_wrapper">
|
||||||
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.get_id(), 'item_id' : element.get_id()}) }}">
|
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}">
|
||||||
<div id="scid_{{element.get_id()}}" class="basket_element ui-corner-all {% if first_item and first_item.get_id() == element.get_id() %}selected{% endif %}">
|
<div id="scid_{{element.getId()}}" class="basket_element ui-corner-all {% if first_item and first_item.getId() == element.getId() %}selected{% endif %}">
|
||||||
<div class="display_id">{{element.get_ord()}}</div>
|
<div class="display_id">{{element.getOrd()}}</div>
|
||||||
{{thumbnail.format(element.get_record().get_thumbnail() ,114,85, '', true, false)}}
|
{{thumbnail.format(element.getRecord().get_thumbnail() ,114,85, '', true, false)}}
|
||||||
<form name="download_form" class="download_form" style="display:none;">
|
<form name="download_form" class="download_form" style="display:none;">
|
||||||
<input type="hidden" name="basrec" value="{{element.get_record().get_serialize_key()}}"/>
|
<input type="hidden" name="basrec" value="{{element.getRecord().get_serialize_key()}}"/>
|
||||||
</form>
|
</form>
|
||||||
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.get_record().get_sbas_id(), 'record_id' : element.get_record().get_record_id() }) }}" class="previewTips"></div>
|
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<i class="icon-download icon-white"></i>
|
<i class="icon-download icon-white"></i>
|
||||||
</button>
|
</button>
|
||||||
<form name="download_form" style="display:none;">
|
<form name="download_form" style="display:none;">
|
||||||
<input type="hidden" name="basrec" value="{{feed_element.get_record().get_serialize_key()}}"/>
|
<input type="hidden" name="basrec" value="{{feed_element.getRecord().get_serialize_key()}}"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block header_rss %}
|
{% block header_rss %}
|
||||||
{% for feed in feeds %}
|
{% for feed in feeds %}
|
||||||
{% set link = feed.get_homepage_link(app['phraseanet.registry'], 'rss') %}
|
{% set link = app['feed.user-link-generator'].generatePublic(feed, 'rss') %}
|
||||||
<link rel="alternate" type="{{ link.get_mimetype() }}" title="{{ link.get_title() }}" href="{{ link.get_href() }}" />
|
<link rel="alternate" type="{{ link.get_mimetype() }}" title="{{ link.get_title() }}" href="{{ link.get_href() }}" />
|
||||||
{% set link = feed.get_homepage_link(app['phraseanet.registry'], 'atom') %}
|
{% set link = app['feed.user-link-generator'].generatePublic(feed, 'atom') %}
|
||||||
<link rel="alternate" type="{{ link.get_mimetype() }}" title="{{ link.get_title() }}" href="{{ link.get_href() }}" />
|
<link rel="alternate" type="{{ link.get_mimetype() }}" title="{{ link.get_title() }}" href="{{ link.get_href() }}" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -16,46 +16,46 @@
|
|||||||
</style>
|
</style>
|
||||||
<div class="PNB" style="height:200px;bottom:auto;">
|
<div class="PNB" style="height:200px;bottom:auto;">
|
||||||
<div class="PNB10 record_list" style="overflow:auto;">
|
<div class="PNB10 record_list" style="overflow:auto;">
|
||||||
{% for content in entry.get_content() %}
|
{% for content in entry.getItems() %}
|
||||||
<div class="sortable" style="position:relative;float:left;">
|
<div class="sortable" style="position:relative;float:left;">
|
||||||
{{ _self.format_diapo(content.get_record()) }}
|
{{ _self.format_diapo(content.getRecord()) }}
|
||||||
<form>
|
<form>
|
||||||
<input type="hidden" name="item_id" value="{{content.get_id()}}" />
|
<input type="hidden" name="item_id" value="{{content.getId()}}" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="{{ path('prod_feeds_entry_update', { 'id' : entry.get_id() }) }}" class="entry_update main_form">
|
<form method="post" action="{{ path('prod_feeds_entry_update', { 'id' : entry.getId() }) }}" class="entry_update main_form">
|
||||||
<input type="hidden" name="sorted_lst" value="" />
|
<input type="hidden" name="sorted_lst" value="" />
|
||||||
<div class="PNB" style="top:200px;bottom:50px;">
|
<div class="PNB" style="top:200px;bottom:50px;">
|
||||||
<div class="PNB" style="width:50%;right:auto;">
|
<div class="PNB" style="width:50%;right:auto;">
|
||||||
<div class="PNB10 fields">
|
<div class="PNB10 fields">
|
||||||
<div><label for="feed_add_title">{% trans 'publication : titre' %}</label></div>
|
<div><label for="feed_add_title">{% trans 'publication : titre' %}</label></div>
|
||||||
<div><input class="required_text" type="text" name="title" id="feed_add_title" value="{{ entry.get_title() }}" /></div>
|
<div><input class="required_text" type="text" name="title" id="feed_add_title" value="{{ entry.getTitle() }}" /></div>
|
||||||
<div><label for="feed_add_subtitle">{% trans 'publication : sous titre' %}</label></div>
|
<div><label for="feed_add_subtitle">{% trans 'publication : sous titre' %}</label></div>
|
||||||
<div><textarea id="feed_add_subtitle" name="subtitle">{{ entry.get_subtitle() }}</textarea></div>
|
<div><textarea id="feed_add_subtitle" name="subtitle">{{ entry.getSubtitle() }}</textarea></div>
|
||||||
<div><label for="feed_add_author_name">{% trans 'publication : autheur' %}</label></div>
|
<div><label for="feed_add_author_name">{% trans 'publication : autheur' %}</label></div>
|
||||||
<div><input class="required_text" type="text" name="author_name" id="feed_add_author_name" value="{{ entry.get_author_name() }}" /></div>
|
<div><input class="required_text" type="text" name="author_name" id="feed_add_author_name" value="{{ entry.getAuthorName() }}" /></div>
|
||||||
<div><label for="feed_add_author_mail">{% trans 'publication : email autheur' %}</label></div>
|
<div><label for="feed_add_author_mail">{% trans 'publication : email autheur' %}</label></div>
|
||||||
<div><input class="required_text" type="text" name="author_mail" id="feed_add_author_mail" value="{{ entry.get_author_email() }}" /></div>
|
<div><input class="required_text" type="text" name="author_mail" id="feed_add_author_mail" value="{{ entry.getAuthorEmail() }}" /></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="PNB" style="width:50%;left:auto;">
|
<div class="PNB" style="width:50%;left:auto;">
|
||||||
<div class="PNB10 feeds">
|
<div class="PNB10 feeds">
|
||||||
<h1>{% trans 'Fils disponibles' %}</h1>
|
<h1>{% trans 'Fils disponibles' %}</h1>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
{% set feed_id = entry.get_feed().get_id() %}
|
{% set feed_id = entry.getFeed().getId() %}
|
||||||
{% for feed in feeds.get_feeds() %}
|
{% for feed in feeds %}
|
||||||
{% if feed.is_publisher(app['authentication'].getUser()) %}
|
{% if feed.isPublisher(app['authentication'].getUser()) %}
|
||||||
<div class="feed {% if loop.index is odd%}odd{% endif %} {% if feed_id == feed.get_id() %}selected{% endif %}">
|
<div class="feed {% if loop.index is odd%}odd{% endif %} {% if feed_id == feed.getId() %}selected{% endif %}">
|
||||||
<span>{{ feed.get_title() }}</span>
|
<span>{{ feed.getTitle() }}</span>
|
||||||
<input type="hidden" value="{{ feed.get_id() }}"/>
|
<input type="hidden" value="{{ feed.getId() }}"/>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<input type="hidden" value="{{ feed_id }}" name="feed_id" />
|
<input type="hidden" value="{{ feed_id }}" name="feed_id" />
|
||||||
<input type="hidden" value="{{ entry.get_id() }}" name="entry_id" />
|
<input type="hidden" value="{{ entry.getId() }}" name="entry_id" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block rss %}
|
{% block rss %}
|
||||||
{% for feed in aggregate.getFeeds() %}
|
{% for feed in feeds %}
|
||||||
{% set link = app['feed.user-link-generator'].generate(feed, app['authentication'].getUser(), 'rss') %}
|
{% set link = app['feed.user-link-generator'].generate(feed, app['authentication'].getUser(), 'rss') %}
|
||||||
<link rel="alternate" type="{{ link.getMimetype() }}" title="{{ link.getTitle() }}" href="{{ link.getURI() }}" />
|
<link rel="alternate" type="{{ link.getMimetype() }}" title="{{ link.getTitle() }}" href="{{ link.getURI() }}" />
|
||||||
{% set link = app['feed.user-link-generator'].generate(feed, app['authentication'].getUser(), 'rss') %}
|
{% set link = app['feed.user-link-generator'].generate(feed, app['authentication'].getUser(), 'rss') %}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Feed\Aggregate;
|
|
||||||
use Alchemy\Phrasea\Feed\AggregateLinkGenerator;
|
|
||||||
use Alchemy\Phrasea\Feed\LinkGenerator;
|
|
||||||
use Symfony\Component\CssSelector\CssSelector;
|
use Symfony\Component\CssSelector\CssSelector;
|
||||||
|
|
||||||
class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
@@ -41,34 +38,6 @@ class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
protected $entry_authorname = 'author name';
|
protected $entry_authorname = 'author name';
|
||||||
protected $entry_authormail = 'author.mail@example.com';
|
protected $entry_authormail = 'author.mail@example.com';
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
// $this->publisher = new \Entities\FeedPublisher(self::$DI['user']);
|
|
||||||
//
|
|
||||||
// $this->feed = new \Entities\Feed($this->publisher, $this->feed_title, $this->feed_subtitle);
|
|
||||||
//
|
|
||||||
// $this->entry = new \Entities\FeedEntry(
|
|
||||||
// $this->feed
|
|
||||||
// , $this->publisher
|
|
||||||
// , $this->entry_title
|
|
||||||
// , $this->entry_subtitle
|
|
||||||
// , $this->entry_authorname
|
|
||||||
// , $this->entry_authormail
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// $this->item = new \Entities\FeedItem($this->entry, self::$DI['record_1']);
|
|
||||||
//
|
|
||||||
// $this->publisher->setFeed($this->feed);
|
|
||||||
//
|
|
||||||
// self::$DI['app']["EM"]->persist($this->feed);
|
|
||||||
// self::$DI['app']["EM"]->persist($this->publisher);
|
|
||||||
// self::$DI['app']["EM"]->persist($this->entry);
|
|
||||||
// self::$DI['app']["EM"]->persist($this->item);
|
|
||||||
// self::$DI['app']["EM"]->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
@@ -80,21 +49,6 @@ class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
self::$DI['user']->ACL()->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000');
|
self::$DI['user']->ACL()->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
|
||||||
{
|
|
||||||
// if ($this->feed instanceof \Entities\Feed) {
|
|
||||||
// self::$DI['app']["EM"]->remove($this->feed);
|
|
||||||
// } else if ($this->entry instanceof \Entities\FeedEntry) {
|
|
||||||
// self::$DI['app']["EM"]->remove($this->entry);
|
|
||||||
// if ($this->publisher instanceof \Entities\FeedPublisher) {
|
|
||||||
// self::$DI['app']["EM"]->remove($this->publisher);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// self::$DI['app']["EM"]->flush();
|
|
||||||
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRequestAvailable()
|
public function testRequestAvailable()
|
||||||
{
|
{
|
||||||
$feed = $this->insertOneFeed(self::$DI['user']);
|
$feed = $this->insertOneFeed(self::$DI['user']);
|
||||||
@@ -178,12 +132,9 @@ class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
{
|
{
|
||||||
$entry = $this->insertOneFeedEntry(self::$DI['user_alt1']);
|
$entry = $this->insertOneFeedEntry(self::$DI['user_alt1']);
|
||||||
|
|
||||||
try {
|
$crawler = self::$DI['client']->request('GET', '/prod/feeds/entry/' . $entry->getId() . '/edit/');
|
||||||
$crawler = self::$DI['client']->request('GET', '/prod/feeds/entry/' . $entry->getId() . '/edit/');
|
$pageContent = self::$DI['client']->getResponse();
|
||||||
$this->fail('Should raise an exception');
|
$this->assertEquals(403, $pageContent->getStatusCode());
|
||||||
} catch (\Exception_UnauthorizedAction $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEntryUpdate()
|
public function testEntryUpdate()
|
||||||
@@ -474,46 +425,67 @@ class ControllerFeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
{
|
{
|
||||||
$feed = $this->insertOneFeed(self::$DI['user']);
|
$feed = $this->insertOneFeed(self::$DI['user']);
|
||||||
|
|
||||||
$generator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGenerator')
|
self::$DI['app']['feed.aggregate-link-generator'] = $this->getMockBuilder('Alchemy\Phrasea\Feed\AggregateLinkGenerator')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
$link = $this->getMockBuilder('Alchemy\Phrasea\Feed\FeedLink')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$link->expects($this->once())
|
||||||
|
->method('getURI')
|
||||||
|
->will($this->returnValue('http://aggregated-link/'));
|
||||||
|
self::$DI['app']['feed.aggregate-link-generator']->expects($this->once())
|
||||||
|
->method('generate')
|
||||||
|
->with($this->isInstanceOf('Alchemy\Phrasea\Feed\Aggregate'), $this->isInstanceOf('\User_Adapter'), 'rss', null, false)
|
||||||
|
->will($this->returnValue($link));
|
||||||
|
|
||||||
$random = self::$DI['app']['tokens'];
|
self::$DI['client']->request('GET', '/prod/feeds/subscribe/aggregated/');
|
||||||
|
|
||||||
$aggregateGenerator = new AggregateLinkGenerator($generator, self::$DI['app']['EM'], $random);
|
|
||||||
|
|
||||||
$feeds = self::$DI['app']["EM"]->getRepository("\Entities\Feed")->getAllForUser(self::$DI['user']);
|
|
||||||
$crawler = self::$DI['client']->request('GET', '/prod/feeds/subscribe/aggregated/');
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertTrue(is_object($pageContent));
|
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent(), true);
|
||||||
$this->assertTrue(is_string($pageContent->texte));
|
|
||||||
$aggregate = new Aggregate(self::$DI['app'], $feeds);
|
$this->assertArrayHasKey('texte', $pageContent);
|
||||||
$suscribe_link = $aggregateGenerator->generate($aggregate, self::$DI['user'], AggregateLinkGenerator::FORMAT_RSS);
|
$this->assertArrayHasKey('titre', $pageContent);
|
||||||
$this->assertContains($suscribe_link->getURI(), $pageContent->texte);
|
|
||||||
|
$this->assertInternalType('string', $pageContent['texte']);
|
||||||
|
$this->assertInternalType('string', $pageContent['titre']);
|
||||||
|
|
||||||
|
$this->assertContains('http://aggregated-link/', $pageContent['texte']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSuscribe()
|
public function testSuscribe()
|
||||||
{
|
{
|
||||||
$feed = $this->insertOneFeed(self::$DI['user']);
|
$feed = $this->insertOneFeed(self::$DI['user']);
|
||||||
|
|
||||||
$generator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGenerator')
|
self::$DI['app']['feed.user-link-generator'] = $this->getMockBuilder('Alchemy\Phrasea\Feed\LinkGenerator')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
$link = $this->getMockBuilder('Alchemy\Phrasea\Feed\FeedLink')
|
||||||
$random = self::$DI['app']['tokens'];
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
$linkGenerator = new LinkGenerator($generator, self::$DI['app']['EM'], $random);
|
$link->expects($this->once())
|
||||||
|
->method('getURI')
|
||||||
|
->will($this->returnValue('http://user-link/'));
|
||||||
|
self::$DI['app']['feed.user-link-generator']->expects($this->once())
|
||||||
|
->method('generate')
|
||||||
|
->with($this->isInstanceOf('\Entities\Feed'), $this->isInstanceOf('\User_Adapter'), 'rss', null, false)
|
||||||
|
->will($this->returnValue($link));
|
||||||
|
|
||||||
$crawler = self::$DI['client']->request('GET', '/prod/feeds/subscribe/' . $feed->getId() . '/');
|
$crawler = self::$DI['client']->request('GET', '/prod/feeds/subscribe/' . $feed->getId() . '/');
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertTrue(is_object($pageContent));
|
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent(), true);
|
||||||
$this->assertTrue(is_string($pageContent->texte));
|
|
||||||
$suscribe_link = $linkGenerator->generate($feed, self::$DI['user'], LinkGenerator::FORMAT_RSS);
|
$this->assertArrayHasKey('texte', $pageContent);
|
||||||
var_dump($suscribe_link);
|
$this->assertArrayHasKey('titre', $pageContent);
|
||||||
$this->assertContains($suscribe_link->getURI(), $pageContent->texte);
|
|
||||||
|
$this->assertInternalType('string', $pageContent['texte']);
|
||||||
|
$this->assertInternalType('string', $pageContent['titre']);
|
||||||
|
|
||||||
|
$this->assertContains('http://user-link/', $pageContent['texte']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
$link = $linkGenerator->generate($aggregate, $user, $format, $page, $renew);
|
$link = $linkGenerator->generate($aggregate, $user, $format, $page, $renew);
|
||||||
|
|
||||||
$this->assertSame($expected, $link->getUri());
|
|
||||||
if ($format == "atom") {
|
if ($format == "atom") {
|
||||||
$this->assertSame("application/atom+xml", $link->getMimetype());
|
$this->assertSame("application/atom+xml", $link->getMimetype());
|
||||||
$this->assertSame("AGGREGATE - Atom", $link->getTitle());
|
$this->assertSame("AGGREGATE - Atom", $link->getTitle());
|
||||||
@@ -61,8 +60,10 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
if ($alreadyCreated) {
|
if ($alreadyCreated) {
|
||||||
if ($renew) {
|
if ($renew) {
|
||||||
$this->assertCount(2, $capture);
|
|
||||||
$this->assertEquals($format, $capture['format']);
|
$this->assertEquals($format, $capture['format']);
|
||||||
|
if (null !== $page) {
|
||||||
|
$this->assertEquals($page, $capture['page']);
|
||||||
|
}
|
||||||
$this->assertNotEquals($tokenValue, $capture['token']);
|
$this->assertNotEquals($tokenValue, $capture['token']);
|
||||||
|
|
||||||
$this->assertCount(0, self::$DI['app']['EM']
|
$this->assertCount(0, self::$DI['app']['EM']
|
||||||
@@ -72,17 +73,25 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
->getRepository("Entities\AggregateToken")
|
->getRepository("Entities\AggregateToken")
|
||||||
->findBy(array('value' => $capture['token'])));
|
->findBy(array('value' => $capture['token'])));
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(array(
|
$expectedParams = array(
|
||||||
'token' => $tokenValue,
|
'token' => $tokenValue,
|
||||||
'format' => $format,
|
'format' => $format,
|
||||||
), $capture);
|
);
|
||||||
|
|
||||||
|
if ($page !== null) {
|
||||||
|
$expectedParams['page'] = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($expectedParams, $capture);
|
||||||
|
|
||||||
$this->assertCount(1, self::$DI['app']['EM']
|
$this->assertCount(1, self::$DI['app']['EM']
|
||||||
->getRepository("Entities\AggregateToken")
|
->getRepository("Entities\AggregateToken")
|
||||||
->findBy(array('value' => $tokenValue)));
|
->findBy(array('value' => $tokenValue)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->assertCount(2, $capture);
|
if (null !== $page) {
|
||||||
|
$this->assertEquals($page, $capture['page']);
|
||||||
|
}
|
||||||
$this->assertEquals($format, $capture['format']);
|
$this->assertEquals($format, $capture['format']);
|
||||||
$this->assertEquals(12, strlen($capture['token']));
|
$this->assertEquals(12, strlen($capture['token']));
|
||||||
|
|
||||||
@@ -126,4 +135,14 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
array('doliprane', 'rss', $user, 1, true, true),
|
array('doliprane', 'rss', $user, 1, true, true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideGenerationDataPublic()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('doliprane', 'atom', null),
|
||||||
|
array('doliprane', 'atom', 1),
|
||||||
|
array('doliprane', 'rss', null),
|
||||||
|
array('doliprane', 'rss', 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,12 @@ class LinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
if ($alreadyCreated) {
|
if ($alreadyCreated) {
|
||||||
if ($renew) {
|
if ($renew) {
|
||||||
$this->assertCount(3, $capture);
|
|
||||||
$this->assertEquals($feed->getId(), $capture['id']);
|
$this->assertEquals($feed->getId(), $capture['id']);
|
||||||
$this->assertEquals($format, $capture['format']);
|
$this->assertEquals($format, $capture['format']);
|
||||||
$this->assertNotEquals($tokenValue, $capture['token']);
|
$this->assertNotEquals($tokenValue, $capture['token']);
|
||||||
|
if (null !== $page) {
|
||||||
|
$this->assertEquals($page, $capture['page']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertCount(0, self::$DI['app']['EM']
|
$this->assertCount(0, self::$DI['app']['EM']
|
||||||
->getRepository("Entities\FeedToken")
|
->getRepository("Entities\FeedToken")
|
||||||
@@ -64,18 +66,26 @@ class LinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
->getRepository("Entities\FeedToken")
|
->getRepository("Entities\FeedToken")
|
||||||
->findBy(array('value' => $capture['token'])));
|
->findBy(array('value' => $capture['token'])));
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(array(
|
$expectedParams = array(
|
||||||
'token' => $tokenValue,
|
'token' => $tokenValue,
|
||||||
'id' => $feed->getId(),
|
'id' => $feed->getId(),
|
||||||
'format' => $format,
|
'format' => $format,
|
||||||
), $capture);
|
);
|
||||||
|
|
||||||
|
if ($page !== null) {
|
||||||
|
$expectedParams['page'] = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($expectedParams, $capture);
|
||||||
|
|
||||||
$this->assertCount(1, self::$DI['app']['EM']
|
$this->assertCount(1, self::$DI['app']['EM']
|
||||||
->getRepository("Entities\FeedToken")
|
->getRepository("Entities\FeedToken")
|
||||||
->findBy(array('value' => $tokenValue)));
|
->findBy(array('value' => $tokenValue)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->assertCount(3, $capture);
|
if (null !== $page) {
|
||||||
|
$this->assertEquals($page, $capture['page']);
|
||||||
|
}
|
||||||
$this->assertEquals($feed->getId(), $capture['id']);
|
$this->assertEquals($feed->getId(), $capture['id']);
|
||||||
$this->assertEquals($format, $capture['format']);
|
$this->assertEquals($format, $capture['format']);
|
||||||
$this->assertEquals(12, strlen($capture['token']));
|
$this->assertEquals(12, strlen($capture['token']));
|
||||||
@@ -91,6 +101,51 @@ class LinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
self::$DI['app']['EM']->flush();
|
self::$DI['app']['EM']->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideGenerationDataPublic
|
||||||
|
*/
|
||||||
|
public function testGeneratePublic($expected, $format, $feed, $page)
|
||||||
|
{
|
||||||
|
self::$DI['app']['EM']->persist($feed);
|
||||||
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
|
$generator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGenerator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$capture = null;
|
||||||
|
$generator->expects($this->once())
|
||||||
|
->method('generate')
|
||||||
|
->with('feed_public', $this->isType('array'), UrlGenerator::ABSOLUTE_URL)
|
||||||
|
->will($this->returnCallback(function ($name, $data, $option) use (&$capture, $expected) {
|
||||||
|
$capture = $data;
|
||||||
|
|
||||||
|
return $expected;
|
||||||
|
}));
|
||||||
|
|
||||||
|
$random = self::$DI['app']['tokens'];
|
||||||
|
|
||||||
|
$linkGenerator = new LinkGenerator($generator, self::$DI['app']['EM'], $random);
|
||||||
|
|
||||||
|
$link = $linkGenerator->generatePublic($feed, $format, $page);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $link->getUri());
|
||||||
|
if ($format == "atom") {
|
||||||
|
$this->assertSame("application/atom+xml", $link->getMimetype());
|
||||||
|
$this->assertSame("Title - Atom", $link->getTitle());
|
||||||
|
}
|
||||||
|
elseif ($format == "rss") {
|
||||||
|
$this->assertSame("application/rss+xml", $link->getMimetype());
|
||||||
|
$this->assertSame("Title - RSS", $link->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $page) {
|
||||||
|
$this->assertEquals($page, $capture['page']);
|
||||||
|
}
|
||||||
|
$this->assertEquals($feed->getId(), $capture['id']);
|
||||||
|
$this->assertEquals($format, $capture['format']);
|
||||||
|
}
|
||||||
|
|
||||||
public function provideGenerationData()
|
public function provideGenerationData()
|
||||||
{
|
{
|
||||||
$user = $this->getMockBuilder('User_Adapter')
|
$user = $this->getMockBuilder('User_Adapter')
|
||||||
@@ -123,4 +178,17 @@ class LinkGeneratorTest extends \PhraseanetPHPUnitAbstract
|
|||||||
array('doliprane', 'rss', $feed, $user, 1, true, true),
|
array('doliprane', 'rss', $feed, $user, 1, true, true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideGenerationDataPublic()
|
||||||
|
{
|
||||||
|
$feed = new \Entities\Feed();
|
||||||
|
$feed->setTitle('Title');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array('doliprane', 'atom', $feed, null),
|
||||||
|
array('doliprane', 'atom', $feed, 1),
|
||||||
|
array('doliprane', 'rss', $feed, null),
|
||||||
|
array('doliprane', 'rss', $feed, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user