Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/i18n #31

Merged
merged 20 commits into from
Dec 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions Bundle/BlogBundle/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public function newBlogArticleAction(Blog $blog)
* @param Request $request
* @param Page $article
*
* @Route("/{id}/{newTranslation}/settings", name="victoire_blog_article_settings", defaults={"newTranslation"=false})
* @Route("/{id}/settings", name="victoire_blog_article_settings")
*
* @ParamConverter("article", class="VictoireBlogBundle:Article")
* @return template
*/
public function settingsAction(Request $request, BasePage $article, $newTranslation=false)
public function settingsAction(Request $request, BasePage $article)
{
$response = parent::settingsAction($request, $article, $newTranslation);
$response = parent::settingsAction($request, $article);

$pattern = $article->getTemplate();

Expand All @@ -98,6 +98,33 @@ public function settingsAction(Request $request, BasePage $article, $newTranslat
return new JsonResponse($response);
}

/**
* Article translation
*
* @param Request $request
* @param Page $article
*
* @Route("/{id}/translate", name="victoire_blog_article_translate")
*
* @ParamConverter("article", class="VictoireBlogBundle:Article")
* @return template
*/
public function translateAction(Request $request, BasePage $article)
{
$response = parent::translateAction($request, $article);

$pattern = $article->getTemplate();

$page = $this->container->get('victoire_page.page_helper')->findPageByParameters(array(
'viewId' => $pattern->getId(),
'locale' => $request->getLocale(),
'entityId' => $article->getId()
));
$response['url'] = $this->generateUrl('victoire_core_page_show', array('url' => $page->getUrl()));

return new JsonResponse($response);
}

/**
* Page delete
*
Expand Down Expand Up @@ -126,6 +153,15 @@ protected function getPageSettingsType()
return 'victoire_article_settings_type';
}

/**
*
* @return string
*/
protected function getPageTranslateType()
{
return 'victoire_view_translate_type';
}

/**
*
* @return string
Expand Down
40 changes: 33 additions & 7 deletions Bundle/BlogBundle/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class BlogController extends BasePageController
public function __construct()
{
$this->routes = array(
'new' => 'victoire_blog_index',
'show' => 'victoire_core_page_show',
'settings' => 'victoire_blog_settings',
'delete' => 'victoire_blog_delete',
'new' => 'victoire_blog_index',
'show' => 'victoire_core_page_show',
'settings' => 'victoire_blog_settings',
'translate' => 'victoire_blog_translate',
'delete' => 'victoire_blog_delete',
);
}

Expand Down Expand Up @@ -79,13 +80,29 @@ public function newAction($isHomepage = false)
* @param Page $blog
*
* @return template
* @Route("/{id}/{newTranslation}/settings", name="victoire_blog_settings", defaults={"newTranslation"=false})
* @Route("/{id}/settings", name="victoire_blog_settings")
* @Template()
* @ParamConverter("blog", class="VictoirePageBundle:BasePage")
*/
public function settingsAction(Request $request, BasePage $blog, $newTranslation = false)
public function settingsAction(Request $request, BasePage $blog)
{
return new JsonResponse(parent::settingsAction($request, $blog, $newTranslation));
return new JsonResponse(parent::settingsAction($request, $blog));
}

/**
* Blog translation
*
* @param Request $request
* @param Page $blog
*
* @return template
* @Route("/{id}/translate", name="victoire_blog_translate")
* @Template()
* @ParamConverter("blog", class="VictoirePageBundle:BasePage")
*/
public function translateAction(Request $request, BasePage $blog)
{
return new JsonResponse(parent::translateAction($request, $blog));
}

/**
Expand Down Expand Up @@ -116,6 +133,15 @@ protected function getPageSettingsType()
return 'victoire_blog_settings_type';
}

/**
*
* @return string
*/
protected function getPageTranslateType()
{
return 'victoire_view_translate_type';
}

/**
*
* @return string
Expand Down
8 changes: 7 additions & 1 deletion Bundle/BlogBundle/Form/BlogSettingsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@

use Symfony\Component\Form\FormBuilderInterface;
use Victoire\Bundle\PageBundle\Entity\PageStatus;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Edit Blog Type
*/
class BlogSettingsType extends BlogType
{

public function __construct($available_locales, RequestStack $requestStack)
{
parent::__construct($available_locales, $requestStack);
}

/**
* define form fields
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm( FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
Expand Down
21 changes: 21 additions & 0 deletions Bundle/BlogBundle/Listener/BlogMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ public function addContextual($event)
)
)->setLinkAttribute('data-toggle', 'vic-modal');

$mainItem->addChild('menu.blog.article.settings',
array(
'route' => 'victoire_blog_article_settings',
'routeParameters' => array('id' => $event->getPage()->getId())
)
)->setLinkAttribute('data-toggle', 'vic-modal');

$mainItem->addChild('menu.blog.article.translate',
array(
'route' => 'victoire_blog_article_translate',
'routeParameters' => array('id' => $event->getPage()->getId())
)
)->setLinkAttribute('data-toggle', 'vic-modal');

return $mainItem;
}

Expand All @@ -62,6 +76,13 @@ public function addBlogContextual($event)
)
)->setLinkAttribute('data-toggle', 'vic-modal');

$mainItem->addChild('menu.blog.translate',
array(
'route' => 'victoire_blog_translate',
'routeParameters' => array('id' => $event->getPage()->getId())
)
)->setLinkAttribute('data-toggle', 'vic-modal');

$mainItem->addChild('menu.blog.article.new',
array(
'route' => 'victoire_blog_article_new',
Expand Down
3 changes: 3 additions & 0 deletions Bundle/BlogBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ services:

victoire_blog.blog_settings.form.type:
class: Victoire\Bundle\BlogBundle\Form\BlogSettingsType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type, alias: victoire_blog_settings_type }

Expand Down
31 changes: 31 additions & 0 deletions Bundle/BlogBundle/Resources/views/Article/translate.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends 'VictoirePageBundle:Page:settings.html.twig' %}

{% trans_default_domain "victoire" %}

{% block modal_body_content %}

<div class="vic-tab-content vic-modal-tab-content">
{# Only display this business entity property list when related to a business entity #}
{% if page.businessEntity is defined %}
{% include 'VictoireBusinessEntityBundle:BusinessProperty:list.html.twig' with { 'businessProperties': businessProperties } %}
{% endif %}

<div class="vic-tab-pane vic-active" id="basics">
<form method="POST" action="{{path('victoire_blog_article_translate', {'id':page.id} )}}">
<div class="vic-form-group">
<div class="vic-col-lg-8">
{{ form_row(form.name) }}
{{ form_row(form.locale) }}
</div>
</div>
{{ form_rest(form) }}
</form>
</div>
</div>


{% endblock modal_body_content %}

{% block modal_header_title %}
{{ 'modal.form.article.translate.title'|trans({'%articleName%' : page.name}, 'victoire')|raw }}
{% endblock modal_header_title %}
31 changes: 31 additions & 0 deletions Bundle/BlogBundle/Resources/views/Blog/translate.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends 'VictoirePageBundle:Page:settings.html.twig' %}

{% trans_default_domain "victoire" %}

{% block modal_body_content %}

<div class="vic-tab-content vic-modal-tab-content">
{# Only display this business entity property list when related to a business entity #}
{% if page.businessEntity is defined %}
{% include 'VictoireBusinessEntityBundle:BusinessProperty:list.html.twig' with { 'businessProperties': businessProperties } %}
{% endif %}

<div class="vic-tab-pane vic-active" id="basics">
<form method="POST" action="{{path('victoire_blog_translate', {'id':page.id} )}}">
<div class="vic-form-group">
<div class="vic-col-lg-8">
{{ form_row(form.name) }}
{{ form_row(form.locale)}}
</div>
</div>
{{ form_rest(form) }}
</form>
</div>
</div>


{% endblock modal_body_content %}

{% block modal_header_title %}
{{ 'modal.form.blog.translate.title'|trans({'%blogName%' : page.name}, 'victoire')|raw }}
{% endblock modal_header_title %}
7 changes: 4 additions & 3 deletions Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/
class BusinessEntityHelper
{
protected $annotationReader = null;
protected $em = null;
protected $businessEntities = null;
protected $annotationReader;
protected $em;
protected $businessEntities;

/**
* Constructor
Expand All @@ -29,6 +29,7 @@ public function __construct(AnnotationReader $annotationReader, EntityManager $e
{
$this->annotationReader = $annotationReader;
$this->em = $entityManager;
$this->businessEntities = null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ private function createDeleteForm($id)
public function listEntitiesAction(BusinessEntityPagePattern $entity)
{
//services
$businessEntityPagePatternHelper = $this->get('victoire_business_entity_page.business_entity_page_helper');
$bepHelper = $this->get('victoire_business_entity_page.business_entity_page_helper');

$entities = $businessEntityPagePatternHelper->getEntitiesAllowed($entity);
$entities = $bepHelper->getEntitiesAllowed($entity);

//parameters for the view
$parameters = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class BusinessEntityPagePattern extends Template implements WebViewInterface
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\BusinessEntityPageBundle\Entity\BusinessEntityPage", mappedBy="pattern")
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\BusinessEntityPageBundle\Entity\BusinessEntityPage", mappedBy="template")
*/
protected $instances;
protected $inheritors;

/**
* contruct
Expand All @@ -37,8 +37,8 @@ public function __construct()
$this->status = PageStatus::PUBLISHED;
}

public function getInstances() { return $this->instances; }
public function setInstances($instances) { $this->instances = $instances; return $this; }
public function getInstances() { return $this->inheritors; }
public function setInstances($inheritors) { $this->inheritors = $inheritors; return $this; }
public function getLayout() { return $this->getTemplate()->getLayout(); }

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function generateEntityPageFromPattern(BusinessEntityPagePattern $bepPatt
$accessor = PropertyAccess::createPropertyAccessor();

foreach ($patternProperties as $property) {
if (!in_array($property->getName(), array('id', 'slug', 'widgetMap', 'slots')) && !$property->isStatic()) {
if (!in_array($property->getName(), array('id', 'slug', 'widgetMap', 'slots', 'seo')) && !$property->isStatic()) {
$value = $accessor->getValue($bepPattern, $property->getName());
$setMethod = 'set'.ucfirst($property->getName());
if (method_exists($page, $setMethod)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
class: Victoire\Bundle\BusinessEntityPageBundle\Form\BusinessEntityPagePatternType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type, alias: victoire_business_entity_page_type }

Expand Down
Loading