Skip to content

Commit

Permalink
add vu flag to posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Petrash committed Apr 23, 2017
1 parent 0d4e837 commit f597e05
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/Resources/translations/messages.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ post-item:
post-info:
icon-images: Фото внутри
icon-videos: Видео внутри
icon-vu: volleyball.ua
icon-hits: Просмотров
source: Источник

Expand Down
1 change: 1 addition & 0 deletions app/Resources/translations/messages.uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ post-item:
post-info:
icon-images: Фото всередині
icon-videos: Відео всередині
icon-vu: volleyball.ua
icon-hits: Переглядів
source: Джерело

Expand Down
6 changes: 5 additions & 1 deletion src/Volley/FaceBundle/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function indexAction(Request $request)
$stateFilter = 12;
$featuredFilter = 12;
$recommendedFilter = 12;
$vuFilter = 12;
$userFilter = null;
$searchFilter = '';
$page = 1;
Expand All @@ -45,6 +46,7 @@ public function indexAction(Request $request)
$stateFilter = $request->request->get('state', $session->get('stateFilter', 12));
$featuredFilter = $request->request->get('featured', $session->get('featuredFilter', 12));
$recommendedFilter = $request->request->get('recommended', $session->get('recommendedFilter', 12));
$vuFilter = $request->request->get('vu', $session->get('vuFilter', 12));
$userFilter = $request->request->get('user', $session->get('userFilter', null));
$searchFilter = $request->request->get('search', $session->get('searchFilter', ''));
if ($session->get('stateFilter') != $stateFilter || $session->get('searchFilter') != $searchFilter || $session->get('featuredFilter') != $featuredFilter || $session->get('recommendedFilter') != $recommendedFilter || $session->get('categoryFilter') != $categoryFilter)
Expand All @@ -57,11 +59,12 @@ public function indexAction(Request $request)
$session->set('stateFilter', $stateFilter);
$session->set('featuredFilter', $featuredFilter);
$session->set('recommendedFilter', $recommendedFilter);
$session->set('vuFilter', $vuFilter);
$session->set('userFilter', $userFilter);
$session->set('searchFilter', $searchFilter);
$session->set('page', $page);

$filter = new Filter($categoryFilter ? $em->getRepository('VolleyFaceBundle:Category')->find($categoryFilter) : null, $stateFilter, $featuredFilter, $recommendedFilter, $userFilter ? $em->getRepository('VolleyUserBundle:User')->find($userFilter) : null, $searchFilter);
$filter = new Filter($categoryFilter ? $em->getRepository('VolleyFaceBundle:Category')->find($categoryFilter) : null, $stateFilter, $featuredFilter, $recommendedFilter, $vuFilter,$userFilter ? $em->getRepository('VolleyUserBundle:User')->find($userFilter) : null, $searchFilter);
$filterForm = $this->createForm(new FilterType(), $filter);

$query = $em->getRepository('VolleyFaceBundle:Post')
Expand All @@ -70,6 +73,7 @@ public function indexAction(Request $request)
$stateFilter,
$featuredFilter,
$recommendedFilter,
$vuFilter,
$userFilter,
$searchFilter
);
Expand Down
23 changes: 23 additions & 0 deletions src/Volley/FaceBundle/Entity/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ class Post
*/
private $translated;

/**
* @var boolean
*
* @ORM\Column(name="vu", type="boolean")
*/
private $vu;

/**
* @var string
*
Expand Down Expand Up @@ -755,6 +762,22 @@ public function setTranslated($translated)
$this->translated = $translated;
}

/**
* @return bool
*/
public function isVu()
{
return $this->vu;
}

/**
* @param bool $vu
*/
public function setVu($vu)
{
$this->vu = $vu;
}

/**
* Set language
*
Expand Down
4 changes: 3 additions & 1 deletion src/Volley/FaceBundle/Entity/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function unsetFeatured($entity)
->execute();
}

public function findAllPosts($categoryFilter = null, $stateFilter = 12, $featuredFilter = 12, $recommendedFilter = 12, $userFilter = null, $searchFilter = "")
public function findAllPosts($categoryFilter = null, $stateFilter = 12, $featuredFilter = 12, $recommendedFilter = 12, $vuFilter = 12, $userFilter = null, $searchFilter = "")
{
$qb = $this->createQueryBuilder('p');
$qb->select('p')
Expand All @@ -120,6 +120,8 @@ public function findAllPosts($categoryFilter = null, $stateFilter = 12, $feature
$qb->andWhere('p.createdBy = ?4')->setParameter(4, $userFilter);
if ($recommendedFilter < 12)
$qb->andWhere('p.recommended = ?5')->setParameter(5, $recommendedFilter);
if ($vuFilter < 12)
$qb->andWhere('p.vu = ?6')->setParameter(6, $vuFilter);
if ($searchFilter != "")
$qb->andWhere($qb->expr()->like('p.title', $qb->expr()->literal('%' . $searchFilter . '%')));

Expand Down
8 changes: 8 additions & 0 deletions src/Volley/FaceBundle/Form/FilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'expanded' => false,
'empty_value' => false
])
->add('vu', 'choice', [
'choices' => [12 => "All", 0 => 'None VU', 1 => 'VU'],
'label' => 'Filter',
'required' => false,
'multiple' => false,
'expanded' => false,
'empty_value' => false
])
->add('user',EntityType::class, [
'class' => 'Volley\UserBundle\Entity\User',
'required' => false
Expand Down
24 changes: 23 additions & 1 deletion src/Volley/FaceBundle/Form/Model/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Filter
*/
private $recommended;

/**
* @var integer
*/
private $vu;

/**
* @var User
*/
Expand All @@ -42,12 +47,13 @@ class Filter
*/
protected $form;

function __construct($category, $state, $featured, $recommended, $user, $search)
function __construct($category, $state, $featured, $recommended, $vu, $user, $search)
{
$this->category = $category;
$this->state = $state;
$this->featured = $featured;
$this->recommended = $recommended;
$this->vu = $vu;
$this->user = $user;
$this->search = $search;
}
Expand Down Expand Up @@ -116,6 +122,22 @@ public function setRecommended($recommended)
$this->recommended = $recommended;
}

/**
* @return int
*/
public function getVu()
{
return $this->vu;
}

/**
* @param int $vu
*/
public function setVu($vu)
{
$this->vu = $vu;
}

/**
* @return User
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Volley/FaceBundle/Form/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'label' => false,
'attr' => ['data-toggle' => 'toggle', 'data-on' => 'Translated', 'data-off' => "Not translated", 'data-onstyle' => 'info']
])
->add('vu',null,[
'label' => false,
'attr' => ['data-toggle' => 'toggle', 'data-on' => 'VU', 'data-off' => "Not VU", 'data-onstyle' => 'info']
])
->add('language')
->add('category','entity', [
'class' => 'Volley\FaceBundle\Entity\Category',
Expand Down
13 changes: 12 additions & 1 deletion src/Volley/FaceBundle/Resources/public/css/custom/body.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
}

.news-item .news-info .icon-images,
.news-item .news-info .icon-videos {
.news-item .news-info .icon-videos,
.news-item .news-info .icon-vu {
float: right;
margin: 5px 0 5px 5px;
}
Expand All @@ -110,6 +111,16 @@
background-image: url('../bundles/volleyface/images/icon-video.png');
}

.news-item .news-info .icon-vu {
width: 21px;
height: 12px;
margin: 6px 0 6px 5px;
background-image: url('../bundles/volleyface/images/icon-vu.png');
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}

.underline {
display: block;
height: 1px;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
alt="{{ item.title ~ ' ' ~ item.metakey }}">
</a>
<div class="news-info row">
<div class="col col-lg-9 col-md-9 col-sm-9 col-xs-9">
<div class="col col-lg-8 col-md-8 col-sm-8 col-xs-8">
<span class="news-date">{{ item.created|localizeddate('none', 'none', null, null, "cccc, d MMMM") }} <br/>
<a href="{{ path('volley_face_blog',{'category_slug': item.category.slug}) }}"
title="{{ item.category.name }}"
style="color: {{ color }}">{{ item.category.name }}</a></span>
{#<span class="news-author"> / {{ item.createdBy }}</span>#}
</div>
<div class="col col-lg-3 col-md-3 col-sm-3 col-xs-3">
<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-34">
{% if item.videos %}
<a href="{{ path('volley_face_post',{'category_slug': item.category.slug,'post_slug': item.slug}) }}">
<div class="icon-videos" title="{{ 'post-item.post-info.icon-videos'|trans({}) }}"></div>
Expand All @@ -26,6 +26,11 @@
<div class="icon-images" title="{{ 'post-item.post-info.icon-images'|trans({}) }}"></div>
</a>
{% endif %}
{% if item.vu %}
<a href="{{ path('volley_face_post',{'category_slug': item.category.slug,'post_slug': item.slug}) }}">
<div class="icon-vu" title="{{ 'post-item.post-info.icon-vu'|trans({}) }}"></div>
</a>
{% endif %}
</div>
<span class="clearfix"></span>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Volley/FaceBundle/Resources/views/Post/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
{{ form_row(edit_form.images) }}
{{ form_row(edit_form.videos) }}
{{ form_row(edit_form.translated) }}
{{ form_row(edit_form.vu) }}
</div>
<div role="tabpanel" class="tab-pane" id="meta">
<br>
Expand Down
4 changes: 4 additions & 0 deletions src/Volley/FaceBundle/Resources/views/Post/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<label for="volley_facebundle_filter_recommended">Recommended: </label>
{{ form_widget(filter.recommended) }}
</div>
<div class="form-group">
<label for="volley_facebundle_filter_recommended">VU: </label>
{{ form_widget(filter.vu) }}
</div>
<div class="form-group">
<label for="volley_facebundle_filter_featured">User: </label>
{{ form_widget(filter.user) }}
Expand Down

0 comments on commit f597e05

Please sign in to comment.