normalize entries fields

This commit is contained in:
Nicolas Lœuillet 2015-02-05 22:33:36 +01:00
parent c8dee95396
commit 905ae369bd
5 changed files with 34 additions and 34 deletions

View file

@ -125,7 +125,7 @@ class WallabagRestController extends Controller
}
if (!is_null($isArchived)) {
$entry->setRead($isArchived);
$entry->setArchived($isArchived);
}
if (!is_null($isDeleted)) {
@ -133,7 +133,7 @@ class WallabagRestController extends Controller
}
if (!is_null($isStarred)) {
$entry->setFav($isStarred);
$entry->setStarred($isStarred);
}
$em = $this->getDoctrine()->getManager();

View file

@ -42,16 +42,16 @@ class Entries
/**
* @var boolean
*
* @ORM\Column(name="is_read", type="boolean", nullable=true, options={"default" = false})
* @ORM\Column(name="is_archived", type="boolean", nullable=true, options={"default" = false})
*/
private $isRead = false;
private $isArchived = false;
/**
* @var boolean
*
* @ORM\Column(name="is_fav", type="boolean", nullable=true, options={"default" = false})
* @ORM\Column(name="is_starred", type="boolean", nullable=true, options={"default" = false})
*/
private $isFav = false;
private $isStarred = false;
/**
* @var boolean
@ -180,61 +180,61 @@ class Entries
}
/**
* Set isRead
* Set isArchived
*
* @param string $isRead
* @param string $isArchived
* @return Entries
*/
public function setRead($isRead)
public function setArchived($isArchived)
{
$this->isRead = $isRead;
$this->isArchived = $isArchived;
return $this;
}
/**
* Get isRead
* Get isArchived
*
* @return string
*/
public function isRead()
public function isArchived()
{
return $this->isRead;
return $this->isArchived;
}
public function toggleArchive()
{
$this->isRead = $this->getIsRead() ^ 1;
$this->isArchived = $this->isArchived() ^ 1;
return $this;
}
/**
* Set isFav
* Set isStarred
*
* @param string $isFav
* @param string $isStarred
* @return Entries
*/
public function setFav($isFav)
public function setStarred($isStarred)
{
$this->isFav = $isFav;
$this->isStarred = $isStarred;
return $this;
}
/**
* Get isFav
* Get isStarred
*
* @return string
*/
public function isFav()
public function isStarred()
{
return $this->isFav;
return $this->isStarred;
}
public function toggleStar()
{
$this->isFav = $this->getIsFav() ^ 1;
$this->isStarred = $this->isStarred() ^ 1;
return $this;
}

View file

@ -23,9 +23,9 @@ class EntriesRepository extends EntityRepository
->select('e')
->setFirstResult($firstResult)
->setMaxResults($maxResults)
->where('e.isRead = 0')
->where('e.isArchived = false')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
->andWhere('e.isDeleted=false')
->orderBy('e.createdAt', 'desc')
->getQuery();
@ -48,9 +48,9 @@ class EntriesRepository extends EntityRepository
->select('e')
->setFirstResult($firstResult)
->setMaxResults($maxResults)
->where('e.isRead = 1')
->where('e.isArchived = true')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
->andWhere('e.isDeleted=false')
->orderBy('e.createdAt', 'desc')
->getQuery();
@ -73,9 +73,9 @@ class EntriesRepository extends EntityRepository
->select('e')
->setFirstResult($firstResult)
->setMaxResults($maxResults)
->where('e.isFav = 1')
->where('e.isStarred = true')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
->andWhere('e.isDeleted=false')
->orderBy('e.createdAt', 'desc')
->getQuery();
@ -91,11 +91,11 @@ class EntriesRepository extends EntityRepository
->where('e.userId =:userId')->setParameter('userId', $userId);
if (!is_null($isArchived)) {
$qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived);
$qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', $isArchived);
}
if (!is_null($isStarred)) {
$qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred);
$qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', $isStarred);
}
if (!is_null($isDeleted)) {

View file

@ -35,8 +35,8 @@
{% endif %}
<ul class="tools links">
<li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
<li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
<li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
<li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
<li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}delete{% endtrans %}</span></a></li>
<li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | domainName }}</span></a></li>
</ul>

View file

@ -11,8 +11,8 @@
<ul class="links">
<li class="topPosF"><a href="#top" title="{% trans %}Back to top{% endtrans %}" class="tool top icon icon-arrow-up-thick"><span>{% trans %}Back to top{% endtrans %}</span></a></li>
<li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.url | e | domainName }}</span></a></li>
<li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
<li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li>
<li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
<li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li>
<li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li>
{% if share_twitter %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}Tweet{% endtrans %}"><span>{% trans %}Tweet{% endtrans %}</span></a></li>{% endif %}
{% if share_mail %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %}