Replaced remaining occurrences of Feed_ classes, updated tests

This commit is contained in:
Andrey
2013-06-12 17:54:36 +02:00
parent 9a5baff4a0
commit 84300f3c92
33 changed files with 310 additions and 296 deletions

View File

@@ -62,7 +62,7 @@ class Publications implements ControllerProviderInterface
$feed->setIconUrl(false);
if ($request->request->get('public') == '1') {
$feed->setPublic(true);
$feed->setIsPublic(true);
} elseif ($request->request->get('base_id')) {
$feed->setCollection(\collection::get_from_base_id($app, $request->request->get('base_id')));
}
@@ -102,7 +102,7 @@ class Publications implements ControllerProviderInterface
$feed->setSubtitle($subtitle);
}
$feed->setCollection($collection);
$feed->setPublic($request->request->get('public') === '1' ? true : false);
$feed->setIsPublic($request->request->get('public') === '1' ? true : false);
$app['EM']->persist($feed);
$app['EM']->flush();

View File

@@ -161,12 +161,12 @@ class Lightbox implements ControllerProviderInterface
$controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(SilexApplication $app, $entry_id, $item_id) {
$entry = $app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$item = $entry->getItems()->getItem($item_id);
$item = $entry->getItem($item_id);
if ($app['browser']->isMobile()) {
$output = $app['twig']->render('lightbox/feed_element.html.twig', array(
'feed_element' => $item,
'module_name' => $item->getRecord()->get_title()
'module_name' => $item->getRecord($app)->get_title()
)
);
@@ -181,12 +181,12 @@ class Lightbox implements ControllerProviderInterface
}
$ret = array();
$ret['number'] = $item->get_record()->get_number();
$ret['title'] = $item->get_record()->get_title();
$ret['number'] = $item->getRecord($app)->get_number();
$ret['title'] = $item->getRecord($app)->get_title();
$ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->get_record(), 'not_wrapped' => true));
$ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->getRecord($app), 'not_wrapped' => true));
$ret['options_html'] = $app['twig']->render($template_options, array('feed_element' => $item));
$ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->get_record()));
$ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->getRecord($app)));
$ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = '';
@@ -313,7 +313,7 @@ class Lightbox implements ControllerProviderInterface
return $app->redirectPath('logout');
}
$feed_entry = $app['EM']->getEntity('Entities\FeedEntry')->find($entry_id);
$feed_entry = $app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$template = 'lightbox/feed.html.twig';
@@ -322,10 +322,11 @@ class Lightbox implements ControllerProviderInterface
}
$content = $feed_entry->getItems();
$first = $content->first();
$output = $app['twig']->render($template, array(
'feed_entry' => $feed_entry,
'first_item' => array_shift($content),
'first_item' => $first,
'local_title' => $feed_entry->getTitle(),
'module' => 'lightbox',
'module_name' => _('admin::monitor: module validation')

View File

@@ -36,7 +36,7 @@ class RSSFeeds implements ControllerProviderInterface
$app->abort(404, 'Feed not found');
}
if (!$feed->getPublic()) {
if (!$feed->isPublic()) {
$app->abort(403, 'Forbidden');
}
@@ -110,7 +110,7 @@ class RSSFeeds implements ControllerProviderInterface
$page = (int) $request->query->get('page');
$page = $page < 1 ? 1 : $page;
return $app[$this->getFormater('cooliris')]->createResponse($feed, $page);
return $app[$this->getFormater('cooliris')]->createResponse($feed, $page, null, 'Phraseanet', $app);
})
->bind('feed_public_cooliris');

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
@@ -34,7 +35,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf
return $response;
}
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{
$title = $feed->getTitle();
$subtitle = $feed->getSubtitle();

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
use Symfony\Component\HttpFoundation\Response;
@@ -26,15 +27,15 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
$this->linkGenerator = $generator;
}
public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{
$content = $this->format($feed, $page, $user, $generator);
$content = $this->format($feed, $page, $user, $generator, $app);
$response = new Response($content, 200, array('Content-Type' => 'application/rss+xml'));
$response->setCharset('UTF-8');
return $response;
}
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{
$title = $feed->getTitle();
$subtitle = $feed->getSubtitle();
@@ -158,28 +159,28 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
}
foreach ($feed->getEntries() as $item) {
$this->addItem($doc, $channel, $item);
$this->addItem($app, $doc, $channel, $item);
}
return $doc->saveXML();
}
protected function addItem(\DOMDocument $document, \DOMNode $feed, FeedEntry $entry)
protected function addItem(Application $app, \DOMDocument $document, \DOMNode $feed, FeedEntry $entry)
{
foreach ($entry->get_content() as $content) {
$this->addContent($document, $feed, $entry, $content);
$this->addContent($app, $document, $feed, $entry, $content);
}
}
protected function addContent(\DOMDocument $document, \DOMNode $node, FeedItem $content)
protected function addContent(Application $app, \DOMDocument $document, \DOMNode $node, FeedItem $content)
{
$preview_sd = $content->getRecord()->get_subdef('preview');
$preview_sd = $content->getRecord($app)->get_subdef('preview');
$preview_permalink = $preview_sd->get_permalink();
$thumbnail_sd = $content->getRecord()->get_thumbnail();
$thumbnail_sd = $content->getRecord($app)->get_thumbnail();
$thumbnail_permalink = $thumbnail_sd->get_permalink();
$medium = strtolower($content->getRecord()->get_type());
$medium = strtolower($content->getRecord($app)->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this;
@@ -192,13 +193,13 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
//add item node to channel node
$item = $this->addTag($document, $node, 'item');
$caption = $content->getRecord()->get_caption();
$caption = $content->getRecord($app)->get_caption();
$title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) {
$str_title = $title_field->get_serialized_values(' ');
} else {
$str_title = $content->getRecord()->get_title();
$str_title = $content->getRecord($app)->get_title();
}
//attach tile node to item node
@@ -214,7 +215,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
//attach desc node to item node
$desc = $this->addTag($document, $item, 'description', $str_desc);
$duration = $content->getRecord()->get_duration();
$duration = $content->getRecord($app)->get_duration();
if ($preview_permalink) {
$preview = $this->addTag($document, $item, 'media:content');

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
abstract class FeedFormatterAbstract
{
const PAGE_SIZE = 20;
@@ -41,14 +43,14 @@ abstract class FeedFormatterAbstract
* @param FeedItem $content
* @return FeedFormaterInterface
*/
protected function addContent(\DOMDocument $document, \DOMNode $item, FeedItem $content)
protected function addContent(Application $app, \DOMDocument $document, \DOMNode $item, FeedItem $content)
{
$preview_sd = $content->getRecord()->get_subdef('preview');
$preview_sd = $content->getRecord($app)->get_subdef('preview');
$preview_permalink = $preview_sd->get_permalink();
$thumbnail_sd = $content->getRecord()->get_thumbnail();
$thumbnail_sd = $content->getRecord($app)->get_thumbnail();
$thumbnail_permalink = $thumbnail_sd->get_permalink();
$medium = strtolower($content->getRecord()->get_type());
$medium = strtolower($content->getRecord($app)->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this;
@@ -60,7 +62,7 @@ abstract class FeedFormatterAbstract
$group = $this->addTag($document, $item, 'media:group');
$caption = $content->getRecord()->get_caption();
$caption = $content->getRecord($app)->get_caption();
$title_field = $caption->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) {

View File

@@ -16,5 +16,5 @@ interface FeedFormatterInterface
*
* @return string
*/
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet');
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null);
}

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
@@ -35,7 +36,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa
return $response;
}
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', $app = null)
{
$title = $feed->getTitle();
$subtitle = $feed->getSubtitle();

View File

@@ -91,7 +91,7 @@ class Feed implements FeedInterface
* @param boolean $public
* @return Feed
*/
public function setPublic($public)
public function setIsPublic($public)
{
$this->public = $public;
@@ -103,7 +103,7 @@ class Feed implements FeedInterface
*
* @return boolean
*/
public function getPublic()
public function isPublic()
{
return $this->public;
}

View File

@@ -2,7 +2,7 @@
namespace Entities;
use Doctrine\ORM\Mapping as ORM;
use Alchemy\Phrasea\Application;
/**
* FeedItem
@@ -196,4 +196,9 @@ class FeedItem
{
$this->setOrd($this->getEntry()->getItems()->count() + 1);
}
public function getRecord(Application $app)
{
return new \record_adapter($app, $this->getSbasId(), $this->getRecordId(), $this->getOrd());
}
}

View File

@@ -57,7 +57,7 @@ class SessionRepository extends EntityRepository
$feed = $this->find($id);
if ($feed) {
$coll = $feed->getCollection($app);
if ($feed->getPublic()
if ($feed->isPublic()
|| $coll === null
|| in_array($coll->get_base_id(), array_keys($user->ACL()->get_granted_base()))) {
return $feed;

View File

@@ -9,11 +9,16 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Feed\Aggregate;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Border\Manager as BorderManager;
use Entities\Feed;
use Entities\FeedEntry;
use Entities\FeedItem;
use Entities\UserQuery;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -1479,10 +1484,10 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
$coll = Feed_Collection::load_all($this->app, $user);
$coll = $this->app['EM']->getRepository('Entities\Feed')->getAllForUser($user);
$datas = array();
foreach ($coll->get_feeds() as $feed) {
foreach ($coll as $feed) {
$datas[] = $this->list_publication($feed, $user);
}
@@ -1512,7 +1517,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
$feed = Feed_Adapter::load_with_user($this->app, $user, $publication_id);
$feed = $this->app['EM']->getRepository('Entities\Feed')->loadWithUser($this->app, $user, $publication_id);
$offset_start = (int) ($request->get('offset_start') ? : 0);
$per_page = (int) ($request->get('per_page') ? : 5);
@@ -1535,7 +1540,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
$feed = Feed_Aggregate::load_with_user($this->app, $user);
$feed = Aggregate::createFromUser($this->app['EM'], $user);
$offset_start = (int) ($request->get('offset_start') ? : 0);
$per_page = (int) ($request->get('per_page') ? : 5);
@@ -1543,7 +1548,7 @@ class API_V1_adapter extends API_V1_Abstract
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
$datas = array(
'total_entries' => $feed->get_count_total_entries(),
'total_entries' => $feed->getCountTotalEntries(),
'offset_start' => $offset_start,
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
@@ -1558,9 +1563,9 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
$entry = Feed_Entry_Adapter::load_from_id($this->app, $entry_id);
$entry = $this->app['EM']->getRepository('Entities\FeedEntry')->find($entry_id);
$collection = $entry->get_feed()->get_collection();
$collection = $entry->getFeed()->getCollection($this->app);
if (null !== $collection && !$user->ACL()->has_access_to_base($collection->get_base_id())) {
throw new \API_V1_exception_forbidden('You have not access to the parent feed');
@@ -1578,38 +1583,38 @@ class API_V1_adapter extends API_V1_Abstract
/**
* Retrieve detailled informations about one feed
*
* @param Feed_Adapter $feed
* @param Feed $feed
* @param type $user
* @return array
*/
protected function list_publication(Feed_Adapter $feed, $user)
protected function list_publication(Feed $feed, $user)
{
return array(
'id' => $feed->get_id(),
'title' => $feed->get_title(),
'subtitle' => $feed->get_subtitle(),
'total_entries' => $feed->get_count_total_entries(),
'icon' => $feed->get_icon_url(),
'public' => $feed->is_public(),
'readonly' => !$feed->is_publisher($user),
'deletable' => $feed->is_owner($user),
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
'id' => $feed->getId(),
'title' => $feed->getTitle(),
'subtitle' => $feed->getSubtitle(),
'total_entries' => $feed->getCountTotalEntries(),
'icon' => $feed->getIconUrl(),
'public' => $feed->isPublic(),
'readonly' => !$feed->isPublisher($user),
'deletable' => $feed->isOwner($user),
'created_on' => $feed->getCreatedOn()->format(DATE_ATOM),
'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM),
);
}
/**
* Retrieve all entries of one feed
*
* @param Feed_Adapter $feed
* @param FeedInterface $feed
* @param int $offset_start
* @param int $how_many
* @return array
*/
protected function list_publications_entries(Feed_Abstract $feed, $offset_start = 0, $how_many = 5)
protected function list_publications_entries(FeedInterface $feed, $offset_start = 0, $how_many = 5)
{
$entries = $feed->get_entries($offset_start, $how_many)->get_entries();
$entries = $feed->getEntries($offset_start, $how_many);
$out = array();
foreach ($entries as $entry) {
@@ -1622,42 +1627,42 @@ class API_V1_adapter extends API_V1_Abstract
/**
* Retrieve detailled information about one feed entry
*
* @param Feed_Entry_Adapter $entry
* @param FeedEntry $entry
* @return array
*/
protected function list_publication_entry(Feed_Entry_Adapter $entry)
protected function list_publication_entry(FeedEntry $entry)
{
$items = array();
foreach ($entry->get_content() as $item) {
foreach ($entry->getItems() as $item) {
$items[] = $this->list_publication_entry_item($item);
}
return array(
'id' => $entry->get_id(),
'author_email' => $entry->get_author_email(),
'author_name' => $entry->get_author_name(),
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
'title' => $entry->get_title(),
'subtitle' => $entry->get_subtitle(),
'id' => $entry->getId(),
'author_email' => $entry->getAuthorEmail(),
'author_name' => $entry->getAuthorName(),
'created_on' => $entry->getCreatedOn()->format(DATE_ATOM),
'updated_on' => $entry->getUpdatedOn()->format(DATE_ATOM),
'title' => $entry->getTitle(),
'subtitle' => $entry->getSubtitle(),
'items' => $items,
'feed_id' => $entry->get_feed()->get_id(),
'feed_url' => '/feeds/' . $entry->get_feed()->get_id() . '/content/',
'url' => '/feeds/entry/' . $entry->get_id() . '/',
'feed_id' => $entry->getFeed()->getId(),
'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/',
'url' => '/feeds/entry/' . $entry->getId() . '/',
);
}
/**
* Retrieve detailled informations about one feed entry item
*
* @param Feed_Entry_Item $item
* @param FeedItem $item
* @return array
*/
protected function list_publication_entry_item(Feed_Entry_Item $item)
protected function list_publication_entry_item(FeedItem $item)
{
$datas = array(
'item_id' => $item->get_id()
, 'record' => $this->list_record($item->get_record())
'item_id' => $item->getId()
, 'record' => $this->list_record($item->getRecord($this->app))
);
return $datas;

View File

@@ -140,7 +140,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$sx = simplexml_load_string($datas);
try {
$entry = $this->app['EM']->getRepository("Entities\FeedEntry")->find((int) $sx->entry_id);
$entry = $this->app['EM']->getRepository('Entities\FeedEntry')->find((int) $sx->entry_id);
} catch (\Exception $e) {
return array();
}

View File

@@ -175,30 +175,30 @@ class record_preview extends record_adapter
}
break;
case "FEED":
$entry = Feed_Entry_Adapter::load_from_id($app, $contId);
$entry = $app['EM']->getRepository('Entities\FeedEntry')->find($contId);
$this->container = $entry;
$this->total = count($entry->get_content());
$this->total = count($entry->getItems());
$i = 0;
$first = true;
foreach ($entry->get_content() as $element) {
foreach ($entry->getItems() as $element) {
$i ++;
if ($first) {
$sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
$sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->getRecord()->get_record_id();
$this->original_item = $element;
$this->name = $entry->get_title();
$number = $element->get_ord();
$this->name = $entry->getTitle();
$number = $element->getOrd();
}
$first = false;
if ($element->get_ord() == $pos) {
$sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
if ($element->getOrd() == $pos) {
$sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->getRecord()->get_record_id();
$this->original_item = $element;
$this->name = $entry->get_title();
$number = $element->get_ord();
$this->name = $entry->getTitle();
$number = $element->getOrd();
}
}
break;

View File

@@ -0,0 +1,95 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\Feed;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Entities\Feed;
class LoadOneFeed extends AbstractFixture implements FixtureInterface
{
/**
*
* @var \Entities\Feed
*/
public $feed;
public $user;
public $title;
public $public;
public function load(ObjectManager $manager)
{
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new feed');
}
$feed = new Feed();
$publisher = new \Entities\FeedPublisher();
$publisher->setUsrId($this->user->get_id());
$publisher->setIsOwner(true);
$publisher->setFeed($feed);
$feed->addPublisher($publisher);
if (isset($this->title) && $this->title !== null) {
$feed->setTitle($this->title);
}
else {
$feed->setTitle("test");
}
if (isset($this->public) && $this->public !== null) {
$feed->setIsPublic($this->public);
}
$feed->setSubtitle("description");
$manager->persist($feed);
$manager->persist($publisher);
$manager->flush();
$this->feed = $feed;
$this->addReference('one-feed', $feed);
}
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function getUser()
{
return $this->user;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
public function setPublic($public)
{
$this->public = $public;
}
public function getPublic()
{
return $this->public;
}
}

View File

@@ -12,26 +12,26 @@
{% block content %}
<div id="home" data-role="page">
<div data-role="header">
<h1>{{feed_entry.get_title()}}</h1>
<h1>{{feed_entry.getTitle()}}</h1>
<a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">{% trans 'Home' %}</a>
</div>
<div data-role="content">
<p>
{{feed_entry.get_subtitle()|nl2br|raw}}
{{feed_entry.getSubtitle()|nl2br|raw}}
</p>
<p>
{% set author = feed_entry.get_author_name() %}
{% set author = feed_entry.getAuthorName() %}
<span class="author">{% trans %}Par {{ author }}{% endtrans %}</span>
{% set entry_length = feed_entry.get_content()|length %}
{% set entry_length = feed_entry.getItems()|length %}
{% trans %}{{entry_length}} documents{% endtrans %}
</p>
<ul class="image_set">
{% for item in feed_entry.get_content() %}
<li class="image_box" id="item_{{item.get_id()}}">
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.get_id(), 'item_id' : item.get_id()}) }}">
{{thumbnail.format(item.get_record().get_thumbnail(), 80, 80, '', true, false)}}
{% for item in feed_entry.getItems() %}
<li class="image_box" id="item_{{item.getId()}}">
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : item.getId()}) }}">
{{thumbnail.format(item.getRecord().get_thumbnail(), 80, 80, '', true, false)}}
</a>
<input type="hidden" class="display_id" name="display_id" value="{{item.get_ord()}}" />
<input type="hidden" class="display_id" name="display_id" value="{{item.getOrd()}}" />
</li>
{% endfor %}
</ul>

View File

@@ -11,11 +11,11 @@
{% endblock %}
{% block content %}
{% set record = feed_element.get_record() %}
{% set record = feed_element.getRecord(app) %}
<div data-role="page">
<div data-role="header">
<a href="{{ path('lightbox_feed_entry', { 'entry_id' : feed_element.get_entry().get_id() }) }}" data-rel="back" data-icon="arrow-l">Back</a>
<h1>{{feed_element.get_ord()}} - {{record.get_title()}}</h1>
<a href="{{ path('lightbox_feed_entry', { 'entry_id' : feed_element.getEntry().getId() }) }}" data-rel="back" data-icon="arrow-l">Back</a>
<h1>{{feed_element.getOrd()}} - {{record.getTitle()}}</h1>
<a rel="external" href="{{ path('lightbox') }}" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
</div>
<div data-role="content">

View File

@@ -99,7 +99,7 @@
<div class="control-group">
<label class="control-label" for="edit_pub_base_id">{% trans 'Etendue de la publication' %} :</label>
<div class="controls">
<select id="edit_pub_base_id" class="input-large" name="base_id" {% if feed.getPublic() %}disabled="disabled"{% endif %}>
<select id="edit_pub_base_id" class="input-large" name="base_id" {% if feed.isPublic() %}disabled="disabled"{% endif %}>
<option value="">{% trans 'Non-Restreinte (publique)' %}</option>
{% for databox in app['authentication'].getUser().ACL().get_granted_sbas('bas_chupub') %}
<optgroup label="{{ databox.get_label(app['locale.I18n']) }}">
@@ -114,7 +114,7 @@
<div class="control-group">
<div class="controls">
<label class="checkbox" for="edit_pub_public">
<input type="checkbox" id="edit_pub_public" class="input-large" name="public" value="1" {% if feed.getPublic() %}checked="checked"{% endif %} />
<input type="checkbox" id="edit_pub_public" class="input-large" name="public" value="1" {% if feed.isPublic() %}checked="checked"{% endif %} />
{% trans 'Publique' %}
</label>
</div>

View File

@@ -85,7 +85,7 @@
{% endif %}
</td>
<td valign="center" align="center">
{% if feed.getPublic() %}
{% if feed.isPublic() %}
<img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/>
{% endif %}
</td>

View File

@@ -18,11 +18,11 @@
<tr valign="middle">
<td style="width:10px;"></td>
<td style="width:35px;text-align:center;">
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div>
<div class="display_id">{% if first_item %}{{first_item.getOrd()}}{% endif %}</div>
</td>
<td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().get_title}}{% endif %}
<div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div>
</td>
<td style="text-align:right;width:230px;">
@@ -34,10 +34,10 @@
</div>
<div class="lightbox_container left">
{% if first_item %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %}
{% set preview = first_item.get_record().get_preview() %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.getRecord(app), 'preview') %}
{% set preview = first_item.getRecord(app).get_preview() %}
{% else %}
{% set preview = first_item.get_record().get_thumbnail() %}
{% set preview = first_item.getRecord(app).get_thumbnail() %}
{% endif %}
{{thumbnail.format(preview, preview.get_width(), preview.get_height(),'', false, false)}}
{% endif %}
@@ -52,8 +52,8 @@
<div class="display_id"></div>
</td>
<td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.get_record().get_title|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().get_title}}{% endif %}
<div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div>
</td>
<td style="text-align:right;width:230px;">
@@ -81,9 +81,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;">
<div id="record_infos">
<div class="lightbox_container">
{% 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.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %}
{{caption.format_caption(first_item.get_record(), '', null, business)}}
{{caption.format_caption(first_item.getRecord(app), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -6,9 +6,9 @@
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}">
<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.getOrd()}}</div>
{{thumbnail.format(element.getRecord().get_thumbnail() ,114,85, '', true, false)}}
{{thumbnail.format(element.getRecord(app).get_thumbnail() ,114,85, '', true, false)}}
<form name="download_form" class="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{element.getRecord().get_serialize_key()}}"/>
<input type="hidden" name="basrec" value="{{element.getRecord(app).get_serialize_key()}}"/>
</form>
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div>
</div>

View File

@@ -22,7 +22,7 @@
<img src="/skins/lightbox/saveie6.png"/>
</button>
<form name="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{feed_element.getRecord().get_serialize_key()}}"/>
<input type="hidden" name="basrec" value="{{feed_element.getRecord(app).get_serialize_key()}}"/>
</form>
|
{% endif %}

View File

@@ -24,11 +24,11 @@
<tr valign="middle">
<td style="width:10px;"></td>
<td style="width:35px;text-align:center;">
<div class="display_id">{% if first_item %}{{first_item.get_ord()}}{% endif %}</div>
<div class="display_id">{% if first_item %}{{first_item.getOrd()}}{% endif %}</div>
</td>
<td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().getTitle|e}}{% endif %}">
{% if first_item %}{{first_item.get_record().getTitle|raw}}{% endif %}
<div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord(app).get_title|raw}}{% endif %}
</div>
</td>
<td style="text-align:right;width:230px;">
@@ -42,10 +42,10 @@
</div>
<div class="lightbox_container PNB record_display_box">
{% if first_item %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.get_record(), 'preview') %}
{% set bask_prev = first_item.getRecord().get_preview() %}
{% if app['authentication'].getUser().ACL().has_access_to_subdef(first_item.getRecord(app), 'preview') %}
{% set bask_prev = first_item.getRecord(app).get_preview() %}
{% else %}
{% set bask_prev = first_item.getRecord().get_thumbnail() %}
{% set bask_prev = first_item.getRecord(app).get_thumbnail() %}
{% endif %}
{{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'', false, false)}}
{% endif %}
@@ -60,8 +60,8 @@
<div class="display_id"></div>
</td>
<td style="text-align:left;width:auto;">
<div class="title title15" title="{% if first_item %}{{first_item.getRecord().get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord().get_title}}{% endif %}
<div class="title title15" title="{% if first_item %}{{first_item.getRecord(app).get_title|e}}{% endif %}">
{% if first_item %}{{first_item.getRecord(app).get_title}}{% endif %}
</div>
</td>
<td style="text-align:right;width:230px;">
@@ -81,9 +81,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB">
<div id="record_infos" class="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.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %}
{{caption.format_caption(first_item.getRecord(), '', null, business)}}
{{caption.format_caption(first_item.getRecord(app), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -6,9 +6,9 @@
<a href="{{ path('lightbox_ajax_load_feeditem', { 'entry_id' : feed_entry.getId(), 'item_id' : element.getId()}) }}">
<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.getOrd()}}</div>
{{thumbnail.format(element.getRecord().get_thumbnail() ,114,85, '', true, false)}}
{{thumbnail.format(element.getRecord(app).get_thumbnail() ,114,85, '', true, false)}}
<form name="download_form" class="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{element.getRecord().get_serialize_key()}}"/>
<input type="hidden" name="basrec" value="{{element.getRecord(app).get_serialize_key()}}"/>
</form>
<div tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : element.getRecord().get_sbas_id(), 'record_id' : element.getRecord().get_record_id() }) }}" class="previewTips"></div>
</div>

View File

@@ -22,7 +22,7 @@
<i class="icon-download icon-white"></i>
</button>
<form name="download_form" style="display:none;">
<input type="hidden" name="basrec" value="{{feed_element.getRecord().get_serialize_key()}}"/>
<input type="hidden" name="basrec" value="{{feed_element.getRecord(app).get_serialize_key()}}"/>
</form>
|
{% endif %}

View File

@@ -57,7 +57,7 @@
{% if feed.isPublisher(app['authentication'].getUser()) %}
<div class="feed {% if loop.index is odd%}odd{% endif %}">
<span>{{ feed.getTitle() }}</span>
{% if feed.getPublic() %}
{% if feed.isPublic() %}
<img src="/skins/icons/ligth-on.png" title="{% trans 'This feed is public' %}"/>
{% endif %}
<input type="hidden" value="{{ feed.getId() }}"/>

View File

@@ -1673,9 +1673,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
public function testFeedList()
{
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle);
$created_feed = $this->insertOneFeed(self::$DI['user'], $title);
$this->setToken(self::$token);
$route = '/api/v1/feeds/list/';
@@ -1695,15 +1694,12 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->evaluateGoodFeed($feed);
if ($feed['id'] == $created_feed->get_id()) {
if ($feed['id'] == $created_feed->getId()) {
$found = true;
$this->assertEquals($title, $feed['title']);
$this->assertEquals($subtitle, $feed['subtitle']);
}
}
$created_feed->delete();
if (!$found) {
$this->fail('feed not found !');
}
@@ -1722,10 +1718,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$entry_title = 'Superman';
@@ -1733,11 +1725,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']);
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$created_item = $this->insertOneFeedItem(self::$DI['user']);
$created_entry = $created_item->getEntry();
$created_entry->setAuthorEmail($author_email);
$created_entry->setAuthorName($author);
$created_entry->setTitle($entry_title);
$created_entry->setSubtitle($entry_subtitle);
self::$DI['app']['EM']->persist($created_entry);
self::$DI['app']['EM']->flush();
$this->setToken(self::$token);
$route = '/api/v1/feeds/content/';
@@ -1760,7 +1755,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
foreach ($content['response']['entries'] as $entry) {
$this->assertGoodEntry($entry);
if ($entry['id'] == $created_entry->get_id()) {
if ($entry['id'] == $created_entry->getId()) {
$found = true;
$this->assertEquals($author_email, $entry['author_email']);
$this->assertEquals($author, $entry['author_name']);
@@ -1769,8 +1764,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
}
}
$created_feed->delete();
if (!$found) {
$this->fail('entry not found !');
}
@@ -1786,10 +1779,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$entry_title = 'Superman';
@@ -1797,14 +1786,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']);
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$created_item = $this->insertOneFeedItem(self::$DI['user']);
$created_entry = $created_item->getEntry();
$this->setToken(self::$token);
$route = '/api/v1/feeds/entry/' . $created_entry->get_id() . '/';
$route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1817,9 +1803,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey('entry', $content['response']);
$this->assertGoodEntry($content['response']['entry']);
$this->assertEquals($created_entry->get_id(), $content['response']['entry']['id']);
$this->assertEquals($created_entry->getId(), $content['response']['entry']['id']);
$created_feed->delete();
}
/**
@@ -1832,10 +1817,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$entry_title = 'Superman';
@@ -1843,16 +1824,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']);
$created_item = $this->insertOneFeedItem(self::$DI['user']);
$created_entry = $created_item->getEntry();
$created_feed = $created_entry->getFeed();
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$created_feed->set_collection(self::$DI['collection_no_access']);
$created_feed->setCollection(self::$DI['collection_no_access']);
$this->setToken(self::$adminToken);
$route = '/api/v1/feeds/entry/' . $created_entry->get_id() . '/';
$route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1876,25 +1855,19 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$title = 'Yellow title';
$subtitle = 'Trololololo !';
$entry_title = 'Superman';
$entry_subtitle = 'Wonder Woman';
$author = "W. Shakespeare";
$author_email = "gontran.bonheur@gmail.com";
$created_feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], $title, $subtitle);
$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], $created_feed, self::$DI['user']);
$created_entry = \Feed_Entry_Adapter::create(self::$DI['app'], $created_feed, $publisher, $entry_title, $entry_subtitle, $author, $author_email);
$created_item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $created_entry, self::$DI['record_1']);
$created_item = $this->insertOneFeedItem(self::$DI['user']);
$created_entry = $created_item->getEntry();
$created_feed = $created_entry->getFeed();
$created_entry->setTitle($entry_title);
$created_entry->setSubtitle($entry_subtitle);
self::$DI['app']['EM']->persist($created_entry);
self::$DI['app']['EM']->flush();
$this->setToken(self::$token);
$route = '/api/v1/feeds/' . $created_feed->get_id() . '/content/';
$route = '/api/v1/feeds/' . $created_feed->getId() . '/content/';
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
@@ -1912,16 +1885,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
foreach ($content['response']['entries'] as $entry) {
$this->assertGoodEntry($entry);
if ($entry['id'] == $created_entry->get_id()) {
if ($entry['id'] == $created_entry->getId()) {
$this->assertEquals($entry_title, $entry['title']);
$this->assertEquals($entry_subtitle, $entry['subtitle']);
$found = true;
}
}
$this->assertEquals($created_feed->get_id(), $content['response']['feed']['id']);
$created_feed->delete();
$this->assertEquals($created_feed->getId(), $content['response']['feed']['id']);
if (!$found) {
$this->fail('Entry not found');
@@ -2037,7 +2008,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
$this->assertInternalType('string', $feed['title']);
$this->assertInternalType('string', $feed['subtitle']);
$this->assertInternalType('integer', $feed['total_entries']);
$this->assertInternalType('string', $feed['icon']);
$this->assertInternalType('boolean', $feed['icon']);
$this->assertInternalType('boolean', $feed['public']);
$this->assertInternalType('boolean', $feed['readonly']);
$this->assertInternalType('boolean', $feed['deletable']);

View File

@@ -18,22 +18,10 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$this->feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
$publishers = $this->feed->get_publishers();
$publisher = array_shift($publishers);
$this->entry = \Feed_Entry_Adapter::create(self::$DI['app'], $this->feed, $publisher, 'title', "sub Titkle", " jean pierre", "jp@test.com");
$this->item = \Feed_Entry_Item::create(self::$DI['app']['phraseanet.appbox'], $this->entry, self::$DI['record_1']);
}
public function tearDown()
{
if ($this->feed instanceof \Feed_Adapter)
$this->feed->delete();
parent::tearDown();
}
@@ -148,7 +136,10 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
{
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
$item = $this->insertOneFeedItem(self::$DI['user']);
$entry = $item->getEntry();
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
@@ -164,7 +155,7 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
@@ -180,7 +171,7 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/');
$crawler = self::$DI['client']->request('GET', '/lightbox/ajax/LOAD_FEED_ITEM/' . $entry->getId() . '/' . $item->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertNotEquals('application/json', self::$DI['client']->getResponse()->headers->get('Content-type'));
}
@@ -241,19 +232,22 @@ class ApplicationLightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/');
$item = $this->insertOneFeedItem(self::$DI['user']);
$entry = $item->getEntry();
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/');
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $this->entry->get_id() . '/');
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
}

View File

@@ -68,7 +68,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$this->assertEquals('test', $feed->getTitle());
$this->assertEquals('test', $feed->getSubtitle());
$this->assertTrue($feed->getPublic());
$this->assertTrue($feed->isPublic());
$this->assertNull($feed->getCollection(self::$DI['app']));
}
@@ -95,7 +95,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$this->assertEquals('test', $feed->getTitle());
$this->assertEquals('test', $feed->getSubtitle());
$this->assertTrue($feed->getPublic());
$this->assertTrue($feed->isPublic());
$this->assertEquals(self::$DI['collection']->get_base_id(), $collection->get_base_id());
$this->assertTrue(

View File

@@ -7,37 +7,6 @@ use Symfony\Component\CssSelector\CssSelector;
class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
/**
*
* @var \Feed_Adapter
*/
protected $feed;
/**
*
* @var \Feed_Entry_Adapter
*/
protected $entry;
/**
*
* @var \Feed_Entry_Item
*/
protected $item;
/**
*
* @var \Feed_Publisher_Adapter
*/
protected $publisher;
protected $client;
protected $feed_title = 'feed title';
protected $feed_subtitle = 'feed subtitle';
protected $entry_title = 'entry title';
protected $entry_subtitle = 'entry subtitle';
protected $entry_authorname = 'author name';
protected $entry_authormail = 'author.mail@example.com';
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
@@ -360,7 +329,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
if ($one_feed->has_access(self::$DI['user'])) {
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
} else {
$this->fail('Feed_collection::load_all should return feed where I got access');
$this->fail('FeedRepository::getAllForUser should return feeds I am allowed to access');
}
}
}
@@ -382,7 +351,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
if ($one_feed->hasAccess(self::$DI['user'], self::$DI['app'])) {
$this->assertEquals(1, $crawler->filterXPath($path)->count(), $msg);
} else {
$this->fail('Feed_collection::load_all should return feed where I got access');
$this->fail('FeedRepository::getAllForUser should return feeds I am allowed to access');
}
}
}

View File

@@ -11,14 +11,9 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected static $feed;
public static function tearDownAfterClass()
{
if (self::$feed instanceof \Feed_Adapter) {
self::$feed->delete();
}
parent::tearDownAfterClass();
}
@@ -193,46 +188,18 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
self::$DI['app']['authentication']->openAccount(self::$DI['user']);
self::$feed = \Feed_Adapter::create(
self::$DI['app'],
self::$DI['user'],
'titi',
'toto'
);
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
self::$DI['app']['notification.deliverer']->expects($this->atLeastOnce())
->method('deliver')
->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null));
$feedEntry = \Feed_Entry_Adapter::create(
self::$DI['app'],
self::$feed,
\Feed_Publisher_Adapter::getPublisher(
self::$DI['app']['phraseanet.appbox'],
self::$feed,
self::$DI['user']
),
'titi',
'toto',
'tata',
'tutu@test.fr'
);
\Feed_Entry_Item::create(
self::$DI['app']['phraseanet.appbox'],
$feedEntry,
self::$DI['record_1']
);
$item = $this->insertOneFeedItem(self::$DI['user']);
$feedEntry = $item->getEntry();
$this->XMLHTTPRequest('POST', '/prod/records/', array(
'env' => 'FEED',
'pos' => 0,
'query' => '',
'cont' => $feedEntry->get_id()
'cont' => $feedEntry->getId()
));
$response = self::$DI['client']->getResponse();

View File

@@ -178,7 +178,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic();
foreach ($all_feeds as $feed) {
$this->assertTrue($feed->getPublic());
$this->assertTrue($feed->isPublic());
}
$crawler = self::$DI['client']->request("GET", "/feeds/aggregated/rss/");
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
@@ -195,7 +195,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$all_feeds = self::$DI['app']['EM']->getRepository('Entities\Feed')->findAllPublic();
foreach ($all_feeds as $feed) {
$this->assertTrue($feed->getPublic());
$this->assertTrue($feed->isPublic());
}
$crawler = self::$DI['client']->request("GET", "/feeds/aggregated/atom/");
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
@@ -633,48 +633,48 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
$this->assertEquals($feed->getCountTotalEntries(), $count);
}
public function checkATOMEntryNode(\DOMNode $node, \DOMXPath $xpath, \Feed_Adapter $feed, \Feed_Entry_Adapter $entry)
public function checkATOMEntryNode(\DOMNode $node, \DOMXPath $xpath, Feed $feed, FeedEntry $entry)
{
foreach ($node->childNodes as $child) {
if ($child->nodeType !== XML_TEXT_NODE) {
switch ($child->nodeName) {
case 'id':
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->get_id()), $child->nodeValue);
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $child->nodeValue);
break;
case 'link':
foreach ($child->attributes as $attribute) {
if ($attribute->name == "href") {
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->get_id()), $attribute->value);
$this->assertEquals(sprintf('%sentry/%d/', self::$DI['app']['feed.user-link-generator']->generatePublic($feed, 'atom', 1)->getURI(), $entry->getId()), $attribute->value);
break;
}
}
break;
case 'updated':
$this->assertEquals($entry->get_updated_on()->format(DATE_ATOM), $child->nodeValue);
$this->assertEquals($entry->getUpdatedOn()->format(DATE_ATOM), $child->nodeValue);
break;
case 'published':
$this->assertEquals($entry->get_created_on()->format(DATE_ATOM), $child->nodeValue);
$this->assertEquals($entry->getCreatedOn()->format(DATE_ATOM), $child->nodeValue);
break;
case 'title':
$this->assertEquals($entry->get_title(), $child->nodeValue);
$this->assertEquals($entry->getTitle(), $child->nodeValue);
break;
case 'content':
$this->assertEquals($entry->get_subtitle(), $child->nodeValue);
$this->assertEquals($entry->getSubtitle(), $child->nodeValue);
break;
case 'author':
foreach ($node->childNodes as $child) {
if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "email")
$this->assertEquals($entry->get_author_email(), $child->nodeValue);
$this->assertEquals($entry->getAuthorEmail(), $child->nodeValue);
if ($child->nodeType !== XML_TEXT_NODE && $child->nodeName == "name")
$this->assertEquals($entry->get_author_name(), $child->nodeValue);
$this->assertEquals($entry->getAuthorName(), $child->nodeValue);
}
break;
}
}
}
$content = $entry->get_content();
$content = $entry->getItems()->toArray();
$available_medium = array('image', 'audio', 'video');
@@ -686,7 +686,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
foreach ($media_group as $media) {
$entry_item = array_shift($content);
if ($entry_item instanceof \Feed_Entry_Item) {
if ($entry_item instanceof FeedEntry) {
$this->verifyMediaItem($entry_item, $media);
}
}

View File

@@ -431,7 +431,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
*
* @return \Entities\FeedEntry
* @return \Entities\FeedItem
*/
protected function insertOneFeedItem(\User_Adapter $user)
{
@@ -440,6 +440,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$item = new \Entities\FeedItem();
$item->setEntry($entry);
$item->setRecordId(self::$DI['record_1']->get_record_id());
$item->setSbasId(self::$DI['record_1']->get_sbas_id());
$entry->addItem($item);
@@ -449,11 +451,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$em->persist($item);
$em->flush();
return $entry;
} catch (\Exception $e) {
$this->fail('Fail to load one FeedEntry : ' . $e->getMessage());
}
return $item;
}
/**