// Merge -> 10309
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10333 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -156,73 +156,13 @@ XML;
|
||||
|
||||
$xml = new SimpleXMLElement($xmlString);
|
||||
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS') AND sizeof($langs) > 1)
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS') && count($langs) > 1)
|
||||
foreach($langs as $lang)
|
||||
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.$lang['iso_code'].'/', '1.00', 'daily', date('Y-m-d'));
|
||||
else
|
||||
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__, '1.00', 'daily', date('Y-m-d'));
|
||||
|
||||
/* CMS Generator */
|
||||
if (Configuration::get('GSITEMAP_ALL_CMS') OR !Module::isInstalled('blockcms'))
|
||||
$sql = 'SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').'
|
||||
FROM '._DB_PREFIX_.'cms_lang cl
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
|
||||
LEFT JOIN '._DB_PREFIX_.'cms_shop cs ON cs.id_cms = cl.id_cms
|
||||
WHERE l.`active` = 1
|
||||
AND cs.id_shop = '.$shopID.'
|
||||
ORDER BY cl.id_cms, cl.id_lang ASC';
|
||||
else if (Module::isInstalled('blockcms'))
|
||||
$sql = 'SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').'
|
||||
FROM '._DB_PREFIX_.'cms_block_page b
|
||||
LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (b.id_cms = cl.id_cms)
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
|
||||
LEFT JOIN '._DB_PREFIX_.'cms_shop cs ON cs.id_cms = cl.id_cms
|
||||
WHERE l.`active` = 1
|
||||
AND cs.id_shop = '.$shopID.'
|
||||
ORDER BY cl.id_cms, cl.id_lang ASC';
|
||||
|
||||
$cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
foreach ($cmss AS $cms)
|
||||
{
|
||||
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $this->context->link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $this->context->link->getCMSLink((int)$cms['id_cms']);
|
||||
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
|
||||
}
|
||||
|
||||
/* Categories Generator */
|
||||
$limits = Category::getInterval($shop->getCategory());
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
{
|
||||
$sql = 'SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON c.id_category = cl.id_category AND cl.id_shop = '.$shopID.'
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON cl.id_lang = l.id_lang
|
||||
WHERE l.`active` = 1
|
||||
AND c.`active` = 1
|
||||
AND c.id_category != 1
|
||||
AND nleft >= '.$limits['nleft'].'
|
||||
AND nright <= '.$limits['nright'].'
|
||||
ORDER BY cl.id_category, cl.id_lang ASC';
|
||||
$categories = Db::getInstance()->executeS($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
WHERE nleft >= '.$limits['nleft'].'
|
||||
AND nright <= '.$limits['nright'].'
|
||||
ORDER BY c.id_category ASC';
|
||||
$categories = Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
foreach($categories as $category)
|
||||
{
|
||||
if (($priority = 0.9 - ($category['level_depth'] / 10)) < 0.1)
|
||||
$priority = 0.1;
|
||||
|
||||
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $this->context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $this->context->link->getCategoryLink((int)$category['id_category']);
|
||||
$this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($category['date_upd'], 0, 10));
|
||||
}
|
||||
|
||||
/* Product Generator */
|
||||
$sql = 'SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, (
|
||||
SELECT MIN(level_depth)
|
||||
FROM '._DB_PREFIX_.'product p2
|
||||
@@ -245,7 +185,7 @@ XML;
|
||||
|
||||
$tmp = null;
|
||||
$res = null;
|
||||
foreach($products AS $product)
|
||||
foreach ($products as $product)
|
||||
{
|
||||
if ($tmp == $product['id_product'])
|
||||
$res[$tmp]['images'] []= array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']);
|
||||
@@ -268,18 +208,65 @@ XML;
|
||||
$sitemap = $this->_addSitemapNodeImage($sitemap, $product);
|
||||
}
|
||||
|
||||
/* Categories Generator */
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
$categories = Db::getInstance()->ExecuteS('
|
||||
SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON c.id_category = cl.id_category
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON cl.id_lang = l.id_lang
|
||||
WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1
|
||||
ORDER BY cl.id_category, cl.id_lang ASC');
|
||||
else
|
||||
$categories = Db::getInstance()->ExecuteS(
|
||||
'SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
ORDER BY c.id_category ASC');
|
||||
|
||||
|
||||
foreach($categories as $category)
|
||||
{
|
||||
if (($priority = 0.9 - ($category['level_depth'] / 10)) < 0.1)
|
||||
$priority = 0.1;
|
||||
|
||||
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $link->getCategoryLink((int)$category['id_category']);
|
||||
$this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10));
|
||||
}
|
||||
|
||||
/* CMS Generator */
|
||||
if (Configuration::get('GSITEMAP_ALL_CMS') || !Module::isInstalled('blockcms'))
|
||||
$sql_cms = '
|
||||
SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').
|
||||
' FROM '._DB_PREFIX_.'cms_lang cl
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
|
||||
WHERE l.`active` = 1
|
||||
ORDER BY cl.id_cms, cl.id_lang ASC';
|
||||
else if (Module::isInstalled('blockcms'))
|
||||
$sql_cms = '
|
||||
SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').
|
||||
' FROM '._DB_PREFIX_.'cms_block_page b
|
||||
LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (b.id_cms = cl.id_cms)
|
||||
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
|
||||
WHERE l.`active` = 1
|
||||
ORDER BY cl.id_cms, cl.id_lang ASC';
|
||||
|
||||
$cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms);
|
||||
foreach($cmss as $cms)
|
||||
{
|
||||
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $link->getCMSLink((int)$cms['id_cms']);
|
||||
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
|
||||
}
|
||||
|
||||
/* Add classic pages (contact, best sales, new products...) */
|
||||
$pages = array(
|
||||
'authentication' => true,
|
||||
'best-sales' => false,
|
||||
'contact' => true,
|
||||
'discount' => false,
|
||||
'index' => false,
|
||||
'supplier' => false,
|
||||
'manufacturer' => false,
|
||||
'new-products' => false,
|
||||
'prices-drop' => false,
|
||||
'supplier' => false,
|
||||
'store' => false);
|
||||
'stores' => false,
|
||||
'authentication' => true,
|
||||
'best-sales' => false,
|
||||
'contact-form' => true);
|
||||
|
||||
// Don't show suppliers and manufacturers if they are disallowed
|
||||
if (!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS'))
|
||||
@@ -290,11 +277,11 @@ XML;
|
||||
|
||||
// Generate nodes for pages
|
||||
if(Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
foreach ($pages AS $page => $ssl)
|
||||
foreach ($pages as $page => $ssl)
|
||||
foreach($langs as $lang)
|
||||
$this->_addSitemapNode($xml, $this->context->link->getPageLink($page, $ssl, $lang['id_lang']), '0.5', 'monthly');
|
||||
else
|
||||
foreach($pages AS $page => $ssl)
|
||||
foreach($pages as $page => $ssl)
|
||||
$this->_addSitemapNode($xml, $this->context->link->getPageLink($page, $ssl), '0.5', 'monthly');
|
||||
|
||||
$xmlString = $xml->asXML();
|
||||
@@ -344,14 +331,14 @@ XML;
|
||||
|
||||
private function _displaySitemap()
|
||||
{
|
||||
if (file_exists(GSITEMAP_FILE) AND filesize(GSITEMAP_FILE))
|
||||
if (file_exists(GSITEMAP_FILE) && filesize(GSITEMAP_FILE))
|
||||
{
|
||||
$fp = fopen(GSITEMAP_FILE, 'r');
|
||||
$fstat = fstat($fp);
|
||||
fclose($fp);
|
||||
$xml = simplexml_load_file(GSITEMAP_FILE);
|
||||
|
||||
$nbPages = sizeof($xml->url);
|
||||
$nbPages = count($xml->url);
|
||||
|
||||
$this->_html .= '<p>'.$this->l('Your Google sitemap file is online at the following address:').'<br />
|
||||
<a href="'.Tools::getShopDomain(true, true).__PS_BASE_URI__.'sitemap.xml" target="_blank"><b>'.Tools::getShopDomain(true, true).__PS_BASE_URI__.'sitemap.xml</b></a></p><br />';
|
||||
@@ -380,15 +367,15 @@ XML;
|
||||
public function getContent()
|
||||
{
|
||||
$this->_html .= '<h2>'.$this->l('Search Engine Optimization').'</h2>
|
||||
'.$this->l('See').' <a href="https://www.google.com/webmasters/tools/docs/en/about.html" style="font-weight:bold;text-decoration:underline;" target="_blank">
|
||||
'.$this->l('See').' <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156184&from=40318&rd=1" style="font-weight:bold;text-decoration:underline;" target="_blank">
|
||||
'.$this->l('this page').'</a> '.$this->l('for more information').'<br /><br />';
|
||||
if (Tools::isSubmit('btnSubmit'))
|
||||
{
|
||||
$this->_postValidation();
|
||||
if (!sizeof($this->_postErrors))
|
||||
if (!count($this->_postErrors))
|
||||
$this->_postProcess();
|
||||
else
|
||||
foreach ($this->_postErrors AS $err)
|
||||
foreach ($this->_postErrors as $err)
|
||||
$this->_html .= '<div class="alert error">'.$err.'</div>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user