Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
xmlsitemap
Commits
1ae2d059
Commit
1ae2d059
authored
Apr 07, 2010
by
Dave Reid
Browse files
by Dave Reid: Fixed engine sitemap operations.
parent
7f1363c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
xmlsitemap.generate.inc
View file @
1ae2d059
...
...
@@ -360,6 +360,10 @@ function xmlsitemap_generate_index(array $sitemap, $handle, &$status) {
/**
* Batch information callback for regenerating the sitemap files.
*
* @param $smids
* An optional array of XML sitemap IDs. If not provided, it will load all
* existing XML sitemaps.
*/
function
xmlsitemap_regenerate_batch
(
array
$smids
=
array
())
{
if
(
empty
(
$smids
))
{
...
...
xmlsitemap.module
View file @
1ae2d059
...
...
@@ -119,12 +119,17 @@ function xmlsitemap_permission() {
);
}
function
xmlsitemap_sitemap_load
(
$smid
)
{
$sitemap
=
db_query
_range
(
"SELECT * FROM
{
xmlsitemap_sitemap
}
WHERE smid
=
:smid"
,
0
,
1
,
array
(
':smid'
=>
$smid
))
->
fetchAssoc
();
if
(
$sitemap
)
{
$sitemap
[
'context'
]
=
unserialize
(
$sitemap
[
'context'
]);
function
xmlsitemap_sitemap_load
_multiple
(
array
$smid
s
)
{
$sitemap
s
=
db_query
(
"SELECT * FROM
{
xmlsitemap_sitemap
}
WHERE smid
IN (
:smid
s)
"
,
array
(
':smid
s
'
=>
$smid
s
))
->
fetchA
llA
ssoc
(
'smid'
,
PDO
::
FETCH_ASSOC
);
foreach
(
$sitemaps
as
$smid
=>
$sitemap
)
{
$sitemap
s
[
$smid
]
[
'context'
]
=
unserialize
(
$sitemap
[
'context'
]);
}
return
$sitemap
;
return
$sitemaps
;
}
function
xmlsitemap_sitemap_load
(
$smid
)
{
$sitemap
=
xmlsitemap_sitemap_load_multiple
(
array
(
$smid
));
return
$sitemap
?
reset
(
$sitemap
)
:
FALSE
;
}
function
xmlsitemap_sitemap_load_by_context
(
array
$context
=
NULL
)
{
...
...
xmlsitemap_engines/xmlsitemap_engines.module
View file @
1ae2d059
<?php
// $Id$
/**
* Implements hook_hook_info().
*/
function
xmlsitemap_engines_hook_info
()
{
$hooks
[
'xmlsitemap_engine_info'
]
=
array
(
'group'
=>
'xmlsitemap'
,
);
$hooks
[
'xmlsitemap_engine_info_alter'
]
=
array
(
'group'
=>
'xmlsitemap'
,
);
return
$hooks
;
}
/**
* Implements hook_help().
*/
...
...
@@ -47,13 +60,25 @@ function xmlsitemap_engines_cron() {
}
}
function
xmlsitemap_engines_submit
_access
()
{
function
xmlsitemap_engines_
can_
submit
()
{
// Skip if the site is offline since search engines will not be able to
// access the site's content.
if
(
variable_get
(
'site_offline'
,
0
))
{
return
FALSE
;
}
if
(
!
variable_get
(
'xmlsitemap_engines_engines'
,
array
())
&&
!
variable_get
(
'xmlsitemap_engines_custom_urls'
,
''
))
{
return
FALSE
;
}
return
TRUE
;
}
function
xmlsitemap_engines_submit_access
()
{
if
(
!
xmlsitemap_engines_can_submit
())
{
return
FALSE
;
}
// Allow manual submissions to run.
//if ($_GET['q'] == 'admin/config/search/xmlsitemap/engines/submit' && user_access('administer xmlsitemap')) {
// return TRUE;
...
...
@@ -78,9 +103,17 @@ function xmlsitemap_engines_submit_access() {
/**
* Submit the sitemaps to all the specified search engines.
*
* @param $smids
* An optional array of XML sitemap IDs. If not provided, it will load all
* existing XML sitemaps.
*/
function
xmlsitemap_engines_submit_engines
()
{
$sitemaps
=
xmlsitemap_get_sitemaps
();
function
xmlsitemap_engines_submit_engines
(
array
$smids
=
array
())
{
if
(
empty
(
$smids
))
{
$smids
=
db_query
(
"SELECT smid FROM
{
xmlsitemap_sitemap
}
"
)
->
fetchCol
();
}
$sitemaps
=
xmlsitemap_sitemap_load_multiple
(
$smids
);
$engines
=
variable_get
(
'xmlsitemap_engines_engines'
,
array
());
$engine_info
=
xmlsitemap_engines_get_engine_info
();
...
...
@@ -105,7 +138,7 @@ function xmlsitemap_engines_submit_engines() {
* @param $sitemaps
* An array of URLs of the sitemaps to submit.
*/
function
xmlsitemap_engines_submit_sitemaps
(
$url
,
$sitemaps
=
array
())
{
function
xmlsitemap_engines_submit_sitemaps
(
$url
,
array
$sitemaps
=
array
())
{
foreach
(
$sitemaps
as
$sitemap
)
{
$submit_url
=
xmlsitemap_engines_prepare_url
(
$url
,
$sitemap
);
$request
=
drupal_http_request
(
$submit_url
);
...
...
@@ -209,14 +242,16 @@ function xmlsitemap_engines_variables() {
return
$variables
;
}
/**
* Implements hook_xmlsitemap_sitemap_operations().
*/
function
xmlsitemap_engines_xmlsitemap_sitemap_operations
()
{
$operations
[
'xmlsitemap_engines_submit'
]
=
array
(
'label'
=>
t
(
'Submit to search engines'
),
'callback'
=>
'xmlsitemap_engines_sitemap_multiple_submit'
,
);
return
$operations
;
}
function
xmlsitemap_engines_sitemap_multiple_submit
(
array
$sitemaps
)
{
if
(
xmlsitemap_engines_can_submit
())
{
$operations
[
'xmlsitemap_engines_submit'
]
=
array
(
'label'
=>
t
(
'Submit to search engines'
),
'action past'
=>
t
(
'Submitted'
),
'callback'
=>
'xmlsitemap_engines_submit_engines'
,
);
return
$operations
;
}
}
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