<?php
/**
* Funções de Sitemap
*
* @package SEO
* @author Lucas/Postali
*/
namespace SEO;
use Navigation\Navigation;
class Sitemap extends \Core
{
/**
* @var Valores permitidos para o parâmetro "changefreq"
**/
const ALLOWED_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];
/**
* Exibe o conteúdo do sitemap.xml
*
* @return string
**/
public function show ()
{
//Iniciar a captura de dados
ob_start();
//Conjunto de URLS
$urlset = [];
//Para cada página declarada
foreach ($this->_config('page') as $key => $page)
{
$sitemap = isset($page['sitemap']) ? $page['sitemap'] : [];
//Se o sitemap for false, ignorar
if($sitemap === false)
continue;
//Se não há um caminho estático e não há um caminho definido em SEO => loc, ignorar
if( !isset($page['static']) && !isset($sitemap['loc']) && !isset($page['pattern']))
continue;
if( isset($page['pattern']) && !isset($sitemap['locVariablesSource']) )
continue;
//Se for uma página de redirecionamento e não houver sitemap declarado, ignorar
if(isset($page['redirect']) && (!$sitemap || empty($sitemap)))
continue;
//Iniciar valores desse conjunto
$url = [];
if(isset($page['pattern']) && isset($sitemap['locVariablesSource']))
{
if(isset($sitemap['locVariablesSource']) && is_string($sitemap['locVariablesSource']))
$locVariablesSources = $this->parseMethod($sitemap['locVariablesSource'], true);
else
$locVariablesSources = $sitemap['locVariablesSource'];
}
//Se houver um changefreq definido e ele for válido, incluí-lo
if(isset($sitemap['changefreq']) && in_array($sitemap['changefreq'], self::ALLOWED_CHANGEFREQ))
$url['changefreq'] = $sitemap['changefreq'];
//Se houver um lastmod definido
if(isset($sitemap['lastmod']))
//Se for true, gerar automaticamente
if($sitemap['lastmod'] === true)
$url['lastmod'] = date('Y-m-d', filemtime($this->getPath('View/'.$page['file'])));
//Senão, incluir o valor declarado
else
$url['lastmod'] = $sitemap['lastmod'];
//Se houver um priority e ele for válido, incluí-lo
if(isset($sitemap['priority']) &&
is_numeric($sitemap['priority']) && $sitemap['priority'] >= 0 && $sitemap['priority'] <= 1)
$url['priority'] = $sitemap['priority'];
//Se houver uma localização definida, incluir
if($sitemap && isset($sitemap['loc']))
{
//Se for solicitado parsear o parâmtro LOC
if(isset($sitemap['locParse']) && $sitemap['locParse'] === true)
$url['loc'] = $this->getURL() . "/" . $sitemap['loc'];
//Senão, incluí-lo normalmente
else
$url['loc'] = $sitemap['loc'];
}
//Se houver pattern
else if(isset($page['pattern']) && $locVariablesSources)
{
//Se há vários valores dentro do array, incluir várias páginas
if( isset($locVariablesSources[0]) && is_array($locVariablesSources[0]) )
{
//Para cada um desses arrays
foreach ($locVariablesSources as $locVar)
{
//Se houver parâmetros adicionais de sitemap
if(isset($locVar['sitemap']))
{
$params = $locVar['sitemap'];
//Se houver um lastmod definido
if(isset($params['lastmod']))
$url['lastmod'] = $params['lastmod'];
//Se houver um changefreq definido
if(isset($params['changefreq']) && in_array($params['changefreq'], self::ALLOWED_CHANGEFREQ))
$url['changefreq'] = $params['changefreq'];
//Se houver um priority definido
if(isset($params['priority']) &&
is_numeric($params['priority']) && $params['priority'] >= 0 && $params['priority'] <= 1)
$url['priority'] = $params['priority'];
$locVar = $locVar['variables'];
}
$url['loc'] = $this->getRouteURL($key, $locVar);
$urlset[] = ['url' => $url ];
}
continue;
}
//Se é um array comum apenas com os valores, retornar
$url['loc'] = $this->getRouteURL($key, $locVariablesSources);
}
//Senão, receber o link da página estática
else
{
$url['loc'] = $this->getRouteURL($key);
}
$urlset[] = ['url' => $url ];
}
//Montar XML
$urlset = [
'urlset' => $urlset,
'_params' =>
['attribute_ns' =>
[
'schemaLocation' => ['prefix' => 'xsi', 'value' => "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd", 'uri' => "http://www.w3.org/2001/XMLSchema-instance"],
],
'attribute' =>
[
'xmlns' => "http://www.sitemaps.org/schemas/sitemap/0.9"
]
]
];
//Parsear XML
$xml = XMLConverter::arrayToXMLConverter($urlset);
//Limpar saída de dados
ob_end_clean();
//Retornar conteúdo do XML
return $xml;
}
}You can see detailed error trace in the console.
render ()
/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/index.php 20
parseMethod (array (
0 => 'SEO\\Sitemap',
1 => 'show',
),
true,
\Navigation\Page::__set_state(array(
'_currentCulture' => NULL,
'_currentCurrency' => NULL,
'_currentLanguage' => NULL,
'languageContent' =>
array (
),
'_currentTimezone' => NULL,
'navigationConfig' => NULL,
'pagesConfig' => NULL,
'outputed' => false,
'navigationConfig' => NULL,
'pagesConfig' =>
array (
'header' =>
array (
'file' => 'header.php',
'headerAssets' =>
array (
0 => 'css',
),
),
'footer' =>
array (
'file' => 'footer.php',
),
'redirect' =>
array (
'static' => '',
'redirect' => 'admin',
),
'sitemap' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'robots' =>
array (
'method' => 'SEO\\Robots::show',
'static' => 'robots.txt',
'contentType' => 'text/plain',
'sitemap' => false,
),
'fimjgmw8j1' =>
array (
'static' => 'fimjgmw8j1',
'file' => '../Config/SEO.config',
'sitemap' => false,
'p' => '',
),
'cielo-payment' =>
array (
'method' => 'Cielo/Cielo::Notify',
'static' => 'cielo/notify',
'contentType' => 'application/json',
),
'cms-header' =>
array (
'file' => 'CMS/header.php',
),
'cms-footer' =>
array (
'file' => 'CMS/footer.php',
),
'cms-login' =>
array (
'file' => 'CMS/login.php',
'static' => 'admin/login',
'includeBefore' =>
array (
0 => 'cms-header',
),
'includeAfter' =>
array (
0 => 'cms-footer',
),
'using' =>
array (
0 => 'CMSController\\Login',
),
'sitemap' => false,
),
'cms' =>
array (
'file' => 'CMS/index.php',
'pattern' => 'admin/?/?',
'variables' =>
array (
0 => 'module',
1 => 'block',
),
'includeBefore' =>
array (
0 => 'cms-header',
),
'includeAfter' =>
array (
0 => 'cms-footer',
),
'using' =>
array (
0 => 'CMSController\\Main',
),
'sitemap' => false,
),
'cms-style' =>
array (
'file' => 'CMS/style.php',
'static' => 'cms-custom/style.css',
'contentType' => 'text/css',
'using' =>
array (
0 => 'CMSController\\Main',
),
'sitemap' => false,
),
'n-cms-partial-menu-mobile' =>
array (
'file' => 'CMS/partials/_header-mobile.php',
),
'n-cms-partial-aside' =>
array (
'file' => 'CMS/partials/_aside.php',
),
'n-cms-partial-header' =>
array (
'file' => 'CMS/partials/_header.php',
),
'n-cms-partial-footer' =>
array (
'file' => 'CMS/partials/_footer.php',
),
'n-cms-partial-subheader' =>
array (
'file' => 'CMS/partials/subheader-v5.php',
),
'n-cms-partial-content' =>
array (
'file' => 'CMS/partials/_content.php',
),
'n-cms-partial-dropdown-user' =>
array (
'file' => 'CMS/partials/_dropdown_user.php',
),
'n-cms-partial-dropdown-notifications' =>
array (
'file' => 'CMS/partials/_dropdown_notifications.php',
),
'newsletter-table' =>
array (
'static' => 'cms/Newsletter/Datatable',
'method' => 'Newsletter\\Newsletter::Datatable',
),
'newsletter-export' =>
array (
'static' => 'cms/Newsletter/Newsletter.csv',
'method' => 'Newsletter\\Newsletter::Export',
'contentType' => 'text/csv',
),
'shopper-api' =>
array (
'pattern' => 'shopper/$/$',
'variables' =>
array (
0 => 'module',
1 => 'method',
),
'method' => 'Shopper/Api/Api::Request',
),
'shopper-dynamic-js' =>
array (
'static' => 'shopper/script.js',
'method' => 'Shopper/DynamicJS::show',
'contentType' => 'application/javascript',
),
'shopper-cms-customer-list-export' =>
array (
'pattern' => 'shopper/admin/customer/list/export',
'method' => 'ShopperMethod/Shopper::customerListExport',
),
'shopper-cms-order-list-export' =>
array (
'pattern' => 'shopper/admin/order/list/export',
'method' => 'ShopperMethod/Shopper::orderListExport',
),
'shopper-cms-order-print' =>
array (
'pattern' => 'shopper/admin/order/print',
'method' => 'ShopperMethod/Shopper::orderPrint',
),
'shopper-cms-report-order-export' =>
array (
'pattern' => 'shopper/admin/resport/order/export',
'method' => 'ShopperMethod/Reports::exportAdvancedOrderReport',
),
'shopper-cms-report-item-export' =>
array (
'pattern' => 'shopper/admin/resport/item/export',
'method' => 'ShopperMethod/Reports::exportAdvancedItemReport',
),
'shopper-cms-report-inventory-export' =>
array (
'pattern' => 'shopper/admin/resport/inventory/export',
'method' => 'ShopperMethod/Reports::exportAdvancedInventoryReport',
),
),
'currentPage' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'_name' => 'sitemap',
'variables' =>
array (
),
'_structure' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'_tags' =>
array (
),
'_assets' =>
array (
'header' =>
array (
),
'footer' =>
array (
),
),
'_usingClasses' =>
array (
),
)))
/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/Modules/Core/Navigation/Page.php 377
show (\Navigation\Page::__set_state(array(
'_currentCulture' => NULL,
'_currentCurrency' => NULL,
'_currentLanguage' => NULL,
'languageContent' =>
array (
),
'_currentTimezone' => NULL,
'navigationConfig' => NULL,
'pagesConfig' => NULL,
'outputed' => false,
'navigationConfig' => NULL,
'pagesConfig' =>
array (
'header' =>
array (
'file' => 'header.php',
'headerAssets' =>
array (
0 => 'css',
),
),
'footer' =>
array (
'file' => 'footer.php',
),
'redirect' =>
array (
'static' => '',
'redirect' => 'admin',
),
'sitemap' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'robots' =>
array (
'method' => 'SEO\\Robots::show',
'static' => 'robots.txt',
'contentType' => 'text/plain',
'sitemap' => false,
),
'fimjgmw8j1' =>
array (
'static' => 'fimjgmw8j1',
'file' => '../Config/SEO.config',
'sitemap' => false,
'p' => '',
),
'cielo-payment' =>
array (
'method' => 'Cielo/Cielo::Notify',
'static' => 'cielo/notify',
'contentType' => 'application/json',
),
'cms-header' =>
array (
'file' => 'CMS/header.php',
),
'cms-footer' =>
array (
'file' => 'CMS/footer.php',
),
'cms-login' =>
array (
'file' => 'CMS/login.php',
'static' => 'admin/login',
'includeBefore' =>
array (
0 => 'cms-header',
),
'includeAfter' =>
array (
0 => 'cms-footer',
),
'using' =>
array (
0 => 'CMSController\\Login',
),
'sitemap' => false,
),
'cms' =>
array (
'file' => 'CMS/index.php',
'pattern' => 'admin/?/?',
'variables' =>
array (
0 => 'module',
1 => 'block',
),
'includeBefore' =>
array (
0 => 'cms-header',
),
'includeAfter' =>
array (
0 => 'cms-footer',
),
'using' =>
array (
0 => 'CMSController\\Main',
),
'sitemap' => false,
),
'cms-style' =>
array (
'file' => 'CMS/style.php',
'static' => 'cms-custom/style.css',
'contentType' => 'text/css',
'using' =>
array (
0 => 'CMSController\\Main',
),
'sitemap' => false,
),
'n-cms-partial-menu-mobile' =>
array (
'file' => 'CMS/partials/_header-mobile.php',
),
'n-cms-partial-aside' =>
array (
'file' => 'CMS/partials/_aside.php',
),
'n-cms-partial-header' =>
array (
'file' => 'CMS/partials/_header.php',
),
'n-cms-partial-footer' =>
array (
'file' => 'CMS/partials/_footer.php',
),
'n-cms-partial-subheader' =>
array (
'file' => 'CMS/partials/subheader-v5.php',
),
'n-cms-partial-content' =>
array (
'file' => 'CMS/partials/_content.php',
),
'n-cms-partial-dropdown-user' =>
array (
'file' => 'CMS/partials/_dropdown_user.php',
),
'n-cms-partial-dropdown-notifications' =>
array (
'file' => 'CMS/partials/_dropdown_notifications.php',
),
'newsletter-table' =>
array (
'static' => 'cms/Newsletter/Datatable',
'method' => 'Newsletter\\Newsletter::Datatable',
),
'newsletter-export' =>
array (
'static' => 'cms/Newsletter/Newsletter.csv',
'method' => 'Newsletter\\Newsletter::Export',
'contentType' => 'text/csv',
),
'shopper-api' =>
array (
'pattern' => 'shopper/$/$',
'variables' =>
array (
0 => 'module',
1 => 'method',
),
'method' => 'Shopper/Api/Api::Request',
),
'shopper-dynamic-js' =>
array (
'static' => 'shopper/script.js',
'method' => 'Shopper/DynamicJS::show',
'contentType' => 'application/javascript',
),
'shopper-cms-customer-list-export' =>
array (
'pattern' => 'shopper/admin/customer/list/export',
'method' => 'ShopperMethod/Shopper::customerListExport',
),
'shopper-cms-order-list-export' =>
array (
'pattern' => 'shopper/admin/order/list/export',
'method' => 'ShopperMethod/Shopper::orderListExport',
),
'shopper-cms-order-print' =>
array (
'pattern' => 'shopper/admin/order/print',
'method' => 'ShopperMethod/Shopper::orderPrint',
),
'shopper-cms-report-order-export' =>
array (
'pattern' => 'shopper/admin/resport/order/export',
'method' => 'ShopperMethod/Reports::exportAdvancedOrderReport',
),
'shopper-cms-report-item-export' =>
array (
'pattern' => 'shopper/admin/resport/item/export',
'method' => 'ShopperMethod/Reports::exportAdvancedItemReport',
),
'shopper-cms-report-inventory-export' =>
array (
'pattern' => 'shopper/admin/resport/inventory/export',
'method' => 'ShopperMethod/Reports::exportAdvancedInventoryReport',
),
),
'currentPage' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'_name' => 'sitemap',
'variables' =>
array (
),
'_structure' =>
array (
'method' => 'SEO\\Sitemap::show',
'static' => 'sitemap.xml',
'contentType' => 'application/xml',
'sitemap' => false,
),
'_tags' =>
array (
),
'_assets' =>
array (
'header' =>
array (
),
'footer' =>
array (
),
),
'_usingClasses' =>
array (
),
)),
NULL)
/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/Modules/Core/Utils/Util.php 144
{closure} (8192,
'Calling static trait method SEO\\XMLConverter::arrayToXMLConverter is deprecated, it should only be called on a class using the trait',
'/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/Modules/Classes/SEO/Sitemap.php',
159)
/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/Modules/Classes/SEO/Sitemap.php 159
HandlerError (8192,
'Calling static trait method SEO\\XMLConverter::arrayToXMLConverter is deprecated, it should only be called on a class using the trait',
'/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/Modules/Classes/SEO/Sitemap.php',
159)
/var/www/homologacao-clubedepontos.gazinsemijoias.com.br/main.php 27
You can see detailed error trace in the console.
main
System ready
'/var/www/homologacao-clubedepontos.gazinsemijoias.com.br'
web
Starting session
true
web
Starting web module
''
Culture
Auto discovering culture
NULL
Culture
Setting culture
'Brasil'
Navigation\Navigation
Setting Navigation default timezone
'America/Sao_Paulo'
Navigation\Navigation
Setting Navigation default language
false
web
User
'216.73.216.24'
Navigation\Navigation
Interpreting URI
'sitemap.xml'