Marion Muszynski 3a8798c7fe meta
2015-09-25 15:24:19 +02:00

79 lines
3.4 KiB
PHP

<?php
class Meta extends MetaCore {
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 ($page_name == 'product' && ($id_product = Tools::getValue('id_product')))
return Meta::getProductMetas($id_product, $id_lang, $page_name);
elseif ($page_name == 'category' && ($id_category = Tools::getValue('id_category')))
return Meta::getCategoryMetas($id_category, $id_lang, $page_name, $title);
elseif ($page_name == 'manufacturer' && ($id_manufacturer = Tools::getValue('id_manufacturer')))
return Meta::getManufacturerMetas($id_manufacturer, $id_lang, $page_name);
elseif ($page_name == 'supplier' && ($id_supplier = Tools::getValue('id_supplier')))
return Meta::getSupplierMetas($id_supplier, $id_lang, $page_name);
elseif ($page_name == 'cms' && ($id_cms = Tools::getValue('id_cms')))
return Meta::getCmsMetas($id_cms, $id_lang, $page_name);
elseif ($page_name == 'cms' && ($id_cms_category = Tools::getValue('id_cms_category')))
return Meta::getCmsCategoryMetas($id_cms_category, $id_lang, $page_name);
elseif ($page_name == 'categorycms'&& ($id_category = Tools::getValue('id_category_cms')))
return Meta::getMetaCategoryCms($id_category, $id_lang, $page_name);
elseif ($page_name == 'postcms'&& ($id_post = Tools::getValue('id_post_cms')))
return Meta::getMetaPostCms($id_post, $id_lang, $page_name);
elseif ($page_name == 'postedito'&& ($id_edito = Tools::getValue('id_post_edito')))
return Meta::getMetaEditoCms($id_edito, $id_lang, $page_name);
}
return Meta::getHomeMetas($id_lang, $page_name);
}
public static function getMetaCategoryCms($id_category, $id_lang, $page_name) {
$sql = 'SELECT `meta_title`, `meta_desc`
FROM `'._DB_PREFIX_.'cmsps_categories_lang`
WHERE id_lang = '.(int)$id_lang.'
AND id_category = '.(int)$id_category.
((int)Context::getContext()->shop->id ?
' AND id_shop = '.(int)Context::getContext()->shop->id : '');
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) {
return Meta::completeMetaTags($row, $row['meta_title']);
}
return Meta::getHomeMetas($id_lang, $page_name);
}
public static function getMetaPostCms($id_post, $id_lang, $page_name) {
$sql = 'SELECT `meta_title`, `meta_desc`
FROM `'._DB_PREFIX_.'cmsps_posts_lang`
WHERE id_lang = '.(int)$id_lang.'
AND id_post = '.(int)$id_post.
((int)Context::getContext()->shop->id ?
' AND id_shop = '.(int)Context::getContext()->shop->id : '');
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) {
return Meta::completeMetaTags($row, $row['meta_title']);
}
return Meta::getHomeMetas($id_lang, $page_name);
}
public static function getMetaEditoCms($id_edito, $id_lang, $page_name) {
$sql = 'SELECT `meta_title`, `meta_desc`
FROM `'._DB_PREFIX_.'cmsps_editos_lang`
WHERE id_lang = '.(int)$id_lang.'
AND id_edito = '.(int)$id_edito.
((int)Context::getContext()->shop->id ?
' AND id_shop = '.(int)Context::getContext()->shop->id : '');
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql)) {
return Meta::completeMetaTags($row, $row['meta_title']);
}
return Meta::getHomeMetas($id_lang, $page_name);
}
}