Commit 4370a109 authored by Hermann Mayer's avatar Hermann Mayer

Added DoctrineExtendsions Bundle. Refactored the Sidebar-Section Entities.…

Added DoctrineExtendsions Bundle. Refactored the Sidebar-Section Entities. (Sortable Many-to-Many implemented) Added Google Prettify, and customzied the obsidian theme. Some minor fixed.
parent 3d753732
......@@ -22,6 +22,7 @@ class AppKernel extends Kernel
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
new Jity\HomepageBundle\JityHomepageBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
......
......@@ -9,6 +9,8 @@
{% stylesheets
'@JityHomepageBundle/Resources/public/css/*.css'
'@JityHomepageBundle/Resources/public/js/google-code-prettify/*.css'
filter='?yui_css'
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
......@@ -208,6 +210,7 @@
{% javascripts
'@JityHomepageBundle/Resources/public/js/*.js'
'@JityHomepageBundle/Resources/public/js/google-code-prettify/*.js'
filter='?closure'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
......
......@@ -47,6 +47,12 @@ doctrine:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Enable required doctrine extensions
stof_doctrine_extensions:
orm:
default:
sortable: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
......
No preview for this file type
{
"name": "symfony/framework-standard-edition",
"name": "jity/hp",
"description": "The \"Symfony Standard Edition\" distribution",
"version": "0.1.0-dev",
"license": "GPL-3.0+",
"authors": [
{
"name": "Hermann Mayer",
"email": "hermann.mayer@unister.de",
"role": "Developer"
}
],
"autoload": {
"psr-0": { "": "src/" }
},
......@@ -21,7 +30,8 @@
"jms/di-extra-bundle": "1.1.*",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/data-fixtures": "dev-master",
"knplabs/knp-markdown-bundle": "dev-master"
"knplabs/knp-markdown-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
......@@ -43,6 +53,7 @@
"minimum-stability": "alpha",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
"symfony-web-dir": "web",
"symfony-assets-install": "symlink"
}
}
{
"hash": "6b42c9865fd2e49929ff03f0da736c5f",
"hash": "8f627fcee2e68ff16db3137e5bb3f3bf",
"packages": [
{
"name": "doctrine/common",
......@@ -362,6 +362,66 @@
"orm"
]
},
{
"name": "gedmo/doctrine-extensions",
"version": "v2.3.2",
"source": {
"type": "git",
"url": "git://github.com/l3pp4rd/DoctrineExtensions.git",
"reference": "v2.3.2"
},
"dist": {
"type": "zip",
"url": "https://github.com/l3pp4rd/DoctrineExtensions/zipball/v2.3.2",
"reference": "v2.3.2",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"doctrine/common": ">=2.1,<2.4-dev"
},
"suggest": {
"doctrine/orm": ">=2.1",
"doctrine/mongodb-odm": "*"
},
"time": "2012-07-13 22:26:40",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Gedmo": "lib/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Gediminas Morkevicius",
"email": "gediminas.morkevicius@gmail"
}
],
"description": "Doctrine2 behavioral extensions",
"homepage": "http://gediminasm.org/",
"keywords": [
"tree",
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"sluggable",
"loggable",
"translatable",
"nestedset",
"sortable",
"timestampable"
]
},
{
"name": "jms/aop-bundle",
"version": "1.0.0",
......@@ -926,6 +986,68 @@
],
"description": "This bundle generates code for you"
},
{
"name": "stof/doctrine-extensions-bundle",
"version": "dev-master",
"target-dir": "Stof/DoctrineExtensionsBundle",
"source": {
"type": "git",
"url": "https://github.com/stof/StofDoctrineExtensionsBundle",
"reference": "773b37310ca244570032541be3c8ab27b814a83f"
},
"dist": {
"type": "zip",
"url": "https://github.com/stof/StofDoctrineExtensionsBundle/zipball/773b37310ca244570032541be3c8ab27b814a83f",
"reference": "773b37310ca244570032541be3c8ab27b814a83f",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": "2.1.*",
"gedmo/doctrine-extensions": ">=2.3-dev"
},
"suggest": {
"doctrine/doctrine-bundle": "*",
"doctrine/mongodb-odm-bundle": "2.1.*"
},
"time": "1349111035",
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"installation-source": "source",
"autoload": {
"psr-0": {
"Stof\\DoctrineExtensionsBundle": ""
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "Integration of the gedmo/doctrine-extensions with Symfony2",
"homepage": "https://github.com/stof/StofDoctrineExtensionsBundle",
"keywords": [
"tree",
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"sluggable",
"loggable",
"translatable",
"nestedset",
"sortable",
"timestampable"
]
},
{
"name": "swiftmailer/swiftmailer",
"version": "v4.2.1",
......@@ -1345,6 +1467,7 @@
"stability-flags": {
"doctrine/doctrine-fixtures-bundle": 20,
"doctrine/data-fixtures": 20,
"knplabs/knp-markdown-bundle": 20
"knplabs/knp-markdown-bundle": 20,
"stof/doctrine-extensions-bundle": 20
}
}
......@@ -3,7 +3,7 @@
namespace Jity\HomepageBundle\DataFixtures\ORM;
use Jity\HomepageBundle\Entity\Sidebar;
use Jity\HomepageBundle\Entity\SidebarSection;
use Jity\HomepageBundle\Entity\Section;
use Jity\HomepageBundle\Entity\Page;
use Jity\HomepageBundle\Entity\Category;
use Jity\HomepageBundle\Entity\Navigation;
......@@ -62,7 +62,7 @@ zusätzliche Arbeit bedeutet.
// -------------------------------------
$section = new SidebarSection();
$section = new Section();
$section
->setTitle('Teilen')
->setContent('<p>
......@@ -79,14 +79,14 @@ Freunden und Bekannten über Googles Soziales Netzwerk oder über Facebook.
Facebook
</a>
</p>')
->setSidebar($this->getReference('default-sidebar'))
->addSidebar($this->getReference('default-sidebar'))
;
$manager->persist($section);
// -------------------------------------
$section = new SidebarSection();
$section = new Section();
$section
->setTitle('Favoriten')
->setContent('<p>
......@@ -99,14 +99,14 @@ werden Favoriten für Sie in der Applikation gespeichert.
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_012_heart_plus.png") }}" />
</a>
</p>')
->setSidebar($this->getReference('default-sidebar'))
->addSidebar($this->getReference('default-sidebar'))
;
$manager->persist($section);
// -------------------------------------
$section = new SidebarSection();
$section = new Section();
$section
->setGroup($this->getReference('author-group'))
->setTitle('Quick Operations')
......@@ -122,7 +122,7 @@ Mittel um die aktuelle Seite zu verändern.
<img src="{{ asset("bundles/jityhomepage/img/glyphicons_036_file.png") }}" />
</a>
</p>')
->setSidebar($this->getReference('default-sidebar'))
->addSidebar($this->getReference('default-sidebar'))
;
$manager->persist($section);
......
......@@ -44,7 +44,7 @@ class Group implements RoleInterface, \Serializable
protected $users;
/**
* @ORM\OneToMany(targetEntity="SidebarSection", mappedBy="group")
* @ORM\OneToMany(targetEntity="Section", mappedBy="group")
**/
protected $sections;
......
<?php
namespace Jity\HomepageBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="section")
*/
class Section
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Group", inversedBy="sections")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
**/
protected $group;
/**
* @ORM\Column(type="string", length=100)
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
protected $content;
/**
* @ORM\OneToMany(
* targetEntity="SidebarSection",
* mappedBy="section",
* cascade={"persist", "remove"}
* )
*/
protected $sidebarSection;
/**
* Constructor
*/
public function __construct()
{
$this->sidebarsSections = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
* @return Section
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set content
*
* @param string $content
* @return Section
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set group
*
* @param Jity\HomepageBundle\Entity\Group $group
* @return Section
*/
public function setGroup(\Jity\HomepageBundle\Entity\Group $group = null)
{
$this->group = $group;
return $this;
}
/**
* Get group
*
* @return Jity\HomepageBundle\Entity\Group
*/
public function getGroup()
{
return $this->group;
}
/**
* Add sidebars
*
* @param Jity\HomepageBundle\Entity\SidebarSection $sidebars
* @return Section
*/
public function addSidebar(\Jity\HomepageBundle\Entity\Sidebar $sidebar)
{
// Build new relation object to handle join entity correct
$rel = new \Jity\HomepageBundle\Entity\SidebarSection($sidebar, $this);
// Add relation object to collection
$this->sidebarSection[] = $rel;
return $this;
}
/**
* Remove sidebars
*
* @param Jity\HomepageBundle\Entity\SidebarSection $sidebars
*/
public function removeSidebar(\Jity\HomepageBundle\Entity\Sidebar $sidebar)
{
// Iterate over all join entities to find the correct
foreach ($this->sidebarSection as $rel) {
if ($rel->getSidebar() === $sidebar) {
$rel->removeElement($sidebar);
}
}
}
/**
* Get sidebars
*
* @return Doctrine\Common\Collections\Collection
*/
public function getSidebars()
{
$collection = new \Doctrine\Common\Collections\ArrayCollection();
foreach ($this->sidebarSection as $rel) {
$collection->add($rel->getSidebar());
}
return $collection;
}
}
......@@ -23,9 +23,14 @@ class Sidebar
protected $name;
/**
* @ORM\OneToMany(targetEntity="SidebarSection", mappedBy="sidebar")
**/
protected $sections;
* @ORM\OneToMany(
* targetEntity="SidebarSection",
* mappedBy="sidebar",
* cascade={"persist", "remove"}
* )
* @ORM\OrderBy({"position" = "ASC"})
*/
protected $sidebarSection;
/**
* @ORM\OneToMany(targetEntity="Page", mappedBy="sidebar")
......@@ -34,21 +39,30 @@ class Sidebar
/**
* __construct
*
* @access public
* Replace this Sidebar on all Pages which use this Sidebar
*
* @return void
*/
public function __construct()
public function replaceCategoryOnPages(\Jity\HomepageBundle\Entity\Sidebar $sidebar)
{
$this->sections = new \Doctrine\Common\Collections\ArrayCollection();
$this->pages = new \Doctrine\Common\Collections\ArrayCollection();
foreach ($this->pages as $page) {
$page->setSidebar($sidebar);
}
}
/**
* Constructor
*/
public function __construct()
{
$this->sidebarSection = new \Doctrine\Common\Collections\ArrayCollection();
$this->pages = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
* @return integer
*/
public function getId()
{
......@@ -59,17 +73,19 @@ class Sidebar
* Set name
*
* @param string $name
* @return Sidebar
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
* @return string
*/
public function getName()
{
......@@ -77,78 +93,84 @@ class Sidebar
}
/**
* Get sections
* Add section
*
* @return Doctrine\Common\Collections\Collection
* @param Jity\HomepageBundle\Entity\SidebarSection $sections
* @return Sidebar
*/
public function getSections()
public function addSection(\Jity\HomepageBundle\Entity\Section $section)
{
return $this->sections;
}
// Build new relation object to handle join entity correct
$rel = new \Jity\HomepageBundle\Entity\SidebarSection($this, $section);
/**
* Add pages
*
* @param Jity\HomepageBundle\Entity\Page $pages
*/
public function addPage(\Jity\HomepageBundle\Entity\Page $pages)
{
$this->pages[] = $pages;
// Add relation object to collection
$this->sidebarSection[] = $rel;
return $this;
}
/**
* Get pages
* Remove section
*
* @return Doctrine\Common\Collections\Collection
* @param Jity\HomepageBundle\Entity\SidebarSection $sections
*/
public function getPages()
public function removeSection(\Jity\HomepageBundle\Entity\Section $section)
{
return $this->pages;
// Iterate over all join entities to find the correct
foreach ($this->sidebarSection as $rel) {
if ($rel->getSection() === $section) {
$rel->removeElement($section);
}
}
}
/**
* Replace this Sidebar on all Pages which use this Sidebar
* Get sections
*
* @return void
* @return Doctrine\Common\Collections\Collection
*/
public function replaceCategoryOnPages(\Jity\HomepageBundle\Entity\Sidebar $sidebar)
public function getSections()
{
foreach ($this->pages as $page) {
$page->setSidebar($sidebar);
$collection = new \Doctrine\Common\Collections\ArrayCollection();
foreach ($this->sidebarSection as $rel) {
$collection->add($rel->getSection());
}
return $collection;
}
/**
* Add sections
* Add pages
*
* @param Jity\HomepageBundle\Entity\SidebarSection $sections
* @param Jity\HomepageBundle\Entity\Page $pages
* @return Sidebar
*/
public function addSection(\Jity\HomepageBundle\Entity\SidebarSection $sections)
public function addPage(\Jity\HomepageBundle\Entity\Page $pages)
{
$this->sections[] = $sections;
$this->pages[] = $pages;
return $this;
}
/**
* Remove sections
* Remove pages
*
* @param Jity\HomepageBundle\Entity\SidebarSection $sections
* @param Jity\HomepageBundle\Entity\Page $pages
*/
public function removeSection(\Jity\HomepageBundle\Entity\SidebarSection $sections)
public function removePage(\Jity\HomepageBundle\Entity\Page $pages)
{
$this->sections->removeElement($sections);
$this->pages->removeElement($pages);
}
/**
* Remove pages
* Get pages
*
* @param Jity\HomepageBundle\Entity\Page $pages
* @return Doctrine\Common\Collections\Collection
*/
public function removePage(\Jity\HomepageBundle\Entity\Page $pages)
public function getPages()
{
$this->pages->removeElement($pages);
return $this->pages;
}
}
\ No newline at end of file
}
......@@ -2,11 +2,16 @@
namespace Jity\HomepageBundle\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Jity\HomepageBundle\Entity\Sidebar;
use Jity\HomepageBundle\Entity\Section;
/**
* @ORM\Entity
* @ORM\Table(name="sidebar_section")
* @ORM\Table(name="sidebars_sections")
* @ORM\Entity(repositoryClass="Gedmo\Sortable\Entity\Repository\SortableRepository")
*/
class SidebarSection
{
......@@ -18,95 +23,89 @@ class SidebarSection
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Group", inversedBy="sections")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
* @Gedmo\SortableGroup
* @ORM\ManyToOne(targetEntity="Sidebar", inversedBy="sidebarSection")
* @ORM\JoinColumn(name="sidebar_id", referencedColumnName="id", nullable=false)
**/
protected $group;
/**
* @ORM\Column(type="string", length=100)
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
protected $content;
protected $sidebar;
/**
* @ORM\ManyToOne(targetEntity="Sidebar", inversedBy="sections")
* @ORM\JoinColumn(name="sidebar_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity="Section", inversedBy="sidebarSection")
* @ORM\JoinColumn(name="section_id", referencedColumnName="id", nullable=false)
**/
protected $sidebar;
protected $section;
/**
* Get id
*
* @return integer
* @Gedmo\SortablePosition
* @ORM\Column(name="position", type="integer")
*/
public function getId()
{
return $this->id;
}
protected $position;
/**
* Set title
*