Commit cd2f2bc0 authored by Dries's avatar Dries

- More code improvements by JonBob. Thanks a bunch.

parent 10c5e95a
......@@ -62,7 +62,7 @@ function menu_perm() {
}
/**
* Present the main menu management page.
* Menu callback; present the main menu management page.
*/
function menu_overview() {
menu_rebuild();
......@@ -71,7 +71,7 @@ function menu_overview() {
}
/**
* Clear the database, resetting the menu to factory defaults.
* Menu callback; clear the database, resetting the menu to factory defaults.
*/
function menu_reset() {
$op = $_POST['op'];
......@@ -93,7 +93,7 @@ function menu_reset() {
}
/**
* Handle the adding of a new menu.
* Menu callback; handle the adding of a new menu.
*/
function menu_add_menu() {
$op = $_POST['op'];
......@@ -115,7 +115,7 @@ function menu_add_menu() {
}
/**
* Reset a single modified item.
* Menu callback; reset a single modified item.
*/
function menu_reset_item($mid) {
$op = $_POST['op'];
......@@ -137,7 +137,7 @@ function menu_reset_item($mid) {
}
/**
* Delete a single custom item.
* Menu callback; delete a single custom item.
*/
function menu_delete_item($mid) {
$op = $_POST['op'];
......@@ -159,17 +159,17 @@ function menu_delete_item($mid) {
}
/**
* Hide a menu item.
* Menu callback; hide a menu item.
*/
function menu_disable_item($mid) {
db_query("UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d", MENU_HIDE, MENU_MODIFIED, $mid);
db_query('UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d', MENU_HIDE, MENU_MODIFIED, $mid);
menu_rebuild();
drupal_set_message(t('menu item disabled.'));
print theme('page', menu_overview_tree());
}
/**
* Dispatch to the appropriate menu item edit function.
* Menu callback; dispatch to the appropriate menu item edit function.
*/
function menu_edit_item($mid) {
$op = $_POST['op'];
......
......@@ -62,7 +62,7 @@ function menu_perm() {
}
/**
* Present the main menu management page.
* Menu callback; present the main menu management page.
*/
function menu_overview() {
menu_rebuild();
......@@ -71,7 +71,7 @@ function menu_overview() {
}
/**
* Clear the database, resetting the menu to factory defaults.
* Menu callback; clear the database, resetting the menu to factory defaults.
*/
function menu_reset() {
$op = $_POST['op'];
......@@ -93,7 +93,7 @@ function menu_reset() {
}
/**
* Handle the adding of a new menu.
* Menu callback; handle the adding of a new menu.
*/
function menu_add_menu() {
$op = $_POST['op'];
......@@ -115,7 +115,7 @@ function menu_add_menu() {
}
/**
* Reset a single modified item.
* Menu callback; reset a single modified item.
*/
function menu_reset_item($mid) {
$op = $_POST['op'];
......@@ -137,7 +137,7 @@ function menu_reset_item($mid) {
}
/**
* Delete a single custom item.
* Menu callback; delete a single custom item.
*/
function menu_delete_item($mid) {
$op = $_POST['op'];
......@@ -159,17 +159,17 @@ function menu_delete_item($mid) {
}
/**
* Hide a menu item.
* Menu callback; hide a menu item.
*/
function menu_disable_item($mid) {
db_query("UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d", MENU_HIDE, MENU_MODIFIED, $mid);
db_query('UPDATE {menu} SET visibility = %d, status = %d WHERE mid = %d', MENU_HIDE, MENU_MODIFIED, $mid);
menu_rebuild();
drupal_set_message(t('menu item disabled.'));
print theme('page', menu_overview_tree());
}
/**
* Dispatch to the appropriate menu item edit function.
* Menu callback; dispatch to the appropriate menu item edit function.
*/
function menu_edit_item($mid) {
$op = $_POST['op'];
......
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
function ping_help($section = "admin/help#ping") {
$output = "";
/**
* Implementation of hook_help().
*/
function ping_help($section) {
switch ($section) {
case 'admin/help#ping':
$output .= t("
......@@ -11,82 +12,94 @@ function ping_help($section = "admin/help#ping") {
<p>%weblogs, a web site that tracks and displays links to changed weblogs and news-oriented web sites. To get your Drupal site listed, weblogs.com must be informed about your site's updates. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %weblogs system. The ping module automatically notifies weblogs.com when your site is updated. To do so, Drupal implements the %weblogs-XML.</p>
<p>%weblogs-RSS, a web site that tracks and displays links to recently changed RSS feeds in XML format. To get your Drupal site listed, %weblogs-RSS must be informed about updates to your RSS feed. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %weblogs-RSS-changes system. The ping module automatically notifies %weblogs-RSS when your site is updated.</p>
<p>%blo-gs, a directory of recently updated weblogs and tools for tracking interesting weblogs, in the spirit of services like %weblogs, %blogtracker and %blogrolling. To get your Drupal site listed, %blo-gs must be informed about your site's updates. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %blo-gs system. The ping module automatically notifies blo.gs when your site is updated. To do so, Drupal implements the %blo-gs-XML.</p>
<p>The ping feature requires crontab.</p>", array("%weblogs" => "<a href=\"http://www.weblogs.com/\">Weblogs.com</a>", "%weblogs-XML" => "<a href=\"http://www.xmlrpc.com/weblogsCom/\">". t("XML-RPC interface of weblogs.com") ."</a>", "%weblogs-RSS" => "<a href=\"http://www.xmlrpc.com/weblogsComForRSS\">". t("Weblogs.Com for RSS") ."</a>", "%weblogs-RSS-changes" => "<a href=\"http://www.weblogs.com/rssUpdates/changes.xml\">". t("the weblogs.com for RSS") ."</a>", "%blo-gs" => "<a href=\"http://blo.gs/\">blo.gs</a>", "%blogtracker" => "<a href=\"http://www.dansanderson.com/blogtracker\">blogtracker</a>", "%blogrolling" => "<a href=\"http://www.blogrolling.com\">blogtolling.com</a>", "%blo-gs-XML" => "<a href=\"http://blo.gs/ping.php\">". t("XML-RPC interface of blo.gs") ."</a>"));
<p>The ping feature requires crontab.</p>", array('%weblogs' => '<a href="http://www.weblogs.com/">Weblogs.com</a>', '%weblogs-XML' => '<a href="http://www.xmlrpc.com/weblogsCom/">'. t('XML-RPC interface of weblogs.com') .'</a>', '%weblogs-RSS' => '<a href="http://www.xmlrpc.com/weblogsComForRSS">'. t('Weblogs.Com for RSS') .'</a>', '%weblogs-RSS-changes' => '<a href="http://www.weblogs.com/rssUpdates/changes.xml">'. t('the weblogs.com for RSS') .'</a>', '%blo-gs' => '<a href="http://blo.gs/">blo.gs</a>', '%blogtracker' => '<a href="http://www.dansanderson.com/blogtracker">blogtracker</a>', '%blogrolling' => '<a href="http://www.blogrolling.com">blogrolling.com</a>', '%blo-gs-XML' => '<a href="http://blo.gs/ping.php">'. t('XML-RPC interface of blo.gs') .'</a>'));
break;
case 'admin/system/modules#description':
$output = t("Alerts other site(s) that your site has been updated.");
$output = t('Alerts other sites that your site has been updated.');
break;
}
return $output;
}
/**
* Implementation of hook_cron().
*
* Fire off notifications of updates to remote sites.
*/
function ping_cron() {
global $base_url;
if (variable_get("site_name", 0) && variable_get("site_slogan", 0)) {
if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get("ping_cron_last", time()) ."' OR changed > '". variable_get("ping_cron_last", time()) ."')"), 1)) {
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), $base_url);
if (variable_get('site_name', 0) && variable_get('site_slogan', 0)) {
if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get('ping_cron_last', time()) ."' OR changed > '". variable_get('ping_cron_last', time()) ."')"), 1)) {
_ping_notify(variable_get('site_name', '') .' - '. variable_get('site_slogan', ''), $base_url);
}
variable_set("ping_cron_last", time());
variable_set('ping_cron_last', time());
}
}
/**
* Call hook_ping() in all modules to notify remote sites that there is
* new content at this one.
*/
function _ping_notify($name, $url) {
module_invoke_all("ping", $name, $url);
module_invoke_all('ping', $name, $url);
}
function ping_ping($name = "", $url = "") {
$feed = url("node/feed");
/**
* Implementation of hook_ping().
*
* Notifies weblogs.com, blo.gs, and technorati.com of changes at this site.
*/
function ping_ping($name = '', $url = '') {
$feed = url('node/feed');
$client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80);
$client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'weblogs.com' (site)");
watchdog('error', 'failed to notify "weblogs.com" (site)');
}
unset($client);
$client = new xmlrpc_client("/RPC2", "rssrpc.weblogs.com", 80);
$client = new xmlrpc_client('/RPC2', 'rssrpc.weblogs.com', 80);
$message = new xmlrpcmsg("rssUpdate", array(new xmlrpcval($name), new xmlrpcval($feed)));
$message = new xmlrpcmsg('rssUpdate', array(new xmlrpcval($name), new xmlrpcval($feed)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'weblogs.com' (RSS)");
watchdog('error', 'failed to notify "weblogs.com" (RSS)');
}
unset($client);
$client = new xmlrpc_client("/", "ping.blo.gs", 80);
$client = new xmlrpc_client('/', 'ping.blo.gs', 80);
$message = new xmlrpcmsg("weblogUpdates.extendedPing", array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed)));
$message = new xmlrpcmsg('weblogUpdates.extendedPing', array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'blo.gs' ");
watchdog('error', 'failed to notify "blo.gs" ');
}
unset($client);
$client = new xmlrpc_client("/rpc/ping", "rpc.technorati.com", 80);
$client = new xmlrpc_client('/rpc/ping', 'rpc.technorati.com', 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'technorati.com'");
watchdog('error', 'failed to notify "technorati.com"');
}
}
?>
<?php
// $Id$
function ping_help($section = "admin/help#ping") {
$output = "";
/**
* Implementation of hook_help().
*/
function ping_help($section) {
switch ($section) {
case 'admin/help#ping':
$output .= t("
......@@ -11,82 +12,94 @@ function ping_help($section = "admin/help#ping") {
<p>%weblogs, a web site that tracks and displays links to changed weblogs and news-oriented web sites. To get your Drupal site listed, weblogs.com must be informed about your site's updates. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %weblogs system. The ping module automatically notifies weblogs.com when your site is updated. To do so, Drupal implements the %weblogs-XML.</p>
<p>%weblogs-RSS, a web site that tracks and displays links to recently changed RSS feeds in XML format. To get your Drupal site listed, %weblogs-RSS must be informed about updates to your RSS feed. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %weblogs-RSS-changes system. The ping module automatically notifies %weblogs-RSS when your site is updated.</p>
<p>%blo-gs, a directory of recently updated weblogs and tools for tracking interesting weblogs, in the spirit of services like %weblogs, %blogtracker and %blogrolling. To get your Drupal site listed, %blo-gs must be informed about your site's updates. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %blo-gs system. The ping module automatically notifies blo.gs when your site is updated. To do so, Drupal implements the %blo-gs-XML.</p>
<p>The ping feature requires crontab.</p>", array("%weblogs" => "<a href=\"http://www.weblogs.com/\">Weblogs.com</a>", "%weblogs-XML" => "<a href=\"http://www.xmlrpc.com/weblogsCom/\">". t("XML-RPC interface of weblogs.com") ."</a>", "%weblogs-RSS" => "<a href=\"http://www.xmlrpc.com/weblogsComForRSS\">". t("Weblogs.Com for RSS") ."</a>", "%weblogs-RSS-changes" => "<a href=\"http://www.weblogs.com/rssUpdates/changes.xml\">". t("the weblogs.com for RSS") ."</a>", "%blo-gs" => "<a href=\"http://blo.gs/\">blo.gs</a>", "%blogtracker" => "<a href=\"http://www.dansanderson.com/blogtracker\">blogtracker</a>", "%blogrolling" => "<a href=\"http://www.blogrolling.com\">blogtolling.com</a>", "%blo-gs-XML" => "<a href=\"http://blo.gs/ping.php\">". t("XML-RPC interface of blo.gs") ."</a>"));
<p>The ping feature requires crontab.</p>", array('%weblogs' => '<a href="http://www.weblogs.com/">Weblogs.com</a>', '%weblogs-XML' => '<a href="http://www.xmlrpc.com/weblogsCom/">'. t('XML-RPC interface of weblogs.com') .'</a>', '%weblogs-RSS' => '<a href="http://www.xmlrpc.com/weblogsComForRSS">'. t('Weblogs.Com for RSS') .'</a>', '%weblogs-RSS-changes' => '<a href="http://www.weblogs.com/rssUpdates/changes.xml">'. t('the weblogs.com for RSS') .'</a>', '%blo-gs' => '<a href="http://blo.gs/">blo.gs</a>', '%blogtracker' => '<a href="http://www.dansanderson.com/blogtracker">blogtracker</a>', '%blogrolling' => '<a href="http://www.blogrolling.com">blogrolling.com</a>', '%blo-gs-XML' => '<a href="http://blo.gs/ping.php">'. t('XML-RPC interface of blo.gs') .'</a>'));
break;
case 'admin/system/modules#description':
$output = t("Alerts other site(s) that your site has been updated.");
$output = t('Alerts other sites that your site has been updated.');
break;
}
return $output;
}
/**
* Implementation of hook_cron().
*
* Fire off notifications of updates to remote sites.
*/
function ping_cron() {
global $base_url;
if (variable_get("site_name", 0) && variable_get("site_slogan", 0)) {
if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get("ping_cron_last", time()) ."' OR changed > '". variable_get("ping_cron_last", time()) ."')"), 1)) {
_ping_notify(variable_get("site_name", "") ." - ". variable_get("site_slogan", ""), $base_url);
if (variable_get('site_name', 0) && variable_get('site_slogan', 0)) {
if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get('ping_cron_last', time()) ."' OR changed > '". variable_get('ping_cron_last', time()) ."')"), 1)) {
_ping_notify(variable_get('site_name', '') .' - '. variable_get('site_slogan', ''), $base_url);
}
variable_set("ping_cron_last", time());
variable_set('ping_cron_last', time());
}
}
/**
* Call hook_ping() in all modules to notify remote sites that there is
* new content at this one.
*/
function _ping_notify($name, $url) {
module_invoke_all("ping", $name, $url);
module_invoke_all('ping', $name, $url);
}
function ping_ping($name = "", $url = "") {
$feed = url("node/feed");
/**
* Implementation of hook_ping().
*
* Notifies weblogs.com, blo.gs, and technorati.com of changes at this site.
*/
function ping_ping($name = '', $url = '') {
$feed = url('node/feed');
$client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80);
$client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'weblogs.com' (site)");
watchdog('error', 'failed to notify "weblogs.com" (site)');
}
unset($client);
$client = new xmlrpc_client("/RPC2", "rssrpc.weblogs.com", 80);
$client = new xmlrpc_client('/RPC2', 'rssrpc.weblogs.com', 80);
$message = new xmlrpcmsg("rssUpdate", array(new xmlrpcval($name), new xmlrpcval($feed)));
$message = new xmlrpcmsg('rssUpdate', array(new xmlrpcval($name), new xmlrpcval($feed)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'weblogs.com' (RSS)");
watchdog('error', 'failed to notify "weblogs.com" (RSS)');
}
unset($client);
$client = new xmlrpc_client("/", "ping.blo.gs", 80);
$client = new xmlrpc_client('/', 'ping.blo.gs', 80);
$message = new xmlrpcmsg("weblogUpdates.extendedPing", array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed)));
$message = new xmlrpcmsg('weblogUpdates.extendedPing', array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'blo.gs' ");
watchdog('error', 'failed to notify "blo.gs" ');
}
unset($client);
$client = new xmlrpc_client("/rpc/ping", "rpc.technorati.com", 80);
$client = new xmlrpc_client('/rpc/ping', 'rpc.technorati.com', 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify 'technorati.com'");
watchdog('error', 'failed to notify "technorati.com"');
}
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment