From 78bf4d61b71dfced71d263915b58bf2972a6dd0a Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 25 Aug 2012 22:44:58 +0200 Subject: [PATCH 1/4] Created custom 404 HTML page Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- .../TwigBundle/views/Exception/error404.html.twig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/Resources/TwigBundle/views/Exception/error404.html.twig diff --git a/app/Resources/TwigBundle/views/Exception/error404.html.twig b/app/Resources/TwigBundle/views/Exception/error404.html.twig new file mode 100644 index 0000000..6cdd7d9 --- /dev/null +++ b/app/Resources/TwigBundle/views/Exception/error404.html.twig @@ -0,0 +1,14 @@ +{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} + +{% block content %} +

A keresett oldal nem létezik

+

+{% spaceless %} + A keresett oldal nem létezik. Válassz valamit a menüből +{% if app.user %} + vagy kattints a bal felső sarokban a nevedre a további lehetőségekért +{% endif %} + ! +{% endspaceless %} +

+{% endblock content %} From 4c5b2880b7e880db44f6b9e3357cabc641c84751 Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 25 Aug 2012 23:06:45 +0200 Subject: [PATCH 2/4] Added jmikola/js-assets-helper-bundle This bundle is now used instead of old webRoot hack. Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- app/AppKernel.php | 1 + app/config/config.yml | 8 +++++++- app/config/routing.yml | 3 +++ composer.json | 1 + src/KekRozsak/FrontBundle/Resources/public/js/forum.js | 4 ++-- .../Resources/views/Default/main_template.html.twig | 5 ++--- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/AppKernel.php b/app/AppKernel.php index 954fe08..9a7c2fb 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -24,6 +24,7 @@ class AppKernel extends Kernel new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Io\TcpdfBundle\IoTcpdfBundle(), new FOS\JsRoutingBundle\FOSJsRoutingBundle(), + new Jmikola\JsAssetsHelperBundle\JmikolaJsAssetsHelperBundle(), // Own bundles new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), diff --git a/app/config/config.yml b/app/config/config.yml index efd25ec..86cdcf9 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -8,6 +8,9 @@ jms_di_extra: bundles: [ KekRozsakFrontBundle, KekRozsakSecurityBundle ] directories: [ "%kernel.root_dir%/../src" ] +jmikola_js_assets_helper: + packages_to_expose: [ KekRozsakFrontBundle ] + framework: #esi: ~ #translator: { fallback: %locale% } @@ -17,7 +20,10 @@ framework: form: true csrf_protection: true validation: { enable_annotations: true } - templating: { engines: ['twig'] } #assets_version: SomeVersionScheme + templating: + engines: ['twig'] + packages: + KekRozsakFrontBundle: ~ default_locale: %locale% trust_proxy_headers: false # Should Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP) session: ~ diff --git a/app/config/routing.yml b/app/config/routing.yml index 72fbf89..05c5cf2 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,6 +1,9 @@ fos_js_routing: resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml" +jmikola_js_assets_helper_routing: + resource: "@JmikolaJsAssetsHelperBundle/Resources/config/routing/routing.xml" + KekRozsakAdminBundle: resource: "@KekRozsakAdminBundle/Controller/" type: annotation diff --git a/composer.json b/composer.json index 5284ead..14b67e9 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "doctrine/doctrine-migrations-bundle": "dev-master", "egeloen/ckeditor-bundle": "dev-master", "friendsofsymfony/jsrouting-bundle": "dev-master", + "jmikola/js-assets-helper-bundle": "dev-master", "gergelypolonkai/tcpdfbundle": "dev-master" }, "scripts": { diff --git a/src/KekRozsak/FrontBundle/Resources/public/js/forum.js b/src/KekRozsak/FrontBundle/Resources/public/js/forum.js index e683c52..4c6118e 100644 --- a/src/KekRozsak/FrontBundle/Resources/public/js/forum.js +++ b/src/KekRozsak/FrontBundle/Resources/public/js/forum.js @@ -25,7 +25,7 @@ function favouriteOn() url: url }).done(function() { elem.find('img').attr('alt', '[Kedvenc]'); - elem.find('img').attr('src', webRoot + '/bundles/kekrozsakfront/images/penta-yellow-24.png'); + elem.find('img').attr('src', AssetsHelper.getURL('bundles/kekrozsakfront/images/penta-yellow-24.png')); elem.removeClass('favourite-topic-button'); elem.addClass('unfavourite-topic-button'); elem.attr('id', 'unfavourite-topic-button-' + topicSlug); @@ -60,7 +60,7 @@ function favouriteOff() url: url }).done(function() { elem.find('img').attr('alt', '[Nem kedvenc]'); - elem.find('img').attr('src', webRoot + '/bundles/kekrozsakfront/images/penta-blue-24.png'); + elem.find('img').attr('src', AssetsHelper.getUrl('/bundles/kekrozsakfront/images/penta-blue-24.png')); elem.removeClass('unfavourite-topic-button'); elem.addClass('favourite-topic-button'); elem.attr('id', 'favourite-topic-button-' + topicSlug); diff --git a/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig index 2684fac..370fa57 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig @@ -17,12 +17,11 @@ + + {% javascripts 'bundles/kekrozsakfront/js/*' output='js/kekrozsak.js' %} {% endjavascripts %} - {% block additional_js %}{% endblock %} From 764951f73c1ac3470185dbad12a2b0d84aad2eee Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Mon, 27 Aug 2012 18:09:30 +0200 Subject: [PATCH 3/4] Added blog post view functionality Signed-off-by: Gergely Polonkai --- .../Version20120827162130.php | 31 ++ .../FrontBundle/Controller/BlogController.php | 57 +++ src/KekRozsak/FrontBundle/Entity/BlogPost.php | 358 +++++++++++++++++- .../Resources/views/Blog/list.html.twig | 17 + 4 files changed, 450 insertions(+), 13 deletions(-) create mode 100644 app/DoctrineMigrations/Version20120827162130.php create mode 100644 src/KekRozsak/FrontBundle/Controller/BlogController.php create mode 100644 src/KekRozsak/FrontBundle/Resources/views/Blog/list.html.twig diff --git a/app/DoctrineMigrations/Version20120827162130.php b/app/DoctrineMigrations/Version20120827162130.php new file mode 100644 index 0000000..665dd52 --- /dev/null +++ b/app/DoctrineMigrations/Version20120827162130.php @@ -0,0 +1,31 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("CREATE TABLE blog_posts (id INT AUTO_INCREMENT NOT NULL, group_id INT DEFAULT NULL, created_by_id INT NOT NULL, updated_by_id INT DEFAULT NULL, published TINYINT(1) NOT NULL, title VARCHAR(150) NOT NULL, slug VARCHAR(150) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, update_reason VARCHAR(255) DEFAULT NULL, content LONGTEXT NOT NULL, INDEX IDX_78B2F932FE54D947 (group_id), INDEX IDX_78B2F932B03A8386 (created_by_id), INDEX IDX_78B2F932896DBBDE (updated_by_id), PRIMARY KEY(id)) ENGINE = InnoDB"); + $this->addSql("ALTER TABLE blog_posts ADD CONSTRAINT FK_78B2F932FE54D947 FOREIGN KEY (group_id) REFERENCES groups (id)"); + $this->addSql("ALTER TABLE blog_posts ADD CONSTRAINT FK_78B2F932B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)"); + $this->addSql("ALTER TABLE blog_posts ADD CONSTRAINT FK_78B2F932896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id)"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("DROP TABLE blog_posts"); + } +} diff --git a/src/KekRozsak/FrontBundle/Controller/BlogController.php b/src/KekRozsak/FrontBundle/Controller/BlogController.php new file mode 100644 index 0000000..6cd4202 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Controller/BlogController.php @@ -0,0 +1,57 @@ +getDoctrine() + ->getEntityManager() + ->createQuery(' + SELECT + p + FROM + KekRozsakFrontBundle:BlogPost p + LEFT JOIN + p.group g + LEFT JOIN + g.members m + WHERE + ( + ( + p.group IS NULL + OR m.user = :user + ) + AND p.published = true + ) + OR p.createdBy = :user + '); + $query-> + setParameter( + 'user', + $this + ->get('security.context') + ->getToken() + ->getUser() + ->getId() + ); + $blogPosts = $query->getResult(); + + return array( + 'posts' => $blogPosts, + ); + } +} + diff --git a/src/KekRozsak/FrontBundle/Entity/BlogPost.php b/src/KekRozsak/FrontBundle/Entity/BlogPost.php index ac6b7df..e7f0d57 100644 --- a/src/KekRozsak/FrontBundle/Entity/BlogPost.php +++ b/src/KekRozsak/FrontBundle/Entity/BlogPost.php @@ -1,15 +1,347 @@ id; + } + + /** + * True if the BlogPost is published. If not, only the author and the + * administrators can see it. + * + * @var boolean $published + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $published; + + /** + * Set published + * + * @param boolean $published + * @return BlogPost + */ + public function setPublished($published) + { + // TODO: Check if parameter is boolean! + $this->published = $published; + return $this; + } + + /** + * Get published + * + * @return boolean + */ + public function isPublished() + { + return $this->published; + } + + /** + * The Group which this BlogPost is associated with + * + * @var KekRozsak\FrontBundle\Entity\Group $group + * + * @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\Group") + * @ORM\JoinColumn(name="group_id", nullable=true) + */ + protected $group; + + /** + * Set group + * + * @param KekRozsak\FrontBundle\Entity\Group $group + * @return BlogPost + */ + public function setGroup(Group $group) + { + $this->group = $group; + return $this; + } + + /** + * Get group + * + * @return KekRozsak\FrontBundle\Entity\Group + */ + public function getGroup() + { + return $this->group; + } + + /** + * The title of the BlogPost + * + * @var strinct $title + * + * @ORM\Column(type="string", length=150, nullable=false) + */ + protected $title; + + /** + * Set title + * + * @param string $title + * @return BlogPost + */ + public function setTitle($title) + { + // TODO: Check if not null nor empty! + $this->title = $title; + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * The slugified title of the BlogPost + * + * @var string $slug + * + * @ORM\Column(type="string", length=150, nullable=false) + */ + protected $slug; + + /** + * Set slug + * + * @param string $slug + * @return BlogPost + */ + public function setSlug($slug) + { + // TODO: Check if not null nor empty! + $this->slug = $slug; + return $this; + } + + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } + + /** + * The User who created this BlogPost + * + * @var KekRozsak\SecurityBundle\Entity\User $createdBy + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(name="created_by_id", nullable=false) + */ + protected $createdBy; + + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User $createdBy + * @return BlogPost + */ + public function setCreatedBy(User $createdBy) + { + // TODO: Check if not null! + $this->createdBy = $createdBy; + return $this; + } + + /** + * Get createdBy + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getCreatedBy() + { + return $this->createdBy(); + } + + /** + * The timestamp when this BlogPost was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", name="created_at", nullable=false) + */ + protected $createdAt; + + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return BlogPost + */ + public function setCreatedAt(\DataTime $createdAt) + { + // TODO: Check if not null! + $this->createdAt = $createdAt; + return $this; + } + + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * The User who last updated this BlogPost, or NULL if it is unmodified + * + * @var KekRozsak\SecurityBundle\Entity\User $updatedBy + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(name="updated_by_id", nullable=true) + */ + protected $updatedBy; + + /** + * Set updatedBy + * + * @param KekRozsak\SecurityBundle\Entity\User $updatedBy + * @return BlogPost + */ + public function setUpdatedBy(User $updatedBy) + { + $this->updatedBy = $updatedBy; + return $this; + } + + /** + * Get updatedBy + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getUpdatedBy() + { + return $this->updatedBy; + } + + /** + * The timestamp when this BlogPost was last modified, or null if it is not + * modified + * + * @var DateTime $updatedAt + * + * @ORM\Column(type="datetime", name="updated_at", nullable=true) + */ + protected $updatedAt; + + /** + * Set updatedAt + * + * @param DateTime $updatedAt + * @return BlogPost + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + return $this; + } + + /** + * The reason of the last update, or null if the object is not modified + * + * @var string $updateReason + * + * @ORM\Column(type="string", length=255, name="update_reason", nullable=true) + */ + protected $updateReason; + + /** + * Set updateReason + * + * @param string $updateReason + * @return BlogPost + */ + public function setUpdateReason($updateReason) + { + if (trim($updateReason) == '') { + $updateReason = null; + } + $this->updateReason = $updateReason; + return $this; + } + + /** + * Get updateReason + * + * @return string + */ + public function getUpdateReason() + { + return $this->updateReason; + } + + /** + * The content of this BlogPost + * + * @var string $content + * + * @ORM\Column(type="text", nullable=false) + */ + protected $content; + + /** + * Set content + * + * @param string $content + * @return BlogPost + */ + public function setContent($content) + { + // TODO: Check if not null nor empty! + $this->content = $content; + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } +} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Blog/list.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Blog/list.html.twig new file mode 100644 index 0000000..9aef6a5 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Resources/views/Blog/list.html.twig @@ -0,0 +1,17 @@ +{# vim: ft=htmljinja +#} +{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} +{% block content %} +

Blog

+{% for post in posts %} +

{{ post.title }}

+{{ post.createdAt|date('Y-m-d H:i') }}
+{% if not post.published %} +inaktív
+{% endif %} +{{ post.content }} +
+{% else %} +Nincs bejegyzés. +{% endfor %} +{% endblock %} From efedfa0432ceac5e3fb3186f5d23b28b3e6c83d7 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Tue, 28 Aug 2012 09:43:02 +0200 Subject: [PATCH 4/4] Fixed typo in parameter type name DataTime -> DateTime Signed-off-by: Gergely Polonkai --- src/KekRozsak/FrontBundle/Entity/BlogPost.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KekRozsak/FrontBundle/Entity/BlogPost.php b/src/KekRozsak/FrontBundle/Entity/BlogPost.php index e7f0d57..52a7464 100644 --- a/src/KekRozsak/FrontBundle/Entity/BlogPost.php +++ b/src/KekRozsak/FrontBundle/Entity/BlogPost.php @@ -208,7 +208,7 @@ class BlogPost * @param DateTime $createdAt * @return BlogPost */ - public function setCreatedAt(\DataTime $createdAt) + public function setCreatedAt(\DateTime $createdAt) { // TODO: Check if not null! $this->createdAt = $createdAt;