Commit 24f8b964 authored by Hermann Mayer's avatar Hermann Mayer

Added default values for blog-archiv service parameters. Added fallback concept…

Added default values for blog-archiv service parameters. Added fallback concept for resultless settings for sidebar section and blog-dashboard/archiv pages.
parent 7b2e264e
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20121208180215 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
$this->addSql("ALTER TABLE content CHANGE content content LONGTEXT DEFAULT NULL");
}
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("ALTER TABLE content CHANGE content content LONGTEXT NOT NULL");
}
}
......@@ -40,8 +40,8 @@ class Load05SectionData extends AbstractFixture implements OrderedFixtureInterfa
public function load(ObjectManager $manager)
{
// Build Quick Operations Section
$quickOperationsPage = new Section();
$quickOperationsPage
$quickOperations = new Section();
$quickOperations
->setGroup($this->getReference('author-group'))
->setTitle('Quick Operations')
->setContent('<p>
......@@ -49,32 +49,23 @@ Als Administrator oder Autor bietet Ihnen diese Sektion
Mittel um die aktuelle Seite zu verändern.
</p>
<p>
<a href="{{ path(\'author_page_edit\', { \'id\': page.id }) }}" class="btn btn-danger" title="Seite bearbeiten">
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_030_pencil.png") }}" />
</a>
<a href="{{ path(\'author_page_new\') }}" class="btn btn-danger" title="Neue Seite anlegen">
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_036_file.png") }}" />
</a>
</p>');
/*
* --------------------------------------------------------------------
*/
{% if \'Page\' == page.getType %}
// Build Quick Operations Section
$quickOperationsArticle = new Section();
$quickOperationsArticle
->setGroup($this->getReference('author-group'))
->setTitle('Quick Operations')
->setContent('<p>
Als Administrator oder Autor bietet Ihnen diese Sektion
Mittel um den aktuellen Artikel zu verändern.
</p>
<p>
<a href="{{ path(\'author_article_edit\', { \'id\': page.id }) }}" class="btn btn-danger" title="Artikel bearbeiten">
{% set titleEdit = \'Seite bearbeiten\' %}
{% set titleNew = \'Neue Seite anlegen\' %}
{% elseif \'Article\' == page.getType %}
{% set titleEdit = \'Artikel bearbeiten\' %}
{% set titleNew = \'Neuen Artikel anlegen\' %}
{% endif %}
<a href="{{ path(\'author_\' ~ page.getType|lower ~ \'_edit\', { \'id\': page.id }) }}" class="btn btn-danger" title="{{ titleEdit }}">
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_030_pencil.png") }}" />
</a>
<a href="{{ path(\'author_article_new\') }}" class="btn btn-danger" title="Neuen Artikel anlegen">
<a href="{{ path(\'author_\' ~ page.getType|lower ~ \'_new\') }}" class="btn btn-danger" title="{{ titleNew }}">
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_036_file.png") }}" />
</a>
</p>');
......@@ -185,10 +176,8 @@ werden Favoriten für Sie in der Applikation gespeichert.
* --------------------------------------------------------------------
*/
$quickOperationsPage
->addSidebar($this->getReference('default-sidebar'));
$quickOperationsArticle
$quickOperations
->addSidebar($this->getReference('default-sidebar'))
->addSidebar($this->getReference('blog-sidebar'));
$share
......@@ -211,8 +200,7 @@ werden Favoriten für Sie in der Applikation gespeichert.
*/
// Save all Metadata
$manager->persist($quickOperationsPage);
$manager->persist($quickOperationsArticle);
$manager->persist($quickOperations);
$manager->persist($share);
$manager->persist($follow);
$manager->persist($favorites);
......@@ -224,8 +212,7 @@ werden Favoriten für Sie in der Applikation gespeichert.
$this->addReference('share-section', $share);
$this->addReference('follow-section', $share);
$this->addReference('favorites-section', $favorites);
$this->addReference('quickOperationsPage-section', $quickOperationsPage);
$this->addReference('quickOperationsArticle-section', $quickOperationsArticle);
$this->addReference('quickOperations-section', $quickOperations);
$this->addReference('archiv-section', $archiv);
}
......
......@@ -84,9 +84,12 @@ class BlogArchivController extends AbstractService
$routes->add('service_blog_archiv', new Route(
'{year}/{month}',
array(),
array(
'year' => '\d+',
'year' => date('Y'),
'month' => date('m')
),
array(
'year' => '\d+',
'month' => '^(0?[1-9]|1[0-2])$'
))
);
......@@ -114,7 +117,7 @@ class BlogArchivController extends AbstractService
->select('a')
->from('JityHomepageBundle:Article', 'a')
->where('a.service is NULL')
->where('YEAR(a.createdAt) = :year')
->andwhere('YEAR(a.createdAt) = :year')
->andWhere('MONTH(a.createdAt) = :month')
->getQuery()
->setParameter('year', $range->year)
......@@ -124,8 +127,9 @@ class BlogArchivController extends AbstractService
->get('templating')
->render(
'JityHomepageBundle:Service:Blog/archiv.html.twig', array(
'year' => $range->year,
'month' => $range->month,
'archivRange' => new \DateTime(
$range->year . '-' . $range->month . '-01'
),
'entities' => $query->getResult()
));
}
......
{% if servicePage %}
<ul>
{% for year, months in map %}
{% if loop.first %}<ul>{% endif %}
<li>{{ year }}</li>
<ul>
......@@ -16,9 +16,13 @@
{% endfor %}
</ul>
{% endfor %}
{% if loop.last %}</ul>{% endif %}
{% else %}
</ul>
Es wurden bisher keine Artikel verfasst.
{% endfor %}
{% endif %}
......@@ -2,7 +2,7 @@
<legend>Archiv</legend>
Alle Blog Artikel für das Jahr {{ year }} und den Monat {{ month }}.
Alle Blog Artikel für das Jahr {{ archivRange|date('y') }} und den Monat {{ archivRange|date('MMMM') }}.
<br>
......
......@@ -96,5 +96,25 @@
</div>
{% else %}
<div class="hero-unit">
<div class="row">
<img src="{{ asset('bundles/jityhomepage/img/icons/info.png') }}" class="pull-left"/>
<div class="span5">
<legend>Es konnten keine Artikel gefunden werden</legend>
Der Grund dafür kann zum einen sein, dass bisher kein Autor einen Arikel
verfasst hat, oder da es im festgelegten Zeitraum keine verfügbaren Arikel
gibt, die in dieser Zeit erstellt wurden.
</div>
</div>
</div>
{% endfor %}
......@@ -14,6 +14,7 @@ namespace Jity\HomepageBundle\Twig\Extension;
use Twig_Extension_Core,
Twig_Filter_Method,
Twig_Environment,
Jity\HomepageBundle\Doctrine\Extension\DBAL\Types\IntlDateTime,
JMS\DiExtraBundle\Annotation as DI;
/**
......@@ -75,6 +76,13 @@ class CoreExtension extends Twig_Extension_Core
*/
public function dateFormat(Twig_Environment $env, $date, $format = null)
{
if ($date instanceof \DateTime) {
// Convert plain DateTime Object to IntlDateTime
$newDate = new IntlDateTime();
$date = $newDate->setTimestamp($date->getTimestamp());
}
return twig_date_format_filter($env, $date, $format);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment