// Move and refacto Tools::getMetaTags(), Tools::getHomeMetaTags() and Tools::completeMetaTags() to Meta class
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14938 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+232
-5
@@ -45,7 +45,7 @@ class MetaCore extends ObjectModel
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'page' => array('type' => self::TYPE_STRING, 'validate' => 'isFileName', 'required' => true, 'size' => 64),
|
'page' => array('type' => self::TYPE_STRING, 'validate' => 'isFileName', 'required' => true, 'size' => 64),
|
||||||
|
|
||||||
// Lang fields
|
/* Lang fields */
|
||||||
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||||
'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
'keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
@@ -105,11 +105,8 @@ class MetaCore extends ObjectModel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMetaByPage($page, $id_lang, Context $context = null)
|
public static function getMetaByPage($page, $id_lang)
|
||||||
{
|
{
|
||||||
if (!$context)
|
|
||||||
$context = Context::getContext();
|
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM '._DB_PREFIX_.'meta m
|
FROM '._DB_PREFIX_.'meta m
|
||||||
LEFT JOIN '._DB_PREFIX_.'meta_lang ml on (m.id_meta = ml.id_meta)
|
LEFT JOIN '._DB_PREFIX_.'meta_lang ml on (m.id_meta = ml.id_meta)
|
||||||
@@ -163,5 +160,235 @@ class MetaCore extends ObjectModel
|
|||||||
AND id_lang = '.(int)$new_id_lang.'
|
AND id_lang = '.(int)$new_id_lang.'
|
||||||
AND id_shop = '.Context::getContext()->shop->id);
|
AND id_shop = '.Context::getContext()->shop->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.5.0
|
||||||
|
*/
|
||||||
|
public static function getMetaTags($id_lang, $page_name, $title = '')
|
||||||
|
{
|
||||||
|
global $maintenance;
|
||||||
|
|
||||||
|
if (!(isset($maintenance) && (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))))
|
||||||
|
{
|
||||||
|
if ($id_product = Tools::getValue('id_product'))
|
||||||
|
return Meta::getProductMetas($id_product, $id_lang, $page_name);
|
||||||
|
else if ($id_category = Tools::getValue('id_category'))
|
||||||
|
return Meta::getCategoryMetas($id_category, $id_lang, $page_name, $title);
|
||||||
|
else if ($id_manufacturer = Tools::getValue('id_manufacturer'))
|
||||||
|
return Meta::getManufacturerMetas($id_manufacturer, $id_lang, $page_name);
|
||||||
|
else if ($id_supplier = Tools::getValue('id_supplier'))
|
||||||
|
return Meta::getSupplierMetas($id_supplier, $id_lang, $page_name);
|
||||||
|
else if ($id_cms = Tools::getValue('id_cms'))
|
||||||
|
return Meta::getCmsMetas($id_cms, $id_lang, $page_name);
|
||||||
|
else if ($id_cms_category = Tools::getValue('id_cms_category'))
|
||||||
|
return Meta::getCmsCategoryMetas($id_cms_category, $id_lang, $page_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetaTags($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get meta tags for a given page
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array Meta tags
|
||||||
|
*/
|
||||||
|
public static function getHomeMetas($id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$metas = Meta::getMetaByPage($page_name, $id_lang);
|
||||||
|
$ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'].' - '.Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');
|
||||||
|
$ret['meta_description'] = (isset($metas['description']) && $metas['description']) ? $metas['description'] : '';
|
||||||
|
$ret['meta_keywords'] = (isset($metas['keywords']) && $metas['keywords']) ? $metas['keywords'] : '';
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get product meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_product
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getProductMetas($id_product, $id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short`
|
||||||
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
|
||||||
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
|
WHERE pl.id_lang = '.(int)$id_lang.'
|
||||||
|
AND pl.id_product = '.(int)$id_product.'
|
||||||
|
AND product_shop.active = 1';
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
if (empty($row['meta_description']))
|
||||||
|
$row['meta_description'] = strip_tags($row['description_short']);
|
||||||
|
return Meta::completeMetaTags($row, $row['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_category
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getCategoryMetas($id_category, $id_lang, $page_name, $title = '')
|
||||||
|
{
|
||||||
|
if (!empty($title))
|
||||||
|
$title = ' - '.$title;
|
||||||
|
$page_number = (int)Tools::getValue('p');
|
||||||
|
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
|
||||||
|
FROM `'._DB_PREFIX_.'category_lang` cl
|
||||||
|
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||||
|
AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl');
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
if (empty($row['meta_description']))
|
||||||
|
$row['meta_description'] = strip_tags($row['description']);
|
||||||
|
|
||||||
|
// Paginate title
|
||||||
|
if (!empty($row['meta_title']))
|
||||||
|
$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
else
|
||||||
|
$row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
|
||||||
|
if (!empty($title))
|
||||||
|
$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
|
||||||
|
return Meta::completeMetaTags($row, $row['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get manufacturer meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_manufacturer
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getManufacturerMetas($id_manufacturer, $id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$page_number = (int)Tools::getValue('p');
|
||||||
|
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`
|
||||||
|
FROM `'._DB_PREFIX_.'manufacturer_lang` ml
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (ml.`id_manufacturer` = m.`id_manufacturer`)
|
||||||
|
WHERE ml.id_lang = '.(int)$id_lang.'
|
||||||
|
AND ml.id_manufacturer = '.(int)$id_manufacturer;
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
if (empty($row['meta_description']))
|
||||||
|
$row['meta_description'] = strip_tags($row['meta_description']);
|
||||||
|
$row['meta_title'] .= $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '');
|
||||||
|
$row['meta_title'] .= ' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
return Meta::completeMetaTags($row, $row['meta_title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get supplier meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_supplier
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getSupplierMetas($id_supplier, $id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`
|
||||||
|
FROM `'._DB_PREFIX_.'supplier_lang` sl
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'supplier` s ON (sl.`id_supplier` = s.`id_supplier`)
|
||||||
|
WHERE sl.id_lang = '.(int)$id_lang.'
|
||||||
|
AND sl.id_supplier = '.(int)$id_supplier;
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
if (empty($row['meta_description']))
|
||||||
|
$row['meta_description'] = strip_tags($row['meta_description']);
|
||||||
|
if (!empty($row['meta_title']))
|
||||||
|
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
return Meta::completeMetaTags($row, $row['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get CMS meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_cms
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getCmsMetas($id_cms, $id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords`
|
||||||
|
FROM `'._DB_PREFIX_.'cms_lang`
|
||||||
|
WHERE id_lang = '.(int)$id_lang.'
|
||||||
|
AND id_cms = '.(int)$id_cms;
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
return Meta::completeMetaTags($row, $row['meta_title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get CMS category meta tags
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
|
* @param int $id_cms_category
|
||||||
|
* @param int $id_lang
|
||||||
|
* @param string $page_name
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getCmsCategoryMetas($id_cms_category, $id_lang, $page_name)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT `meta_title`, `meta_description`, `meta_keywords`
|
||||||
|
FROM `'._DB_PREFIX_.'cms_category_lang`
|
||||||
|
WHERE id_lang = '.(int)$id_lang.'
|
||||||
|
AND id_cms_category = '.(int)$id_cms_category;
|
||||||
|
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||||
|
{
|
||||||
|
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
return Meta::completeMetaTags($row, $row['meta_title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.5.0
|
||||||
|
*/
|
||||||
|
public static function completeMetaTags($meta_tags, $default_value, Context $context = null)
|
||||||
|
{
|
||||||
|
if (!$context)
|
||||||
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
if (empty($meta_tags['meta_title']))
|
||||||
|
$meta_tags['meta_title'] = $default_value.' - '.Configuration::get('PS_SHOP_NAME');
|
||||||
|
if (empty($meta_tags['meta_description']))
|
||||||
|
$meta_tags['meta_description'] = Configuration::get('PS_META_DESCRIPTION', $context->language->id) ? Configuration::get('PS_META_DESCRIPTION', $context->language->id) : '';
|
||||||
|
if (empty($meta_tags['meta_keywords']))
|
||||||
|
$meta_tags['meta_keywords'] = Configuration::get('PS_META_KEYWORDS', $context->language->id) ? Configuration::get('PS_META_KEYWORDS', $context->language->id) : '';
|
||||||
|
return $meta_tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+12
-146
@@ -744,164 +744,30 @@ class ToolsCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get meta tages for a given page
|
* @deprecated 1.5.0
|
||||||
*
|
|
||||||
* @param integer $id_lang Language id
|
|
||||||
* @return array Meta tags
|
|
||||||
*/
|
*/
|
||||||
public static function getMetaTags($id_lang, $page_name, $title = '')
|
public static function getMetaTags($id_lang, $page_name, $title = '')
|
||||||
{
|
{
|
||||||
global $maintenance;
|
Tools::displayAsDeprecated();
|
||||||
|
return Meta::getMetaTags($id_lang, $page_name, $title);
|
||||||
if (!(isset($maintenance) && (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))))
|
|
||||||
{
|
|
||||||
/* Products specifics meta tags */
|
|
||||||
if ($id_product = Tools::getValue('id_product'))
|
|
||||||
{
|
|
||||||
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short`
|
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
|
|
||||||
'.Shop::addSqlAssociation('product', 'p').'
|
|
||||||
WHERE pl.id_lang = '.(int)$id_lang.'
|
|
||||||
AND pl.id_product = '.(int)$id_product.'
|
|
||||||
AND product_shop.active = 1';
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
if (empty($row['meta_description']))
|
|
||||||
$row['meta_description'] = strip_tags($row['description_short']);
|
|
||||||
return Tools::completeMetaTags($row, $row['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Categories specifics meta tags */
|
|
||||||
else if ($id_category = Tools::getValue('id_category'))
|
|
||||||
{
|
|
||||||
if (!empty($title))
|
|
||||||
$title = ' - '.$title;
|
|
||||||
$page_number = (int)Tools::getValue('p');
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
|
||||||
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
|
|
||||||
FROM `'._DB_PREFIX_.'category_lang` cl
|
|
||||||
WHERE cl.`id_lang` = '.(int)($id_lang).' AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl'));
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
if (empty($row['meta_description']))
|
|
||||||
$row['meta_description'] = strip_tags($row['description']);
|
|
||||||
|
|
||||||
// Paginate title
|
|
||||||
if (!empty($row['meta_title']))
|
|
||||||
$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
else
|
|
||||||
$row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
|
|
||||||
if (!empty($title))
|
|
||||||
$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
|
|
||||||
return Tools::completeMetaTags($row, $row['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Manufacturers specifics meta tags */
|
|
||||||
else if ($id_manufacturer = Tools::getValue('id_manufacturer'))
|
|
||||||
{
|
|
||||||
$page_number = (int)Tools::getValue('p');
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
|
||||||
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`
|
|
||||||
FROM `'._DB_PREFIX_.'manufacturer_lang` ml
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (ml.`id_manufacturer` = m.`id_manufacturer`)
|
|
||||||
WHERE ml.id_lang = '.(int)($id_lang).' AND ml.id_manufacturer = '.(int)($id_manufacturer));
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
if (empty($row['meta_description']))
|
|
||||||
$row['meta_description'] = strip_tags($row['meta_description']);
|
|
||||||
$row['meta_title'] .= $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '');
|
|
||||||
$row['meta_title'] .= ' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
return Tools::completeMetaTags($row, $row['meta_title']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Suppliers specifics meta tags */
|
|
||||||
else if ($id_supplier = Tools::getValue('id_supplier'))
|
|
||||||
{
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
|
||||||
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`
|
|
||||||
FROM `'._DB_PREFIX_.'supplier_lang` sl
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'supplier` s ON (sl.`id_supplier` = s.`id_supplier`)
|
|
||||||
WHERE sl.id_lang = '.(int)($id_lang).' AND sl.id_supplier = '.(int)($id_supplier));
|
|
||||||
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
if (empty($row['meta_description']))
|
|
||||||
$row['meta_description'] = strip_tags($row['meta_description']);
|
|
||||||
if (!empty($row['meta_title']))
|
|
||||||
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
return Tools::completeMetaTags($row, $row['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CMS specifics meta tags */
|
|
||||||
else if ($id_cms = Tools::getValue('id_cms'))
|
|
||||||
{
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
|
||||||
SELECT `meta_title`, `meta_description`, `meta_keywords`
|
|
||||||
FROM `'._DB_PREFIX_.'cms_lang`
|
|
||||||
WHERE id_lang = '.(int)($id_lang).' AND id_cms = '.(int)($id_cms));
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
return Tools::completeMetaTags($row, $row['meta_title']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CMS category specifics meta tags */
|
|
||||||
else if ($id_cms = Tools::getValue('id_cms_category'))
|
|
||||||
{
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
|
||||||
SELECT `meta_title`, `meta_description`, `meta_keywords`
|
|
||||||
FROM `'._DB_PREFIX_.'cms_category_lang`
|
|
||||||
WHERE id_lang = '.(int)($id_lang).' AND id_cms_category = '.(int)($id_cms));
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
return Tools::completeMetaTags($row, $row['meta_title']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default meta tags */
|
|
||||||
return Tools::getHomeMetaTags($id_lang, $page_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get meta tags for a given page
|
* @deprecated 1.5.0
|
||||||
*
|
|
||||||
* @param integer $id_lang Language id
|
|
||||||
* @return array Meta tags
|
|
||||||
*/
|
*/
|
||||||
public static function getHomeMetaTags($id_lang, $page_name)
|
public static function getHomeMetaTags($id_lang, $page_name)
|
||||||
{
|
{
|
||||||
/* Metas-tags */
|
Tools::displayAsDeprecated();
|
||||||
$metas = Meta::getMetaByPage($page_name, $id_lang);
|
return Meta::getHomeMetas($id_lang, $page_name);
|
||||||
$ret['meta_title'] = (isset($metas['title']) && $metas['title']) ? $metas['title'].' - '.Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');
|
|
||||||
$ret['meta_description'] = (isset($metas['description']) && $metas['description']) ? $metas['description'] : '';
|
|
||||||
$ret['meta_keywords'] = (isset($metas['keywords']) && $metas['keywords']) ? $metas['keywords'] : '';
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public static function completeMetaTags($metaTags, $defaultValue, Context $context = null)
|
* @deprecated 1.5.0
|
||||||
|
*/
|
||||||
|
public static function completeMetaTags($meta_tags, $default_value, Context $context = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
Tools::displayAsDeprecated();
|
||||||
$context = Context::getContext();
|
return Meta::completeMetaTags($meta_tags, $default_value, $context);
|
||||||
|
|
||||||
if (empty($metaTags['meta_title']))
|
|
||||||
$metaTags['meta_title'] = $defaultValue.' - '.Configuration::get('PS_SHOP_NAME');
|
|
||||||
if (empty($metaTags['meta_description']))
|
|
||||||
$metaTags['meta_description'] = Configuration::get('PS_META_DESCRIPTION', $context->language->id) ? Configuration::get('PS_META_DESCRIPTION', $context->language->id) : '';
|
|
||||||
if (empty($metaTags['meta_keywords']))
|
|
||||||
$metaTags['meta_keywords'] = Configuration::get('PS_META_KEYWORDS', $context->language->id) ? Configuration::get('PS_META_KEYWORDS', $context->language->id) : '';
|
|
||||||
return $metaTags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class FrontControllerCore extends Controller
|
|||||||
$page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
|
$page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign(Tools::getMetaTags($this->context->language->id, $page_name));
|
$this->context->smarty->assign(Meta::getMetaTags($this->context->language->id, $page_name));
|
||||||
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
$this->context->smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||||
|
|
||||||
/* Breadcrumb */
|
/* Breadcrumb */
|
||||||
|
|||||||
@@ -1216,7 +1216,8 @@ class BlockLayered extends Module
|
|||||||
if (!empty($val['title']))
|
if (!empty($val['title']))
|
||||||
$val['title'] = $val['title'].' ';
|
$val['title'] = $val['title'].' ';
|
||||||
|
|
||||||
foreach ($val['values'] as $value) {
|
foreach ($val['values'] as $value)
|
||||||
|
{
|
||||||
$title .= $category_title.' '.$val['title'].$value.' - ';
|
$title .= $category_title.' '.$val['title'].$value.' - ';
|
||||||
$description .= $category_title.' '.$val['title'].$value.', ';
|
$description .= $category_title.' '.$val['title'].$value.', ';
|
||||||
$keywords .= $val['title'].$value.', ';
|
$keywords .= $val['title'].$value.', ';
|
||||||
@@ -1227,6 +1228,9 @@ class BlockLayered extends Module
|
|||||||
// Title attributes (ex: <attr1> <value1>/<value2>, <attr2> <value1>)
|
// Title attributes (ex: <attr1> <value1>/<value2>, <attr2> <value1>)
|
||||||
$description = strtolower(rtrim(substr($description, 0, -2)));
|
$description = strtolower(rtrim(substr($description, 0, -2)));
|
||||||
// kewords attributes (ex: <attr1> <value1>, <attr1> <value2>, <attr2> <value1>)
|
// kewords attributes (ex: <attr1> <value1>, <attr1> <value2>, <attr2> <value1>)
|
||||||
|
if (version_compare(_PS_VERSION_, '1.5', '>'))
|
||||||
|
$category_metas = Meta::getMetaTags($id_lang, '', $title);
|
||||||
|
else
|
||||||
$category_metas = Tools::getMetaTags($id_lang, '', $title);
|
$category_metas = Tools::getMetaTags($id_lang, '', $title);
|
||||||
|
|
||||||
if (!empty($title))
|
if (!empty($title))
|
||||||
@@ -1284,7 +1288,8 @@ class BlockLayered extends Module
|
|||||||
foreach ($val as $attr)
|
foreach ($val as $attr)
|
||||||
{
|
{
|
||||||
$attr_id = preg_replace('/_\d+$/', '', $attr);
|
$attr_id = preg_replace('/_\d+$/', '', $attr);
|
||||||
if (in_array($attr_id, $attributes) || in_array(array('id_attribute_group' => $attr_id), $attribute_group_list)) {
|
if (in_array($attr_id, $attributes) || in_array(array('id_attribute_group' => $attr_id), $attribute_group_list))
|
||||||
|
{
|
||||||
$smarty->assign('nobots', true);
|
$smarty->assign('nobots', true);
|
||||||
$smarty->assign('nofollow', true);
|
$smarty->assign('nofollow', true);
|
||||||
return;
|
return;
|
||||||
@@ -1296,7 +1301,8 @@ class BlockLayered extends Module
|
|||||||
foreach ($val as $feat)
|
foreach ($val as $feat)
|
||||||
{
|
{
|
||||||
$feat_id = preg_replace('/_\d+$/', '', $feat);
|
$feat_id = preg_replace('/_\d+$/', '', $feat);
|
||||||
if (in_array($feat_id, $features) || in_array(array('id_feature' => $feat_id), $feature_list)) {
|
if (in_array($feat_id, $features) || in_array(array('id_feature' => $feat_id), $feature_list))
|
||||||
|
{
|
||||||
$smarty->assign('nobots', true);
|
$smarty->assign('nobots', true);
|
||||||
$smarty->assign('nofollow', true);
|
$smarty->assign('nofollow', true);
|
||||||
return;
|
return;
|
||||||
@@ -1455,7 +1461,6 @@ class BlockLayered extends Module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (version_compare(_PS_VERSION_, '1.5', '>'))
|
if (version_compare(_PS_VERSION_, '1.5', '>'))
|
||||||
{
|
{
|
||||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter_shop WHERE `id_layered_filter` = '.(int)$id_layered_filter);
|
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter_shop WHERE `id_layered_filter` = '.(int)$id_layered_filter);
|
||||||
|
|||||||
Reference in New Issue
Block a user