<?php
2/**
3* Funções de Sitemap
4*
5* @package SEO
6* @author Lucas/Postali
7*/
8
9namespace SEO;
10
11use Navigation\Navigation;
12
13class Sitemap extends \Core
14{
15 /**
16 * @var Valores permitidos para o parâmetro "changefreq"
17 **/
18 const ALLOWED_CHANGEFREQ = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];
19
20 /**
21 * Exibe o conteúdo do sitemap.xml
22 *
23 * @return string
24 **/
25 public function show ()
26 {
27 //Iniciar a captura de dados
28 ob_start();
29
30 //Conjunto de URLS
31 $urlset = [];
32
33 //Para cada página declarada
34 foreach ($this->_config('page') as $key => $page)
35 {
36 $sitemap = isset($page['sitemap']) ? $page['sitemap'] : [];
37
38 //Se o sitemap for false, ignorar
39 if($sitemap === false)
40 continue;
41
42 //Se não há um caminho estático e não há um caminho definido em SEO => loc, ignorar
43 if( !isset($page['static']) && !isset($sitemap['loc']) && !isset($page['pattern']))
44 continue;
45
46 if( isset($page['pattern']) && !isset($sitemap['locVariablesSource']) )
47 continue;
48
49 //Se for uma página de redirecionamento e não houver sitemap declarado, ignorar
50 if(isset($page['redirect']) && (!$sitemap || empty($sitemap)))
51 continue;
52
53 //Iniciar valores desse conjunto
54 $url = [];
55
56 if(isset($page['pattern']) && isset($sitemap['locVariablesSource']))
57 {
58 if(isset($sitemap['locVariablesSource']) && is_string($sitemap['locVariablesSource']))
59 $locVariablesSources = $this->parseMethod($sitemap['locVariablesSource'], true);
60 else
61 $locVariablesSources = $sitemap['locVariablesSource'];
62 }
63
64 //Se houver um changefreq definido e ele for válido, incluí-lo
65 if(isset($sitemap['changefreq']) && in_array($sitemap['changefreq'], self::ALLOWED_CHANGEFREQ))
66 $url['changefreq'] = $sitemap['changefreq'];
67
68 //Se houver um lastmod definido
69 if(isset($sitemap['lastmod']))
70
71 //Se for true, gerar automaticamente
72 if($sitemap['lastmod'] === true)
73 $url['lastmod'] = date('Y-m-d', filemtime($this->getPath('View/'.$page['file'])));
74
75 //Senão, incluir o valor declarado
76 else
77 $url['lastmod'] = $sitemap['lastmod'];
78
79 //Se houver um priority e ele for válido, incluí-lo
80 if(isset($sitemap['priority']) &&
81 is_numeric($sitemap['priority']) && $sitemap['priority'] >= 0 && $sitemap['priority'] <= 1)
82 $url['priority'] = $sitemap['priority'];
83
84 //Se houver uma localização definida, incluir
85 if($sitemap && isset($sitemap['loc']))
86 {
87 //Se for solicitado parsear o parâmtro LOC
88 if(isset($sitemap['locParse']) && $sitemap['locParse'] === true)
89 $url['loc'] = $this->getURL() . "/" . $sitemap['loc'];
90
91 //Senão, incluí-lo normalmente
92 else
93 $url['loc'] = $sitemap['loc'];
94 }
95
96 //Se houver pattern
97 else if(isset($page['pattern']) && $locVariablesSources)
98 {
99 //Se há vários valores dentro do array, incluir várias páginas
100 if( isset($locVariablesSources[0]) && is_array($locVariablesSources[0]) )
101 {
102 //Para cada um desses arrays
103 foreach ($locVariablesSources as $locVar)
104 {
105 //Se houver parâmetros adicionais de sitemap
106 if(isset($locVar['sitemap']))
107 {
108 $params = $locVar['sitemap'];
109
110 //Se houver um lastmod definido
111 if(isset($params['lastmod']))
112 $url['lastmod'] = $params['lastmod'];
113
114 //Se houver um changefreq definido
115 if(isset($params['changefreq']) && in_array($params['changefreq'], self::ALLOWED_CHANGEFREQ))
116 $url['changefreq'] = $params['changefreq'];
117
118 //Se houver um priority definido
119 if(isset($params['priority']) &&
120 is_numeric($params['priority']) && $params['priority'] >= 0 && $params['priority'] <= 1)
121 $url['priority'] = $params['priority'];
122
123 $locVar = $locVar['variables'];
124 }
125 $url['loc'] = $this->getRouteURL($key, $locVar);
126 $urlset[] = ['url' => $url ];
127 }
128 continue;
129 }
130
131 //Se é um array comum apenas com os valores, retornar
132 $url['loc'] = $this->getRouteURL($key, $locVariablesSources);
133 }
134 //Senão, receber o link da página estática
135 else
136 {
137 $url['loc'] = $this->getRouteURL($key);
138 }
139
140 $urlset[] = ['url' => $url ];
141 }
142
143 //Montar XML
144 $urlset = [
145 'urlset' => $urlset,
146 '_params' =>
147 ['attribute_ns' =>
148 [
149 '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"],
150 ],
151 'attribute' =>
152 [
153 'xmlns' => "http://www.sitemaps.org/schemas/sitemap/0.9"
154 ]
155 ]
156 ];
157
158 //Parsear XML
159 $xml = XMLConverter::arrayToXMLConverter($urlset);
160
161 //Limpar saída de dados
162 ob_end_clean();
163
164 //Retornar conteúdo do XML
165 return $xml;
166 }
167}You can see detailed error trace in the console.
render ()
/var/www/vendas.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',
),
'head' =>
array (
'file' => 'head.php',
'headerAssets' =>
array (
0 => 'swal',
1 => 'loader',
),
'using' =>
array (
0 => 'Pagina',
1 => 'ShopperMethod\\Catalog',
2 => 'ShopperMethod\\Shopper',
),
),
'foot' =>
array (
'file' => 'foot.php',
),
'header-login' =>
array (
'file' => 'login/header.php',
'headerAssets' =>
array (
0 => 'css',
),
),
'footer-login' =>
array (
'file' => 'login/footer.php',
),
'head-login' =>
array (
'file' => 'login/head.php',
),
'login' =>
array (
'file' => 'login/login.php',
'static' => '',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'footer-login',
),
),
'clientes' =>
array (
'file' => 'login/clientes.php',
'static' => 'clientes',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'produtos' =>
array (
'file' => 'produtos.php',
'static' => 'produtos',
'includeBefore' =>
array (
0 => 'head',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer',
),
),
'sacola' =>
array (
'file' => 'sacola.php',
'static' => 'sacola',
'includeBefore' =>
array (
0 => 'head',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer',
),
),
'head-sacola' =>
array (
'file' => 'closed/head.php',
),
'footer-sacola' =>
array (
'file' => 'closed/footer.php',
),
'sacola-closed' =>
array (
'file' => 'closed/sacola.php',
'pattern' => 'sacola/?',
'variables' =>
array (
0 => 'urlCart',
),
'includeBefore' =>
array (
0 => 'head-sacola',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-sacola',
),
),
'password' =>
array (
'file' => 'login/password.php',
'static' => 'password',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'send-password' =>
array (
'file' => 'login/send-password.php',
'static' => 'send-password',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'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,
),
'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',
),
'shopper_tools_marketing_product_feed' =>
array (
'static' => 'shopper-tools/marketing/product_feed.xml',
'method' => 'Shopper\\Tools\\Marketing\\Feed::productFeed',
),
),
'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/vendas.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',
),
'head' =>
array (
'file' => 'head.php',
'headerAssets' =>
array (
0 => 'swal',
1 => 'loader',
),
'using' =>
array (
0 => 'Pagina',
1 => 'ShopperMethod\\Catalog',
2 => 'ShopperMethod\\Shopper',
),
),
'foot' =>
array (
'file' => 'foot.php',
),
'header-login' =>
array (
'file' => 'login/header.php',
'headerAssets' =>
array (
0 => 'css',
),
),
'footer-login' =>
array (
'file' => 'login/footer.php',
),
'head-login' =>
array (
'file' => 'login/head.php',
),
'login' =>
array (
'file' => 'login/login.php',
'static' => '',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'footer-login',
),
),
'clientes' =>
array (
'file' => 'login/clientes.php',
'static' => 'clientes',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'produtos' =>
array (
'file' => 'produtos.php',
'static' => 'produtos',
'includeBefore' =>
array (
0 => 'head',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer',
),
),
'sacola' =>
array (
'file' => 'sacola.php',
'static' => 'sacola',
'includeBefore' =>
array (
0 => 'head',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer',
),
),
'head-sacola' =>
array (
'file' => 'closed/head.php',
),
'footer-sacola' =>
array (
'file' => 'closed/footer.php',
),
'sacola-closed' =>
array (
'file' => 'closed/sacola.php',
'pattern' => 'sacola/?',
'variables' =>
array (
0 => 'urlCart',
),
'includeBefore' =>
array (
0 => 'head-sacola',
1 => 'header',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-sacola',
),
),
'password' =>
array (
'file' => 'login/password.php',
'static' => 'password',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'send-password' =>
array (
'file' => 'login/send-password.php',
'static' => 'send-password',
'includeBefore' =>
array (
0 => 'head-login',
1 => 'header-login',
),
'includeAfter' =>
array (
0 => 'foot',
1 => 'footer-login',
),
),
'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,
),
'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',
),
'shopper_tools_marketing_product_feed' =>
array (
'static' => 'shopper-tools/marketing/product_feed.xml',
'method' => 'Shopper\\Tools\\Marketing\\Feed::productFeed',
),
),
'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/vendas.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/vendas.gazinsemijoias.com.br/Modules/Classes/SEO/Sitemap.php',
159)
/var/www/vendas.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/vendas.gazinsemijoias.com.br/Modules/Classes/SEO/Sitemap.php',
159)
/var/www/vendas.gazinsemijoias.com.br/main.php 27
You can see detailed error trace in the console.
main
System ready
'/var/www/vendas.gazinsemijoias.com.br'
web
Starting session
true
web
Starting web module
''
Navigation\Navigation
Setting Navigation default timezone
'America/Sao_Paulo'
Navigation\Navigation
Setting Navigation default language
false
web
User
'216.73.216.192'
Navigation\Navigation
Interpreting URI
'sitemap.xml'