Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add event listener to admin menu. Fix bugs

  • Loading branch information...
commit 58e41089abd4348c2ad91e3f808406b0f72ced4b 1 parent c8da66f
@smirik authored
View
7 Controller/AdminQuestionController.php
@@ -82,12 +82,13 @@ public function showAction($id)
/**
* Displays a form to create a new Question entity.
*
- * @Route("/new", name="smirik_quiz_admin_questions_new")
+ * @Route("/{quiz_id}/new", name="smirik_quiz_admin_questions_new")
* @Template("SmirikQuizBundle:Admin\Question:new.html.twig", vars={"get"})
*/
- public function newAction()
+ public function newAction($quiz_id)
{
- $quiz_id = $this->getRequest()->query->get('quiz_id', false);
+ $em = $this->getDoctrine()->getEntityManager();
+ //$quiz_id = $this->getRequest()->query->get('quiz_id', false);
$entity = new Question();
if ($quiz_id)
View
18 EventListener/ConfigureMenuListener.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Smirik\QuizBundle\EventListener;
+
+use Smirik\AdminBundle\Event\ConfigureMenuEvent;
+
+class ConfigureMenuListener
+{
+ /**
+ * @param \Smirik\AdminBundle\Event\ConfigureMenuEvent $event
+ */
+ public function onMenuConfigure(ConfigureMenuEvent $event)
+ {
+ $menu = $event->getMenu();
+ $menu->addChild('admin.quiz.menu', array('route' => 'smirik_quiz_admin_quiz'));
+ $menu->addChild('admin.quiz.users.menu', array('route' => 'smirik_quiz_admin_users_index'));
+ }
+}
View
2  Form/QuestionType.php
@@ -12,7 +12,7 @@ public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('quizes')
- ->add('text')
+ ->add('text', 'textarea', array('attr' => array('class' => 'tinymce xxlarge ylarge', 'tinymce' => '{"theme":"simple"}')))
->add('type', 'choice', array(
'choices' => array('text' => 'text', 'radio' => 'radio', 'checkbox' => 'checkbox')
))
View
22 Menu/Builder.php
@@ -1,22 +0,0 @@
-<?php
-// src/Acme/DemoBundle/Menu/Builder.php
-namespace Smirik\QuizBundle\Menu;
-
-use Knp\Menu\FactoryInterface;
-use Symfony\Component\DependencyInjection\ContainerAware;
-
-class Builder extends ContainerAware
-{
- public function mainMenu(FactoryInterface $factory)
- {
- $menu = $factory->createItem('root');
- $menu->setCurrentUri($this->container->get('request')->getRequestUri());
-
- $menu->addChild('admin.quiz.navigation.quizes', array('route' => 'smirik_quiz_admin_quiz'));
- $menu->addChild('admin.quiz.navigation.questions', array('route' => 'smirik_quiz_admin_questions'));
- $menu->addChild('admin.quiz.navigation.users_quiz', array('route' => 'smirik_quiz_admin_users_index'));
- $menu->addChild('admin.quiz.navigation.content', array('route' => 'sonata_admin_dashboard'));
-
- return $menu;
- }
-}
View
5 Resources/config/services.yml
@@ -25,4 +25,7 @@ services:
user.manager:
class: %user.manager.class%
arguments: ["@doctrine.orm.entity_manager", Smirik\QuizBundle\Entity\User]
-
+ quiz.configure_menu_listener:
+ class: Smirik\QuizBundle\EventListener\ConfigureMenuListener
+ tags:
+ - { name: kernel.event_listener, event: smirik_admin.menu_configure, method: onMenuConfigure }
View
43 Resources/translations/messages.ru.yml
@@ -12,6 +12,9 @@ quiz.select: Выбрать тест
# Quiz translations
+admin.quiz.menu: Тесты
+admin.quiz.users.menu: Активировать тесты
+
admin.quiz.list.page_title: Тесты
admin.quiz.list.title.comment: список
admin.quiz.list.id: Id
@@ -49,33 +52,33 @@ admin.questions.edit.title.comment: редактирование
admin.questions.create.page_title: Вопрос
admin.questions.create.title.comment: создание
-quiz.form.Smirik quizbundle questiontype: " "
+form.Smirik quizbundle questiontype: " "
# Admin Forms
# Quiz Form
-quiz.form.Title: Заголовок
-quiz.form.Description: Описание
-quiz.form.Time: Продолжительность
-quiz.form.Num questions: Количество вопросов
-quiz.form.Is active: Включен?
-quiz.form.Is opened: Публичный?
+form.Title: Заголовок
+form.Description: Описание
+form.Time: Продолжительность
+form.Num questions: Количество вопросов
+form.Is active: Включен?
+form.Is opened: Публичный?
# Question form
-quiz.form.Quiz: Тест
-quiz.form.Quizes: Тесты
-quiz.form.Text: Текст вопроса
-quiz.form.Type: Тип вопроса
-quiz.form.File: Файл
-quiz.form.Num answers: Количество ответов
+form.Quiz: Тест
+form.Quizes: Тесты
+form.Text: Текст вопроса
+form.Type: Тип вопроса
+form.File: Файл
+form.Num answers: Количество ответов
# Answer form
-quiz.form.Answers: Форма ответов
-quiz.form.0: Ответ 1
-quiz.form.1: Ответ 2
-quiz.form.2: Ответ 3
-quiz.form.3: Ответ 4
-quiz.form.Is right: Правильный?
-quiz.form.V file: Файл
+form.Answers: Форма ответов
+form.0: Ответ 1
+form.1: Ответ 2
+form.2: Ответ 3
+form.3: Ответ 4
+form.Is right: Правильный?
+form.V file: Файл
# Users form
users.quiz.connection.created: Тесты для указанных пользователей активированы.
View
10 Resources/views/Admin/Question/index.html.twig
@@ -49,12 +49,8 @@
</tbody>
</table>
-<ul>
- <li>
- <a href="{{ path('smirik_quiz_admin_questions_new', { 'quiz_id': quiz_id }) }}">
- {{ 'quiz.form.actions.create'|trans }}
- </a>
- </li>
-</ul>
+<a href="{{ path('smirik_quiz_admin_questions_new', { 'quiz_id': quiz_id }) }}" class="btn">
+ {{ 'quiz.form.actions.create'|trans }}
+</a>
{% endblock %}
View
10 Resources/views/Admin/Quiz/index.html.twig
@@ -70,12 +70,8 @@
</tbody>
</table>
-<ul>
- <li>
- <a href="{{ path('smirik_quiz_admin_quiz_new') }}">
- {{ 'admin.quiz.action.create'|trans }}
- </a>
- </li>
-</ul>
+<a href="{{ path('smirik_quiz_admin_quiz_new') }}" class="btn">
+ {{ 'admin.quiz.action.create'|trans }}
+</a>
{% endblock %}
View
12 Resources/views/Admin/layout.html.twig
@@ -1,17 +1,7 @@
-{% extends '::base.html.twig' %}
+{% extends 'SmirikAdminBundle::layout.html.twig' %}
{% block stylesheets %}
{% stylesheets output='css/*.css' debug=false 'bundles/smirikquiz/css/main.css' %}
<link href="{{ asset_url }}" rel="stylesheet" media="screen" />
{% endstylesheets %}
{% endblock %}
-
-{% block javascripts %}
-{% javascripts '@SonatajQueryBundle/Resources/public/jquery-1.7.1.js' %}
- <script type="text/javascript" src="{{ asset_url }}"></script>
-{% endjavascripts %}
-{% endblock %}
-
-{% block content_navigation %}
- {% include 'SmirikQuizBundle:Admin:navigation.html.twig' %}
-{% endblock %}
View
2  Resources/views/Form/fields.html.twig
@@ -3,6 +3,6 @@
{% if required %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' required'}) %}
{% endif %}
- <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ ('quiz.form.'~label)|trans({}) }}</label>
+ <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ ('form.'~label)|trans({}) }}</label>
{% endspaceless %}
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.