Add SEO Meta to CATEGORY/PRODUCT/FOLDER/CONTENT

This commit is contained in:
touffies
2013-12-09 14:34:07 +01:00
parent 0684ec2b42
commit d476672150
31 changed files with 381 additions and 311 deletions

View File

@@ -121,13 +121,37 @@ abstract class AbstractSeoCrudController extends AbstractCrudController
->setLocale($formData['locale'])
->setMetaTitle($formData['meta_title'])
->setMetaDescription($formData['meta_description'])
->setMetaKeyword($formData['meta_keyword'])
->setMetaKeywords($formData['meta_keywords'])
;
// Create and dispatch the change event
return $updateSeoEvent;
}
/**
* Hydrate the SEO form for this object, before passing it to the update template
*
* @param unknown $object
*/
protected function hydrateSeoForm($object){
// The "SEO" tab form
$locale = $object->getLocale();
$data = array(
'id' => $object->getId(),
'locale' => $locale,
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keywords' => $object->getMetaKeywords()
);
$seoForm = new SeoForm($this->getRequest(), "form", $data);
$this->getParserContext()->addForm($seoForm);
// URL based on the language
$this->getParserContext()->set('url_language', $this->getUrlLanguage($locale));
}
/**
* Update SEO modification, and either go back to the object list, or stay on the edition page.
*

View File

@@ -47,7 +47,7 @@ use Thelia\Model\CategoryAssociatedContentQuery;
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class CategoryController extends AbstractCrudController
class CategoryController extends AbstractSeoCrudController
{
public function __construct()
{
@@ -62,7 +62,8 @@ class CategoryController extends AbstractCrudController
TheliaEvents::CATEGORY_UPDATE,
TheliaEvents::CATEGORY_DELETE,
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY,
TheliaEvents::CATEGORY_UPDATE_POSITION
TheliaEvents::CATEGORY_UPDATE_POSITION,
TheliaEvents::CATEGORY_UPDATE_SEO
);
}
@@ -102,7 +103,6 @@ class CategoryController extends AbstractCrudController
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
->setVisible($formData['visible'])
->setUrl($formData['url'])
->setParent($formData['parent'])
;
@@ -130,7 +130,10 @@ class CategoryController extends AbstractCrudController
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
// Hydrate the "SEO" tab form
$this->hydrateSeoForm($object);
// The "General" tab form
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
@@ -139,7 +142,6 @@ class CategoryController extends AbstractCrudController
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible(),
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'parent' => $object->getParent()
);

View File

@@ -41,7 +41,7 @@ use Thelia\Model\ContentQuery;
* @package Thelia\Controller\Admin
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class ContentController extends AbstractCrudController
class ContentController extends AbstractSeoCrudController
{
public function __construct()
@@ -57,7 +57,8 @@ class ContentController extends AbstractCrudController
TheliaEvents::CONTENT_UPDATE,
TheliaEvents::CONTENT_DELETE,
TheliaEvents::CONTENT_TOGGLE_VISIBILITY,
TheliaEvents::CONTENT_UPDATE_POSITION
TheliaEvents::CONTENT_UPDATE_POSITION,
TheliaEvents::CONTENT_UPDATE_SEO
);
}
@@ -140,6 +141,9 @@ class ContentController extends AbstractCrudController
*/
protected function hydrateObjectForm($object)
{
// Hydrate the "SEO" tab form
$this->hydrateSeoForm($object);
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -148,8 +152,7 @@ class ContentController extends AbstractCrudController
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible(),
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'visible' => $object->getVisible()
);
// Setup the object form
@@ -191,7 +194,6 @@ class ContentController extends AbstractCrudController
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
->setVisible($formData['visible'])
->setUrl($formData['url'])
->setDefaultFolder($formData['default_folder']);
return $contentUpdateEvent;

View File

@@ -38,7 +38,7 @@ use Thelia\Model\FolderQuery;
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class FolderController extends AbstractCrudController
class FolderController extends AbstractSeoCrudController
{
public function __construct()
@@ -54,7 +54,8 @@ class FolderController extends AbstractCrudController
TheliaEvents::FOLDER_UPDATE,
TheliaEvents::FOLDER_DELETE,
TheliaEvents::FOLDER_TOGGLE_VISIBILITY,
TheliaEvents::FOLDER_UPDATE_POSITION
TheliaEvents::FOLDER_UPDATE_POSITION,
TheliaEvents::FOLDER_UPDATE_SEO
);
}
@@ -81,6 +82,9 @@ class FolderController extends AbstractCrudController
*/
protected function hydrateObjectForm($object)
{
// Hydrate the "SEO" tab form
$this->hydrateSeoForm($object);
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
@@ -90,7 +94,6 @@ class FolderController extends AbstractCrudController
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible(),
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'parent' => $object->getParent()
);
@@ -132,7 +135,6 @@ class FolderController extends AbstractCrudController
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
->setVisible($formData['visible'])
->setUrl($formData['url'])
->setParent($formData['parent'])
;

View File

@@ -68,7 +68,6 @@ use Thelia\Form\ProductModificationForm;
use Thelia\Form\ProductSaleElementUpdateForm;
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
use Thelia\Form\ProductCombinationGenerationForm;
use Thelia\Form\SeoForm;
use Thelia\TaxEngine\Calculator;
use Thelia\Tools\NumberFormat;
@@ -314,23 +313,8 @@ class ProductController extends AbstractSeoCrudController
$this->getParserContext()->addForm($combinationPseForm);
}
// The "SEO" tab form
$locale = $object->getLocale();
$data = array(
'id' => $object->getId(),
'locale' => $locale,
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keyword' => $object->getMetaKeyword()
);
$seoForm = new SeoForm($this->getRequest(), "form", $data);
$this->getParserContext()->addForm($seoForm);
// URL based on the language
$this->getParserContext()->set('url_language', $this->getUrlLanguage($locale));
// Hydrate the "SEO" tab form
$this->hydrateSeoForm($object);
// The "General" tab form
$data = array(