Index: gsitemap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gsitemap/gsitemap.module,v
retrieving revision 1.56
diff -u -r1.56 gsitemap.module
--- gsitemap.module 22 Nov 2006 22:53:16 -0000 1.56
+++ gsitemap.module 31 Dec 2006 10:19:27 -0000
@@ -11,10 +11,8 @@
*/
function gsitemap_help($section) {
switch ($section) {
- case 'admin/modules#description':
- return t('Creates a Google Sitemap at q=gsitemap');
case 'admin/settings/gsitemap':
- return t('The following options allow you to alter the behavior of the Google Sitemap module.');
+ return t('The following options allow you to alter the behavior of the Google Sitemap module. Your sitemap can be found at @url.', array('@url' => url('gsitemap', NULL, NULL, TRUE)));
}
}
@@ -33,102 +31,112 @@
$items = array();
if ($may_cache) {
+ $items[] = array(
+ 'path' => 'admin/settings/gsitemap',
+ 'title' => t('Google Sitemap'),
+ 'description' => t('Adjust the settings used to generate your Google Sitemap.'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('gsitemap_admin_settings'),
+ 'access' => user_access('administer site configuration'),
+ );
+
+ $items[] = array(
+ 'path' => 'gsitemap',
+ 'title' => t('gsitemap'),
+ 'callback' => 'gsitemap_output',
+ 'type' => MENU_CALLBACK,
+ 'access' => user_access('access content'),
+ );
- $items[] = array('path' => 'gsitemap', 'title' => t('gsitemap'),
- 'callback' => 'gsitemap_output',
- 'type' => MENU_CALLBACK,
- 'access' => 1);
-
- if($verify = variable_get('gsitemap_verify','')) {
+ if ($verify = variable_get('gsitemap_verify', '')) {
$items[] = array('path' => $verify, 'title' => t('gsitemap verification page'),
- 'callback' => 'gsitemap_verify',
- 'type' => MENU_CALLBACK,
- 'access' => 1);
+ 'callback' => 'gsitemap_verify',
+ 'type' => MENU_CALLBACK,
+ 'access' => user_access('access content'),
+ );
}
}
return $items;
}
-function gsitemap_form_alter($form_id, &$form)
-{
+function gsitemap_form_alter($form_id, &$form) {
if (user_access('override node priority') && isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node'];
$form['gsitemap_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('gsitemap Settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
+ '#type' => 'fieldset',
+ '#title' => t('gsitemap Settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
$form['gsitemap_settings']['priority_override'] = array(
- '#type' => 'textfield',
- '#title' => t('Priority override'),
- '#default_value' => $node->priority_override,
- '#size' => 10,
- '#maxlength' => 5,
- '#description' => t('Optionally specify a value for the priority in the Google Sitemap, or -1 to prevent it from appearing in the sitemap.'),
- );
+ '#type' => 'textfield',
+ '#title' => t('Priority override'),
+ '#default_value' => $node->priority_override,
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#description' => t('Optionally specify a value for the priority in the Google Sitemap, or -1 to prevent it from appearing in the sitemap.'),
+ );
}
}
/**
* Implmentation of hook_nodeapi().
*/
-function gsitemap_nodeapi(&$node, $op, $teaser = NULL, $page = NULL)
-{
+function gsitemap_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch($op) {
case 'fields':
return array('priority_override');
case 'insert':
- if(!(strlen($node->priority_override) > 0 && is_numeric($node->priority_override) && user_access('override node priority'))) {
+ if (!(strlen($node->priority_override) > 0 && is_numeric($node->priority_override) && user_access('override node priority'))) {
$node->priority_override = 'NULL';
}
db_query("INSERT INTO {gsitemap} (nid, last_changed, priority_override) VALUES(%d, %d, %s)", $node->nid, $node->changed, $node->priority_override);
- if(variable_get('gsitemap_submit',0) && $node->status) {
+ if (variable_get('gsitemap_submit',0) && $node->status) {
_gsitemap_submit();
}
break;
case 'load':
- if($node->nid && user_access('override node priority')) {
+ if ($node->nid && user_access('override node priority')) {
$result = db_query("SELECT priority_override FROM {gsitemap} WHERE nid=%d",$node->nid);
- if($nd = db_fetch_object($result)) {
+ if ($nd = db_fetch_object($result)) {
$node->priority_override = $nd->priority_override;
}
}
break;
case 'update':
- if(!(strlen($node->priority_override) > 0 && is_numeric($node->priority_override) )) {
+ if (!(strlen($node->priority_override) > 0 && is_numeric($node->priority_override) )) {
$node->priority_override = 'NULL';
}
$result = db_query("SELECT * FROM {gsitemap} LEFT JOIN {node} USING(nid) WHERE {gsitemap}.nid=%d",$node->nid);
- if(!($oldnode = db_fetch_object($result))) {
- db_query("INSERT INTO {gsitemap} (nid, last_changed, priority_override) VALUES(%d, %d, %s)", $node->nid, $node->changed, $node->priority_override);
+ if (!($oldnode = db_fetch_object($result))) {
+ db_query("INSERT INTO {gsitemap} (nid, last_changed, priority_override) VALUES(%d, %d, %f)", $node->nid, $node->changed, $node->priority_override);
}
else {
- if(!isset($oldnode->last_changed)) {
+ if (!isset($oldnode->last_changed)) {
$node->last_changed = 'NULL';
}
- if(user_access('override node priority')) {
- db_query("UPDATE {gsitemap} SET last_changed=%d, previously_changed=%d, priority_override=%s WHERE nid=%d", $node->changed, $oldnode->last_changed, $node->priority_override, $node->nid);
+ if (user_access('override node priority')) {
+ db_query("UPDATE {gsitemap} SET last_changed=%d, previously_changed=%d, priority_override=%f WHERE nid=%d", $node->changed, $oldnode->last_changed, $node->priority_override, $node->nid);
}
else {
db_query("UPDATE {gsitemap} SET last_changed=%d, previously_changed=%d WHERE nid=%d", $node->changed, $oldnode->last_changed, $node->nid);
}
}
- if(variable_get('gsitemap_submit',0) && ($node->status || $oldnode->status)) {
+ if (variable_get('gsitemap_submit',0) && ($node->status || $oldnode->status)) {
_gsitemap_submit();
}
break;
case 'delete':
db_query("DELETE FROM {gsitemap} WHERE nid=%d", $node->nid);
- if(variable_get('gsitemap_submit',0) && $node->status) {
+ if (variable_get('gsitemap_submit',0) && $node->status) {
_gsitemap_submit();
}
break;
case 'validate':
- if(strlen($node->priority_override) > 0) {
- if(!is_numeric($node->priority_override) || (($node->priority_override > 1) || ($node->priority_override < 0 && $node->priority_override != -1))) {
+ if (strlen($node->priority_override) > 0) {
+ if (!is_numeric($node->priority_override) || (($node->priority_override > 1) || ($node->priority_override < 0 && $node->priority_override != -1))) {
form_set_error('priority_override', t('Priority must be a number between 0.0 and 1.0, inclusive, or -1 to prevent this node from appearing in the sitemap.'));
}
}
@@ -136,42 +144,42 @@
}
}
-/*
+/**
* Implementation of hook_comment().
*/
function gsitemap_comment($op, $comment) {
- if(is_array($comment)) {
- if($op == 'insert' || $op == 'update' || $op == 'moderate' || $op == 'delete') {
+ if (is_array($comment)) {
+ if ($op == 'insert' || $op == 'update' || $op == 'moderate' || $op == 'delete') {
$result = db_query("SELECT * FROM {gsitemap} WHERE nid=%d",$comment[nid]);
- if(!($node = db_fetch_object($result))) {
+ if (!($node = db_fetch_object($result))) {
$node = db_fetch_object(db_query("SELECT nid,changed FROM {node} WHERE nid=%d",$comment[nid]));
db_query("INSERT INTO {gsitemap} (nid, last_changed, last_comment) VALUES(%d, %d, %d)",$node->nid, $node->changed, $comment[timestamp]);
}
else {
- if(!isset($node->last_comment)) {
+ if (!isset($node->last_comment)) {
$node->last_comment = 'NULL';
}
db_query("UPDATE {gsitemap} SET last_comment=%d, previous_comment=%d WHERE nid=%d", $comment[timestamp], $node->last_comment, $node->nid);
}
- if(variable_get('gsitemap_submit',0)) {
+ if (variable_get('gsitemap_submit',0)) {
_gsitemap_submit();
}
}
}
- else if(is_object($comment)) {
- if($op == 'insert' || $op == 'update' || $op == 'moderate' || $op == 'delete') {
+ elseif (is_object($comment)) {
+ if ($op == 'insert' || $op == 'update' || $op == 'moderate' || $op == 'delete') {
$result = db_query("SELECT * FROM {gsitemap} WHERE nid=%d",$comment->nid);
- if(!($node = db_fetch_object($result))) {
+ if (!($node = db_fetch_object($result))) {
$node = db_fetch_object(db_query("SELECT nid,changed FROM {node} WHERE nid=%d",$comment->nid));
db_query("INSERT INTO {gsitemap} (nid, last_changed, last_comment) VALUES(%d, %d, %d)",$node->nid, $node->changed, $comment->timestamp);
}
else {
- if(!isset($node->last_comment)) {
+ if (!isset($node->last_comment)) {
$node->last_comment = 'NULL';
}
db_query("UPDATE {gsitemap} SET last_comment=%d, previous_comment=%d WHERE nid=%d", $comment->timestamp, $node->last_comment, $node->nid);
}
- if(variable_get('gsitemap_submit',0)) {
+ if (variable_get('gsitemap_submit',0)) {
_gsitemap_submit();
}
}
@@ -179,124 +187,124 @@
}
/**
- * Implementation of hook_settings().
+ * Settings form
*/
-function gsitemap_settings() {
+function gsitemap_admin_settings() {
$form['priority_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Priority Settings'),
- '#collapsible' => TRUE,
- );
+ '#type' => 'fieldset',
+ '#title' => t('Priority Settings'),
+ '#collapsible' => TRUE,
+ );
$form['priority_settings']['gsitemap_frontpage'] = array(
- '#type' => 'textfield',
- '#title' => t('Front page priority'),
- '#default_value' => variable_get('gsitemap_frontpage', '1.0'),
- '#size' => 10,
- '#maxlength' => 5,
- '#description' => t('This is the absolute priority for the front page. Values can range between 0.0 and 1.0.'),
- );
+ '#type' => 'textfield',
+ '#title' => t('Front page priority'),
+ '#default_value' => variable_get('gsitemap_frontpage', '1.0'),
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#description' => t('This is the absolute priority for the front page. Values can range between 0.0 and 1.0.'),
+ );
$form['priority_settings']['gsitemap_promotewt'] = array(
- '#type' => 'textfield',
- '#title' => t('Promotion adjustment'),
- '#default_value' => variable_get('gsitemap_promotewt', 0.3),
- '#size' => 10,
- '#maxlength' => 5,
- '#description' => t('This number will be added to the priority of each node that is promoted to the front page.'),
- );
+ '#type' => 'textfield',
+ '#title' => t('Promotion adjustment'),
+ '#default_value' => variable_get('gsitemap_promotewt', 0.3),
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#description' => t('This number will be added to the priority of each node that is promoted to the front page.'),
+ );
$form['priority_settings']['gsitemap_commentwt'] = array(
- '#type' => 'textfield',
- '#title' => t('Comment ratio weight'),
- '#default_value' => variable_get('gsitemap_commentwt', 0.5),
- '#size' => 10,
- '#maxlength' => 5,
- '#description' => t('This number will be multiplied with the ratio of the number of comments on the node over the number of comments on the node with the most comments, i.e., this number will be added to the priority of the node with the most comments.'),
- );
+ '#type' => 'textfield',
+ '#title' => t('Comment ratio weight'),
+ '#default_value' => variable_get('gsitemap_commentwt', 0.5),
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#description' => t('This number will be multiplied with the ratio of the number of comments on the node over the number of comments on the node with the most comments, i.e., this number will be added to the priority of the node with the most comments.'),
+ );
// markup
$form['priority_settings']['note'] = array(
- '#type' => 'markup',
- '#value' => t('You can enter -1 in any of the following fields to prevent nodes of that type from appearing in the sitemap.'),
- );
+ '#type' => 'markup',
+ '#value' => t('You can enter -1 in any of the following fields to prevent nodes of that type from appearing in the sitemap.'),
+ );
- foreach(node_get_types() as $type => $name) {
+ foreach (node_get_types('names') as $type => $name) {
$form['priority_settings']['gsitemap_'. $type .'wt'] = array(
- '#type' => 'textfield',
- '#title' => t('%name adjustment', array('%name' => ucfirst($name))),
- '#default_value' => variable_get('gsitemap_'. $type .'wt', 0.1),
- '#size' => 10,
- '#maxlength' => 5,
- '#description' => t('This number will be added to the priority of nodes of type %name.', array('%name' => $name)),
- );
+ '#type' => 'textfield',
+ '#title' => t('%name adjustment', array('%name' => ucfirst($name))),
+ '#default_value' => variable_get('gsitemap_'. $type .'wt', 0.1),
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#description' => t('This number will be added to the priority of nodes of type %name.', array('%name' => $name)),
+ );
}
-
+
$form['other_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Other Settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
+ '#type' => 'fieldset',
+ '#title' => t('Other Settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
$form['other_settings']['gsitemap_verify'] = array(
- '#type' => 'textfield',
- '#title' => t('Verification link'),
- '#return value' => '',
- '#default_value' => variable_get('gsitemap_verify',''),
- '#description' => t('In order to view stats, Google will ask you to verify that you control this site by creating a page with a certain name. Enter that name here and the gsitemap module will hook that filename. Note that this will only work if you have clean URLs enabled.'),
- );
+ '#type' => 'textfield',
+ '#title' => t('Verification link'),
+ '#return value' => '',
+ '#default_value' => variable_get('gsitemap_verify',''),
+ '#description' => t('In order to view stats, Google will ask you to verify that you control this site by creating a page with a certain name. Enter that name here and the gsitemap module will hook that filename. Note that this will only work if you have clean URLs enabled.'),
+ );
$form['other_settings']['gsitemap_countcom'] = array(
- '#type' => 'checkbox',
- '#title' => t('Count comments in change date and frequency'),
- '#return_value' => 1,
- '#default_value' => variable_get('gsitemap_countcom', 1),
- '#description' => t('If enabled, the frequency of comments on a node will affect its change frequency and last modification date.'),
- );
+ '#type' => 'checkbox',
+ '#title' => t('Count comments in change date and frequency'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gsitemap_countcom', 1),
+ '#description' => t('If enabled, the frequency of comments on a node will affect its change frequency and last modification date.'),
+ );
$form['other_settings']['gsitemap_showterms'] = array(
- '#type' => 'checkbox',
- '#title' => t('Include links to taxonomy term pages'),
- '#return_value' => 1,
- '#default_value' => variable_get('gsitemap_showterms', 0),
- '#description' => t('If enabled, links to taxonomy term pages will be included in the sitemap.'),
- );
+ '#type' => 'checkbox',
+ '#title' => t('Include links to taxonomy term pages'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gsitemap_showterms', 0),
+ '#description' => t('If enabled, links to taxonomy term pages will be included in the sitemap.'),
+ );
$form['other_settings']['gsitemap_submit'] = array(
- '#type' => 'checkbox',
- '#title' => t('Submit sitemap to Google when updated'),
- '#return_value' => 1,
- '#default_value' => variable_get('gsitemap_submit', 0),
- '#description' => t('If enabled, the sitemap will be submitted to Google via HTTP request each time it is updated. If you have submitted your sitemap using a Google Account, this is probably unnecessary.'),
- );
+ '#type' => 'checkbox',
+ '#title' => t('Submit sitemap to Google when updated'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gsitemap_submit', 0),
+ '#description' => t('If enabled, the sitemap will be submitted to Google via HTTP request each time it is updated. If you have submitted your sitemap using a Google Account, this is probably unnecessary.'),
+ );
$form['other_settings']['gsitemap_cron_submit'] = array(
- '#type' => 'checkbox',
- '#title' => t('Submit sitemap to Google on cron run'),
- '#return_value' => 1,
- '#default_value' => variable_get('gsitemap_cron_submit', 0),
- '#description' => t('If enabled, the sitemap will be submitted to Google via HTTP request each time the cron job is run. If you have submitted your sitemap using a Google Account, this is probably unnecessary.'),
- );
+ '#type' => 'checkbox',
+ '#title' => t('Submit sitemap to Google on cron run'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gsitemap_cron_submit', 0),
+ '#description' => t('If enabled, the sitemap will be submitted to Google via HTTP request each time the cron job is run. If you have submitted your sitemap using a Google Account, this is probably unnecessary.'),
+ );
$form['other_settings']['gsitemap_logacc'] = array(
- '#type' => 'checkbox',
- '#title' => t('Log accesses'),
- '#return_value' => 1,
- '#default_value' => variable_get('gsitemap_logacc', 0),
- '#description' => t('If enabled, an watchdog entry will be made each time the sitemap is accessed, containing information about the requestor.'),
- );
+ '#type' => 'checkbox',
+ '#title' => t('Log accesses'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gsitemap_logacc', 0),
+ '#description' => t('If enabled, an watchdog entry will be made each time the sitemap is accessed, containing information about the requestor.'),
+ );
menu_rebuild(); // Needed for verification link
- return $form;
+ return system_settings_form($form);
}
function gsitemap_cron() {
- if(variable_get('gsitemap_cron_submit',0)) {
+ if (variable_get('gsitemap_cron_submit',0)) {
_gsitemap_submit();
}
}
function gsitemap_output() {
- if(!ini_get('safe_mode')) {
+ if (!ini_get('safe_mode')) {
set_time_limit(240);
}
$countcom = variable_get('gsitemap_countcom',1);
$excluded_types = array("''");
- foreach(node_get_types() as $type => $name) {
- if(variable_get('gsitemap_' . $type . 'wt',0) < 0) {
+ foreach (node_get_types() as $type => $name) {
+ if (variable_get('gsitemap_' . $type . 'wt',0) < 0) {
$excluded_types[] = "'" . $type . "'";
}
}
@@ -310,8 +318,8 @@
$count[0] = db_fetch_object($result);
$result = db_query("SELECT COUNT(*) AS count FROM {gsitemap}");
$count[1] = db_fetch_object($result);
- if(module_exist('comment')) {
- if($count[0]->count != $count[1]->count) {
+ if (module_exists('comment')) {
+ if ($count[0]->count != $count[1]->count) {
$result = db_query("SELECT {node}.nid, changed FROM {node} LEFT JOIN {gsitemap} USING(nid) WHERE {gsitemap}.nid IS NULL");
while($node = db_fetch_object($result)) {
db_query("INSERT INTO {gsitemap} (nid, last_changed) VALUES(%d,%d)", $node->nid, $node->changed);
@@ -325,7 +333,7 @@
$result = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.type, n.status, n.promote, s.comment_count, n.changed, g.previously_changed, s.last_comment_timestamp, g.previous_comment, g.priority_override FROM {node} n LEFT JOIN {node_comment_statistics} s ON n.nid=s.nid LEFT JOIN {gsitemap} g ON n.nid=g.nid LEFT JOIN {url_alias} u ON src=CONCAT('node/', n.nid) WHERE n.status > 0 AND (g.priority_override >= 0 OR g.priority_override IS NULL) AND n.type NOT IN (" . $excludes . ")",'n'));
}
else {
- if($count[0]->count != $count[1]->count) {
+ if ($count[0]->count != $count[1]->count) {
$result = db_query("SELECT {node}.nid, changed FROM {node} LEFT JOIN {gsitemap} USING(nid) WHERE {gsitemap}.nid IS NULL");
while($node = db_fetch_object($result)) {
db_query("INSERT INTO {gsitemap} (nid,last_changed) VALUES(%d,%d)", $node->nid, $node->changed);
@@ -335,11 +343,11 @@
}
while($node = db_fetch_object($result)) {
$pri = _gsitemap_calc_priority($node,$maxcomments->max_comments);
- if($pri < 0) {
+ if ($pri < 0) {
continue;
}
print '';
- if(isset($node->dst)) {
+ if (isset($node->dst)) {
print "" . url($node->dst, NULL, NULL, TRUE) . "";
}
else {
@@ -350,14 +358,14 @@
print "$pri";
$age = time() - max($node->changed,$node->last_comment_timestamp * $countcom);
- if($countcom) {
- if(isset($node->previously_changed) && isset($node->previous_comment)) {
+ if ($countcom) {
+ if (isset($node->previously_changed) && isset($node->previous_comment)) {
$interval = min($node->changed,$node->last_comment_timestamp) - max($node->previously_changed,$node->previous_comment);
}
- else if(isset($node->previously_changed)) {
+ elseif (isset($node->previously_changed)) {
$interval = min($node->changed,$node->last_comment_timestamp) - $node->previously_changed;
}
- else if(isset($node->previous_comment)) {
+ elseif (isset($node->previous_comment)) {
$interval = min($node->changed,$node->last_comment_timestamp) - $node->previous_comment;
}
else {
@@ -365,29 +373,29 @@
}
}
else {
- if(isset($node->previously_changed)) {
+ if (isset($node->previously_changed)) {
$interval = $node->changed - $node->previously_changed;
}
else {
$interval = 0;
}
}
- if(max($age,$interval)<3600) {
+ if (max($age,$interval)<3600) {
print 'always';
}
- elseif(max($age,$interval)<86400) {
+ elseif (max($age,$interval)<86400) {
print 'hourly';
}
- elseif(max($age,$interval)<604800) {
+ elseif (max($age,$interval)<604800) {
print 'daily';
}
- elseif(max($age,$interval)<2419200) {
+ elseif (max($age,$interval)<2419200) {
print 'weekly';
}
- elseif(max($age,$interval)<29030400) {
+ elseif (max($age,$interval)<29030400) {
print 'monthly';
}
- elseif(max($age,$interval)<100000000) {
+ elseif (max($age,$interval)<100000000) {
print 'yearly';
}
else {
@@ -395,53 +403,53 @@
}
print "";
}
- if(variable_get('gsitemap_showterms',0)) {
- foreach(taxonomy_get_vocabularies() as $vocab) {
- foreach(taxonomy_get_tree($vocab->vid) as $term) {
+ if (variable_get('gsitemap_showterms',0)) {
+ foreach (taxonomy_get_vocabularies() as $vocab) {
+ foreach (taxonomy_get_tree($vocab->vid) as $term) {
print '' . url(taxonomy_term_path($term), NULL, NULL, TRUE) . 'always';
}
}
}
$additional = module_invoke_all('gsitemap');
- foreach($additional as $entry)
- {
+ foreach ($additional as $entry) {
print '';
- if($entry['#loc']) {
+ if ($entry['#loc']) {
print '' . $entry['#loc'] . '';
}
- if($entry['#lastmod']) {
+ if ($entry['#lastmod']) {
print '' . $entry['#lastmod'] . '';
}
- if($entry['#changefreq']) {
+ if ($entry['#changefreq']) {
print '' . $entry['#changefreq'] . '';
}
- if($entry['#priority']) {
+ if ($entry['#priority']) {
print '' . $entry['#priority'] . '';
}
print '';
}
print "";
- if(variable_get('gsitemap_logacc',0)) {
- if(strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')) {
- watchdog('gsitemap','Sitemap downloaded by Google.');
+ if (variable_get('gsitemap_logacc',0)) {
+ if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')) {
+ watchdog('gsitemap', t('Sitemap downloaded by Google.'));
}
else {
- watchdog('gsitemap','Sitemap downloaded by ' . $_SERVER['HTTP_USER_AGENT'] . ' at ' . $_SERVER['REMOTE_ADDR'] . '.');
+ watchdog('gsitemap', t('Sitemap downloaded by @user-agent at @address.', array('@user-agent' => $_SERVER['HTTP_USER_AGENT'], '@address' => $_SERVER['REMOTE_ADDR'])));
}
}
}
+
function gsitemap_verify() {
print 'Hello, Google!';
}
-function _gsitemap_calc_priority($node,$maxcomments)
-{
- if(!isset($node->priority_override)) {
+
+function _gsitemap_calc_priority($node,$maxcomments) {
+ if (!isset($node->priority_override)) {
$pri = 0.0; // Default priority
$pri += variable_get('gsitemap_' . $node->type . 'wt', 0.1);
- if($node->promote) {
+ if ($node->promote) {
$pri += variable_get('gsitemap_promotewt',.3);
}
- if($maxcomments != 0) {
+ if ($maxcomments != 0) {
$pri += $node->comment_count / $maxcomments * variable_get('gsitemap_commentwt',0.5);
}
@@ -457,18 +465,17 @@
$pri = min($pri,0.9);
}
else {
- $pri = (($node->priority_override >= 0)?$node->priority_override:-1);
+ $pri = $node->priority_override >= 0 ? $node->priority_override : -1;
}
return $pri;
}
+
function _gsitemap_submit() {
- $result = drupal_http_request('http://www.google.com/webmasters/tools/ping?sitemap=' . url('gsitemap', NULL, NULL, TRUE));
- if($result->code == 200) {
- watchdog("gsitemap","Sitemap successfully submitted to Google.");
+ $result = drupal_http_request('http://www.google.com/webmasters/tools/ping?sitemap='. url('gsitemap', NULL, NULL, TRUE));
+ if ($result->code == 200) {
+ watchdog('gsitemap', t('Sitemap successfully submitted to Google.'));
}
else {
- watchdog("gsitemap","Error occurred submitting sitemap to Google: $result->code",WATCHDOG_ERROR);
+ watchdog('gsitemap', t('Error occurred submitting sitemap to Google: @code', array('@code' => $result->code)), WATCHDOG_ERROR);
}
}
-
-?>
--- gsitemap/gsitemap.info
+++ gsitemap/gsitemap.info
@@ -0,0 +1,3 @@
+; $Id$
+name = Google Sitemap
+description = Creates a Google Sitemap.
--- gsitemap/gsitemap.install
+++ gsitemap/gsitemap.install
@@ -0,0 +1,34 @@
+