Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
8c62d8cc
Commit
8c62d8cc
authored
Mar 21, 2016
by
korolevdima
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.task-on.com:900/ktask/task-on.com
parents
5cd553f8
ae49e8e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
frontend/modules/sitemap/Sitemap.php
frontend/modules/sitemap/Sitemap.php
+3
-2
frontend/modules/sitemap/controllers/DefaultController.php
frontend/modules/sitemap/controllers/DefaultController.php
+24
-0
frontend/modules/sitemap/views/default/index.php
frontend/modules/sitemap/views/default/index.php
+1
-1
No files found.
frontend/modules/sitemap/Sitemap.php
View file @
8c62d8cc
...
...
@@ -59,7 +59,7 @@ class Sitemap extends Module
* @return string
* @throws \yii\base\InvalidConfigException
*/
public
function
buildSitemap
()
public
function
buildSitemap
(
$links
=
false
)
{
$urls
=
$this
->
urls
;
...
...
@@ -85,7 +85,8 @@ class Sitemap extends Module
$sitemapData
=
$this
->
createControllerByID
(
'default'
)
->
renderPartial
(
'index'
,
[
'urls'
=>
$urls
,
'langs'
=>
$langs
'langs'
=>
$langs
,
'links'
=>
$links
]);
$this
->
cacheProvider
->
set
(
$this
->
cacheKey
,
$sitemapData
,
$this
->
cacheExpire
);
...
...
frontend/modules/sitemap/controllers/DefaultController.php
View file @
8c62d8cc
...
...
@@ -39,4 +39,28 @@ class DefaultController extends Controller
return
$sitemapData
;
}
public
function
actionGoogle
()
{
/** @var \himiklab\sitemap\Sitemap $module */
$module
=
$this
->
module
;
if
(
!
$sitemapData
=
$module
->
cacheProvider
->
get
(
$module
->
cacheKey
))
{
$sitemapData
=
$module
->
buildSitemap
(
true
);
}
Yii
::
$app
->
response
->
format
=
\yii\web\Response
::
FORMAT_RAW
;
$headers
=
Yii
::
$app
->
response
->
headers
;
$headers
->
add
(
'Content-Type'
,
'application/xml'
);
if
(
$module
->
enableGzip
)
{
$sitemapData
=
gzencode
(
$sitemapData
);
$headers
->
add
(
'Content-Encoding'
,
'gzip'
);
$headers
->
add
(
'Content-Length'
,
strlen
(
$sitemapData
));
}
return
$sitemapData
;
}
}
frontend/modules/sitemap/views/default/index.php
View file @
8c62d8cc
...
...
@@ -17,7 +17,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
<url>
<loc>
<?=
yii\helpers\Url
::
to
(
$url
[
'loc'
],
true
)
?>
</loc>
<?php
if
(
$langs
)
:
<?php
if
(
$l
inks
&&
$l
angs
)
:
foreach
(
$langs
as
$lang
)
:
?>
<xhtml:link
rel=
"alternate"
hreflang=
"
<?=
$lang
->
url
?>
"
href=
"
<?=
yii\helpers\Url
::
to
((
!
$lang
->
default
?
'/'
.
$lang
->
url
:
''
)
.
(
$url
[
'loc'
]
==
'/'
?
''
:
'/'
.
$url
[
'loc'
]),
true
)
?>
"
/>
<?php
endforeach
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment