118
123
FROM {xmlsitemap_node} WHERE nid = %d",
121
$node->priority_override = $priority !== FALSE ? $priority : -2.0;
126
return array('priority_override' => $priority !== FALSE ? $priority : -2.0);
124
db_query("INSERT INTO {xmlsitemap_node} (nid, last_changed, priority_override) VALUES (%d, %d, %s)",
125
$node->nid, $node->changed, $node->priority_override
128
db_query("INSERT INTO {xmlsitemap_node} (nid, changed, priority_override) VALUES (%d, %d, %s)",
132
isset($node->priority_override) ? $node->priority_override : -2.0,
127
135
if ($node->status) {
128
136
xmlsitemap_update_sitemap();
176
177
$coalesce = 'COALESCE';
180
180
$coalesce = 'FIRST';
184
183
if (module_exists('comment')) {
185
$columns = 'n.nid, n.type, n.promote, n.changed, xn.previously_changed, xn.priority_override, s.comment_count, s.last_comment_timestamp, xn.previous_comment';
184
$columns = 'n.nid, n.type, n.promote, xn.changed, xn.previously_changed, xn.priority_override, s.comment_count, s.last_comment_timestamp, xn.previous_comment';
186
185
$left_join = "LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid";
189
$columns = 'n.nid, n.type, n.promote, n.changed, xn.previously_changed, xn.priority_override';
188
$columns = 'n.nid, n.type, n.promote, xn.changed, xn.previously_changed, xn.priority_override';
192
191
$query = "SELECT $columns, $coalesce(ua.dst) AS alias FROM {node} n
193
192
LEFT JOIN {xmlsitemap_node} xn ON n.nid = xn.nid
195
LEFT JOIN {url_alias} ua ON ua.src = CONCAT('node/', CAST(n.nid AS $cast))
194
LEFT JOIN {url_alias} ua ON ua.src = CONCAT('node/', n.nid)
196
195
WHERE n.status > 0
197
196
AND n.type NOT IN (". db_placeholders($excludes, 'varchar') .")
198
197
AND (xn.priority_override = -2 OR xn.priority_override >= 0)
207
206
$result = db_query(db_rewrite_sql($query), $query_args);
208
207
while ($node = db_fetch_object($result)) {
209
208
db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)",
210
xmlsitemap_url('node/'. $node->nid, $node->alias, NULL, NULL, TRUE),
211
variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed,
212
xmlsitemap_node_frequency($node), xmlsitemap_node_priority($node)
210
xmlsitemap_url('node/'. $node->nid, $node->alias, NULL, NULL, TRUE),
211
variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed,
212
xmlsitemap_node_frequency($node), xmlsitemap_node_priority($node),
245
246
'#description' => t('If enabled, the frequency of comments on a post will affect its change frequency and last modification date.'),
251
* Implementation of hook_xmlsitemap_update_module_tables_batch_operations().
253
function xmlsitemap_node_xmlsitemap_update_module_tables_batch_operations() {
255
'_xmlsitemap_node_module_table_delete_rows',
256
'_xmlsitemap_node_module_table_update_rows',
257
'_xmlsitemap_node_module_table_add_rows',
248
261
/*****************************************************************************
249
262
* Menu callbacks / form builders, submit/validate functions.
250
263
****************************************************************************/
339
352
if ($node->promote) {
340
353
$priority += variable_get('xmlsitemap_node_promote_priority', 0.3);
342
if ($maxcomments != 1) {
355
if ($maxcomments > 1) {
343
356
$priority += $node->comment_count / $maxcomments * variable_get('xmlsitemap_node_comment_priority', 0.2);
345
358
$priority = min(round($priority, 1), 1);
346
359
return $priority;
362
/*****************************************************************************
363
* Private functions - database batch operations.
364
****************************************************************************/
367
* Batch function used to update the module database tables.
369
* The context parameter passed from batch_process().
371
function _xmlsitemap_node_module_table_add_rows(&$context) {
372
if (!isset($context['sandbox']['progress'])) {
373
$context['sandbox']['current_node'] = 0;
374
$context['sandbox']['max'] = (integer) db_result(db_query('SELECT COUNT(n.nid)
376
LEFT JOIN {xmlsitemap_node} xn ON xn.nid = n.nid
377
WHERE xn.nid IS NULL')
379
$context['sandbox']['progress'] = 0;
381
if ($context['sandbox']['max']) {
382
$result = db_query_range('SELECT n.nid, n.created AS previously_changed, n.changed
384
LEFT JOIN {xmlsitemap_node} xn ON xn.nid = n.nid
388
$context['sandbox']['current_node'], 0, 1
390
if ($row = db_fetch_object($result)) {
391
drupal_write_record('xmlsitemap_node', $row);
392
$context['sandbox']['progress']++;
393
$context['sandbox']['current_node'] = $row->nid;
394
$context['results']['added'] = $context['sandbox']['progress'];
396
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
397
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
403
* Batch function used to update the module database tables.
405
* The context parameter passed from batch_process().
407
function _xmlsitemap_node_module_table_delete_rows(&$context) {
408
if (!isset($context['sandbox']['progress'])) {
409
$context['sandbox']['current_node'] = 0;
410
$context['sandbox']['max'] = (integer) db_result(db_query('SELECT COUNT(xn.nid)
411
FROM {xmlsitemap_node} xn
412
LEFT JOIN {node} n ON n.nid = xn.nid
413
WHERE n.nid IS NULL')
415
$context['sandbox']['progress'] = 0;
417
if ($context['sandbox']['max']) {
419
db_query("SELECT xn.nid
420
FROM {xmlsitemap_node} xn
421
LEFT JOIN {node} n ON n.nid = xn.nid
424
$context['sandbox']['current_node']
427
if ($nid === FALSE) {
428
$context['finished'] = 1;
431
db_query('DELETE FROM {xmlsitemap_node} WHERE nid = %d', $nid);
432
$context['sandbox']['progress']++;
433
$context['sandbox']['current_node'] = $nid;
434
$context['results']['deleted'] = $context['sandbox']['progress'];
435
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
436
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
443
* Batch function used to update the module database tables.
445
* The context parameter passed from batch_process().
447
function _xmlsitemap_node_module_table_update_rows(&$context) {
448
if (!isset($context['sandbox']['progress'])) {
449
$context['sandbox']['current_node'] = 0;
450
$context['sandbox']['max'] = (integer) db_result(db_query('SELECT COUNT(n.nid)
452
INNER JOIN {xmlsitemap_node} xn ON xn.nid = n.nid
453
WHERE n.changed > xn.changed')
455
$context['sandbox']['progress'] = 0;
457
if ($context['sandbox']['max']) {
458
$result = db_query_range('SELECT n.nid, xn.changed AS previously_changed, n.changed
460
INNER JOIN {xmlsitemap_node} xn ON xn.nid = n.nid
462
AND n.changed > xn.changed
464
$context['sandbox']['current_node'], 0, 1
466
if ($row = db_fetch_object($result)) {
467
drupal_write_record('xmlsitemap_node', $row, 'nid');
468
$context['sandbox']['progress']++;
469
$context['sandbox']['current_node'] = $row->nid;
470
$context['results']['updated'] = $context['sandbox']['progress'];
472
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
473
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
350
479
* @} End of "addtogroup xmlsitemap".