From a3beb4c6f40b0f7048f1222b8127204142b7a082 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:00:07 +0100 Subject: [PATCH 01/55] Add new fields (meta_title, meta_description and meta_keyword) under I18N Product --- core/lib/Thelia/Model/Base/Product.php | 72 + core/lib/Thelia/Model/Base/ProductI18n.php | 176 +- .../Thelia/Model/Base/ProductI18nQuery.php | 101 +- .../Thelia/Model/Map/ProductI18nTableMap.php | 52 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- install/thelia.sql | 3 + local/config/schema.xml | 2531 +++++++++-------- 7 files changed, 1656 insertions(+), 1281 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 77824575c..e850d2acf 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -5866,6 +5866,78 @@ abstract class Product implements ActiveRecordInterface return $this; } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keyword] column value. + * + * @return string + */ + public function getMetaKeyword() + { + return $this->getCurrentTranslation()->getMetaKeyword(); + } + + + /** + * Set the value of [meta_keyword] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaKeyword($v) + { $this->getCurrentTranslation()->setMetaKeyword($v); + + return $this; + } + // versionable behavior /** diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index cdab7349d..a72f07c83 100644 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -90,6 +90,24 @@ abstract class ProductI18n implements ActiveRecordInterface */ protected $postscriptum; + /** + * The value for the meta_title field. + * @var string + */ + protected $meta_title; + + /** + * The value for the meta_description field. + * @var string + */ + protected $meta_description; + + /** + * The value for the meta_keyword field. + * @var string + */ + protected $meta_keyword; + /** * @var Product */ @@ -440,6 +458,39 @@ abstract class ProductI18n implements ActiveRecordInterface return $this->postscriptum; } + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keyword] column value. + * + * @return string + */ + public function getMetaKeyword() + { + + return $this->meta_keyword; + } + /** * Set the value of [id] column. * @@ -570,6 +621,69 @@ abstract class ProductI18n implements ActiveRecordInterface return $this; } // setPostscriptum() + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[] = ProductI18nTableMap::META_TITLE; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[] = ProductI18nTableMap::META_DESCRIPTION; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keyword] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setMetaKeyword($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keyword !== $v) { + $this->meta_keyword = $v; + $this->modifiedColumns[] = ProductI18nTableMap::META_KEYWORD; + } + + + return $this; + } // setMetaKeyword() + /** * Indicates whether the columns in this object are only set to default values. * @@ -628,6 +742,15 @@ abstract class ProductI18n implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductI18nTableMap::translateFieldName('MetaKeyword', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keyword = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -636,7 +759,7 @@ abstract class ProductI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = ProductI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = ProductI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductI18n object", 0, $e); @@ -875,6 +998,15 @@ abstract class ProductI18n implements ActiveRecordInterface if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } + if ($this->isColumnModified(ProductI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(ProductI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORD)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORD'; + } $sql = sprintf( 'INSERT INTO product_i18n (%s) VALUES (%s)', @@ -904,6 +1036,15 @@ abstract class ProductI18n implements ActiveRecordInterface case 'POSTSCRIPTUM': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORD': + $stmt->bindValue($identifier, $this->meta_keyword, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -977,6 +1118,15 @@ abstract class ProductI18n implements ActiveRecordInterface case 5: return $this->getPostscriptum(); break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeyword(); + break; default: return null; break; @@ -1012,6 +1162,9 @@ abstract class ProductI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), $keys[4] => $this->getChapo(), $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeyword(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1074,6 +1227,15 @@ abstract class ProductI18n implements ActiveRecordInterface case 5: $this->setPostscriptum($value); break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeyword($value); + break; } // switch() } @@ -1104,6 +1266,9 @@ abstract class ProductI18n implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeyword($arr[$keys[8]]); } /** @@ -1121,6 +1286,9 @@ abstract class ProductI18n implements ActiveRecordInterface if ($this->isColumnModified(ProductI18nTableMap::DESCRIPTION)) $criteria->add(ProductI18nTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(ProductI18nTableMap::CHAPO)) $criteria->add(ProductI18nTableMap::CHAPO, $this->chapo); if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProductI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(ProductI18nTableMap::META_TITLE)) $criteria->add(ProductI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(ProductI18nTableMap::META_DESCRIPTION)) $criteria->add(ProductI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORD)) $criteria->add(ProductI18nTableMap::META_KEYWORD, $this->meta_keyword); return $criteria; } @@ -1197,6 +1365,9 @@ abstract class ProductI18n implements ActiveRecordInterface $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeyword($this->getMetaKeyword()); if ($makeNew) { $copyObj->setNew(true); } @@ -1286,6 +1457,9 @@ abstract class ProductI18n implements ActiveRecordInterface $this->description = null; $this->chapo = null; $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keyword = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); diff --git a/core/lib/Thelia/Model/Base/ProductI18nQuery.php b/core/lib/Thelia/Model/Base/ProductI18nQuery.php index d64c95892..01d3af9d4 100644 --- a/core/lib/Thelia/Model/Base/ProductI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ProductI18nQuery.php @@ -27,6 +27,9 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildProductI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column * @method ChildProductI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildProductI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column + * @method ChildProductI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column + * @method ChildProductI18nQuery orderByMetaKeyword($order = Criteria::ASC) Order by the meta_keyword column * * @method ChildProductI18nQuery groupById() Group by the id column * @method ChildProductI18nQuery groupByLocale() Group by the locale column @@ -34,6 +37,9 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18nQuery groupByDescription() Group by the description column * @method ChildProductI18nQuery groupByChapo() Group by the chapo column * @method ChildProductI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildProductI18nQuery groupByMetaTitle() Group by the meta_title column + * @method ChildProductI18nQuery groupByMetaDescription() Group by the meta_description column + * @method ChildProductI18nQuery groupByMetaKeyword() Group by the meta_keyword column * * @method ChildProductI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildProductI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -52,6 +58,9 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18n findOneByDescription(string $description) Return the first ChildProductI18n filtered by the description column * @method ChildProductI18n findOneByChapo(string $chapo) Return the first ChildProductI18n filtered by the chapo column * @method ChildProductI18n findOneByPostscriptum(string $postscriptum) Return the first ChildProductI18n filtered by the postscriptum column + * @method ChildProductI18n findOneByMetaTitle(string $meta_title) Return the first ChildProductI18n filtered by the meta_title column + * @method ChildProductI18n findOneByMetaDescription(string $meta_description) Return the first ChildProductI18n filtered by the meta_description column + * @method ChildProductI18n findOneByMetaKeyword(string $meta_keyword) Return the first ChildProductI18n filtered by the meta_keyword column * * @method array findById(int $id) Return ChildProductI18n objects filtered by the id column * @method array findByLocale(string $locale) Return ChildProductI18n objects filtered by the locale column @@ -59,6 +68,9 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method array findByDescription(string $description) Return ChildProductI18n objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildProductI18n objects filtered by the chapo column * @method array findByPostscriptum(string $postscriptum) Return ChildProductI18n objects filtered by the postscriptum column + * @method array findByMetaTitle(string $meta_title) Return ChildProductI18n objects filtered by the meta_title column + * @method array findByMetaDescription(string $meta_description) Return ChildProductI18n objects filtered by the meta_description column + * @method array findByMetaKeyword(string $meta_keyword) Return ChildProductI18n objects filtered by the meta_keyword column * */ abstract class ProductI18nQuery extends ModelCriteria @@ -147,7 +159,7 @@ abstract class ProductI18nQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM product_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORD FROM product_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -436,6 +448,93 @@ abstract class ProductI18nQuery extends ModelCriteria return $this->addUsingAlias(ProductI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keyword column + * + * Example usage: + * + * $query->filterByMetaKeyword('fooValue'); // WHERE meta_keyword = 'fooValue' + * $query->filterByMetaKeyword('%fooValue%'); // WHERE meta_keyword LIKE '%fooValue%' + * + * + * @param string $metaKeyword The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeyword($metaKeyword = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeyword)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeyword)) { + $metaKeyword = str_replace('*', '%', $metaKeyword); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductI18nTableMap::META_KEYWORD, $metaKeyword, $comparison); + } + /** * Filter the query by a related \Thelia\Model\Product object * diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index 79a01514a..e082ebccb 100644 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -57,7 +57,7 @@ class ProductI18nTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductI18nTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -99,6 +99,21 @@ class ProductI18nTableMap extends TableMap */ const POSTSCRIPTUM = 'product_i18n.POSTSCRIPTUM'; + /** + * the column name for the META_TITLE field + */ + const META_TITLE = 'product_i18n.META_TITLE'; + + /** + * the column name for the META_DESCRIPTION field + */ + const META_DESCRIPTION = 'product_i18n.META_DESCRIPTION'; + + /** + * the column name for the META_KEYWORD field + */ + const META_KEYWORD = 'product_i18n.META_KEYWORD'; + /** * The default string format for model objects of the related table */ @@ -111,12 +126,12 @@ class ProductI18nTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeyword', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeyword', ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ProductI18nTableMap::META_TITLE, ProductI18nTableMap::META_DESCRIPTION, ProductI18nTableMap::META_KEYWORD, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORD', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keyword', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -126,12 +141,12 @@ class ProductI18nTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeyword' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeyword' => 8, ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ProductI18nTableMap::META_TITLE => 6, ProductI18nTableMap::META_DESCRIPTION => 7, ProductI18nTableMap::META_KEYWORD => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORD' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keyword' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -156,6 +171,9 @@ class ProductI18nTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORD', 'MetaKeyword', 'LONGVARCHAR', false, null, null); } // initialize() /** @@ -359,6 +377,9 @@ class ProductI18nTableMap extends TableMap $criteria->addSelectColumn(ProductI18nTableMap::DESCRIPTION); $criteria->addSelectColumn(ProductI18nTableMap::CHAPO); $criteria->addSelectColumn(ProductI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(ProductI18nTableMap::META_TITLE); + $criteria->addSelectColumn(ProductI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(ProductI18nTableMap::META_KEYWORD); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -366,6 +387,9 @@ class ProductI18nTableMap extends TableMap $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORD'); } } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 68a34a393..3cf8d3925 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -230,7 +230,7 @@ class ProductTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keyword', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() diff --git a/install/thelia.sql b/install/thelia.sql index ed27071fb..e26acd742 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1652,6 +1652,9 @@ CREATE TABLE `product_i18n` `description` LONGTEXT, `chapo` TEXT, `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keyword` TEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `product_i18n_FK_1` FOREIGN KEY (`id`) diff --git a/local/config/schema.xml b/local/config/schema.xml index 70df6710e..2a22eaa8e 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1264 +1,1267 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - -
-
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
+
From 186b338f48b8971465befa6111b52929e2ea84be Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:03:32 +0100 Subject: [PATCH 02/55] Add new SEO form --- core/lib/Thelia/Config/Resources/form.xml | 2 +- core/lib/Thelia/Form/SeoFieldsTrait.php | 89 +++++++++++++++++++++++ core/lib/Thelia/Form/SeoForm.php | 81 +++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Form/SeoFieldsTrait.php create mode 100644 core/lib/Thelia/Form/SeoForm.php diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml index cf9ccd489..ec281266e 100644 --- a/core/lib/Thelia/Config/Resources/form.xml +++ b/core/lib/Thelia/Config/Resources/form.xml @@ -17,6 +17,7 @@
+ @@ -39,7 +40,6 @@ - diff --git a/core/lib/Thelia/Form/SeoFieldsTrait.php b/core/lib/Thelia/Form/SeoFieldsTrait.php new file mode 100644 index 000000000..dd66324d8 --- /dev/null +++ b/core/lib/Thelia/Form/SeoFieldsTrait.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +/** + * A trait to add standard localized description fields to a form. + * + * @author Christophe Laffont + */ +trait SeoFieldsTrait +{ + /** + * Add seo meta title, meta description and meta keywords fields + * + * @param array $exclude name of the fields that should not be added to the form + */ + protected function addSeoFields($exclude = array()) + { + + if (! in_array('url', $exclude)) + $this->formBuilder + ->add('url', 'text', array( + 'label' => Translator::getInstance()->trans('Rewriten URL'), + 'label_attr' => array( + 'for' => 'rewriten_url_field' + ), + 'required' => false + ) + ); + + if (! in_array('meta_title', $exclude)) + $this->formBuilder + ->add('meta_title', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Page Title'), + 'label_attr' => array( + 'for' => 'meta_title' + ) + ) + ); + + if (! in_array('meta_description', $exclude)) + $this->formBuilder + ->add('meta_description', 'text', array( + 'label' => Translator::getInstance()->trans('Meta Description'), + 'label_attr' => array( + 'for' => 'meta_description' + ), + 'required' => false + ) + ); + + if (! in_array('meta_keyword', $exclude)) + $this->formBuilder + ->add('meta_keyword', 'text', array( + 'label' => Translator::getInstance()->trans('Meta Keyword'), + 'label_attr' => array( + 'for' => 'meta_keyword' + ), + 'required' => false + ) + ); + } +} diff --git a/core/lib/Thelia/Form/SeoForm.php b/core/lib/Thelia/Form/SeoForm.php new file mode 100644 index 000000000..28c90c9ba --- /dev/null +++ b/core/lib/Thelia/Form/SeoForm.php @@ -0,0 +1,81 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; + +/** + * Class SeoForm + * @package Thelia\Form + * @author Christophe Laffont + */ +class SeoForm extends BaseForm +{ + use SeoFieldsTrait; + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + + $this->formBuilder + ->add("id", "hidden", array( + "constraints" => array( + new GreaterThan(array('value' => 0)) + ) + )) + ->add("locale", "hidden", array( + "constraints" => array( + new NotBlank() + ) + )) + ; + + // Add SEO Fields + $this->addSeoFields(); + } + + public function getName() + { + return "thelia_seo"; + } +} From 1af1f90996848b42d5a2e82693b1de30cb29952c Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:05:03 +0100 Subject: [PATCH 03/55] Add SEO tab for a product --- .../backOffice/default/includes/seo-tab.html | 79 +++++++++++++++++++ .../backOffice/default/product-edit.html | 17 +++- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 templates/backOffice/default/includes/seo-tab.html diff --git a/templates/backOffice/default/includes/seo-tab.html b/templates/backOffice/default/includes/seo-tab.html new file mode 100644 index 000000000..9ae515885 --- /dev/null +++ b/templates/backOffice/default/includes/seo-tab.html @@ -0,0 +1,79 @@ +
+ + + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + + page_url = {$pageUrl} + close_url = {$closeUrl} + } + + {* Hidden field *} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='url'} +
+ +
+ {$url_language|default:{config key="url_site"}} + +
+
+ {/form_field} + + + {form_field form=$form field='meta_title'} +
+ +
+ +
+
+ {/form_field} + + {form_field form=$form field='meta_description'} +
+ + + +
+ {/form_field} + + {form_field form=$form field='meta_keyword'} +
+ + + +
+ {/form_field} + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + hide_flags = true + + page_url = {$pageUrl} + close_url = {$closeUrl} + } + + +
\ No newline at end of file diff --git a/templates/backOffice/default/product-edit.html b/templates/backOffice/default/product-edit.html index e05bc7434..d20d7a953 100644 --- a/templates/backOffice/default/product-edit.html +++ b/templates/backOffice/default/product-edit.html @@ -48,6 +48,8 @@ data-toggle="tab">{intl l="General"} +
  • {intl l="SEO"}
  • +
  • {intl l="Details"}
  • @@ -79,7 +81,7 @@ {intl l="Documents"}
  • {intl l="Modules"}
  • - +
    @@ -87,6 +89,18 @@ {include file="includes/product-general-tab.html"}
    +
    + {form name="thelia.admin.seo"} + {include file="includes/seo-tab.html" + form = $form + currentId = "{$ID}" + formAction = "{url path='/admin/products/seo/save'}" + pageUrl = "{url path='/admin/products/update' product_id=$ID}" + closeUrl = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + {/form} +
    +
    {include file="includes/product-details-tab.html"}
    @@ -110,6 +124,7 @@
    {intl l="Please wait, loading"}
    + From d13bc0579bf494635ce7475652ea12461f12a5e9 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:06:19 +0100 Subject: [PATCH 04/55] Add action buttons at the bottom of the product General tab --- .../default/includes/product-general-tab.html | 73 ++++++++----------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/templates/backOffice/default/includes/product-general-tab.html b/templates/backOffice/default/includes/product-general-tab.html index 84b9a836d..c78e380ae 100644 --- a/templates/backOffice/default/includes/product-general-tab.html +++ b/templates/backOffice/default/includes/product-general-tab.html @@ -11,15 +11,14 @@ close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" } - {* Be sure to get the product ID, even if the form could not be validated *} + {* Be sure to get the product ID, even if the form could not be validated*} - - + {form_hidden_fields form=$form} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='success_url'} @@ -32,33 +31,25 @@ {if $form_error}
    {$form_error_message}
    {/if} -
    - - -
    {$REF}
    - - {form_field form=$form field='ref'} - - {/form_field} - -
    - - {include file="includes/standard-description-form-fields.html"} - - {form_field form=$form field='url'} -
    - - - -
    - {/form_field} -
    -
    +
    + {form_field form=$form field='ref'} +
    + +
    + {* If ref's 'value is not empty the field is disable and the value is sent with an hidden field *} + + {if $value}{/if} +
    +
    + {/form_field} + + {include file="includes/standard-description-form-fields.html"} +
    + +
    {form_field form=$form field='default_category'}
    @@ -79,9 +70,7 @@
    {/form_field} -
    -
    {form_field form=$form field='visible'}
    @@ -96,16 +85,16 @@
    -
    -
    -
    - -
    -

    {intl l='Product created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    -
    -
    -
    -
    + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + hide_flags = true + + page_url = "{url path='/admin/products/update' product_id=$ID}" + close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + + {intl l='Product created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"} {/form} From ad10b984f32503a27881dca83d71e37ff8b4e8bd Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:07:03 +0100 Subject: [PATCH 05/55] Add new route to save the product SEO information --- core/lib/Thelia/Config/Resources/routing/admin.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 591e5c0e7..b821e775c 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -263,6 +263,10 @@ Thelia\Controller\Admin\ProductController::processUpdateAction + + Thelia\Controller\Admin\ProductController::processUpdateSeoAction + + Thelia\Controller\Admin\ProductController::setToggleVisibilityAction From 6418914a6d99fc3a83bbc431ccf67de094881b6d Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:10:10 +0100 Subject: [PATCH 06/55] Add Action + Event to manage SEO information --- core/lib/Thelia/Action/BaseAction.php | 36 ++++- core/lib/Thelia/Action/Product.php | 64 +++++---- .../Admin/AbstractCrudController.php | 115 +++++++++++++++- core/lib/Thelia/Core/Event/TheliaEvents.php | 3 + core/lib/Thelia/Core/Event/UpdateSeoEvent.php | 130 ++++++++++++++++++ 5 files changed, 315 insertions(+), 33 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/UpdateSeoEvent.php diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index e1edab07d..e207a624e 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -23,9 +23,12 @@ namespace Thelia\Action; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Model\AdminLog; use Propel\Runtime\ActiveQuery\ModelCriteria; + use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; + +use \Thelia\Model\Tools\UrlRewritingTrait; class BaseAction { @@ -73,4 +76,35 @@ class BaseAction return $object->movePositionDown(); } } + + /** + * Changes SEO Fields for an object. + * + * @param ModelCriteria $query + * @param UpdateSeoEvent $event + * + * @return mixed + */ + protected function genericUpdateSeo(ModelCriteria $query, UpdateSeoEvent $event) + { + if (null !== $object = $query->findPk($event->getObjectId())) { + + $object + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setMetaTitle($event->getMetaTitle()) + ->setMetaDescription($event->getMetaDescription()) + ->setMetaKeyword($event->getMetaKeyword()) + + ->save() + ; + + // Update the rewriten URL, if required + $object->setRewrittenUrl($event->getLocale(), $event->getUrl()); + + return $object; + } + } + } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 3917827d1..a5b117eb4 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -25,36 +25,37 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductQuery; use Thelia\Model\Product as ProductModel; - -use Thelia\Core\Event\TheliaEvents; - -use Thelia\Core\Event\Product\ProductUpdateEvent; -use Thelia\Core\Event\Product\ProductCreateEvent; -use Thelia\Core\Event\Product\ProductDeleteEvent; -use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; -use Thelia\Core\Event\Product\ProductAddContentEvent; -use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Model\ProductAssociatedContent; use Thelia\Model\ProductAssociatedContentQuery; use Thelia\Model\ProductCategory; use Thelia\Model\TaxRuleQuery; use Thelia\Model\AccessoryQuery; use Thelia\Model\Accessory; -use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; use Thelia\Model\FeatureProduct; -use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; use Thelia\Model\FeatureProductQuery; use Thelia\Model\ProductCategoryQuery; -use Thelia\Core\Event\Product\ProductSetTemplateEvent; use Thelia\Model\ProductSaleElementsQuery; + +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\Product\ProductUpdateEvent; +use Thelia\Core\Event\Product\ProductCreateEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; +use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; +use Thelia\Core\Event\Product\ProductAddContentEvent; +use Thelia\Core\Event\Product\ProductDeleteContentEvent; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; +use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; +use Thelia\Core\Event\Product\ProductSetTemplateEvent; use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; use Thelia\Core\Event\Product\ProductAddCategoryEvent; use Thelia\Core\Event\Product\ProductAddAccessoryEvent; use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; -use Thelia\Model\Map\ProductTableMap; + use Propel\Runtime\Propel; class Product extends BaseAction implements EventSubscriberInterface @@ -113,9 +114,6 @@ class Product extends BaseAction implements EventSubscriberInterface ->save() ; - // Update the rewriten URL, if required - $product->setRewrittenUrl($event->getLocale(), $event->getUrl()); - // Update default category (ifd required) $product->updateDefaultCategory($event->getDefaultCategory()); @@ -123,6 +121,17 @@ class Product extends BaseAction implements EventSubscriberInterface } } + /** + * Change a product SEO + * + * @param \Thelia\Core\Event\UpdateSeoEvent $event + */ + public function updateSeo(UpdateSeoEvent $event) + { + return $this->genericUpdateSeo(ProductQuery::create(), $event); + } + + /** * Delete a product entry * @@ -379,12 +388,13 @@ class Product extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::PRODUCT_CREATE => array("create", 128), - TheliaEvents::PRODUCT_UPDATE => array("update", 128), - TheliaEvents::PRODUCT_DELETE => array("delete", 128), - TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + TheliaEvents::PRODUCT_CREATE => array("create", 128), + TheliaEvents::PRODUCT_UPDATE => array("update", 128), + TheliaEvents::PRODUCT_DELETE => array("delete", 128), + TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128), + TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128), + TheliaEvents::PRODUCT_UPDATE_SEO => array("updateSeo", 128), TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128), TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128), @@ -394,13 +404,13 @@ class Product extends BaseAction implements EventSubscriberInterface TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128), TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128), - TheliaEvents::PRODUCT_ADD_CATEGORY => array("addCategory", 128), - TheliaEvents::PRODUCT_REMOVE_CATEGORY => array("removeCategory", 128), + TheliaEvents::PRODUCT_ADD_CATEGORY => array("addCategory", 128), + TheliaEvents::PRODUCT_REMOVE_CATEGORY => array("removeCategory", 128), - TheliaEvents::PRODUCT_SET_TEMPLATE => array("setProductTemplate", 128), + TheliaEvents::PRODUCT_SET_TEMPLATE => array("setProductTemplate", 128), - TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128), - TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128), + TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128), + TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128), ); } } diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 11ed4fc50..6fe387319 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -23,9 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\AccessManager; -use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Security\AccessManager; + +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\SeoForm; /** * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. @@ -49,6 +52,7 @@ abstract class AbstractCrudController extends BaseAdminController protected $deleteEventIdentifier; protected $visibilityToggleEventIdentifier; protected $changePositionEventIdentifier; + protected $updateSeoEventIdentifier; /** * @param string $objectName the lower case object name. Example. "message" @@ -64,6 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO */ public function __construct( $objectName, @@ -77,7 +82,8 @@ abstract class AbstractCrudController extends BaseAdminController $updateEventIdentifier, $deleteEventIdentifier, $visibilityToggleEventIdentifier = null, - $changePositionEventIdentifier = null + $changePositionEventIdentifier = null, + $updateSeoEventIdentifier = null ) { $this->objectName = $objectName; @@ -91,6 +97,7 @@ abstract class AbstractCrudController extends BaseAdminController $this->deleteEventIdentifier = $deleteEventIdentifier; $this->visibilityToggleEventIdentifier = $visibilityToggleEventIdentifier; $this->changePositionEventIdentifier = $changePositionEventIdentifier; + $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; } /** @@ -139,7 +146,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Get the created object from an event. * - * @param unknown $createEvent + * @param unknown $event */ abstract protected function getObjectFromEvent($event); @@ -230,7 +237,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object position change processing if required. * - * @param unknown $deleteEvent the delete event + * @param unknown $positionChangeEvent the delete event * @return Response a response, or null to continue normal processing */ protected function performAdditionalUpdatePositionAction($positionChangeEvent) @@ -238,6 +245,17 @@ abstract class AbstractCrudController extends BaseAdminController return null; } + /** + * Put in this method post object update SEO processing if required. + * + * @param unknown $seoUpdateEvent the update event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdateSeoAction($updateSeoEvent) + { + return null; + } + /** * Return the current list order identifier, updating it in the same time. */ @@ -423,6 +441,93 @@ abstract class AbstractCrudController extends BaseAdminController return $this->renderEditionTemplate(); } + + /** + * Return the update SEO form for this object + */ + protected function getUpdateSeoForm() + { + return new SeoForm($this->getRequest()); + } + + /** + * Creates the update SEO event with the provided form data + * + * @param $formData + * @return UpdateSeoEvent + */ + protected function getUpdateSeoEvent($formData) + { + + $updateSeoEvent = new UpdateSeoEvent($formData['id']); + + $updateSeoEvent + ->setLocale($formData['locale']) + ->setMetaTitle($formData['meta_title']) + ->setMetaDescription($formData['meta_description']) + ->setMetaKeyword($formData['meta_keyword']) + ; + + // Create and dispatch the change event + return $updateSeoEvent; + } + + /** + * Update SEO modification, and either go back to the object list, or stay on the edition page. + * + * @return Thelia\Core\HttpFoundation\Response the response + */ + + public function processUpdateSeoAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; + + $error_msg = false; + + // Create the form from the request + $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); + + try { + + // Check the form against constraints violations + $form = $this->validateForm($updateSeoForm, "POST"); + + // Get the form field values + $data = $form->getData(); + + $updateSeoEvent = $this->getUpdateSeoEvent($data); + + $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); + + } catch (FormValidationException $ex) { + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + + $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); + + if ($response == null) { + // If we have to stay on the same page, do not redirect to the successUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($updateSeoForm->getSuccessUrl()); + } else { + return $response; + } + + // At this point, the form has errors, and should be redisplayed. + return $this->renderEditionTemplate(); + } + /** * Update object position (only for objects whichsupport that) * diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 1dfcb673c..ac2a6422f 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -167,6 +167,7 @@ final class TheliaEvents const CATEGORY_DELETE = "action.deleteCategory"; const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_UPDATE_SEO = "action.updateCategorySeo"; const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; @@ -204,6 +205,7 @@ final class TheliaEvents const CONTENT_DELETE = "action.deleteContent"; const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility"; const CONTENT_UPDATE_POSITION = "action.updateContentPosition"; + const CONTENT_UPDATE_SEO = "action.updateContentSeo"; const CONTENT_ADD_FOLDER = "action.contentAddFolder"; const CONTENT_REMOVE_FOLDER = "action.contentRemoveFolder"; @@ -276,6 +278,7 @@ final class TheliaEvents const PRODUCT_DELETE = "action.deleteProduct"; const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility"; const PRODUCT_UPDATE_POSITION = "action.updateProductPosition"; + const PRODUCT_UPDATE_SEO = "action.updateProductSeo"; const PRODUCT_ADD_CONTENT = "action.productAddContent"; const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; diff --git a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php new file mode 100644 index 000000000..99b19efe8 --- /dev/null +++ b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php @@ -0,0 +1,130 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class UpdateSeoEvent extends ActionEvent +{ + protected $object_id; + protected $locale; + protected $url; + protected $meta_title; + protected $meta_description; + protected $meta_keyword; + + protected $object; + + public function __construct($object_id, $locale = null, $url = null, $meta_title = null, $meta_description = null, $meta_keyword = null) + { + $this->object_id = $object_id; + $this->locale = $locale; + $this->url = $url; + $this->meta_title = $meta_title; + $this->meta_description = $meta_description; + $this->meta_keyword = $meta_keyword; + } + + public function getObjectId() + { + return $this->object_id; + } + + public function setObjectId($object_id) + { + $this->object_id = $object_id; + + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getUrl() + { + return $this->url; + } + + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } + + public function getMetaTitle() + { + return $this->meta_title; + } + + public function setMetaTitle($meta_title) + { + $this->meta_title = $meta_title; + + return $this; + } + + public function getMetaDescription() + { + return $this->meta_description; + } + + public function setMetaDescription($meta_description) + { + $this->meta_description = $meta_description; + + return $this; + } + + public function getMetaKeyword() + { + return $this->meta_keyword; + } + + public function setMetaKeyword($meta_keyword) + { + $this->meta_keyword = $meta_keyword; + + return $this; + } +} From dc28ce2d30a07365e86d200dc87b401f19061058 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:11:45 +0100 Subject: [PATCH 07/55] Move URL to SeoForm (SEO tab) --- .../Core/Event/Product/ProductUpdateEvent.php | 13 ------------- core/lib/Thelia/Form/ProductModificationForm.php | 7 +------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php index 535f04462..7d0f9469c 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php @@ -33,7 +33,6 @@ class ProductUpdateEvent extends ProductCreateEvent protected $description; protected $postscriptum; - protected $url; protected $parent; public function __construct($product_id) @@ -89,18 +88,6 @@ class ProductUpdateEvent extends ProductCreateEvent return $this; } - public function getUrl() - { - return $this->url; - } - - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php index 34785cf45..708599ffb 100644 --- a/core/lib/Thelia/Form/ProductModificationForm.php +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -24,7 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; -use Symfony\Component\Validator\Constraints\NotBlank; + class ProductModificationForm extends ProductCreationForm { @@ -46,11 +46,6 @@ class ProductModificationForm extends ProductCreationForm "label_attr" => array("for" => "product_template_field") )) - ->add("url", "text", array( - "label" => Translator::getInstance()->trans("Rewriten URL *"), - "constraints" => array(new NotBlank()), - "label_attr" => array("for" => "rewriten_url_field") - )) ; // Add standard description fields, excluding title and locale, which a re defined in parent class From a571db9a43cbb9d47b1799e7d6ea3d229fc458b5 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:12:24 +0100 Subject: [PATCH 08/55] Hydrate SeoForm under SEO Tab --- .../Controller/Admin/ProductController.php | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 9aa2d279e..109e95a68 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -23,50 +23,56 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\Resource\AdminResources; -use Thelia\Core\Event\Product\ProductAddCategoryEvent; -use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; -use Thelia\Core\Event\Product\ProductDeleteEvent; +use Symfony\Component\HttpFoundation\JsonResponse; +use Propel\Runtime\ActiveQuery\Criteria; + use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Product\ProductUpdateEvent; use Thelia\Core\Event\Product\ProductCreateEvent; -use Thelia\Core\Security\AccessManager; -use Thelia\Model\ProductQuery; -use Thelia\Form\ProductModificationForm; -use Thelia\Form\ProductCreationForm; -use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\Product\ProductAddCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Core\Event\Product\ProductAddContentEvent; -use Thelia\Model\FolderQuery; -use Thelia\Model\ContentQuery; -use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Model\ProductAssociatedContentQuery; -use Thelia\Model\AccessoryQuery; -use Thelia\Model\CategoryQuery; - use Thelia\Core\Event\Product\ProductAddAccessoryEvent; use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; -use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Core\Event\Product\ProductCombinationGenerationEvent; +use Thelia\Core\Event\Product\ProductSetTemplateEvent; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementDeleteEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent; + +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\AccessManager; + +use Thelia\Model\AccessoryQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; use Thelia\Model\AttributeQuery; use Thelia\Model\AttributeAvQuery; -use Thelia\Form\ProductSaleElementUpdateForm; +use Thelia\Model\ProductQuery; +use Thelia\Model\ProductAssociatedContentQuery; +use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; -use Thelia\Form\ProductDefaultSaleElementUpdateForm; use Thelia\Model\ProductPrice; use Thelia\Model\Currency; -use Symfony\Component\HttpFoundation\JsonResponse; -use Thelia\TaxEngine\Calculator; -use Thelia\Model\Country; -use Thelia\Tools\NumberFormat; -use Thelia\Model\Product; use Thelia\Model\CurrencyQuery; +use Thelia\Model\Country; +use Thelia\Model\Product; + +use Thelia\Form\ProductCreationForm; +use Thelia\Form\ProductModificationForm; +use Thelia\Form\ProductSaleElementUpdateForm; +use Thelia\Form\ProductDefaultSaleElementUpdateForm; use Thelia\Form\ProductCombinationGenerationForm; -use Thelia\Core\Event\Product\ProductCombinationGenerationEvent; -use Thelia\Core\Event\Product\ProductSetTemplateEvent; +use Thelia\Form\SeoForm; + +use Thelia\TaxEngine\Calculator; +use Thelia\Tools\NumberFormat; + /** * Manages products @@ -89,7 +95,8 @@ class ProductController extends AbstractCrudController TheliaEvents::PRODUCT_DELETE, TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, - TheliaEvents::PRODUCT_UPDATE_POSITION + TheliaEvents::PRODUCT_UPDATE_POSITION, + TheliaEvents::PRODUCT_UPDATE_SEO ); } @@ -153,9 +160,9 @@ class ProductController extends AbstractCrudController protected function getUpdateEvent($formData) { + $changeEvent = new ProductUpdateEvent($formData['id']); - // Create and dispatch the change event $changeEvent ->setLocale($formData['locale']) ->setTitle($formData['title']) @@ -163,10 +170,10 @@ class ProductController extends AbstractCrudController ->setDescription($formData['description']) ->setPostscriptum($formData['postscriptum']) ->setVisible($formData['visible']) - ->setUrl($formData['url']) ->setDefaultCategory($formData['default_category']) - ; + ; + // Create and dispatch the change event return $changeEvent; } @@ -307,6 +314,20 @@ class ProductController extends AbstractCrudController $this->getParserContext()->addForm($combinationPseForm); } + // The "SEO" tab form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + '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); + + // The "General" tab form $data = array( 'id' => $object->getId(), @@ -317,7 +338,6 @@ class ProductController extends AbstractCrudController 'description' => $object->getDescription(), 'postscriptum' => $object->getPostscriptum(), 'visible' => $object->getVisible(), - 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'default_category' => $object->getDefaultCategoryId() ); From ee7d62f9d5f82fe7df37ce452a7ec07f5001990b Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 09:50:13 +0100 Subject: [PATCH 09/55] Extend AbstractCrudController to manage the SEO methods --- .../Admin/AbstractCrudController.php | 111 +---------- .../Admin/AbstractSeoCrudController.php | 183 ++++++++++++++++++ .../Controller/Admin/ProductController.php | 2 +- 3 files changed, 187 insertions(+), 109 deletions(-) create mode 100644 core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 6fe387319..19d0b782d 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -23,12 +23,9 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Core\Security\AccessManager; - use Thelia\Form\Exception\FormValidationException; -use Thelia\Form\SeoForm; +use Thelia\Core\Event\UpdatePositionEvent; /** * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. @@ -37,7 +34,7 @@ use Thelia\Form\SeoForm; */ abstract class AbstractCrudController extends BaseAdminController { - protected $objectName; + protected $objectName; // List ordering protected $defaultListOrder; @@ -52,7 +49,6 @@ abstract class AbstractCrudController extends BaseAdminController protected $deleteEventIdentifier; protected $visibilityToggleEventIdentifier; protected $changePositionEventIdentifier; - protected $updateSeoEventIdentifier; /** * @param string $objectName the lower case object name. Example. "message" @@ -68,7 +64,6 @@ abstract class AbstractCrudController extends BaseAdminController * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION - * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO */ public function __construct( $objectName, @@ -82,8 +77,7 @@ abstract class AbstractCrudController extends BaseAdminController $updateEventIdentifier, $deleteEventIdentifier, $visibilityToggleEventIdentifier = null, - $changePositionEventIdentifier = null, - $updateSeoEventIdentifier = null + $changePositionEventIdentifier = null ) { $this->objectName = $objectName; @@ -97,7 +91,6 @@ abstract class AbstractCrudController extends BaseAdminController $this->deleteEventIdentifier = $deleteEventIdentifier; $this->visibilityToggleEventIdentifier = $visibilityToggleEventIdentifier; $this->changePositionEventIdentifier = $changePositionEventIdentifier; - $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; } /** @@ -245,17 +238,6 @@ abstract class AbstractCrudController extends BaseAdminController return null; } - /** - * Put in this method post object update SEO processing if required. - * - * @param unknown $seoUpdateEvent the update event - * @return Response a response, or null to continue normal processing - */ - protected function performAdditionalUpdateSeoAction($updateSeoEvent) - { - return null; - } - /** * Return the current list order identifier, updating it in the same time. */ @@ -441,93 +423,6 @@ abstract class AbstractCrudController extends BaseAdminController return $this->renderEditionTemplate(); } - - /** - * Return the update SEO form for this object - */ - protected function getUpdateSeoForm() - { - return new SeoForm($this->getRequest()); - } - - /** - * Creates the update SEO event with the provided form data - * - * @param $formData - * @return UpdateSeoEvent - */ - protected function getUpdateSeoEvent($formData) - { - - $updateSeoEvent = new UpdateSeoEvent($formData['id']); - - $updateSeoEvent - ->setLocale($formData['locale']) - ->setMetaTitle($formData['meta_title']) - ->setMetaDescription($formData['meta_description']) - ->setMetaKeyword($formData['meta_keyword']) - ; - - // Create and dispatch the change event - return $updateSeoEvent; - } - - /** - * Update SEO modification, and either go back to the object list, or stay on the edition page. - * - * @return Thelia\Core\HttpFoundation\Response the response - */ - - public function processUpdateSeoAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; - - $error_msg = false; - - // Create the form from the request - $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); - - try { - - // Check the form against constraints violations - $form = $this->validateForm($updateSeoForm, "POST"); - - // Get the form field values - $data = $form->getData(); - - $updateSeoEvent = $this->getUpdateSeoEvent($data); - - $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); - - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); - } - - - $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); - - if ($response == null) { - // If we have to stay on the same page, do not redirect to the successUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToEditionTemplate($this->getRequest()); - } - - // Redirect to the success URL - $this->redirect($updateSeoForm->getSuccessUrl()); - } else { - return $response; - } - - // At this point, the form has errors, and should be redisplayed. - return $this->renderEditionTemplate(); - } - /** * Update object position (only for objects whichsupport that) * diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php new file mode 100644 index 000000000..744c4af17 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -0,0 +1,183 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Security\AccessManager; + +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\SeoForm; + +/** + * Extend abstract CRUD controller to manage basic CRUD + SEO operations on a given object. + * + * @author Christophe Laffont + */ +abstract class AbstractSeoCrudController extends AbstractCrudController +{ + // Events + protected $updateSeoEventIdentifier; + + /** + * @param string $objectName the lower case object name. Example. "message" + * + * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) + * + * @param string $resourceCode the 'resource' code. Example: "admin.configuration.message" + * + * @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE + * @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE + * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE + * + * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY + * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO + */ + public function __construct( + $objectName, + + $defaultListOrder = null, + $orderRequestParameterName = null, + + $resourceCode, + + $createEventIdentifier, + $updateEventIdentifier, + $deleteEventIdentifier, + $visibilityToggleEventIdentifier = null, + $changePositionEventIdentifier = null, + $updateSeoEventIdentifier = null + ) + { + parent::__construct( + $objectName, + $defaultListOrder, + $orderRequestParameterName, + $resourceCode, + $createEventIdentifier, + $updateEventIdentifier, + $deleteEventIdentifier, + $visibilityToggleEventIdentifier, + $changePositionEventIdentifier + ); + + $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; + + } + + /** + * Put in this method post object update SEO processing if required. + * + * @param unknown $updateSeoEvent the update event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdateSeoAction($updateSeoEvent) + { + return null; + } + + /** + * Return the update SEO form for this object + */ + protected function getUpdateSeoForm() + { + return new SeoForm($this->getRequest()); + } + + /** + * Creates the update SEO event with the provided form data + * + * @param $formData + * @return UpdateSeoEvent + */ + protected function getUpdateSeoEvent($formData) + { + + $updateSeoEvent = new UpdateSeoEvent($formData['id']); + + $updateSeoEvent + ->setLocale($formData['locale']) + ->setMetaTitle($formData['meta_title']) + ->setMetaDescription($formData['meta_description']) + ->setMetaKeyword($formData['meta_keyword']) + ; + + // Create and dispatch the change event + return $updateSeoEvent; + } + + /** + * Update SEO modification, and either go back to the object list, or stay on the edition page. + * + * @return Thelia\Core\HttpFoundation\Response the response + */ + public function processUpdateSeoAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; + + // Create the form from the request + $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); + + try { + + // Check the form against constraints violations + $form = $this->validateForm($updateSeoForm, "POST"); + + // Get the form field values + $data = $form->getData(); + + $updateSeoEvent = $this->getUpdateSeoEvent($data); + + $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); + + } catch (FormValidationException $ex) { + // Form cannot be validated + return $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + + $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); + + if ($response == null) { + // If we have to stay on the same page, do not redirect to the successUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($updateSeoForm->getSuccessUrl()); + } else { + return $response; + } + + // At this point, the form has errors, and should be redisplayed. + return $this->renderEditionTemplate(); + } +} diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 109e95a68..abc233684 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -79,7 +79,7 @@ use Thelia\Tools\NumberFormat; * * @author Franck Allimant */ -class ProductController extends AbstractCrudController +class ProductController extends AbstractSeoCrudController { public function __construct() { From a375d942ec39809f6b5a92da50d4540f7084cf82 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 09:51:10 +0100 Subject: [PATCH 10/55] Missing hidden field product_id for the redirection when the user click "Save" --- templates/backOffice/default/includes/seo-tab.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/backOffice/default/includes/seo-tab.html b/templates/backOffice/default/includes/seo-tab.html index 9ae515885..5db7d3b06 100644 --- a/templates/backOffice/default/includes/seo-tab.html +++ b/templates/backOffice/default/includes/seo-tab.html @@ -11,6 +11,7 @@ } {* Hidden field *} + {form_hidden_fields form=$form} From 0d5cfd29e058f4ded9b448c7be78977919baf4be Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:00:07 +0100 Subject: [PATCH 11/55] Add new fields (meta_title, meta_description and meta_keyword) under I18N Product --- local/config/schema.xml | 2538 +++++++++++++++++++-------------------- 1 file changed, 1267 insertions(+), 1271 deletions(-) diff --git a/local/config/schema.xml b/local/config/schema.xml index 785483704..2a22eaa8e 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1271 +1,1267 @@ - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - -
    - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    +
    From 945921048e50f35978be49ede074f1f0073446e2 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:03:32 +0100 Subject: [PATCH 12/55] Add new SEO form --- core/lib/Thelia/Config/Resources/form.xml | 2 +- core/lib/Thelia/Form/SeoFieldsTrait.php | 89 +++++++++++++++++++++++ core/lib/Thelia/Form/SeoForm.php | 81 +++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Form/SeoFieldsTrait.php create mode 100644 core/lib/Thelia/Form/SeoForm.php diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml index cf9ccd489..ec281266e 100644 --- a/core/lib/Thelia/Config/Resources/form.xml +++ b/core/lib/Thelia/Config/Resources/form.xml @@ -17,6 +17,7 @@
    + @@ -39,7 +40,6 @@ - diff --git a/core/lib/Thelia/Form/SeoFieldsTrait.php b/core/lib/Thelia/Form/SeoFieldsTrait.php new file mode 100644 index 000000000..dd66324d8 --- /dev/null +++ b/core/lib/Thelia/Form/SeoFieldsTrait.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +/** + * A trait to add standard localized description fields to a form. + * + * @author Christophe Laffont + */ +trait SeoFieldsTrait +{ + /** + * Add seo meta title, meta description and meta keywords fields + * + * @param array $exclude name of the fields that should not be added to the form + */ + protected function addSeoFields($exclude = array()) + { + + if (! in_array('url', $exclude)) + $this->formBuilder + ->add('url', 'text', array( + 'label' => Translator::getInstance()->trans('Rewriten URL'), + 'label_attr' => array( + 'for' => 'rewriten_url_field' + ), + 'required' => false + ) + ); + + if (! in_array('meta_title', $exclude)) + $this->formBuilder + ->add('meta_title', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Page Title'), + 'label_attr' => array( + 'for' => 'meta_title' + ) + ) + ); + + if (! in_array('meta_description', $exclude)) + $this->formBuilder + ->add('meta_description', 'text', array( + 'label' => Translator::getInstance()->trans('Meta Description'), + 'label_attr' => array( + 'for' => 'meta_description' + ), + 'required' => false + ) + ); + + if (! in_array('meta_keyword', $exclude)) + $this->formBuilder + ->add('meta_keyword', 'text', array( + 'label' => Translator::getInstance()->trans('Meta Keyword'), + 'label_attr' => array( + 'for' => 'meta_keyword' + ), + 'required' => false + ) + ); + } +} diff --git a/core/lib/Thelia/Form/SeoForm.php b/core/lib/Thelia/Form/SeoForm.php new file mode 100644 index 000000000..28c90c9ba --- /dev/null +++ b/core/lib/Thelia/Form/SeoForm.php @@ -0,0 +1,81 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; + +/** + * Class SeoForm + * @package Thelia\Form + * @author Christophe Laffont + */ +class SeoForm extends BaseForm +{ + use SeoFieldsTrait; + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + + $this->formBuilder + ->add("id", "hidden", array( + "constraints" => array( + new GreaterThan(array('value' => 0)) + ) + )) + ->add("locale", "hidden", array( + "constraints" => array( + new NotBlank() + ) + )) + ; + + // Add SEO Fields + $this->addSeoFields(); + } + + public function getName() + { + return "thelia_seo"; + } +} From ba48bc985ea10fb97d362e13d40fb4bfe5c93d9d Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:05:03 +0100 Subject: [PATCH 13/55] Add SEO tab for a product --- .../backOffice/default/includes/seo-tab.html | 79 +++++++++++++++++++ .../backOffice/default/product-edit.html | 17 +++- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 templates/backOffice/default/includes/seo-tab.html diff --git a/templates/backOffice/default/includes/seo-tab.html b/templates/backOffice/default/includes/seo-tab.html new file mode 100644 index 000000000..9ae515885 --- /dev/null +++ b/templates/backOffice/default/includes/seo-tab.html @@ -0,0 +1,79 @@ +
    + + + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + + page_url = {$pageUrl} + close_url = {$closeUrl} + } + + {* Hidden field *} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='url'} +
    + +
    + {$url_language|default:{config key="url_site"}} + +
    +
    + {/form_field} + + + {form_field form=$form field='meta_title'} +
    + +
    + +
    +
    + {/form_field} + + {form_field form=$form field='meta_description'} +
    + + + +
    + {/form_field} + + {form_field form=$form field='meta_keyword'} +
    + + + +
    + {/form_field} + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + hide_flags = true + + page_url = {$pageUrl} + close_url = {$closeUrl} + } + + +
    \ No newline at end of file diff --git a/templates/backOffice/default/product-edit.html b/templates/backOffice/default/product-edit.html index 36af15aa0..9773df9dc 100755 --- a/templates/backOffice/default/product-edit.html +++ b/templates/backOffice/default/product-edit.html @@ -48,6 +48,8 @@ data-toggle="tab">{intl l="General"} +
  • {intl l="SEO"}
  • +
  • {intl l="Details"}
  • @@ -79,7 +81,7 @@ {intl l="Documents"}
  • {intl l="Modules"}
  • - +
    @@ -87,6 +89,18 @@ {include file="includes/product-general-tab.html"}
    +
    + {form name="thelia.admin.seo"} + {include file="includes/seo-tab.html" + form = $form + currentId = "{$ID}" + formAction = "{url path='/admin/products/seo/save'}" + pageUrl = "{url path='/admin/products/update' product_id=$ID}" + closeUrl = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + {/form} +
    +
    {include file="includes/product-details-tab.html"}
    @@ -110,6 +124,7 @@
    {module_include location='product-edit'}
    +
    From 9d885524925a42a0525e0fc30c72e13724f683d2 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:06:19 +0100 Subject: [PATCH 14/55] Add action buttons at the bottom of the product General tab --- .../default/includes/product-general-tab.html | 80 ++++++++----------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/templates/backOffice/default/includes/product-general-tab.html b/templates/backOffice/default/includes/product-general-tab.html index f91aeff9e..9cc34c815 100755 --- a/templates/backOffice/default/includes/product-general-tab.html +++ b/templates/backOffice/default/includes/product-general-tab.html @@ -11,54 +11,45 @@ close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" } - {* Be sure to get the product ID, even if the form could not be validated *} - - - + {* Be sure to get the product ID, even if the form could not be validated*} + + {form_hidden_fields form=$form} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='success_url'} - + {/form_field} {form_field form=$form field='locale'} - + {/form_field} {if $form_error}
    {$form_error_message}
    {/if} -
    - - -
    {$REF}
    - - {form_field form=$form field='ref'} - - {/form_field} - -
    - - {include file="includes/standard-description-form-fields.html"} - - {form_field form=$form field='url'} -
    - - - -
    - {/form_field} -
    -
    +
    + {form_field form=$form field='ref'} +
    + +
    + {* If ref's 'value is not empty the field is disable and the value is sent with an hidden field *} + + {if $value}{/if} +
    +
    + {/form_field} + + {include file="includes/standard-description-form-fields.html"} +
    + +
    {form_field form=$form field='default_category'}
    @@ -79,9 +70,6 @@
    {/form_field} -
    - -
    {form_field form=$form field='visible'}
    @@ -96,16 +84,16 @@
    -
    -
    -
    - -
    -

    {intl l='Product created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    -
    -
    -
    -
    + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + hide_flags = true + + page_url = "{url path='/admin/products/update' product_id=$ID}" + close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + + {intl l='Product created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"} {/form} From 9bbaaf75a406192fd2f992e68c72fb4fce6eeedd Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:07:03 +0100 Subject: [PATCH 15/55] Add new route to save the product SEO information --- core/lib/Thelia/Config/Resources/routing/admin.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 591e5c0e7..b821e775c 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -263,6 +263,10 @@ Thelia\Controller\Admin\ProductController::processUpdateAction + + Thelia\Controller\Admin\ProductController::processUpdateSeoAction + + Thelia\Controller\Admin\ProductController::setToggleVisibilityAction From 6447385605ca2ee180663286a5cecd3753eceaf4 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:10:10 +0100 Subject: [PATCH 16/55] Add Action + Event to manage SEO information --- core/lib/Thelia/Action/BaseAction.php | 36 ++++- core/lib/Thelia/Action/Product.php | 49 +++---- .../Admin/AbstractCrudController.php | 115 +++++++++++++++- core/lib/Thelia/Core/Event/TheliaEvents.php | 3 + core/lib/Thelia/Core/Event/UpdateSeoEvent.php | 130 ++++++++++++++++++ 5 files changed, 304 insertions(+), 29 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/UpdateSeoEvent.php diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index e1edab07d..e207a624e 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -23,9 +23,12 @@ namespace Thelia\Action; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Model\AdminLog; use Propel\Runtime\ActiveQuery\ModelCriteria; + use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; + +use \Thelia\Model\Tools\UrlRewritingTrait; class BaseAction { @@ -73,4 +76,35 @@ class BaseAction return $object->movePositionDown(); } } + + /** + * Changes SEO Fields for an object. + * + * @param ModelCriteria $query + * @param UpdateSeoEvent $event + * + * @return mixed + */ + protected function genericUpdateSeo(ModelCriteria $query, UpdateSeoEvent $event) + { + if (null !== $object = $query->findPk($event->getObjectId())) { + + $object + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setMetaTitle($event->getMetaTitle()) + ->setMetaDescription($event->getMetaDescription()) + ->setMetaKeyword($event->getMetaKeyword()) + + ->save() + ; + + // Update the rewriten URL, if required + $object->setRewrittenUrl($event->getLocale(), $event->getUrl()); + + return $object; + } + } + } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index ff32921b6..2ec14518b 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -25,38 +25,37 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Exception\UrlRewritingException; -use Thelia\Form\Exception\FormValidationException; +use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductQuery; use Thelia\Model\Product as ProductModel; - -use Thelia\Core\Event\TheliaEvents; - -use Thelia\Core\Event\Product\ProductUpdateEvent; -use Thelia\Core\Event\Product\ProductCreateEvent; -use Thelia\Core\Event\Product\ProductDeleteEvent; -use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; -use Thelia\Core\Event\Product\ProductAddContentEvent; -use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Model\ProductAssociatedContent; use Thelia\Model\ProductAssociatedContentQuery; use Thelia\Model\ProductCategory; use Thelia\Model\TaxRuleQuery; use Thelia\Model\AccessoryQuery; use Thelia\Model\Accessory; -use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; use Thelia\Model\FeatureProduct; -use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; use Thelia\Model\FeatureProductQuery; use Thelia\Model\ProductCategoryQuery; -use Thelia\Core\Event\Product\ProductSetTemplateEvent; use Thelia\Model\ProductSaleElementsQuery; + +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\Product\ProductUpdateEvent; +use Thelia\Core\Event\Product\ProductCreateEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; +use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; +use Thelia\Core\Event\Product\ProductAddContentEvent; +use Thelia\Core\Event\Product\ProductDeleteContentEvent; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; +use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; +use Thelia\Core\Event\Product\ProductSetTemplateEvent; use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; use Thelia\Core\Event\Product\ProductAddCategoryEvent; use Thelia\Core\Event\Product\ProductAddAccessoryEvent; use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; -use Thelia\Model\Map\ProductTableMap; + use Propel\Runtime\Propel; class Product extends BaseAction implements EventSubscriberInterface @@ -115,13 +114,6 @@ class Product extends BaseAction implements EventSubscriberInterface ->save() ; - // Update the rewritten URL, if required - try { - $product->setRewrittenUrl($event->getLocale(), $event->getUrl()); - } catch(UrlRewritingException $e) { - throw new FormValidationException($e->getMessage(), $e->getCode()); - } - // Update default category (ifd required) $product->updateDefaultCategory($event->getDefaultCategory()); @@ -129,6 +121,17 @@ class Product extends BaseAction implements EventSubscriberInterface } } + /** + * Change a product SEO + * + * @param \Thelia\Core\Event\UpdateSeoEvent $event + */ + public function updateSeo(UpdateSeoEvent $event) + { + return $this->genericUpdateSeo(ProductQuery::create(), $event); + } + + /** * Delete a product entry * diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index dd6d19bcd..fdf0f6288 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -23,9 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\AccessManager; -use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Security\AccessManager; + +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\SeoForm; /** * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. @@ -49,6 +52,7 @@ abstract class AbstractCrudController extends BaseAdminController protected $deleteEventIdentifier; protected $visibilityToggleEventIdentifier; protected $changePositionEventIdentifier; + protected $updateSeoEventIdentifier; /** * @param string $objectName the lower case object name. Example. "message" @@ -64,6 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO */ public function __construct( $objectName, @@ -77,7 +82,8 @@ abstract class AbstractCrudController extends BaseAdminController $updateEventIdentifier, $deleteEventIdentifier, $visibilityToggleEventIdentifier = null, - $changePositionEventIdentifier = null + $changePositionEventIdentifier = null, + $updateSeoEventIdentifier = null ) { $this->objectName = $objectName; @@ -91,6 +97,7 @@ abstract class AbstractCrudController extends BaseAdminController $this->deleteEventIdentifier = $deleteEventIdentifier; $this->visibilityToggleEventIdentifier = $visibilityToggleEventIdentifier; $this->changePositionEventIdentifier = $changePositionEventIdentifier; + $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; } /** @@ -139,7 +146,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Get the created object from an event. * - * @param unknown $createEvent + * @param unknown $event */ abstract protected function getObjectFromEvent($event); @@ -230,7 +237,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object position change processing if required. * - * @param unknown $deleteEvent the delete event + * @param unknown $positionChangeEvent the delete event * @return Response a response, or null to continue normal processing */ protected function performAdditionalUpdatePositionAction($positionChangeEvent) @@ -238,6 +245,17 @@ abstract class AbstractCrudController extends BaseAdminController return null; } + /** + * Put in this method post object update SEO processing if required. + * + * @param unknown $seoUpdateEvent the update event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdateSeoAction($updateSeoEvent) + { + return null; + } + /** * Return the current list order identifier, updating it in the same time. */ @@ -423,6 +441,93 @@ abstract class AbstractCrudController extends BaseAdminController return $this->renderEditionTemplate(); } + + /** + * Return the update SEO form for this object + */ + protected function getUpdateSeoForm() + { + return new SeoForm($this->getRequest()); + } + + /** + * Creates the update SEO event with the provided form data + * + * @param $formData + * @return UpdateSeoEvent + */ + protected function getUpdateSeoEvent($formData) + { + + $updateSeoEvent = new UpdateSeoEvent($formData['id']); + + $updateSeoEvent + ->setLocale($formData['locale']) + ->setMetaTitle($formData['meta_title']) + ->setMetaDescription($formData['meta_description']) + ->setMetaKeyword($formData['meta_keyword']) + ; + + // Create and dispatch the change event + return $updateSeoEvent; + } + + /** + * Update SEO modification, and either go back to the object list, or stay on the edition page. + * + * @return Thelia\Core\HttpFoundation\Response the response + */ + + public function processUpdateSeoAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; + + $error_msg = false; + + // Create the form from the request + $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); + + try { + + // Check the form against constraints violations + $form = $this->validateForm($updateSeoForm, "POST"); + + // Get the form field values + $data = $form->getData(); + + $updateSeoEvent = $this->getUpdateSeoEvent($data); + + $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); + + } catch (FormValidationException $ex) { + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + + $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); + + if ($response == null) { + // If we have to stay on the same page, do not redirect to the successUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($updateSeoForm->getSuccessUrl()); + } else { + return $response; + } + + // At this point, the form has errors, and should be redisplayed. + return $this->renderEditionTemplate(); + } + /** * Update object position (only for objects whichsupport that) * diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 15a049512..7e22dc938 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -160,6 +160,7 @@ final class TheliaEvents const CATEGORY_DELETE = "action.deleteCategory"; const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_UPDATE_SEO = "action.updateCategorySeo"; const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; @@ -197,6 +198,7 @@ final class TheliaEvents const CONTENT_DELETE = "action.deleteContent"; const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility"; const CONTENT_UPDATE_POSITION = "action.updateContentPosition"; + const CONTENT_UPDATE_SEO = "action.updateContentSeo"; const CONTENT_ADD_FOLDER = "action.contentAddFolder"; const CONTENT_REMOVE_FOLDER = "action.contentRemoveFolder"; @@ -269,6 +271,7 @@ final class TheliaEvents const PRODUCT_DELETE = "action.deleteProduct"; const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility"; const PRODUCT_UPDATE_POSITION = "action.updateProductPosition"; + const PRODUCT_UPDATE_SEO = "action.updateProductSeo"; const PRODUCT_ADD_CONTENT = "action.productAddContent"; const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; diff --git a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php new file mode 100644 index 000000000..99b19efe8 --- /dev/null +++ b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php @@ -0,0 +1,130 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class UpdateSeoEvent extends ActionEvent +{ + protected $object_id; + protected $locale; + protected $url; + protected $meta_title; + protected $meta_description; + protected $meta_keyword; + + protected $object; + + public function __construct($object_id, $locale = null, $url = null, $meta_title = null, $meta_description = null, $meta_keyword = null) + { + $this->object_id = $object_id; + $this->locale = $locale; + $this->url = $url; + $this->meta_title = $meta_title; + $this->meta_description = $meta_description; + $this->meta_keyword = $meta_keyword; + } + + public function getObjectId() + { + return $this->object_id; + } + + public function setObjectId($object_id) + { + $this->object_id = $object_id; + + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getUrl() + { + return $this->url; + } + + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } + + public function getMetaTitle() + { + return $this->meta_title; + } + + public function setMetaTitle($meta_title) + { + $this->meta_title = $meta_title; + + return $this; + } + + public function getMetaDescription() + { + return $this->meta_description; + } + + public function setMetaDescription($meta_description) + { + $this->meta_description = $meta_description; + + return $this; + } + + public function getMetaKeyword() + { + return $this->meta_keyword; + } + + public function setMetaKeyword($meta_keyword) + { + $this->meta_keyword = $meta_keyword; + + return $this; + } +} From 083f3bfa8c9724f09b9cc7b76d419206007d519c Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:11:45 +0100 Subject: [PATCH 17/55] Move URL to SeoForm (SEO tab) --- .../Core/Event/Product/ProductUpdateEvent.php | 13 ------------- core/lib/Thelia/Form/ProductModificationForm.php | 9 +-------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php index 535f04462..7d0f9469c 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php @@ -33,7 +33,6 @@ class ProductUpdateEvent extends ProductCreateEvent protected $description; protected $postscriptum; - protected $url; protected $parent; public function __construct($product_id) @@ -89,18 +88,6 @@ class ProductUpdateEvent extends ProductCreateEvent return $this; } - public function getUrl() - { - return $this->url; - } - - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php index 15a629302..9dce2e4e5 100644 --- a/core/lib/Thelia/Form/ProductModificationForm.php +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -24,7 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; -use Symfony\Component\Validator\Constraints\NotBlank; + class ProductModificationForm extends ProductCreationForm { @@ -39,17 +39,10 @@ class ProductModificationForm extends ProductCreationForm "label" => Translator::getInstance()->trans("Prodcut ID *"), "label_attr" => array("for" => "product_id_field"), "constraints" => array(new GreaterThan(array('value' => 0))) - )) ->add("template_id", "integer", array( "label" => Translator::getInstance()->trans("Product template"), "label_attr" => array("for" => "product_template_field") - - )) - ->add("url", "text", array( - "label" => Translator::getInstance()->trans("Rewritten URL *"), - "constraints" => array(new NotBlank()), - "label_attr" => array("for" => "rewriten_url_field") )) ; From 5980ff44fc39b47de130b1bb38c07ac4d8bdbff4 Mon Sep 17 00:00:00 2001 From: touffies Date: Thu, 28 Nov 2013 12:12:24 +0100 Subject: [PATCH 18/55] Hydrate SeoForm under SEO Tab --- .../Controller/Admin/ProductController.php | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index eca9849e3..a4f310e5e 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -23,50 +23,56 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\Resource\AdminResources; -use Thelia\Core\Event\Product\ProductAddCategoryEvent; -use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; -use Thelia\Core\Event\Product\ProductDeleteEvent; +use Symfony\Component\HttpFoundation\JsonResponse; +use Propel\Runtime\ActiveQuery\Criteria; + use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Product\ProductUpdateEvent; use Thelia\Core\Event\Product\ProductCreateEvent; -use Thelia\Core\Security\AccessManager; -use Thelia\Model\ProductQuery; -use Thelia\Form\ProductModificationForm; -use Thelia\Form\ProductCreationForm; -use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\Product\ProductAddCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Core\Event\Product\ProductAddContentEvent; -use Thelia\Model\FolderQuery; -use Thelia\Model\ContentQuery; -use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Model\ProductAssociatedContentQuery; -use Thelia\Model\AccessoryQuery; -use Thelia\Model\CategoryQuery; - use Thelia\Core\Event\Product\ProductAddAccessoryEvent; use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; -use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Core\Event\Product\ProductCombinationGenerationEvent; +use Thelia\Core\Event\Product\ProductSetTemplateEvent; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementDeleteEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent; use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent; + +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\AccessManager; + +use Thelia\Model\AccessoryQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; use Thelia\Model\AttributeQuery; use Thelia\Model\AttributeAvQuery; -use Thelia\Form\ProductSaleElementUpdateForm; +use Thelia\Model\ProductQuery; +use Thelia\Model\ProductAssociatedContentQuery; +use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; -use Thelia\Form\ProductDefaultSaleElementUpdateForm; use Thelia\Model\ProductPrice; use Thelia\Model\Currency; -use Symfony\Component\HttpFoundation\JsonResponse; -use Thelia\TaxEngine\Calculator; -use Thelia\Model\Country; -use Thelia\Tools\NumberFormat; -use Thelia\Model\Product; use Thelia\Model\CurrencyQuery; +use Thelia\Model\Country; +use Thelia\Model\Product; + +use Thelia\Form\ProductCreationForm; +use Thelia\Form\ProductModificationForm; +use Thelia\Form\ProductSaleElementUpdateForm; +use Thelia\Form\ProductDefaultSaleElementUpdateForm; use Thelia\Form\ProductCombinationGenerationForm; -use Thelia\Core\Event\Product\ProductCombinationGenerationEvent; -use Thelia\Core\Event\Product\ProductSetTemplateEvent; +use Thelia\Form\SeoForm; + +use Thelia\TaxEngine\Calculator; +use Thelia\Tools\NumberFormat; + /** * Manages products @@ -89,7 +95,8 @@ class ProductController extends AbstractCrudController TheliaEvents::PRODUCT_DELETE, TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, - TheliaEvents::PRODUCT_UPDATE_POSITION + TheliaEvents::PRODUCT_UPDATE_POSITION, + TheliaEvents::PRODUCT_UPDATE_SEO ); } @@ -153,9 +160,9 @@ class ProductController extends AbstractCrudController protected function getUpdateEvent($formData) { + $changeEvent = new ProductUpdateEvent($formData['id']); - // Create and dispatch the change event $changeEvent ->setLocale($formData['locale']) ->setTitle($formData['title']) @@ -163,10 +170,10 @@ class ProductController extends AbstractCrudController ->setDescription($formData['description']) ->setPostscriptum($formData['postscriptum']) ->setVisible($formData['visible']) - ->setUrl($formData['url']) ->setDefaultCategory($formData['default_category']) - ; + ; + // Create and dispatch the change event return $changeEvent; } @@ -307,6 +314,20 @@ class ProductController extends AbstractCrudController $this->getParserContext()->addForm($combinationPseForm); } + // The "SEO" tab form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + '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); + + // The "General" tab form $data = array( 'id' => $object->getId(), @@ -317,7 +338,6 @@ class ProductController extends AbstractCrudController 'description' => $object->getDescription(), 'postscriptum' => $object->getPostscriptum(), 'visible' => $object->getVisible(), - 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'default_category' => $object->getDefaultCategoryId() ); From c1140ec2798caf272036daabce1865d93b049640 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 09:50:13 +0100 Subject: [PATCH 19/55] Extend AbstractCrudController to manage the SEO methods --- .../Admin/AbstractCrudController.php | 111 +---------- .../Admin/AbstractSeoCrudController.php | 183 ++++++++++++++++++ .../Controller/Admin/ProductController.php | 2 +- 3 files changed, 187 insertions(+), 109 deletions(-) create mode 100644 core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index fdf0f6288..25edcafaa 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -23,12 +23,9 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Core\Security\AccessManager; - use Thelia\Form\Exception\FormValidationException; -use Thelia\Form\SeoForm; +use Thelia\Core\Event\UpdatePositionEvent; /** * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. @@ -37,7 +34,7 @@ use Thelia\Form\SeoForm; */ abstract class AbstractCrudController extends BaseAdminController { - protected $objectName; + protected $objectName; // List ordering protected $defaultListOrder; @@ -52,7 +49,6 @@ abstract class AbstractCrudController extends BaseAdminController protected $deleteEventIdentifier; protected $visibilityToggleEventIdentifier; protected $changePositionEventIdentifier; - protected $updateSeoEventIdentifier; /** * @param string $objectName the lower case object name. Example. "message" @@ -68,7 +64,6 @@ abstract class AbstractCrudController extends BaseAdminController * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION - * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO */ public function __construct( $objectName, @@ -82,8 +77,7 @@ abstract class AbstractCrudController extends BaseAdminController $updateEventIdentifier, $deleteEventIdentifier, $visibilityToggleEventIdentifier = null, - $changePositionEventIdentifier = null, - $updateSeoEventIdentifier = null + $changePositionEventIdentifier = null ) { $this->objectName = $objectName; @@ -97,7 +91,6 @@ abstract class AbstractCrudController extends BaseAdminController $this->deleteEventIdentifier = $deleteEventIdentifier; $this->visibilityToggleEventIdentifier = $visibilityToggleEventIdentifier; $this->changePositionEventIdentifier = $changePositionEventIdentifier; - $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; } /** @@ -245,17 +238,6 @@ abstract class AbstractCrudController extends BaseAdminController return null; } - /** - * Put in this method post object update SEO processing if required. - * - * @param unknown $seoUpdateEvent the update event - * @return Response a response, or null to continue normal processing - */ - protected function performAdditionalUpdateSeoAction($updateSeoEvent) - { - return null; - } - /** * Return the current list order identifier, updating it in the same time. */ @@ -441,93 +423,6 @@ abstract class AbstractCrudController extends BaseAdminController return $this->renderEditionTemplate(); } - - /** - * Return the update SEO form for this object - */ - protected function getUpdateSeoForm() - { - return new SeoForm($this->getRequest()); - } - - /** - * Creates the update SEO event with the provided form data - * - * @param $formData - * @return UpdateSeoEvent - */ - protected function getUpdateSeoEvent($formData) - { - - $updateSeoEvent = new UpdateSeoEvent($formData['id']); - - $updateSeoEvent - ->setLocale($formData['locale']) - ->setMetaTitle($formData['meta_title']) - ->setMetaDescription($formData['meta_description']) - ->setMetaKeyword($formData['meta_keyword']) - ; - - // Create and dispatch the change event - return $updateSeoEvent; - } - - /** - * Update SEO modification, and either go back to the object list, or stay on the edition page. - * - * @return Thelia\Core\HttpFoundation\Response the response - */ - - public function processUpdateSeoAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; - - $error_msg = false; - - // Create the form from the request - $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); - - try { - - // Check the form against constraints violations - $form = $this->validateForm($updateSeoForm, "POST"); - - // Get the form field values - $data = $form->getData(); - - $updateSeoEvent = $this->getUpdateSeoEvent($data); - - $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); - - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); - } - - - $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); - - if ($response == null) { - // If we have to stay on the same page, do not redirect to the successUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToEditionTemplate($this->getRequest()); - } - - // Redirect to the success URL - $this->redirect($updateSeoForm->getSuccessUrl()); - } else { - return $response; - } - - // At this point, the form has errors, and should be redisplayed. - return $this->renderEditionTemplate(); - } - /** * Update object position (only for objects whichsupport that) * diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php new file mode 100644 index 000000000..744c4af17 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -0,0 +1,183 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\UpdateSeoEvent; +use Thelia\Core\Security\AccessManager; + +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\SeoForm; + +/** + * Extend abstract CRUD controller to manage basic CRUD + SEO operations on a given object. + * + * @author Christophe Laffont + */ +abstract class AbstractSeoCrudController extends AbstractCrudController +{ + // Events + protected $updateSeoEventIdentifier; + + /** + * @param string $objectName the lower case object name. Example. "message" + * + * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) + * + * @param string $resourceCode the 'resource' code. Example: "admin.configuration.message" + * + * @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE + * @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE + * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE + * + * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY + * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO + */ + public function __construct( + $objectName, + + $defaultListOrder = null, + $orderRequestParameterName = null, + + $resourceCode, + + $createEventIdentifier, + $updateEventIdentifier, + $deleteEventIdentifier, + $visibilityToggleEventIdentifier = null, + $changePositionEventIdentifier = null, + $updateSeoEventIdentifier = null + ) + { + parent::__construct( + $objectName, + $defaultListOrder, + $orderRequestParameterName, + $resourceCode, + $createEventIdentifier, + $updateEventIdentifier, + $deleteEventIdentifier, + $visibilityToggleEventIdentifier, + $changePositionEventIdentifier + ); + + $this->updateSeoEventIdentifier = $updateSeoEventIdentifier; + + } + + /** + * Put in this method post object update SEO processing if required. + * + * @param unknown $updateSeoEvent the update event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdateSeoAction($updateSeoEvent) + { + return null; + } + + /** + * Return the update SEO form for this object + */ + protected function getUpdateSeoForm() + { + return new SeoForm($this->getRequest()); + } + + /** + * Creates the update SEO event with the provided form data + * + * @param $formData + * @return UpdateSeoEvent + */ + protected function getUpdateSeoEvent($formData) + { + + $updateSeoEvent = new UpdateSeoEvent($formData['id']); + + $updateSeoEvent + ->setLocale($formData['locale']) + ->setMetaTitle($formData['meta_title']) + ->setMetaDescription($formData['meta_description']) + ->setMetaKeyword($formData['meta_keyword']) + ; + + // Create and dispatch the change event + return $updateSeoEvent; + } + + /** + * Update SEO modification, and either go back to the object list, or stay on the edition page. + * + * @return Thelia\Core\HttpFoundation\Response the response + */ + public function processUpdateSeoAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; + + // Create the form from the request + $updateSeoForm = $this->getUpdateSeoForm($this->getRequest()); + + try { + + // Check the form against constraints violations + $form = $this->validateForm($updateSeoForm, "POST"); + + // Get the form field values + $data = $form->getData(); + + $updateSeoEvent = $this->getUpdateSeoEvent($data); + + $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent); + + } catch (FormValidationException $ex) { + // Form cannot be validated + return $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + + $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent); + + if ($response == null) { + // If we have to stay on the same page, do not redirect to the successUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($updateSeoForm->getSuccessUrl()); + } else { + return $response; + } + + // At this point, the form has errors, and should be redisplayed. + return $this->renderEditionTemplate(); + } +} diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index a4f310e5e..68d3d7b2d 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -79,7 +79,7 @@ use Thelia\Tools\NumberFormat; * * @author Franck Allimant */ -class ProductController extends AbstractCrudController +class ProductController extends AbstractSeoCrudController { public function __construct() { From 2d9e2df5a422fc2edb47f485f352a26c79140dbc Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 09:51:10 +0100 Subject: [PATCH 20/55] Missing hidden field product_id for the redirection when the user click "Save" --- templates/backOffice/default/includes/seo-tab.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/backOffice/default/includes/seo-tab.html b/templates/backOffice/default/includes/seo-tab.html index 9ae515885..5db7d3b06 100644 --- a/templates/backOffice/default/includes/seo-tab.html +++ b/templates/backOffice/default/includes/seo-tab.html @@ -11,6 +11,7 @@ } {* Hidden field *} + {form_hidden_fields form=$form} From 3d48eab76c8dd6994e9c59dcff8837a0a1d10547 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 14:28:19 +0100 Subject: [PATCH 21/55] Remove unused variable $current_id --- templates/backOffice/default/product-edit.html | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/backOffice/default/product-edit.html b/templates/backOffice/default/product-edit.html index 9773df9dc..97f06a537 100755 --- a/templates/backOffice/default/product-edit.html +++ b/templates/backOffice/default/product-edit.html @@ -93,7 +93,6 @@ {form name="thelia.admin.seo"} {include file="includes/seo-tab.html" form = $form - currentId = "{$ID}" formAction = "{url path='/admin/products/seo/save'}" pageUrl = "{url path='/admin/products/update' product_id=$ID}" closeUrl = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" From 71302493c166c80a855ceefebb1fdb1ca2ab2f58 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 14:29:12 +0100 Subject: [PATCH 22/55] Add a new method to get the site URL based on the language --- .../Controller/Admin/BaseAdminController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 849438539..65d2e07fb 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -302,6 +302,23 @@ class BaseAdminController extends BaseController return $this->getCurrentEditionLang()->getLocale(); } + /** + * A simple helper to get the URL based on the language. + */ + protected function getUrlLanguage($locale = null) + { + // Check if the functionality is activated + if(!ConfigQuery::read("one_domain_foreach_lang", false)) + return; + + // If we don't have a locale value, use the locale value in the session + if(!$locale) + $locale = $this->getCurrentEditionLocale(); + + return LangQuery::create()->findOneByLocale($locale)->getUrl(); + } + + /** * Return the current list order identifier for a given object name, * updating in using the current request. From d6f39787d0b92afe101edcca3a246a83bc5c6dae Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 29 Nov 2013 14:30:40 +0100 Subject: [PATCH 23/55] Add to the context the site URL based on the language (Used in the SEO tab) --- core/lib/Thelia/Controller/Admin/ProductController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 68d3d7b2d..18fd5abad 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -315,9 +315,10 @@ class ProductController extends AbstractSeoCrudController } // The "SEO" tab form + $locale = $object->getLocale(); $data = array( 'id' => $object->getId(), - 'locale' => $object->getLocale(), + 'locale' => $locale, 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'meta_title' => $object->getMetaTitle(), 'meta_description' => $object->getMetaDescription(), @@ -327,6 +328,9 @@ class ProductController extends AbstractSeoCrudController $seoForm = new SeoForm($this->getRequest(), "form", $data); $this->getParserContext()->addForm($seoForm); + // URL based on the language + $this->getParserContext()->set('url_language', $this->getUrlLanguage($locale)); + // The "General" tab form $data = array( From 0d8e9437b11383b09b8c06989a29825b80b3024f Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 6 Dec 2013 10:34:59 +0100 Subject: [PATCH 24/55] Remove space before Doctype HTML --- templates/frontOffice/default/layout.tpl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/templates/frontOffice/default/layout.tpl b/templates/frontOffice/default/layout.tpl index c652e5b07..c02c7fcc4 100755 --- a/templates/frontOffice/default/layout.tpl +++ b/templates/frontOffice/default/layout.tpl @@ -1,10 +1,3 @@ -{* Declare assets directory, relative to template base directory *} -{declare_assets directory='assets'} -{block name="no-return-functions"}{/block} -{assign var="store_name" value="{config key="store_name"}"} -{if not $store_name} - {assign var="store_name" value="{intl l='Thelia V2'}"} -{/if} +{* Declare assets directory, relative to template base directory *} +{declare_assets directory='assets'} +{block name="no-return-functions"}{/block} +{assign var="store_name" value="{config key="store_name"}"} +{if not $store_name}{assign var="store_name" value="{intl l='Thelia V2'}"}{/if} + {* paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither *} From 0684ec2b42546c2a15ab0c0608e9253b63080908 Mon Sep 17 00:00:00 2001 From: touffies Date: Mon, 9 Dec 2013 10:00:10 +0100 Subject: [PATCH 25/55] Rename meta_keyword to meta_keywords Add SEO to folder --- core/lib/Thelia/Model/Base/Category.php | 72 +++++++ core/lib/Thelia/Model/Base/CategoryI18n.php | 176 +++++++++++++++++- .../Thelia/Model/Base/CategoryI18nQuery.php | 101 +++++++++- core/lib/Thelia/Model/Base/Content.php | 72 +++++++ core/lib/Thelia/Model/Base/ContentI18n.php | 176 +++++++++++++++++- .../Thelia/Model/Base/ContentI18nQuery.php | 101 +++++++++- core/lib/Thelia/Model/Base/Folder.php | 72 +++++++ core/lib/Thelia/Model/Base/FolderI18n.php | 176 +++++++++++++++++- .../lib/Thelia/Model/Base/FolderI18nQuery.php | 101 +++++++++- core/lib/Thelia/Model/Base/Product.php | 12 +- core/lib/Thelia/Model/Base/ProductI18n.php | 48 ++--- .../Thelia/Model/Base/ProductI18nQuery.php | 28 +-- .../Thelia/Model/Map/CategoryI18nTableMap.php | 52 ++++-- .../lib/Thelia/Model/Map/CategoryTableMap.php | 2 +- .../Thelia/Model/Map/ContentI18nTableMap.php | 52 ++++-- core/lib/Thelia/Model/Map/ContentTableMap.php | 2 +- .../Thelia/Model/Map/FolderI18nTableMap.php | 52 ++++-- core/lib/Thelia/Model/Map/FolderTableMap.php | 2 +- .../Thelia/Model/Map/ProductI18nTableMap.php | 30 +-- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- install/thelia.sql | 11 +- local/config/schema.xml | 23 ++- 22 files changed, 1246 insertions(+), 117 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index d5272d1e4..aacf774c0 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -3651,6 +3651,78 @@ abstract class Category implements ActiveRecordInterface return $this; } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + return $this->getCurrentTranslation()->getMetaKeywords(); + } + + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); + + return $this; + } + // versionable behavior /** diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index bd9bf2608..0eb196d29 100644 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -90,6 +90,24 @@ abstract class CategoryI18n implements ActiveRecordInterface */ protected $postscriptum; + /** + * The value for the meta_title field. + * @var string + */ + protected $meta_title; + + /** + * The value for the meta_description field. + * @var string + */ + protected $meta_description; + + /** + * The value for the meta_keywords field. + * @var string + */ + protected $meta_keywords; + /** * @var Category */ @@ -440,6 +458,39 @@ abstract class CategoryI18n implements ActiveRecordInterface return $this->postscriptum; } + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + + return $this->meta_keywords; + } + /** * Set the value of [id] column. * @@ -570,6 +621,69 @@ abstract class CategoryI18n implements ActiveRecordInterface return $this; } // setPostscriptum() + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::META_TITLE; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::META_DESCRIPTION; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::META_KEYWORDS; + } + + + return $this; + } // setMetaKeywords() + /** * Indicates whether the columns in this object are only set to default values. * @@ -628,6 +742,15 @@ abstract class CategoryI18n implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -636,7 +759,7 @@ abstract class CategoryI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = CategoryI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = CategoryI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CategoryI18n object", 0, $e); @@ -875,6 +998,15 @@ abstract class CategoryI18n implements ActiveRecordInterface if ($this->isColumnModified(CategoryI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } + if ($this->isColumnModified(CategoryI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(CategoryI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(CategoryI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; + } $sql = sprintf( 'INSERT INTO category_i18n (%s) VALUES (%s)', @@ -904,6 +1036,15 @@ abstract class CategoryI18n implements ActiveRecordInterface case 'POSTSCRIPTUM': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -977,6 +1118,15 @@ abstract class CategoryI18n implements ActiveRecordInterface case 5: return $this->getPostscriptum(); break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeywords(); + break; default: return null; break; @@ -1012,6 +1162,9 @@ abstract class CategoryI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), $keys[4] => $this->getChapo(), $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeywords(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1074,6 +1227,15 @@ abstract class CategoryI18n implements ActiveRecordInterface case 5: $this->setPostscriptum($value); break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeywords($value); + break; } // switch() } @@ -1104,6 +1266,9 @@ abstract class CategoryI18n implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); } /** @@ -1121,6 +1286,9 @@ abstract class CategoryI18n implements ActiveRecordInterface if ($this->isColumnModified(CategoryI18nTableMap::DESCRIPTION)) $criteria->add(CategoryI18nTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(CategoryI18nTableMap::CHAPO)) $criteria->add(CategoryI18nTableMap::CHAPO, $this->chapo); if ($this->isColumnModified(CategoryI18nTableMap::POSTSCRIPTUM)) $criteria->add(CategoryI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(CategoryI18nTableMap::META_TITLE)) $criteria->add(CategoryI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(CategoryI18nTableMap::META_DESCRIPTION)) $criteria->add(CategoryI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(CategoryI18nTableMap::META_KEYWORDS)) $criteria->add(CategoryI18nTableMap::META_KEYWORDS, $this->meta_keywords); return $criteria; } @@ -1197,6 +1365,9 @@ abstract class CategoryI18n implements ActiveRecordInterface $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); if ($makeNew) { $copyObj->setNew(true); } @@ -1286,6 +1457,9 @@ abstract class CategoryI18n implements ActiveRecordInterface $this->description = null; $this->chapo = null; $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keywords = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); diff --git a/core/lib/Thelia/Model/Base/CategoryI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php index 595a72aa9..44ef90de3 100644 --- a/core/lib/Thelia/Model/Base/CategoryI18nQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php @@ -27,6 +27,9 @@ use Thelia\Model\Map\CategoryI18nTableMap; * @method ChildCategoryI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildCategoryI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column * @method ChildCategoryI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildCategoryI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column + * @method ChildCategoryI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column + * @method ChildCategoryI18nQuery orderByMetaKeywords($order = Criteria::ASC) Order by the meta_keywords column * * @method ChildCategoryI18nQuery groupById() Group by the id column * @method ChildCategoryI18nQuery groupByLocale() Group by the locale column @@ -34,6 +37,9 @@ use Thelia\Model\Map\CategoryI18nTableMap; * @method ChildCategoryI18nQuery groupByDescription() Group by the description column * @method ChildCategoryI18nQuery groupByChapo() Group by the chapo column * @method ChildCategoryI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildCategoryI18nQuery groupByMetaTitle() Group by the meta_title column + * @method ChildCategoryI18nQuery groupByMetaDescription() Group by the meta_description column + * @method ChildCategoryI18nQuery groupByMetaKeywords() Group by the meta_keywords column * * @method ChildCategoryI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildCategoryI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -52,6 +58,9 @@ use Thelia\Model\Map\CategoryI18nTableMap; * @method ChildCategoryI18n findOneByDescription(string $description) Return the first ChildCategoryI18n filtered by the description column * @method ChildCategoryI18n findOneByChapo(string $chapo) Return the first ChildCategoryI18n filtered by the chapo column * @method ChildCategoryI18n findOneByPostscriptum(string $postscriptum) Return the first ChildCategoryI18n filtered by the postscriptum column + * @method ChildCategoryI18n findOneByMetaTitle(string $meta_title) Return the first ChildCategoryI18n filtered by the meta_title column + * @method ChildCategoryI18n findOneByMetaDescription(string $meta_description) Return the first ChildCategoryI18n filtered by the meta_description column + * @method ChildCategoryI18n findOneByMetaKeywords(string $meta_keywords) Return the first ChildCategoryI18n filtered by the meta_keywords column * * @method array findById(int $id) Return ChildCategoryI18n objects filtered by the id column * @method array findByLocale(string $locale) Return ChildCategoryI18n objects filtered by the locale column @@ -59,6 +68,9 @@ use Thelia\Model\Map\CategoryI18nTableMap; * @method array findByDescription(string $description) Return ChildCategoryI18n objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildCategoryI18n objects filtered by the chapo column * @method array findByPostscriptum(string $postscriptum) Return ChildCategoryI18n objects filtered by the postscriptum column + * @method array findByMetaTitle(string $meta_title) Return ChildCategoryI18n objects filtered by the meta_title column + * @method array findByMetaDescription(string $meta_description) Return ChildCategoryI18n objects filtered by the meta_description column + * @method array findByMetaKeywords(string $meta_keywords) Return ChildCategoryI18n objects filtered by the meta_keywords column * */ abstract class CategoryI18nQuery extends ModelCriteria @@ -147,7 +159,7 @@ abstract class CategoryI18nQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM category_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM category_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -436,6 +448,93 @@ abstract class CategoryI18nQuery extends ModelCriteria return $this->addUsingAlias(CategoryI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keywords column + * + * Example usage: + * + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' + * + * + * @param string $metaKeywords The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeywords)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); + } + /** * Filter the query by a related \Thelia\Model\Category object * diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index bb7299f17..6618ae9c7 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -3904,6 +3904,78 @@ abstract class Content implements ActiveRecordInterface return $this; } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + return $this->getCurrentTranslation()->getMetaKeywords(); + } + + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); + + return $this; + } + // versionable behavior /** diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index e5de214c8..5b5dd2459 100644 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -90,6 +90,24 @@ abstract class ContentI18n implements ActiveRecordInterface */ protected $postscriptum; + /** + * The value for the meta_title field. + * @var string + */ + protected $meta_title; + + /** + * The value for the meta_description field. + * @var string + */ + protected $meta_description; + + /** + * The value for the meta_keywords field. + * @var string + */ + protected $meta_keywords; + /** * @var Content */ @@ -440,6 +458,39 @@ abstract class ContentI18n implements ActiveRecordInterface return $this->postscriptum; } + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + + return $this->meta_keywords; + } + /** * Set the value of [id] column. * @@ -570,6 +621,69 @@ abstract class ContentI18n implements ActiveRecordInterface return $this; } // setPostscriptum() + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[] = ContentI18nTableMap::META_TITLE; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[] = ContentI18nTableMap::META_DESCRIPTION; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[] = ContentI18nTableMap::META_KEYWORDS; + } + + + return $this; + } // setMetaKeywords() + /** * Indicates whether the columns in this object are only set to default values. * @@ -628,6 +742,15 @@ abstract class ContentI18n implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ContentI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ContentI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -636,7 +759,7 @@ abstract class ContentI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = ContentI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = ContentI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ContentI18n object", 0, $e); @@ -875,6 +998,15 @@ abstract class ContentI18n implements ActiveRecordInterface if ($this->isColumnModified(ContentI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } + if ($this->isColumnModified(ContentI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(ContentI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(ContentI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; + } $sql = sprintf( 'INSERT INTO content_i18n (%s) VALUES (%s)', @@ -904,6 +1036,15 @@ abstract class ContentI18n implements ActiveRecordInterface case 'POSTSCRIPTUM': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -977,6 +1118,15 @@ abstract class ContentI18n implements ActiveRecordInterface case 5: return $this->getPostscriptum(); break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeywords(); + break; default: return null; break; @@ -1012,6 +1162,9 @@ abstract class ContentI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), $keys[4] => $this->getChapo(), $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeywords(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1074,6 +1227,15 @@ abstract class ContentI18n implements ActiveRecordInterface case 5: $this->setPostscriptum($value); break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeywords($value); + break; } // switch() } @@ -1104,6 +1266,9 @@ abstract class ContentI18n implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); } /** @@ -1121,6 +1286,9 @@ abstract class ContentI18n implements ActiveRecordInterface if ($this->isColumnModified(ContentI18nTableMap::DESCRIPTION)) $criteria->add(ContentI18nTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(ContentI18nTableMap::CHAPO)) $criteria->add(ContentI18nTableMap::CHAPO, $this->chapo); if ($this->isColumnModified(ContentI18nTableMap::POSTSCRIPTUM)) $criteria->add(ContentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(ContentI18nTableMap::META_TITLE)) $criteria->add(ContentI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(ContentI18nTableMap::META_DESCRIPTION)) $criteria->add(ContentI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(ContentI18nTableMap::META_KEYWORDS)) $criteria->add(ContentI18nTableMap::META_KEYWORDS, $this->meta_keywords); return $criteria; } @@ -1197,6 +1365,9 @@ abstract class ContentI18n implements ActiveRecordInterface $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); if ($makeNew) { $copyObj->setNew(true); } @@ -1286,6 +1457,9 @@ abstract class ContentI18n implements ActiveRecordInterface $this->description = null; $this->chapo = null; $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keywords = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); diff --git a/core/lib/Thelia/Model/Base/ContentI18nQuery.php b/core/lib/Thelia/Model/Base/ContentI18nQuery.php index cfd638318..ed844f4c2 100644 --- a/core/lib/Thelia/Model/Base/ContentI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ContentI18nQuery.php @@ -27,6 +27,9 @@ use Thelia\Model\Map\ContentI18nTableMap; * @method ChildContentI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildContentI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column * @method ChildContentI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildContentI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column + * @method ChildContentI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column + * @method ChildContentI18nQuery orderByMetaKeywords($order = Criteria::ASC) Order by the meta_keywords column * * @method ChildContentI18nQuery groupById() Group by the id column * @method ChildContentI18nQuery groupByLocale() Group by the locale column @@ -34,6 +37,9 @@ use Thelia\Model\Map\ContentI18nTableMap; * @method ChildContentI18nQuery groupByDescription() Group by the description column * @method ChildContentI18nQuery groupByChapo() Group by the chapo column * @method ChildContentI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildContentI18nQuery groupByMetaTitle() Group by the meta_title column + * @method ChildContentI18nQuery groupByMetaDescription() Group by the meta_description column + * @method ChildContentI18nQuery groupByMetaKeywords() Group by the meta_keywords column * * @method ChildContentI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildContentI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -52,6 +58,9 @@ use Thelia\Model\Map\ContentI18nTableMap; * @method ChildContentI18n findOneByDescription(string $description) Return the first ChildContentI18n filtered by the description column * @method ChildContentI18n findOneByChapo(string $chapo) Return the first ChildContentI18n filtered by the chapo column * @method ChildContentI18n findOneByPostscriptum(string $postscriptum) Return the first ChildContentI18n filtered by the postscriptum column + * @method ChildContentI18n findOneByMetaTitle(string $meta_title) Return the first ChildContentI18n filtered by the meta_title column + * @method ChildContentI18n findOneByMetaDescription(string $meta_description) Return the first ChildContentI18n filtered by the meta_description column + * @method ChildContentI18n findOneByMetaKeywords(string $meta_keywords) Return the first ChildContentI18n filtered by the meta_keywords column * * @method array findById(int $id) Return ChildContentI18n objects filtered by the id column * @method array findByLocale(string $locale) Return ChildContentI18n objects filtered by the locale column @@ -59,6 +68,9 @@ use Thelia\Model\Map\ContentI18nTableMap; * @method array findByDescription(string $description) Return ChildContentI18n objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildContentI18n objects filtered by the chapo column * @method array findByPostscriptum(string $postscriptum) Return ChildContentI18n objects filtered by the postscriptum column + * @method array findByMetaTitle(string $meta_title) Return ChildContentI18n objects filtered by the meta_title column + * @method array findByMetaDescription(string $meta_description) Return ChildContentI18n objects filtered by the meta_description column + * @method array findByMetaKeywords(string $meta_keywords) Return ChildContentI18n objects filtered by the meta_keywords column * */ abstract class ContentI18nQuery extends ModelCriteria @@ -147,7 +159,7 @@ abstract class ContentI18nQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM content_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM content_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -436,6 +448,93 @@ abstract class ContentI18nQuery extends ModelCriteria return $this->addUsingAlias(ContentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keywords column + * + * Example usage: + * + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' + * + * + * @param string $metaKeywords The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeywords)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); + } + /** * Filter the query by a related \Thelia\Model\Content object * diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index e62e9b71e..20a7e8dbc 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -3368,6 +3368,78 @@ abstract class Folder implements ActiveRecordInterface return $this; } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + return $this->getCurrentTranslation()->getMetaKeywords(); + } + + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); + + return $this; + } + // versionable behavior /** diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index 8e972b307..ec57cff1d 100644 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -90,6 +90,24 @@ abstract class FolderI18n implements ActiveRecordInterface */ protected $postscriptum; + /** + * The value for the meta_title field. + * @var string + */ + protected $meta_title; + + /** + * The value for the meta_description field. + * @var string + */ + protected $meta_description; + + /** + * The value for the meta_keywords field. + * @var string + */ + protected $meta_keywords; + /** * @var Folder */ @@ -440,6 +458,39 @@ abstract class FolderI18n implements ActiveRecordInterface return $this->postscriptum; } + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + + return $this->meta_keywords; + } + /** * Set the value of [id] column. * @@ -570,6 +621,69 @@ abstract class FolderI18n implements ActiveRecordInterface return $this; } // setPostscriptum() + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[] = FolderI18nTableMap::META_TITLE; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[] = FolderI18nTableMap::META_DESCRIPTION; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[] = FolderI18nTableMap::META_KEYWORDS; + } + + + return $this; + } // setMetaKeywords() + /** * Indicates whether the columns in this object are only set to default values. * @@ -628,6 +742,15 @@ abstract class FolderI18n implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -636,7 +759,7 @@ abstract class FolderI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = FolderI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = FolderI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\FolderI18n object", 0, $e); @@ -875,6 +998,15 @@ abstract class FolderI18n implements ActiveRecordInterface if ($this->isColumnModified(FolderI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } + if ($this->isColumnModified(FolderI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(FolderI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(FolderI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; + } $sql = sprintf( 'INSERT INTO folder_i18n (%s) VALUES (%s)', @@ -904,6 +1036,15 @@ abstract class FolderI18n implements ActiveRecordInterface case 'POSTSCRIPTUM': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -977,6 +1118,15 @@ abstract class FolderI18n implements ActiveRecordInterface case 5: return $this->getPostscriptum(); break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeywords(); + break; default: return null; break; @@ -1012,6 +1162,9 @@ abstract class FolderI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), $keys[4] => $this->getChapo(), $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeywords(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1074,6 +1227,15 @@ abstract class FolderI18n implements ActiveRecordInterface case 5: $this->setPostscriptum($value); break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeywords($value); + break; } // switch() } @@ -1104,6 +1266,9 @@ abstract class FolderI18n implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); } /** @@ -1121,6 +1286,9 @@ abstract class FolderI18n implements ActiveRecordInterface if ($this->isColumnModified(FolderI18nTableMap::DESCRIPTION)) $criteria->add(FolderI18nTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(FolderI18nTableMap::CHAPO)) $criteria->add(FolderI18nTableMap::CHAPO, $this->chapo); if ($this->isColumnModified(FolderI18nTableMap::POSTSCRIPTUM)) $criteria->add(FolderI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(FolderI18nTableMap::META_TITLE)) $criteria->add(FolderI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(FolderI18nTableMap::META_DESCRIPTION)) $criteria->add(FolderI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(FolderI18nTableMap::META_KEYWORDS)) $criteria->add(FolderI18nTableMap::META_KEYWORDS, $this->meta_keywords); return $criteria; } @@ -1197,6 +1365,9 @@ abstract class FolderI18n implements ActiveRecordInterface $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); if ($makeNew) { $copyObj->setNew(true); } @@ -1286,6 +1457,9 @@ abstract class FolderI18n implements ActiveRecordInterface $this->description = null; $this->chapo = null; $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keywords = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); diff --git a/core/lib/Thelia/Model/Base/FolderI18nQuery.php b/core/lib/Thelia/Model/Base/FolderI18nQuery.php index bc1e5adf4..5a95c3689 100644 --- a/core/lib/Thelia/Model/Base/FolderI18nQuery.php +++ b/core/lib/Thelia/Model/Base/FolderI18nQuery.php @@ -27,6 +27,9 @@ use Thelia\Model\Map\FolderI18nTableMap; * @method ChildFolderI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildFolderI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column * @method ChildFolderI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildFolderI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column + * @method ChildFolderI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column + * @method ChildFolderI18nQuery orderByMetaKeywords($order = Criteria::ASC) Order by the meta_keywords column * * @method ChildFolderI18nQuery groupById() Group by the id column * @method ChildFolderI18nQuery groupByLocale() Group by the locale column @@ -34,6 +37,9 @@ use Thelia\Model\Map\FolderI18nTableMap; * @method ChildFolderI18nQuery groupByDescription() Group by the description column * @method ChildFolderI18nQuery groupByChapo() Group by the chapo column * @method ChildFolderI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildFolderI18nQuery groupByMetaTitle() Group by the meta_title column + * @method ChildFolderI18nQuery groupByMetaDescription() Group by the meta_description column + * @method ChildFolderI18nQuery groupByMetaKeywords() Group by the meta_keywords column * * @method ChildFolderI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildFolderI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -52,6 +58,9 @@ use Thelia\Model\Map\FolderI18nTableMap; * @method ChildFolderI18n findOneByDescription(string $description) Return the first ChildFolderI18n filtered by the description column * @method ChildFolderI18n findOneByChapo(string $chapo) Return the first ChildFolderI18n filtered by the chapo column * @method ChildFolderI18n findOneByPostscriptum(string $postscriptum) Return the first ChildFolderI18n filtered by the postscriptum column + * @method ChildFolderI18n findOneByMetaTitle(string $meta_title) Return the first ChildFolderI18n filtered by the meta_title column + * @method ChildFolderI18n findOneByMetaDescription(string $meta_description) Return the first ChildFolderI18n filtered by the meta_description column + * @method ChildFolderI18n findOneByMetaKeywords(string $meta_keywords) Return the first ChildFolderI18n filtered by the meta_keywords column * * @method array findById(int $id) Return ChildFolderI18n objects filtered by the id column * @method array findByLocale(string $locale) Return ChildFolderI18n objects filtered by the locale column @@ -59,6 +68,9 @@ use Thelia\Model\Map\FolderI18nTableMap; * @method array findByDescription(string $description) Return ChildFolderI18n objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildFolderI18n objects filtered by the chapo column * @method array findByPostscriptum(string $postscriptum) Return ChildFolderI18n objects filtered by the postscriptum column + * @method array findByMetaTitle(string $meta_title) Return ChildFolderI18n objects filtered by the meta_title column + * @method array findByMetaDescription(string $meta_description) Return ChildFolderI18n objects filtered by the meta_description column + * @method array findByMetaKeywords(string $meta_keywords) Return ChildFolderI18n objects filtered by the meta_keywords column * */ abstract class FolderI18nQuery extends ModelCriteria @@ -147,7 +159,7 @@ abstract class FolderI18nQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM folder_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM folder_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -436,6 +448,93 @@ abstract class FolderI18nQuery extends ModelCriteria return $this->addUsingAlias(FolderI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keywords column + * + * Example usage: + * + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' + * + * + * @param string $metaKeywords The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeywords)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); + } + /** * Filter the query by a related \Thelia\Model\Folder object * diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index e850d2acf..50d8e96a3 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -5916,24 +5916,24 @@ abstract class Product implements ActiveRecordInterface /** - * Get the [meta_keyword] column value. + * Get the [meta_keywords] column value. * * @return string */ - public function getMetaKeyword() + public function getMetaKeywords() { - return $this->getCurrentTranslation()->getMetaKeyword(); + return $this->getCurrentTranslation()->getMetaKeywords(); } /** - * Set the value of [meta_keyword] column. + * Set the value of [meta_keywords] column. * * @param string $v new value * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ - public function setMetaKeyword($v) - { $this->getCurrentTranslation()->setMetaKeyword($v); + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); return $this; } diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index a72f07c83..44f67373d 100644 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -103,10 +103,10 @@ abstract class ProductI18n implements ActiveRecordInterface protected $meta_description; /** - * The value for the meta_keyword field. + * The value for the meta_keywords field. * @var string */ - protected $meta_keyword; + protected $meta_keywords; /** * @var Product @@ -481,14 +481,14 @@ abstract class ProductI18n implements ActiveRecordInterface } /** - * Get the [meta_keyword] column value. + * Get the [meta_keywords] column value. * * @return string */ - public function getMetaKeyword() + public function getMetaKeywords() { - return $this->meta_keyword; + return $this->meta_keywords; } /** @@ -664,25 +664,25 @@ abstract class ProductI18n implements ActiveRecordInterface } // setMetaDescription() /** - * Set the value of [meta_keyword] column. + * Set the value of [meta_keywords] column. * * @param string $v new value * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ - public function setMetaKeyword($v) + public function setMetaKeywords($v) { if ($v !== null) { $v = (string) $v; } - if ($this->meta_keyword !== $v) { - $this->meta_keyword = $v; - $this->modifiedColumns[] = ProductI18nTableMap::META_KEYWORD; + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[] = ProductI18nTableMap::META_KEYWORDS; } return $this; - } // setMetaKeyword() + } // setMetaKeywords() /** * Indicates whether the columns in this object are only set to default values. @@ -749,8 +749,8 @@ abstract class ProductI18n implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; $this->meta_description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductI18nTableMap::translateFieldName('MetaKeyword', TableMap::TYPE_PHPNAME, $indexType)]; - $this->meta_keyword = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -1004,8 +1004,8 @@ abstract class ProductI18n implements ActiveRecordInterface if ($this->isColumnModified(ProductI18nTableMap::META_DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; } - if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORD)) { - $modifiedColumns[':p' . $index++] = 'META_KEYWORD'; + if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; } $sql = sprintf( @@ -1042,8 +1042,8 @@ abstract class ProductI18n implements ActiveRecordInterface case 'META_DESCRIPTION': $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); break; - case 'META_KEYWORD': - $stmt->bindValue($identifier, $this->meta_keyword, PDO::PARAM_STR); + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); break; } } @@ -1125,7 +1125,7 @@ abstract class ProductI18n implements ActiveRecordInterface return $this->getMetaDescription(); break; case 8: - return $this->getMetaKeyword(); + return $this->getMetaKeywords(); break; default: return null; @@ -1164,7 +1164,7 @@ abstract class ProductI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), $keys[6] => $this->getMetaTitle(), $keys[7] => $this->getMetaDescription(), - $keys[8] => $this->getMetaKeyword(), + $keys[8] => $this->getMetaKeywords(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1234,7 +1234,7 @@ abstract class ProductI18n implements ActiveRecordInterface $this->setMetaDescription($value); break; case 8: - $this->setMetaKeyword($value); + $this->setMetaKeywords($value); break; } // switch() } @@ -1268,7 +1268,7 @@ abstract class ProductI18n implements ActiveRecordInterface if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setMetaKeyword($arr[$keys[8]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); } /** @@ -1288,7 +1288,7 @@ abstract class ProductI18n implements ActiveRecordInterface if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProductI18nTableMap::POSTSCRIPTUM, $this->postscriptum); if ($this->isColumnModified(ProductI18nTableMap::META_TITLE)) $criteria->add(ProductI18nTableMap::META_TITLE, $this->meta_title); if ($this->isColumnModified(ProductI18nTableMap::META_DESCRIPTION)) $criteria->add(ProductI18nTableMap::META_DESCRIPTION, $this->meta_description); - if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORD)) $criteria->add(ProductI18nTableMap::META_KEYWORD, $this->meta_keyword); + if ($this->isColumnModified(ProductI18nTableMap::META_KEYWORDS)) $criteria->add(ProductI18nTableMap::META_KEYWORDS, $this->meta_keywords); return $criteria; } @@ -1367,7 +1367,7 @@ abstract class ProductI18n implements ActiveRecordInterface $copyObj->setPostscriptum($this->getPostscriptum()); $copyObj->setMetaTitle($this->getMetaTitle()); $copyObj->setMetaDescription($this->getMetaDescription()); - $copyObj->setMetaKeyword($this->getMetaKeyword()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); if ($makeNew) { $copyObj->setNew(true); } @@ -1459,7 +1459,7 @@ abstract class ProductI18n implements ActiveRecordInterface $this->postscriptum = null; $this->meta_title = null; $this->meta_description = null; - $this->meta_keyword = null; + $this->meta_keywords = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); diff --git a/core/lib/Thelia/Model/Base/ProductI18nQuery.php b/core/lib/Thelia/Model/Base/ProductI18nQuery.php index 01d3af9d4..c9eae20ad 100644 --- a/core/lib/Thelia/Model/Base/ProductI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ProductI18nQuery.php @@ -29,7 +29,7 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * @method ChildProductI18nQuery orderByMetaTitle($order = Criteria::ASC) Order by the meta_title column * @method ChildProductI18nQuery orderByMetaDescription($order = Criteria::ASC) Order by the meta_description column - * @method ChildProductI18nQuery orderByMetaKeyword($order = Criteria::ASC) Order by the meta_keyword column + * @method ChildProductI18nQuery orderByMetaKeywords($order = Criteria::ASC) Order by the meta_keywords column * * @method ChildProductI18nQuery groupById() Group by the id column * @method ChildProductI18nQuery groupByLocale() Group by the locale column @@ -39,7 +39,7 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18nQuery groupByPostscriptum() Group by the postscriptum column * @method ChildProductI18nQuery groupByMetaTitle() Group by the meta_title column * @method ChildProductI18nQuery groupByMetaDescription() Group by the meta_description column - * @method ChildProductI18nQuery groupByMetaKeyword() Group by the meta_keyword column + * @method ChildProductI18nQuery groupByMetaKeywords() Group by the meta_keywords column * * @method ChildProductI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ChildProductI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -60,7 +60,7 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method ChildProductI18n findOneByPostscriptum(string $postscriptum) Return the first ChildProductI18n filtered by the postscriptum column * @method ChildProductI18n findOneByMetaTitle(string $meta_title) Return the first ChildProductI18n filtered by the meta_title column * @method ChildProductI18n findOneByMetaDescription(string $meta_description) Return the first ChildProductI18n filtered by the meta_description column - * @method ChildProductI18n findOneByMetaKeyword(string $meta_keyword) Return the first ChildProductI18n filtered by the meta_keyword column + * @method ChildProductI18n findOneByMetaKeywords(string $meta_keywords) Return the first ChildProductI18n filtered by the meta_keywords column * * @method array findById(int $id) Return ChildProductI18n objects filtered by the id column * @method array findByLocale(string $locale) Return ChildProductI18n objects filtered by the locale column @@ -70,7 +70,7 @@ use Thelia\Model\Map\ProductI18nTableMap; * @method array findByPostscriptum(string $postscriptum) Return ChildProductI18n objects filtered by the postscriptum column * @method array findByMetaTitle(string $meta_title) Return ChildProductI18n objects filtered by the meta_title column * @method array findByMetaDescription(string $meta_description) Return ChildProductI18n objects filtered by the meta_description column - * @method array findByMetaKeyword(string $meta_keyword) Return ChildProductI18n objects filtered by the meta_keyword column + * @method array findByMetaKeywords(string $meta_keywords) Return ChildProductI18n objects filtered by the meta_keywords column * */ abstract class ProductI18nQuery extends ModelCriteria @@ -159,7 +159,7 @@ abstract class ProductI18nQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORD FROM product_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM product_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -507,32 +507,32 @@ abstract class ProductI18nQuery extends ModelCriteria } /** - * Filter the query on the meta_keyword column + * Filter the query on the meta_keywords column * * Example usage: * - * $query->filterByMetaKeyword('fooValue'); // WHERE meta_keyword = 'fooValue' - * $query->filterByMetaKeyword('%fooValue%'); // WHERE meta_keyword LIKE '%fooValue%' + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' * * - * @param string $metaKeyword The value to use as filter. + * @param string $metaKeywords The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductI18nQuery The current query, for fluid interface */ - public function filterByMetaKeyword($metaKeyword = null, $comparison = null) + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) { if (null === $comparison) { - if (is_array($metaKeyword)) { + if (is_array($metaKeywords)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $metaKeyword)) { - $metaKeyword = str_replace('*', '%', $metaKeyword); + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(ProductI18nTableMap::META_KEYWORD, $metaKeyword, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); } /** diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php index 8c52aa7b2..4fe5adb5d 100644 --- a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -57,7 +57,7 @@ class CategoryI18nTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CategoryI18nTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -99,6 +99,21 @@ class CategoryI18nTableMap extends TableMap */ const POSTSCRIPTUM = 'category_i18n.POSTSCRIPTUM'; + /** + * the column name for the META_TITLE field + */ + const META_TITLE = 'category_i18n.META_TITLE'; + + /** + * the column name for the META_DESCRIPTION field + */ + const META_DESCRIPTION = 'category_i18n.META_DESCRIPTION'; + + /** + * the column name for the META_KEYWORDS field + */ + const META_KEYWORDS = 'category_i18n.META_KEYWORDS'; + /** * The default string format for model objects of the related table */ @@ -111,12 +126,12 @@ class CategoryI18nTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(CategoryI18nTableMap::ID, CategoryI18nTableMap::LOCALE, CategoryI18nTableMap::TITLE, CategoryI18nTableMap::DESCRIPTION, CategoryI18nTableMap::CHAPO, CategoryI18nTableMap::POSTSCRIPTUM, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(CategoryI18nTableMap::ID, CategoryI18nTableMap::LOCALE, CategoryI18nTableMap::TITLE, CategoryI18nTableMap::DESCRIPTION, CategoryI18nTableMap::CHAPO, CategoryI18nTableMap::POSTSCRIPTUM, CategoryI18nTableMap::META_TITLE, CategoryI18nTableMap::META_DESCRIPTION, CategoryI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -126,12 +141,12 @@ class CategoryI18nTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(CategoryI18nTableMap::ID => 0, CategoryI18nTableMap::LOCALE => 1, CategoryI18nTableMap::TITLE => 2, CategoryI18nTableMap::DESCRIPTION => 3, CategoryI18nTableMap::CHAPO => 4, CategoryI18nTableMap::POSTSCRIPTUM => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(CategoryI18nTableMap::ID => 0, CategoryI18nTableMap::LOCALE => 1, CategoryI18nTableMap::TITLE => 2, CategoryI18nTableMap::DESCRIPTION => 3, CategoryI18nTableMap::CHAPO => 4, CategoryI18nTableMap::POSTSCRIPTUM => 5, CategoryI18nTableMap::META_TITLE => 6, CategoryI18nTableMap::META_DESCRIPTION => 7, CategoryI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -156,6 +171,9 @@ class CategoryI18nTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); } // initialize() /** @@ -359,6 +377,9 @@ class CategoryI18nTableMap extends TableMap $criteria->addSelectColumn(CategoryI18nTableMap::DESCRIPTION); $criteria->addSelectColumn(CategoryI18nTableMap::CHAPO); $criteria->addSelectColumn(CategoryI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(CategoryI18nTableMap::META_TITLE); + $criteria->addSelectColumn(CategoryI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(CategoryI18nTableMap::META_KEYWORDS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -366,6 +387,9 @@ class CategoryI18nTableMap extends TableMap $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); } } diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index cd0ca3799..de74d53ae 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -208,7 +208,7 @@ class CategoryTableMap extends TableMap public function getBehaviors() { return array( - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), ); diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php index f718623b0..a69ac957e 100644 --- a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -57,7 +57,7 @@ class ContentI18nTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ContentI18nTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -99,6 +99,21 @@ class ContentI18nTableMap extends TableMap */ const POSTSCRIPTUM = 'content_i18n.POSTSCRIPTUM'; + /** + * the column name for the META_TITLE field + */ + const META_TITLE = 'content_i18n.META_TITLE'; + + /** + * the column name for the META_DESCRIPTION field + */ + const META_DESCRIPTION = 'content_i18n.META_DESCRIPTION'; + + /** + * the column name for the META_KEYWORDS field + */ + const META_KEYWORDS = 'content_i18n.META_KEYWORDS'; + /** * The default string format for model objects of the related table */ @@ -111,12 +126,12 @@ class ContentI18nTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(ContentI18nTableMap::ID, ContentI18nTableMap::LOCALE, ContentI18nTableMap::TITLE, ContentI18nTableMap::DESCRIPTION, ContentI18nTableMap::CHAPO, ContentI18nTableMap::POSTSCRIPTUM, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(ContentI18nTableMap::ID, ContentI18nTableMap::LOCALE, ContentI18nTableMap::TITLE, ContentI18nTableMap::DESCRIPTION, ContentI18nTableMap::CHAPO, ContentI18nTableMap::POSTSCRIPTUM, ContentI18nTableMap::META_TITLE, ContentI18nTableMap::META_DESCRIPTION, ContentI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -126,12 +141,12 @@ class ContentI18nTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(ContentI18nTableMap::ID => 0, ContentI18nTableMap::LOCALE => 1, ContentI18nTableMap::TITLE => 2, ContentI18nTableMap::DESCRIPTION => 3, ContentI18nTableMap::CHAPO => 4, ContentI18nTableMap::POSTSCRIPTUM => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(ContentI18nTableMap::ID => 0, ContentI18nTableMap::LOCALE => 1, ContentI18nTableMap::TITLE => 2, ContentI18nTableMap::DESCRIPTION => 3, ContentI18nTableMap::CHAPO => 4, ContentI18nTableMap::POSTSCRIPTUM => 5, ContentI18nTableMap::META_TITLE => 6, ContentI18nTableMap::META_DESCRIPTION => 7, ContentI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -156,6 +171,9 @@ class ContentI18nTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); } // initialize() /** @@ -359,6 +377,9 @@ class ContentI18nTableMap extends TableMap $criteria->addSelectColumn(ContentI18nTableMap::DESCRIPTION); $criteria->addSelectColumn(ContentI18nTableMap::CHAPO); $criteria->addSelectColumn(ContentI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(ContentI18nTableMap::META_TITLE); + $criteria->addSelectColumn(ContentI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(ContentI18nTableMap::META_KEYWORDS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -366,6 +387,9 @@ class ContentI18nTableMap extends TableMap $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); } } diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index ae9b908c0..b9d859da3 100644 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -204,7 +204,7 @@ class ContentTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php index d10344811..a09b9ef01 100644 --- a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -57,7 +57,7 @@ class FolderI18nTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FolderI18nTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -99,6 +99,21 @@ class FolderI18nTableMap extends TableMap */ const POSTSCRIPTUM = 'folder_i18n.POSTSCRIPTUM'; + /** + * the column name for the META_TITLE field + */ + const META_TITLE = 'folder_i18n.META_TITLE'; + + /** + * the column name for the META_DESCRIPTION field + */ + const META_DESCRIPTION = 'folder_i18n.META_DESCRIPTION'; + + /** + * the column name for the META_KEYWORDS field + */ + const META_KEYWORDS = 'folder_i18n.META_KEYWORDS'; + /** * The default string format for model objects of the related table */ @@ -111,12 +126,12 @@ class FolderI18nTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(FolderI18nTableMap::ID, FolderI18nTableMap::LOCALE, FolderI18nTableMap::TITLE, FolderI18nTableMap::DESCRIPTION, FolderI18nTableMap::CHAPO, FolderI18nTableMap::POSTSCRIPTUM, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(FolderI18nTableMap::ID, FolderI18nTableMap::LOCALE, FolderI18nTableMap::TITLE, FolderI18nTableMap::DESCRIPTION, FolderI18nTableMap::CHAPO, FolderI18nTableMap::POSTSCRIPTUM, FolderI18nTableMap::META_TITLE, FolderI18nTableMap::META_DESCRIPTION, FolderI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -126,12 +141,12 @@ class FolderI18nTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(FolderI18nTableMap::ID => 0, FolderI18nTableMap::LOCALE => 1, FolderI18nTableMap::TITLE => 2, FolderI18nTableMap::DESCRIPTION => 3, FolderI18nTableMap::CHAPO => 4, FolderI18nTableMap::POSTSCRIPTUM => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(FolderI18nTableMap::ID => 0, FolderI18nTableMap::LOCALE => 1, FolderI18nTableMap::TITLE => 2, FolderI18nTableMap::DESCRIPTION => 3, FolderI18nTableMap::CHAPO => 4, FolderI18nTableMap::POSTSCRIPTUM => 5, FolderI18nTableMap::META_TITLE => 6, FolderI18nTableMap::META_DESCRIPTION => 7, FolderI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -156,6 +171,9 @@ class FolderI18nTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); } // initialize() /** @@ -359,6 +377,9 @@ class FolderI18nTableMap extends TableMap $criteria->addSelectColumn(FolderI18nTableMap::DESCRIPTION); $criteria->addSelectColumn(FolderI18nTableMap::CHAPO); $criteria->addSelectColumn(FolderI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(FolderI18nTableMap::META_TITLE); + $criteria->addSelectColumn(FolderI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(FolderI18nTableMap::META_KEYWORDS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -366,6 +387,9 @@ class FolderI18nTableMap extends TableMap $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); } } diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index b35f63ae3..0346ee0d3 100644 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -208,7 +208,7 @@ class FolderTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index e082ebccb..1954654e8 100644 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -110,9 +110,9 @@ class ProductI18nTableMap extends TableMap const META_DESCRIPTION = 'product_i18n.META_DESCRIPTION'; /** - * the column name for the META_KEYWORD field + * the column name for the META_KEYWORDS field */ - const META_KEYWORD = 'product_i18n.META_KEYWORD'; + const META_KEYWORDS = 'product_i18n.META_KEYWORDS'; /** * The default string format for model objects of the related table @@ -126,11 +126,11 @@ class ProductI18nTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeyword', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeyword', ), - self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ProductI18nTableMap::META_TITLE, ProductI18nTableMap::META_DESCRIPTION, ProductI18nTableMap::META_KEYWORD, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORD', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keyword', ), + self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ProductI18nTableMap::META_TITLE, ProductI18nTableMap::META_DESCRIPTION, ProductI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); @@ -141,11 +141,11 @@ class ProductI18nTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeyword' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeyword' => 8, ), - self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ProductI18nTableMap::META_TITLE => 6, ProductI18nTableMap::META_DESCRIPTION => 7, ProductI18nTableMap::META_KEYWORD => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORD' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keyword' => 8, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ProductI18nTableMap::META_TITLE => 6, ProductI18nTableMap::META_DESCRIPTION => 7, ProductI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); @@ -173,7 +173,7 @@ class ProductI18nTableMap extends TableMap $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); - $this->addColumn('META_KEYWORD', 'MetaKeyword', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); } // initialize() /** @@ -379,7 +379,7 @@ class ProductI18nTableMap extends TableMap $criteria->addSelectColumn(ProductI18nTableMap::POSTSCRIPTUM); $criteria->addSelectColumn(ProductI18nTableMap::META_TITLE); $criteria->addSelectColumn(ProductI18nTableMap::META_DESCRIPTION); - $criteria->addSelectColumn(ProductI18nTableMap::META_KEYWORD); + $criteria->addSelectColumn(ProductI18nTableMap::META_KEYWORDS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -389,7 +389,7 @@ class ProductI18nTableMap extends TableMap $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.META_TITLE'); $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); - $criteria->addSelectColumn($alias . '.META_KEYWORD'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); } } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 3cf8d3925..35ce5c3b3 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -230,7 +230,7 @@ class ProductTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keyword', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), ); } // getBehaviors() diff --git a/install/thelia.sql b/install/thelia.sql index b399c96d6..1d0ecfb63 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1635,6 +1635,9 @@ CREATE TABLE `category_i18n` `description` LONGTEXT, `chapo` TEXT, `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `category_i18n_FK_1` FOREIGN KEY (`id`) @@ -1658,7 +1661,7 @@ CREATE TABLE `product_i18n` `postscriptum` TEXT, `meta_title` VARCHAR(255), `meta_description` TEXT, - `meta_keyword` TEXT, + `meta_keywords` TEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `product_i18n_FK_1` FOREIGN KEY (`id`) @@ -1863,6 +1866,9 @@ CREATE TABLE `folder_i18n` `description` LONGTEXT, `chapo` TEXT, `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `folder_i18n_FK_1` FOREIGN KEY (`id`) @@ -1884,6 +1890,9 @@ CREATE TABLE `content_i18n` `description` LONGTEXT, `chapo` TEXT, `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, PRIMARY KEY (`id`,`locale`), CONSTRAINT `content_i18n_FK_1` FOREIGN KEY (`id`) diff --git a/local/config/schema.xml b/local/config/schema.xml index 2a22eaa8e..1613abafc 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -9,8 +9,11 @@ + + + - + @@ -31,7 +34,7 @@ - + @@ -49,7 +52,7 @@ - + @@ -436,9 +439,12 @@ + + + - + @@ -453,9 +459,12 @@ + + + - + @@ -823,6 +832,10 @@ + + + + From d4766721502ed9f1c042713b30be9b63e2ae6817 Mon Sep 17 00:00:00 2001 From: touffies Date: Mon, 9 Dec 2013 14:34:07 +0100 Subject: [PATCH 26/55] Add SEO Meta to CATEGORY/PRODUCT/FOLDER/CONTENT --- core/lib/Thelia/Action/BaseAction.php | 2 +- core/lib/Thelia/Action/Category.php | 25 +++--- core/lib/Thelia/Action/Content.php | 23 +++--- core/lib/Thelia/Action/Folder.php | 23 +++--- .../Thelia/Config/Resources/routing/admin.xml | 12 +++ .../Admin/AbstractSeoCrudController.php | 26 ++++++- .../Controller/Admin/CategoryController.php | 12 +-- .../Controller/Admin/ContentController.php | 12 +-- .../Controller/Admin/FolderController.php | 10 ++- .../Controller/Admin/ProductController.php | 20 +---- .../Event/Category/CategoryUpdateEvent.php | 13 ---- .../Core/Event/Content/ContentUpdateEvent.php | 22 ------ .../Core/Event/Folder/FolderUpdateEvent.php | 20 ----- core/lib/Thelia/Core/Event/TheliaEvents.php | 1 + core/lib/Thelia/Core/Event/UpdateSeoEvent.php | 76 ++++++++++++++----- .../Thelia/Core/Template/Loop/Category.php | 39 +++++----- .../lib/Thelia/Core/Template/Loop/Content.php | 28 ++++--- core/lib/Thelia/Core/Template/Loop/Folder.php | 31 ++++---- .../lib/Thelia/Core/Template/Loop/Product.php | 10 ++- .../Thelia/Form/CategoryModificationForm.php | 8 -- .../Thelia/Form/ContentModificationForm.php | 8 -- .../Thelia/Form/FolderModificationForm.php | 8 -- core/lib/Thelia/Form/SeoFieldsTrait.php | 8 +- .../backOffice/default/category-edit.html | 48 ++++++------ .../backOffice/default/content-edit.html | 50 ++++++------ templates/backOffice/default/folder-edit.html | 51 +++++++------ .../backOffice/default/includes/seo-tab.html | 2 +- templates/frontOffice/default/category.html | 21 ++++- templates/frontOffice/default/content.html | 55 ++++++++++---- templates/frontOffice/default/layout.tpl | 4 +- templates/frontOffice/default/product.html | 24 ++++-- 31 files changed, 381 insertions(+), 311 deletions(-) diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index e207a624e..ece8b376b 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -95,7 +95,7 @@ class BaseAction ->setLocale($event->getLocale()) ->setMetaTitle($event->getMetaTitle()) ->setMetaDescription($event->getMetaDescription()) - ->setMetaKeyword($event->getMetaKeyword()) + ->setMetaKeywords($event->getMetaKeywords()) ->save() ; diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index ac68baa6a..9d895c7de 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -25,8 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Exception\UrlRewritingException; -use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Model\CategoryQuery; use Thelia\Model\Category as CategoryModel; @@ -74,8 +73,6 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function update(CategoryUpdateEvent $event) { - $search = CategoryQuery::create(); - if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { $category @@ -92,17 +89,22 @@ class Category extends BaseAction implements EventSubscriberInterface ->save(); - // Update the rewritten URL, if required - try { - $category->setRewrittenUrl($event->getLocale(), $event->getUrl()); - } catch(UrlRewritingException $e) { - throw new FormValidationException($e->getMessage(), $e->getCode()); - } - $event->setCategory($category); } } + /** + * Change a Category SEO + * + * @param \Thelia\Core\Event\UpdateSeoEvent $event + * + * @return mixed + */ + public function updateSeo(UpdateSeoEvent $event) + { + return $this->genericUpdateSeo(CategoryQuery::create(), $event); + } + /** * Delete a category entry * @@ -190,6 +192,7 @@ class Category extends BaseAction implements EventSubscriberInterface TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128), + TheliaEvents::CATEGORY_UPDATE_SEO => array("updateSeo", 128), TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128), TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128), diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index d3dbdbba8..986698220 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -32,8 +32,7 @@ use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Exception\UrlRewritingException; -use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Model\ContentFolder; use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentQuery; @@ -81,19 +80,24 @@ class Content extends BaseAction implements EventSubscriberInterface ->save() ; - // Update the rewritten URL, if required - try { - $content->setRewrittenUrl($event->getLocale(), $event->getUrl()); - } catch(UrlRewritingException $e) { - throw new FormValidationException($e->getMessage(), $e->getCode()); - } - $content->updateDefaultFolder($event->getDefaultFolder()); $event->setContent($content); } } + /** + * Change Content SEO + * + * @param \Thelia\Core\Event\UpdateSeoEvent $event + * + * @return mixed + */ + public function updateSeo(UpdateSeoEvent $event) + { + return $this->genericUpdateSeo(ContentQuery::create(), $event); + } + public function updatePosition(UpdatePositionEvent $event) { if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { @@ -203,6 +207,7 @@ class Content extends BaseAction implements EventSubscriberInterface TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array('toggleVisibility', 128), TheliaEvents::CONTENT_UPDATE_POSITION => array('updatePosition', 128), + TheliaEvents::CONTENT_UPDATE_SEO => array('updateSeo', 128), TheliaEvents::CONTENT_ADD_FOLDER => array('addFolder', 128), TheliaEvents::CONTENT_REMOVE_FOLDER => array('removeFolder', 128), diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php index df849898c..2eece4095 100644 --- a/core/lib/Thelia/Action/Folder.php +++ b/core/lib/Thelia/Action/Folder.php @@ -29,8 +29,7 @@ use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; use Thelia\Core\Event\Folder\FolderUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Exception\UrlRewritingException; -use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Model\FolderQuery; use Thelia\Model\Folder as FolderModel; @@ -58,17 +57,22 @@ class Folder extends BaseAction implements EventSubscriberInterface ->save(); ; - // Update the rewritten URL, if required - try { - $folder->setRewrittenUrl($event->getLocale(), $event->getUrl()); - } catch(UrlRewritingException $e) { - throw new FormValidationException($e->getMessage(), $e->getCode()); - } - $event->setFolder($folder); } } + /** + * Change Folder SEO + * + * @param \Thelia\Core\Event\UpdateSeoEvent $event + * + * @return mixed + */ + public function updateSeo(UpdateSeoEvent $event) + { + return $this->genericUpdateSeo(FolderQuery::create(), $event); + } + public function delete(FolderDeleteEvent $event) { if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { @@ -158,6 +162,7 @@ class Folder extends BaseAction implements EventSubscriberInterface TheliaEvents::FOLDER_TOGGLE_VISIBILITY => array("toggleVisibility", 128), TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128), + TheliaEvents::FOLDER_UPDATE_SEO => array('updateSeo', 128) ); } } diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index b821e775c..30238fdac 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -211,6 +211,10 @@ Thelia\Controller\Admin\CategoryController::processUpdateAction + + Thelia\Controller\Admin\CategoryController::processUpdateSeoAction + + Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction @@ -418,6 +422,10 @@ Thelia\Controller\Admin\FolderController::processUpdateAction + + Thelia\Controller\Admin\FolderController::processUpdateSeoAction + + Thelia\Controller\Admin\FolderController::deleteAction @@ -440,6 +448,10 @@ Thelia\Controller\Admin\ContentController::processUpdateAction + + Thelia\Controller\Admin\ContentController::processUpdateSeoAction + + Thelia\Controller\Admin\ContentController::updatePositionAction diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php index 744c4af17..241809399 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -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. * diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 3a8428766..bb37c046f 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -47,7 +47,7 @@ use Thelia\Model\CategoryAssociatedContentQuery; * * @author Franck Allimant */ -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() ); diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php index 82d9ec8bd..bcb588800 100644 --- a/core/lib/Thelia/Controller/Admin/ContentController.php +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -41,7 +41,7 @@ use Thelia\Model\ContentQuery; * @package Thelia\Controller\Admin * @author manuel raynaud */ -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; diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index e35d659d1..779af2306 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -38,7 +38,7 @@ use Thelia\Model\FolderQuery; * @package Thelia\Controller\Admin * @author Manuel Raynaud */ -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']) ; diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 18fd5abad..b971f00c2 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -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( diff --git a/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php index d04e8da08..1ed2c5fe4 100644 --- a/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php @@ -33,7 +33,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent protected $description; protected $postscriptum; - protected $url; protected $parent; public function __construct($category_id) @@ -89,18 +88,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent return $this; } - public function getUrl() - { - return $this->url; - } - - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php index fb5bdfb5e..3cab32425 100644 --- a/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php @@ -36,8 +36,6 @@ class ContentUpdateEvent extends ContentCreateEvent protected $description; protected $postscriptum; - protected $url; - public function __construct($content_id) { $this->content_id = $content_id; @@ -123,24 +121,4 @@ class ContentUpdateEvent extends ContentCreateEvent return $this->postscriptum; } - /** - * @param mixed $url - * - * @return $this - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * @return mixed - */ - public function getUrl() - { - return $this->url; - } - } diff --git a/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php index bb4234d6c..e88026b85 100644 --- a/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php @@ -37,8 +37,6 @@ class FolderUpdateEvent extends FolderCreateEvent protected $description; protected $postscriptum; - protected $url; - public function __construct($folder_id) { $this->folder_id = $folder_id; @@ -116,22 +114,4 @@ class FolderUpdateEvent extends FolderCreateEvent return $this->postscriptum; } - /** - * @param mixed $url - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * @return mixed - */ - public function getUrl() - { - return $this->url; - } - } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 7e22dc938..cba6bb6c2 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -181,6 +181,7 @@ final class TheliaEvents const FOLDER_DELETE = "action.deleteFolder"; const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; + const FOLDER_UPDATE_SEO = "action.updateFolderSeo"; const BEFORE_CREATEFOLDER = "action.before_createFolder"; const AFTER_CREATEFOLDER = "action.after_createFolder"; diff --git a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php index 99b19efe8..0c81a3469 100644 --- a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php +++ b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php @@ -30,25 +30,40 @@ class UpdateSeoEvent extends ActionEvent protected $url; protected $meta_title; protected $meta_description; - protected $meta_keyword; + protected $meta_keywords; protected $object; - public function __construct($object_id, $locale = null, $url = null, $meta_title = null, $meta_description = null, $meta_keyword = null) + /** + * @param $object_id + * @param null $locale + * @param null $url + * @param null $meta_title + * @param null $meta_description + * @param null $meta_keywords + */ + public function __construct($object_id, $locale = null, $url = null, $meta_title = null, $meta_description = null, $meta_keywords = null) { $this->object_id = $object_id; $this->locale = $locale; $this->url = $url; $this->meta_title = $meta_title; $this->meta_description = $meta_description; - $this->meta_keyword = $meta_keyword; + $this->meta_keywords = $meta_keywords; } + /** + * @return mixed + */ public function getObjectId() { return $this->object_id; } + /** + * @param $object_id + * @return $this + */ public function setObjectId($object_id) { $this->object_id = $object_id; @@ -56,11 +71,18 @@ class UpdateSeoEvent extends ActionEvent return $this; } + /** + * @return null + */ public function getLocale() { return $this->locale; } + /** + * @param $locale + * @return $this + */ public function setLocale($locale) { $this->locale = $locale; @@ -68,11 +90,18 @@ class UpdateSeoEvent extends ActionEvent return $this; } + /** + * @return null + */ public function getUrl() { return $this->url; } + /** + * @param $url + * @return $this + */ public function setUrl($url) { $this->url = $url; @@ -80,23 +109,18 @@ class UpdateSeoEvent extends ActionEvent return $this; } - public function getParent() - { - return $this->parent; - } - - public function setParent($parent) - { - $this->parent = $parent; - - return $this; - } - + /** + * @return null + */ public function getMetaTitle() { return $this->meta_title; } + /** + * @param $meta_title + * @return $this + */ public function setMetaTitle($meta_title) { $this->meta_title = $meta_title; @@ -104,11 +128,18 @@ class UpdateSeoEvent extends ActionEvent return $this; } + /** + * @return null + */ public function getMetaDescription() { return $this->meta_description; } + /** + * @param $meta_description + * @return $this + */ public function setMetaDescription($meta_description) { $this->meta_description = $meta_description; @@ -116,14 +147,21 @@ class UpdateSeoEvent extends ActionEvent return $this; } - public function getMetaKeyword() + /** + * @return null + */ + public function getMetaKeywords() { - return $this->meta_keyword; + return $this->meta_keywords; } - public function setMetaKeyword($meta_keyword) + /** + * @param $meta_keywords + * @return $this + */ + public function setMetaKeywords($meta_keywords) { - $this->meta_keyword = $meta_keyword; + $this->meta_keywords = $meta_keywords; return $this; } diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index b03f6dbb0..922f3161b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -96,7 +96,7 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface $search = CategoryQuery::create(); /* manage translations */ - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS')); $id = $this->getId(); @@ -213,25 +213,28 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface $loopResultRow = new LoopResultRow($category); $loopResultRow - ->set("ID", $category->getId()) - ->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE",$this->locale) - ->set("TITLE", $category->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("PARENT", $category->getParent()) - ->set("URL", $category->getUrl($this->locale)) - ->set("PRODUCT_COUNT", $category->countAllProducts()) - ->set("CHILD_COUNT", $category->countChild()) - ->set("VISIBLE", $category->getVisible() ? "1" : "0") - ->set("POSITION", $category->getPosition()) + ->set("ID" , $category->getId()) + ->set("IS_TRANSLATED" ,$category->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" ,$this->locale) + ->set("TITLE" , $category->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $category->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $category->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $category->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("PARENT" , $category->getParent()) + ->set("URL" , $category->getUrl($this->locale)) + ->set("META_TITLE" , $category->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $category->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $category->getVirtualColumn('i18n_META_KEYWORDS')) + ->set("PRODUCT_COUNT" , $category->countAllProducts()) + ->set("CHILD_COUNT" , $category->countChild()) + ->set("VISIBLE" , $category->getVisible() ? "1" : "0") + ->set("POSITION" , $category->getPosition()) - ->set("HAS_PREVIOUS", $previous != null ? 1 : 0) - ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) - ->set("PREVIOUS", $previous != null ? $previous->getId() : -1) - ->set("NEXT" , $next != null ? $next->getId() : -1) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index bbf9e2c78..ee028e16d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -85,7 +85,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface $search = ContentQuery::create(); /* manage translations */ - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS')); $id = $this->getId(); @@ -215,17 +215,21 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface foreach ($loopResult->getResultDataCollection() as $content) { $loopResultRow = new LoopResultRow($content); - $loopResultRow->set("ID", $content->getId()) - ->set("IS_TRANSLATED",$content->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE",$this->locale) - ->set("TITLE",$content->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $content->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("POSITION", $content->getPosition()) - ->set("DEFAULT_FOLDER", $content->getDefaultFolderId()) - ->set("URL", $content->getUrl($this->locale)) - ->set("VISIBLE", $content->getVisible()) + $loopResultRow->set("ID" , $content->getId()) + ->set("IS_TRANSLATED" , $content->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $this->locale) + ->set("TITLE" , $content->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $content->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $content->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $content->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("URL" , $content->getUrl($this->locale)) + ->set("META_TITLE" , $content->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $content->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $content->getVirtualColumn('i18n_META_KEYWORDS')) + ->set("POSITION" , $content->getPosition()) + ->set("DEFAULT_FOLDER" , $content->getDefaultFolderId()) + + ->set("VISIBLE" , $content->getVisible()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index 539436983..84dee9f82 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -78,7 +78,7 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface $search = FolderQuery::create(); /* manage translations */ - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS')); $id = $this->getId(); @@ -164,19 +164,22 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface $loopResultRow = new LoopResultRow($folder); $loopResultRow - ->set("ID", $folder->getId()) - ->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE",$this->locale) - ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("PARENT", $folder->getParent()) - ->set("URL", $folder->getUrl($this->locale)) - ->set("CHILD_COUNT", $folder->countChild()) - ->set("CONTENT_COUNT", $folder->countAllContents()) - ->set("VISIBLE", $folder->getVisible() ? "1" : "0") - ->set("POSITION", $folder->getPosition()) + ->set("ID" , $folder->getId()) + ->set("IS_TRANSLATED" , $folder->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $this->locale) + ->set("TITLE" , $folder->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $folder->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $folder->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("PARENT" , $folder->getParent()) + ->set("URL" , $folder->getUrl($this->locale)) + ->set("META_TITLE" , $folder->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $folder->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $folder->getVirtualColumn('i18n_META_KEYWORDS')) + ->set("CHILD_COUNT" , $folder->countChild()) + ->set("CONTENT_COUNT" , $folder->countAllContents()) + ->set("VISIBLE" , $folder->getVisible() ? "1" : "0") + ->set("POSITION" , $folder->getPosition()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 09aff4479..c780ee40e 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -222,7 +222,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL } /* manage translations */ - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS')); $id = $this->getId(); @@ -518,6 +518,9 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("URL" , $product->getUrl($this->locale)) + ->set("META_TITLE" , $product->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $product->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $product->getVirtualColumn('i18n_META_KEYWORDS')) ->set("BEST_PRICE" , $product->getVirtualColumn('is_promo') ? $promoPrice : $price) ->set("BEST_PRICE_TAX" , $taxedPrice - $product->getVirtualColumn('is_promo') ? $taxedPromoPrice - $promoPrice : $taxedPrice - $price) ->set("BEST_TAXED_PRICE" , $product->getVirtualColumn('is_promo') ? $taxedPromoPrice : $taxedPrice) @@ -569,7 +572,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL $search = ProductQuery::create(); /* manage translations */ - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS')); $attributeNonStrictMatch = $this->getAttribute_non_strict_match(); $isPSELeftJoinList = array(); @@ -1025,6 +1028,9 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("URL" , $product->getUrl($this->locale)) + ->set("META_TITLE" , $product->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $product->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $product->getVirtualColumn('i18n_META_KEYWORDS')) ->set("BEST_PRICE" , $price) ->set("BEST_PRICE_TAX" , $taxedPrice - $price) ->set("BEST_TAXED_PRICE" , $taxedPrice) diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index 567f9e41f..a4463126d 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -23,8 +23,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; -use Thelia\Core\Translation\Translator; -use Symfony\Component\Validator\Constraints\NotBlank; class CategoryModificationForm extends CategoryCreationForm { @@ -36,12 +34,6 @@ class CategoryModificationForm extends CategoryCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - - ->add("url", "text", array( - "label" => Translator::getInstance()->trans("Rewritten URL *"), - "constraints" => array(new NotBlank()), - "label_attr" => array("for" => "rewriten_url") - )) ; // Add standard description fields, excluding title and locale, which a re defined in parent class diff --git a/core/lib/Thelia/Form/ContentModificationForm.php b/core/lib/Thelia/Form/ContentModificationForm.php index c3887b88e..b0130b2d2 100644 --- a/core/lib/Thelia/Form/ContentModificationForm.php +++ b/core/lib/Thelia/Form/ContentModificationForm.php @@ -24,8 +24,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; -use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Core\Translation\Translator; use Thelia\Form\StandardDescriptionFieldsTrait; /** @@ -43,12 +41,6 @@ class ContentModificationForm extends ContentCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - - ->add("url", "text", array( - "label" => Translator::getInstance()->trans("Rewritten URL *"), - "constraints" => array(new NotBlank()), - "label_attr" => array("for" => "rewritten_url") - )) ; // Add standard description fields, excluding title and locale, which a re defined in parent class diff --git a/core/lib/Thelia/Form/FolderModificationForm.php b/core/lib/Thelia/Form/FolderModificationForm.php index 9c4e4c601..daab3b5ad 100644 --- a/core/lib/Thelia/Form/FolderModificationForm.php +++ b/core/lib/Thelia/Form/FolderModificationForm.php @@ -23,8 +23,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; -use Thelia\Core\Translation\Translator; -use Symfony\Component\Validator\Constraints\NotBlank; class FolderModificationForm extends FolderCreationForm { @@ -36,12 +34,6 @@ class FolderModificationForm extends FolderCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - - ->add("url", "text", array( - "label" => Translator::getInstance()->trans("Rewritten URL *"), - "constraints" => array(new NotBlank()), - "label_attr" => array("for" => "rewriten_url") - )) ; // Add standard description fields, excluding title and locale, which a re defined in parent class diff --git a/core/lib/Thelia/Form/SeoFieldsTrait.php b/core/lib/Thelia/Form/SeoFieldsTrait.php index dd66324d8..5b3270793 100644 --- a/core/lib/Thelia/Form/SeoFieldsTrait.php +++ b/core/lib/Thelia/Form/SeoFieldsTrait.php @@ -75,12 +75,12 @@ trait SeoFieldsTrait ) ); - if (! in_array('meta_keyword', $exclude)) + if (! in_array('meta_keywords', $exclude)) $this->formBuilder - ->add('meta_keyword', 'text', array( - 'label' => Translator::getInstance()->trans('Meta Keyword'), + ->add('meta_keywords', 'text', array( + 'label' => Translator::getInstance()->trans('Meta Keywords'), 'label_attr' => array( - 'for' => 'meta_keyword' + 'for' => 'meta_keywords' ), 'required' => false ) diff --git a/templates/backOffice/default/category-edit.html b/templates/backOffice/default/category-edit.html index 7225ddf6e..546fd7a74 100755 --- a/templates/backOffice/default/category-edit.html +++ b/templates/backOffice/default/category-edit.html @@ -42,6 +42,7 @@