modif sitemap
This commit is contained in:
parent
c64fb2e5f1
commit
08bb953dd4
@ -53,7 +53,11 @@ if ($gsitemapOverride->active)
|
|||||||
/* for the main run initiat the sitemap's files name stored in the database */
|
/* for the main run initiat the sitemap's files name stored in the database */
|
||||||
if (!isset($_GET['continue']))
|
if (!isset($_GET['continue']))
|
||||||
$gsitemapOverride->emptySitemap((int)$id_shop);
|
$gsitemapOverride->emptySitemap((int)$id_shop);
|
||||||
|
$gsitemapOverride->createSpecificSitemap(1, (int)$id_shop);
|
||||||
$gsitemapOverride->createSpecificSitemap(2, (int)$id_shop);
|
$gsitemapOverride->createSpecificSitemap(2, (int)$id_shop);
|
||||||
|
$gsitemapOverride->createSpecificSitemap(3, (int)$id_shop);
|
||||||
|
$gsitemapOverride->createSpecificSitemap(4, (int)$id_shop, true);
|
||||||
|
$gsitemapOverride->createSpecificSitemap(5, (int)$id_shop, true);
|
||||||
$gsitemapOverride->createSitemap((int)$id_shop);
|
$gsitemapOverride->createSitemap((int)$id_shop);
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,6 +376,7 @@ class Gsitemap extends Module
|
|||||||
if (isset($id_image['id_image']))
|
if (isset($id_image['id_image']))
|
||||||
{
|
{
|
||||||
$image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.(int)$id_image['id_image'], 'large_default');
|
$image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.(int)$id_image['id_image'], 'large_default');
|
||||||
|
|
||||||
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
||||||
array(
|
array(
|
||||||
'https',
|
'https',
|
||||||
|
@ -131,5 +131,15 @@ class Link extends LinkCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getPostCmsImageLink($id_post, $type = null)
|
||||||
|
{
|
||||||
|
if ($this->allow == 1 && $type) {
|
||||||
|
$uri_path = __PS_BASE_URI__.'img/cms_post/'.(int)$id_post.'/'.$type.'.jpg';
|
||||||
|
}
|
||||||
|
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ class GsitemapOverride extends Gsitemap
|
|||||||
{
|
{
|
||||||
/* @Override */
|
/* @Override */
|
||||||
protected $metas_plus;
|
protected $metas_plus;
|
||||||
|
private $sql_checks = array();
|
||||||
|
|
||||||
/* @Override */
|
/* @Override */
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -57,16 +58,43 @@ class GsitemapOverride extends Gsitemap
|
|||||||
$this->emptySitemap();
|
$this->emptySitemap();
|
||||||
$this->createSitemap();
|
$this->createSitemap();
|
||||||
}
|
}
|
||||||
elseif (Tools::isSubmit('SubmitBlogGsitemap'))
|
elseif (Tools::isSubmit('SubmitBlogCatGsitemap'))
|
||||||
{
|
{
|
||||||
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
||||||
$this->type_array = array('cmspscategory', 'cmspspost', 'cmspsedito');
|
$this->type_array = array('cmspscategory');
|
||||||
|
$this->metas_plus = array('cmspscategory');
|
||||||
|
$this->createSpecificSitemap(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif (Tools::isSubmit('SubmitBlogArticleGsitemap'))
|
||||||
|
{
|
||||||
|
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
||||||
|
$this->type_array = array('cmspspost');
|
||||||
|
$this->metas_plus = array('cmspspost');
|
||||||
$this->createSpecificSitemap(2);
|
$this->createSpecificSitemap(2);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif (Tools::isSubmit('SubmitImgGsitemap'))
|
elseif (Tools::isSubmit('SubmitBlogEditoGsitemap'))
|
||||||
{
|
{
|
||||||
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
||||||
|
$this->type_array = array('cmspsedito');
|
||||||
|
$this->metas_plus = array('cmspsedito');
|
||||||
|
$this->createSpecificSitemap(3);
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif (Tools::isSubmit('SubmitProductImgGsitemap'))
|
||||||
|
{
|
||||||
|
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
||||||
|
$this->type_array = array('product');
|
||||||
|
$this->metas_plus = array('product');
|
||||||
|
$this->createSpecificSitemap(4, 0, true);
|
||||||
|
}
|
||||||
|
elseif (Tools::isSubmit('SubmitArticleImgGsitemap'))
|
||||||
|
{
|
||||||
|
Configuration::updateValue('GSITEMAP_FREQUENCY', pSQL(Tools::getValue('gsitemap_frequency')));
|
||||||
|
$this->type_array = array('cmspspost');
|
||||||
|
$this->metas_plus = array('cmspspost');
|
||||||
|
$this->createSpecificSitemap(5, 0, true);
|
||||||
}
|
}
|
||||||
/* if no posted form and the variable [continue] is found in the HTTP request variable keep creating sitemap */
|
/* if no posted form and the variable [continue] is found in the HTTP request variable keep creating sitemap */
|
||||||
elseif (Tools::getValue('continue'))
|
elseif (Tools::getValue('continue'))
|
||||||
@ -101,7 +129,61 @@ class GsitemapOverride extends Gsitemap
|
|||||||
return $this->display(__FILE__, 'views/templates/admin/configuration.tpl');
|
return $this->display(__FILE__, 'views/templates/admin/configuration.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSpecificSitemap($index, $id_shop = 0)
|
public function createSitemap($id_shop = 0)
|
||||||
|
{
|
||||||
|
if (@fopen($this->normalizeDirectory(_PS_ROOT_DIR_).'/test.txt', 'w') == false)
|
||||||
|
{
|
||||||
|
$this->context->smarty->assign('google_maps_error', $this->l('An error occured while trying to check your file permissions. Please adjust your permissions to allow PrestaShop to write a file in your root directory.'));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
@unlink($this->normalizeDirectory(_PS_ROOT_DIR_).'test.txt');
|
||||||
|
|
||||||
|
if ($id_shop != 0)
|
||||||
|
$this->context->shop = new Shop((int)$id_shop);
|
||||||
|
|
||||||
|
$type = Tools::getValue('type') ? Tools::getValue('type') : '';
|
||||||
|
$languages = Language::getLanguages(true, $id_shop);
|
||||||
|
$lang_stop = Tools::getValue('lang') ? true : false;
|
||||||
|
$id_obj = Tools::getValue('id') ? (int)Tools::getValue('id') : 0;
|
||||||
|
foreach ($languages as $lang)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$index = (Tools::getValue('index') && Tools::getValue('lang') == $lang['iso_code']) ? (int)Tools::getValue('index') : 0;
|
||||||
|
if ($lang_stop && $lang['iso_code'] != Tools::getValue('lang'))
|
||||||
|
continue;
|
||||||
|
elseif ($lang_stop && $lang['iso_code'] == Tools::getValue('lang'))
|
||||||
|
$lang_stop = false;
|
||||||
|
|
||||||
|
$link_sitemap = array();
|
||||||
|
foreach ($this->type_array as $type_val)
|
||||||
|
{
|
||||||
|
if ($type == '' || $type == $type_val)
|
||||||
|
{
|
||||||
|
$function = '_get'.ucfirst($type_val).'Link';
|
||||||
|
if (!$this->$function($link_sitemap, $lang, $index, $i, $id_obj))
|
||||||
|
return false;
|
||||||
|
$type = '';
|
||||||
|
$id_obj = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_recursiveSitemapCreator($link_sitemap, $lang['iso_code'], $index);
|
||||||
|
$page = '';
|
||||||
|
$index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_createIndexSitemap();
|
||||||
|
Configuration::updateValue('GSITEMAP_LAST_EXPORT', date('r'));
|
||||||
|
Tools::file_get_contents('http://www.google.com/webmasters/sitemaps/ping?sitemap='.urlencode('http'.(Configuration::get('PS_SSL_ENABLED') ? 's' : '').'://'.Tools::getShopDomain(false, true).$this->context->shop->physical_uri.$this->context->shop->virtual_uri.$this->context->shop->id.'_index_sitemap.xml'));
|
||||||
|
|
||||||
|
if ($this->cron)
|
||||||
|
die();
|
||||||
|
header('location: ./index.php?tab=AdminModules&configure=gsitemap&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='.$this->tab.'&module_name=gsitemap&validation');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createSpecificSitemap($index, $id_shop = 0, $img_url=false)
|
||||||
{
|
{
|
||||||
if (@fopen($this->normalizeDirectory(_PS_ROOT_DIR_).'/test.txt', 'w') == false)
|
if (@fopen($this->normalizeDirectory(_PS_ROOT_DIR_).'/test.txt', 'w') == false)
|
||||||
{
|
{
|
||||||
@ -134,8 +216,11 @@ class GsitemapOverride extends Gsitemap
|
|||||||
if ($type == '' || $type == $type_val)
|
if ($type == '' || $type == $type_val)
|
||||||
{
|
{
|
||||||
$function = '_get'.ucfirst($type_val).'Link';
|
$function = '_get'.ucfirst($type_val).'Link';
|
||||||
if (!$this->$function($link_sitemap, $lang, $index, $i, $id_obj))
|
if($img_url && !$this->$function($link_sitemap, $lang, $index, $i, $id_obj, true)) {
|
||||||
return false;
|
return false;
|
||||||
|
} elseif (!$this->$function($link_sitemap, $lang, $index, $i, $id_obj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$type = '';
|
$type = '';
|
||||||
$id_obj = 0;
|
$id_obj = 0;
|
||||||
}
|
}
|
||||||
@ -183,6 +268,7 @@ class GsitemapOverride extends Gsitemap
|
|||||||
$write_fd = fopen($this->normalizeDirectory(_PS_ROOT_DIR_).$sitemap_link, 'w');
|
$write_fd = fopen($this->normalizeDirectory(_PS_ROOT_DIR_).$sitemap_link, 'w');
|
||||||
|
|
||||||
fwrite($write_fd, '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\r\n");
|
fwrite($write_fd, '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\r\n");
|
||||||
|
|
||||||
foreach ($link_sitemap as $key => $file)
|
foreach ($link_sitemap as $key => $file)
|
||||||
{
|
{
|
||||||
fwrite($write_fd, '<url>'."\r\n");
|
fwrite($write_fd, '<url>'."\r\n");
|
||||||
@ -315,6 +401,360 @@ class GsitemapOverride extends Gsitemap
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getHomeLink(&$link_sitemap, $lang, &$index, &$i)
|
||||||
|
{
|
||||||
|
if (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'))
|
||||||
|
$protocol = 'https://';
|
||||||
|
else
|
||||||
|
$protocol = 'http://';
|
||||||
|
|
||||||
|
return $this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'home',
|
||||||
|
'page' => 'home',
|
||||||
|
'link' => $protocol.Tools::getShopDomainSsl(false).$this->context->shop->getBaseURI().(method_exists('Language', 'isMultiLanguageActivated') ? Language::isMultiLanguageActivated() ? $lang['iso_code'].'/' : '' : ''),
|
||||||
|
'image' => false
|
||||||
|
), $lang['iso_code'], $index, $i, -1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getMetaLink(&$link_sitemap, $lang, &$index, &$i, $id_meta = 0)
|
||||||
|
{
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
$link = new Link();
|
||||||
|
if (version_compare(_PS_VERSION_, '1.6', '>='))
|
||||||
|
$metas = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'meta` WHERE `configurable` > 0 AND `id_meta` >= '.(int)$id_meta.' ORDER BY `id_meta` ASC');
|
||||||
|
else
|
||||||
|
$metas = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'meta` WHERE `id_meta` >= '.(int)$id_meta.' ORDER BY `id_meta` ASC');
|
||||||
|
foreach ($metas as $meta)
|
||||||
|
{
|
||||||
|
$url = '';
|
||||||
|
if (!in_array($meta['id_meta'], explode(',', Configuration::get('GSITEMAP_DISABLE_LINKS'))))
|
||||||
|
{
|
||||||
|
$url_rewrite = Db::getInstance()->getValue('SELECT url_rewrite, id_shop FROM `'._DB_PREFIX_.'meta_lang` WHERE `id_meta` = '.(int)$meta['id_meta'].' AND `id_shop` ='.(int)$this->context->shop->id.' AND `id_lang` = '.(int)$lang['id_lang']);
|
||||||
|
Dispatcher::getInstance()->addRoute($meta['page'], (isset($url_rewrite) ? $url_rewrite : $meta['page']), $meta['page'], $lang['id_lang']);
|
||||||
|
$uri_path = Dispatcher::getInstance()->createUrl($meta['page'], $lang['id_lang'], array(), (bool)Configuration::get('PS_REWRITING_SETTINGS'));
|
||||||
|
$url .= Tools::getShopDomainSsl(true).(($this->context->shop->virtual_uri) ? __PS_BASE_URI__.$this->context->shop->virtual_uri : __PS_BASE_URI__).(Language::isMultiLanguageActivated() ? $lang['iso_code'].'/' : '').ltrim($uri_path, '/');
|
||||||
|
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'meta',
|
||||||
|
'page' => $meta['page'],
|
||||||
|
'link' => $url,
|
||||||
|
'image' => false
|
||||||
|
), $lang['iso_code'], $index, $i, $meta['id_meta']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getProductLink(&$link_sitemap, $lang, &$index, &$i, $id_product = 0, $img_url=false)
|
||||||
|
{
|
||||||
|
$link = new Link();
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
|
||||||
|
$products_id = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `'._DB_PREFIX_.'product_shop` WHERE `id_product` >= '.intval($id_product).' AND `active` = 1 AND `id_shop`='.$this->context->shop->id.' ORDER BY `id_product` ASC');
|
||||||
|
|
||||||
|
foreach ($products_id as $product_id)
|
||||||
|
{
|
||||||
|
$product = new Product((int)$product_id['id_product'], false, (int)$lang['id_lang']);
|
||||||
|
|
||||||
|
$url = $link->getProductLink($product, $product->link_rewrite, htmlspecialchars(strip_tags($product->category)), $product->ean13, (int)$lang['id_lang'], (int)$this->context->shop->id, 0, true);
|
||||||
|
|
||||||
|
if(Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')==true || $img_url) {
|
||||||
|
|
||||||
|
$id_image = Product::getCover((int)$product_id['id_product']);
|
||||||
|
if (isset($id_image['id_image']))
|
||||||
|
{
|
||||||
|
$image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.(int)$id_image['id_image'], 'large_default');
|
||||||
|
|
||||||
|
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
||||||
|
array(
|
||||||
|
'https',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri
|
||||||
|
), array(
|
||||||
|
'http',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri.Context::getContext()->shop->virtual_uri
|
||||||
|
), $image_link
|
||||||
|
) : $image_link;
|
||||||
|
}
|
||||||
|
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
|
||||||
|
$image_product = array();
|
||||||
|
if (isset($image_link) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
||||||
|
$image_product = array(
|
||||||
|
'title_img' => htmlspecialchars(strip_tags($product->name)),
|
||||||
|
'caption' => htmlspecialchars(strip_tags($product->description_short)),
|
||||||
|
'link' => $image_link
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$image_product = false;
|
||||||
|
}
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'product',
|
||||||
|
'page' => 'product',
|
||||||
|
'lastmod' => $product->date_upd,
|
||||||
|
'link' => $url,
|
||||||
|
'image' => $image_product
|
||||||
|
), $lang['iso_code'], $index, $i, $product_id['id_product']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
unset($image_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getSupplierLink(&$link_sitemap, $lang, &$index, &$i, $id_supplier = 0)
|
||||||
|
{
|
||||||
|
$link = new Link();
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
$suppliers_id = Db::getInstance()->ExecuteS(
|
||||||
|
'SELECT s.`id_supplier` FROM `'._DB_PREFIX_.'supplier` s
|
||||||
|
INNER JOIN `'._DB_PREFIX_.'supplier_lang` sl ON s.`id_supplier` = sl.`id_supplier` '.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'supplier_shop') ? 'INNER JOIN `'._DB_PREFIX_.'supplier_shop` ss ON s.`id_supplier` = ss.`id_supplier`' : '').'
|
||||||
|
WHERE s.`active` = 1 AND s.`id_supplier` >= '.(int)$id_supplier.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'supplier_shop') ? ' AND ss.`id_shop` = '.(int)$this->context->shop->id : '').'
|
||||||
|
AND sl.`id_lang` = '.(int)$lang['id_lang'].'
|
||||||
|
ORDER BY s.`id_supplier` ASC'
|
||||||
|
);
|
||||||
|
foreach ($suppliers_id as $supplier_id)
|
||||||
|
{
|
||||||
|
$supplier = new Supplier((int)$supplier_id['id_supplier'], $lang['id_lang']);
|
||||||
|
$url = $link->getSupplierLink($supplier, $supplier->link_rewrite, $lang['id_lang']);
|
||||||
|
if(Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')==true) {
|
||||||
|
$image_link = 'http://'.Tools::getMediaServer(_THEME_SUP_DIR_)._THEME_SUP_DIR_.((!file_exists(_THEME_SUP_DIR_.'/'.(int)$supplier->id.'-medium_default.jpg')) ? $lang['iso_code'].'-default' : (int)$supplier->id).'-medium_default.jpg';
|
||||||
|
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
||||||
|
array(
|
||||||
|
'https',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri
|
||||||
|
), array(
|
||||||
|
'http',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri.Context::getContext()->shop->virtual_uri
|
||||||
|
), $image_link
|
||||||
|
) : $image_link;
|
||||||
|
|
||||||
|
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
|
||||||
|
$supplier_image = array();
|
||||||
|
if ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true)
|
||||||
|
$supplier_image = array(
|
||||||
|
'title_img' => htmlspecialchars(strip_tags($supplier->name)),
|
||||||
|
'link' => 'http'.(Configuration::get('PS_SSL_ENABLED') ? 's' : '').'://'.Tools::getMediaServer(_THEME_SUP_DIR_)._THEME_SUP_DIR_.((!file_exists(_THEME_SUP_DIR_.'/'.(int)$supplier->id.'-medium_default.jpg')) ? $lang['iso_code'].'-default' : (int)$supplier->id).'-medium_default.jpg'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$supplier_image = false;
|
||||||
|
}
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'supplier',
|
||||||
|
'page' => 'supplier',
|
||||||
|
'lastmod' => $supplier->date_upd,
|
||||||
|
'link' => $url,
|
||||||
|
'image' => $supplier_image
|
||||||
|
), $lang['iso_code'], $index, $i, $supplier_id['id_supplier']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getCmsLink(&$link_sitemap, $lang, &$index, &$i, $id_cms = 0)
|
||||||
|
{
|
||||||
|
$link = new Link();
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
$cmss_id = Db::getInstance()->ExecuteS(
|
||||||
|
'SELECT c.`id_cms` FROM `'._DB_PREFIX_.'cms` c INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms` '.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'supplier_shop') ? 'INNER JOIN `'._DB_PREFIX_.'cms_shop` cs ON c.`id_cms` = cs.`id_cms` ' : '').
|
||||||
|
'INNER JOIN `'._DB_PREFIX_.'cms_category` cc ON c.id_cms_category = cc.id_cms_category AND cc.active = 1
|
||||||
|
WHERE c.`active` =1 AND c.`indexation` =1 AND c.`id_cms` >= '.(int)$id_cms.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'supplier_shop') ? ' AND cs.id_shop = '.(int)$this->context->shop->id : '').
|
||||||
|
' AND cl.`id_lang` = '.(int)$lang['id_lang'].
|
||||||
|
' ORDER BY c.`id_cms` ASC'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_array($cmss_id))
|
||||||
|
foreach ($cmss_id as $cms_id)
|
||||||
|
{
|
||||||
|
$cms = new CMS((int)$cms_id['id_cms'], $lang['id_lang']);
|
||||||
|
$cms->link_rewrite = urlencode((is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$lang['id_lang']] : $cms->link_rewrite));
|
||||||
|
$url = $link->getCMSLink($cms, null, null, $lang['id_lang']);
|
||||||
|
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'cms',
|
||||||
|
'page' => 'cms',
|
||||||
|
'link' => $url,
|
||||||
|
'image' => false
|
||||||
|
), $lang['iso_code'], $index, $i, $cms_id['id_cms']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getModuleLink(&$link_sitemap, $lang, &$index, &$i, $num_link = 0)
|
||||||
|
{
|
||||||
|
$modules_links = Hook::exec(self::HOOK_ADD_URLS, array('lang' => $lang), null, true);
|
||||||
|
if (empty($modules_links) || !is_array($modules_links))
|
||||||
|
return true;
|
||||||
|
$links = array();
|
||||||
|
foreach ($modules_links as $module_links)
|
||||||
|
$links = array_merge($links, $module_links);
|
||||||
|
foreach ($module_links as $n => $link)
|
||||||
|
{
|
||||||
|
if ($num_link > $n)
|
||||||
|
continue;
|
||||||
|
$link['type'] = 'module';
|
||||||
|
if (!$this->_addLinkToSitemap($link_sitemap, $link, $lang['iso_code'], $index, $i, $n))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Override
|
||||||
|
*/
|
||||||
|
private function _getCategoryLink(&$link_sitemap, $lang, &$index, &$i, $id_category = 0)
|
||||||
|
{
|
||||||
|
$link = new Link();
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
|
||||||
|
$categories_id = Db::getInstance()->ExecuteS(
|
||||||
|
'SELECT c.id_category FROM `'._DB_PREFIX_.'category` c
|
||||||
|
INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON c.`id_category` = cs.`id_category`
|
||||||
|
WHERE c.`id_category` >= '.intval($id_category).' AND c.`active` = 1 AND c.`id_category` != 1 AND c.id_parent > 0 AND c.`id_category` > 0 AND cs.`id_shop` = '.(int)$this->context->shop->id.' ORDER BY c.`id_category` ASC'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($categories_id as $category_id)
|
||||||
|
{
|
||||||
|
$category = new Category((int)$category_id['id_category'], (int)$lang['id_lang']);
|
||||||
|
$url = $link->getCategoryLink($category, urlencode($category->link_rewrite), (int)$lang['id_lang']);
|
||||||
|
|
||||||
|
if (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')==true) {
|
||||||
|
if ($category->id_image)
|
||||||
|
{
|
||||||
|
$image_link = $this->context->link->getCatImageLink($category->link_rewrite, (int)$category->id_image, 'category_default');
|
||||||
|
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
||||||
|
array(
|
||||||
|
'https',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri
|
||||||
|
), array(
|
||||||
|
'http',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri.Context::getContext()->shop->virtual_uri
|
||||||
|
), $image_link
|
||||||
|
) : $image_link;
|
||||||
|
}
|
||||||
|
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
|
||||||
|
$image_category = array();
|
||||||
|
if (isset($image_link) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
||||||
|
$image_category = array(
|
||||||
|
'title_img' => htmlspecialchars(strip_tags($category->name)),
|
||||||
|
'link' => $image_link
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$image_category = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'category',
|
||||||
|
'page' => 'category',
|
||||||
|
'lastmod' => $category->date_upd,
|
||||||
|
'link' => $url,
|
||||||
|
'image' => $image_category
|
||||||
|
), $lang['iso_code'], $index, $i, (int)$category_id['id_category']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
unset($image_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getManufacturerLink(&$link_sitemap, $lang, &$index, &$i, $id_manufacturer = 0)
|
||||||
|
{
|
||||||
|
$link = new Link();
|
||||||
|
if (method_exists('ShopUrl', 'resetMainDomainCache'))
|
||||||
|
ShopUrl::resetMainDomainCache();
|
||||||
|
$manufacturers_id = Db::getInstance()->ExecuteS(
|
||||||
|
'SELECT m.`id_manufacturer` FROM `'._DB_PREFIX_.'manufacturer` m
|
||||||
|
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml on m.`id_manufacturer` = ml.`id_manufacturer`'.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'manufacturer_shop') ? ' INNER JOIN `'._DB_PREFIX_.'manufacturer_shop` ms ON m.`id_manufacturer` = ms.`id_manufacturer` ' : '').
|
||||||
|
' WHERE m.`active` = 1 AND m.`id_manufacturer` >= '.(int)$id_manufacturer.
|
||||||
|
($this->tableColumnExists(_DB_PREFIX_.'manufacturer_shop') ? ' AND ms.`id_shop` = '.(int)$this->context->shop->id : '').
|
||||||
|
' AND ml.`id_lang` = '.(int)$lang['id_lang'].
|
||||||
|
' ORDER BY m.`id_manufacturer` ASC'
|
||||||
|
);
|
||||||
|
foreach ($manufacturers_id as $manufacturer_id)
|
||||||
|
{
|
||||||
|
$manufacturer = new Manufacturer((int)$manufacturer_id['id_manufacturer'], $lang['id_lang']);
|
||||||
|
$url = $link->getManufacturerLink($manufacturer, $manufacturer->link_rewrite, $lang['id_lang']);
|
||||||
|
|
||||||
|
if (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')==true) {
|
||||||
|
$image_link = 'http'.(Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE') ? 's' : '').'://'.Tools::getMediaServer(_THEME_MANU_DIR_)._THEME_MANU_DIR_.((!file_exists(_PS_MANU_IMG_DIR_.'/'.(int)$manufacturer->id.'-medium_default.jpg')) ? $lang['iso_code'].'-default' : (int)$manufacturer->id).'-medium_default.jpg';
|
||||||
|
$image_link = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link))) ? str_replace(
|
||||||
|
array(
|
||||||
|
'https',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri
|
||||||
|
), array(
|
||||||
|
'http',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri.Context::getContext()->shop->virtual_uri
|
||||||
|
), $image_link
|
||||||
|
) : $image_link;
|
||||||
|
|
||||||
|
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_link) : true;
|
||||||
|
$manifacturer_image = array();
|
||||||
|
if ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true)
|
||||||
|
$manifacturer_image = array(
|
||||||
|
'title_img' => htmlspecialchars(strip_tags($manufacturer->name)),
|
||||||
|
'caption' => htmlspecialchars(strip_tags($manufacturer->short_description)),
|
||||||
|
'link' => $image_link
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$manifacturer_image = false;
|
||||||
|
}
|
||||||
|
if (!$this->_addLinkToSitemap(
|
||||||
|
$link_sitemap, array(
|
||||||
|
'type' => 'manufacturer',
|
||||||
|
'page' => 'manufacturer',
|
||||||
|
'lastmod' => $manufacturer->date_upd,
|
||||||
|
'link' => $url,
|
||||||
|
'image' => $manifacturer_image
|
||||||
|
), $lang['iso_code'], $index, $i, $manufacturer_id['id_manufacturer']
|
||||||
|
))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hydrate $link_sitemap with cmspscategories link
|
* Hydrate $link_sitemap with cmspscategories link
|
||||||
*
|
*
|
||||||
@ -349,25 +789,13 @@ class GsitemapOverride extends Gsitemap
|
|||||||
$category = new CmsPsCategory((int)$category_id['id_category'], (int)$lang['id_lang']);
|
$category = new CmsPsCategory((int)$category_id['id_category'], (int)$lang['id_lang']);
|
||||||
$url = $link->getCategoryCmsLink((int)$category->id);
|
$url = $link->getCategoryCmsLink((int)$category->id);
|
||||||
|
|
||||||
if(file_exists(_CMS_CAT_IMG_DIR_.(int)$category->id.'.jpg')) {
|
|
||||||
$image = _CMS_CAT_IMG_DIR_.(int)$category->id.'.jpg';
|
|
||||||
$image_url = ImageManager::thumbnail($image, 'cmsps_categories_'.(int)(int)$category->id.'.jpg', 350, 'jpg', true, true);
|
|
||||||
}
|
|
||||||
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_url) : true;
|
|
||||||
$image_category = array();
|
|
||||||
if (isset($image_url) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
|
||||||
$image_category = array(
|
|
||||||
'title_img' => htmlspecialchars(strip_tags($category->title)),
|
|
||||||
'link' => $image_url
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$this->_addLinkToSitemap(
|
if (!$this->_addLinkToSitemap(
|
||||||
$link_sitemap, array(
|
$link_sitemap, array(
|
||||||
'type' => 'cmspscategory',
|
'type' => 'cmspscategory',
|
||||||
'page' => 'categorycms',
|
'page' => 'categorycms',
|
||||||
'lastmod' => $category->date_upd,
|
'lastmod' => $category->date_upd,
|
||||||
'link' => $url,
|
'link' => $url,
|
||||||
'image' => $image_category
|
'image' => false
|
||||||
), $lang['iso_code'], $index, $i, (int)$category->id
|
), $lang['iso_code'], $index, $i, (int)$category->id
|
||||||
))
|
))
|
||||||
return false;
|
return false;
|
||||||
@ -389,7 +817,7 @@ class GsitemapOverride extends Gsitemap
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _getCmspspostLink(&$link_sitemap, $lang, &$index, &$i, $id_post = 0)
|
protected function _getCmspspostLink(&$link_sitemap, $lang, &$index, &$i, $id_post = 0, $img_url=false)
|
||||||
{
|
{
|
||||||
if(!class_exists('CmsPS')) {
|
if(!class_exists('CmsPS')) {
|
||||||
require _PS_MODULE_DIR_.'cmsps/cmsps.php';
|
require _PS_MODULE_DIR_.'cmsps/cmsps.php';
|
||||||
@ -411,20 +839,29 @@ class GsitemapOverride extends Gsitemap
|
|||||||
{
|
{
|
||||||
$post = new CmsPsPost((int)$post_id['id_post'], (int)$lang['id_lang']);
|
$post = new CmsPsPost((int)$post_id['id_post'], (int)$lang['id_lang']);
|
||||||
$url = $link->getPostCmsLink((int)$post->id, (int)$lang['id_lang']);
|
$url = $link->getPostCmsLink((int)$post->id, (int)$lang['id_lang']);
|
||||||
|
|
||||||
if(file_exists(_CMS_CAT_IMG_DIR_.(int)$post->id.'.jpg')) {
|
if(Configuration::get('GSITEMAP_CHECK_IMAGE_FILE') == true || $img_url) {
|
||||||
$image = _CMS_CAT_IMG_DIR_.(int)$post->id.'.jpg';
|
$image_post = array();
|
||||||
$image_url = ImageManager::thumbnail($image, 'cmsps_posts_'.(int)(int)$post->id.'.jpg', 350, 'jpg', true, true);
|
$image_url = $this->context->link->getPostCmsImageLink((int)$post->id, 'small');
|
||||||
}
|
$image_url = (!in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_url))) ? str_replace(
|
||||||
|
array(
|
||||||
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_url) : true;
|
'https',
|
||||||
$image_post = array();
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri
|
||||||
if (isset($image_url) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
), array(
|
||||||
|
'http',
|
||||||
|
Context::getContext()->shop->domain.Context::getContext()->shop->physical_uri.Context::getContext()->shop->virtual_uri
|
||||||
|
), $image_url
|
||||||
|
) : $image_url;
|
||||||
|
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_url) : true;
|
||||||
|
if (isset($image_url) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
||||||
$image_post = array(
|
$image_post = array(
|
||||||
'title_img' => htmlspecialchars(strip_tags($post->title)),
|
'title_img' => htmlspecialchars(strip_tags($post->title)),
|
||||||
'link' => $image_url
|
'link' => $image_url
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$image_post = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->_addLinkToSitemap(
|
if (!$this->_addLinkToSitemap(
|
||||||
$link_sitemap, array(
|
$link_sitemap, array(
|
||||||
'type' => 'cmspspost',
|
'type' => 'cmspspost',
|
||||||
@ -476,25 +913,13 @@ class GsitemapOverride extends Gsitemap
|
|||||||
$edito = new CmsPsEdito((int)$edito_id['id_edito'], (int)$lang['id_lang']);
|
$edito = new CmsPsEdito((int)$edito_id['id_edito'], (int)$lang['id_lang']);
|
||||||
$url = $link->getPostEditoLink((int)$edito->id);
|
$url = $link->getPostEditoLink((int)$edito->id);
|
||||||
|
|
||||||
if(file_exists(_CMS_CAT_IMG_DIR_.(int)$edito->id.'.jpg')) {
|
|
||||||
$image = _CMS_CAT_IMG_DIR_.(int)$edito->id.'.jpg';
|
|
||||||
$image_url = ImageManager::thumbnail($image, 'cmsps_editos_'.(int)(int)$edito->id.'.jpg', 350, 'jpg', true, true);
|
|
||||||
}
|
|
||||||
$file_headers = (Configuration::get('GSITEMAP_CHECK_IMAGE_FILE')) ? @get_headers($image_url) : true;
|
|
||||||
$image_edito = array();
|
|
||||||
if (isset($image_url) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true))
|
|
||||||
$image_edito = array(
|
|
||||||
'title_img' => htmlspecialchars(strip_tags($edito->title)),
|
|
||||||
'link' => $image_url
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$this->_addLinkToSitemap(
|
if (!$this->_addLinkToSitemap(
|
||||||
$link_sitemap, array(
|
$link_sitemap, array(
|
||||||
'type' => 'cmspsedito',
|
'type' => 'cmspsedito',
|
||||||
'page' => 'editocms',
|
'page' => 'editocms',
|
||||||
'lastmod' => $edito->date_upd,
|
'lastmod' => $edito->date_upd,
|
||||||
'link' => $url,
|
'link' => $url,
|
||||||
'image' => $image_edito
|
'image' => false
|
||||||
), $lang['iso_code'], $index, $i, (int)$edito->id
|
), $lang['iso_code'], $index, $i, (int)$edito->id
|
||||||
))
|
))
|
||||||
return false;
|
return false;
|
||||||
@ -504,4 +929,5 @@ class GsitemapOverride extends Gsitemap
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -131,18 +131,22 @@
|
|||||||
<div class="col-lg-6 col-lg-offset-4">
|
<div class="col-lg-6 col-lg-offset-4">
|
||||||
<form class="" action="{$gsitemap_form|escape:'htmlall':'UTF-8'}" method="post">
|
<form class="" action="{$gsitemap_form|escape:'htmlall':'UTF-8'}" method="post">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<label for="gsitemap_frequency" >{l s='How often do you update your store?' mod='gsitemap'}
|
<input class="btn btn-default" type="submit" name="SubmitBlogCatGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for blog categories' mod='gsitemap'}" />
|
||||||
<select name="gsitemap_frequency" class="form-control">
|
<input class="btn btn-default" type="submit" name="SubmitBlogArticleGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for blog articles' mod='gsitemap'}" />
|
||||||
<option{if $gsitemap_frequency == 'always'} selected="selected"{/if} value='always'>{l s='always' mod='gsitemap'}</option>
|
<input class="btn btn-default" type="submit" name="SubmitBlogEditoGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for blog editos' mod='gsitemap'}" />
|
||||||
<option{if $gsitemap_frequency == 'hourly'} selected="selected"{/if} value='hourly'>{l s='hourly' mod='gsitemap'}</option>
|
</div>
|
||||||
<option{if $gsitemap_frequency == 'daily'} selected="selected"{/if} value='daily'>{l s='daily' mod='gsitemap'}</option>
|
</form>
|
||||||
<option{if $gsitemap_frequency == 'weekly' || $gsitemap_frequency == ''} selected="selected"{/if} value='weekly'>{l s='weekly' mod='gsitemap'}</option>
|
</div>
|
||||||
<option{if $gsitemap_frequency == 'monthly'} selected="selected"{/if} value='monthly'>{l s='monthly' mod='gsitemap'}</option>
|
</div>
|
||||||
<option{if $gsitemap_frequency == 'yearly'} selected="selected"{/if} value='yearly'>{l s='yearly' mod='gsitemap'}</option>
|
<div class="panel clearfix">
|
||||||
<option{if $gsitemap_frequency == 'never'} selected="selected"{/if} value='never'>{l s='never' mod='gsitemap'}</option>
|
<div class="panel-heading">
|
||||||
</select>
|
<img src="{$module_dir|escape:'htmlall':'UTF-8'}logo.gif" alt="" /> {l s='Generate specific image Sitemaps' mod='gsitemap'}
|
||||||
</label>
|
</div>
|
||||||
<input class="btn btn-default" type="submit" name="SubmitBlogGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for blog' mod='gsitemap'}" />
|
<div class="col-lg-6 col-lg-offset-4">
|
||||||
|
<form class="" action="{$gsitemap_form|escape:'htmlall':'UTF-8'}" method="post">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input class="btn btn-default" type="submit" name="SubmitProductImgGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for Product Images' mod='gsitemap'}" />
|
||||||
|
<input class="btn btn-default" type="submit" name="SubmitArticleImgGsitemap" onclick="$('#gsitemap_loader').show();" value="{l s='Generate Sitemap for Article Images' mod='gsitemap'}" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user