📄 serendipity_event_weblogping.php
字号:
<?php # $Id: serendipity_event_weblogping.php,v 1.4.4.1 2004/06/14 10:36:49 garvinhicking Exp $/*******************************************************汉化作者:youngong(http://youngong.blogbus.com) **官方主页:http://www.s9y.corg **我的信箱:youngong@163.com **如果有问题,欢迎和作者及汉化作者联系。 ********************************************************/switch ($serendipity['lang']) { case 'de': @define('PLUGIN_EVENT_WEBLOGPING_PING', 'Eintr鋑e ank黱digen (via XML-RPC ping) bei:'); @define('PLUGIN_EVENT_WEBLOGPING_SENDINGPING', 'Sende XML-RPC ping zu %s'); @define('PLUGIN_EVENT_WEBLOGPING_TITLE', 'Eintr鋑e ank黱digen'); @define('PLUGIN_EVENT_WEBLOGPING_DESC', '(via XML-RPC ping)'); @define('PLUGIN_EVENT_WEBLOGPING_SUPERSEDES', '(ersetzt %s)'); break; case 'cn': @define('PLUGIN_EVENT_WEBLOGPING_PING', '为声明项目(via XML-RPC ping):'); @define('PLUGIN_EVENT_WEBLOGPING_SENDINGPING', '给%s主机发送XML-RPC ping'); @define('PLUGIN_EVENT_WEBLOGPING_TITLE', '声明项目'); @define('PLUGIN_EVENT_WEBLOGPING_DESC', '(via XML-RPC ping)'); @define('PLUGIN_EVENT_WEBLOGPING_SUPERSEDES', '(延迟 %s)'); break; case 'en': case 'es': default: @define('PLUGIN_EVENT_WEBLOGPING_PING', 'Announce entries (via XML-RPC ping) to:'); @define('PLUGIN_EVENT_WEBLOGPING_SENDINGPING', 'Sending XML-RPC ping to host %s'); @define('PLUGIN_EVENT_WEBLOGPING_TITLE', 'Announce entries'); @define('PLUGIN_EVENT_WEBLOGPING_DESC', '(via XML-RPC ping)'); @define('PLUGIN_EVENT_WEBLOGPING_SUPERSEDES', '(supersedes %s)'); break;}class serendipity_event_weblogping extends serendipity_event{var $services; function introspect(&$propbag) { global $serendipity; $propbag->add('name', PLUGIN_EVENT_WEBLOGPING_TITLE); $propbag->add('description', PLUGIN_EVENT_WEBLOGPING_DESC); $propbag->add('event_hooks', array( 'backend_display' => true, 'frontend_display' => true, 'backend_insert' => true, 'backend_update' => true, 'backend_publish' => true, 'backend_draft' => true )); $this->services = array( array( 'name' => 'blo.gs', 'host' => 'ping.blo.gs', 'path' => '/', 'extended' => true ), array( 'name' => 'blogrolling.com', 'host' => 'rpc.blogrolling.com', 'path' => '/pinger/' ), array( 'name' => 'technorati.com', 'host' => 'rpc.technorati.com', 'path' => '/rpc/ping' ), array( 'name' => 'weblogs.com', 'host' => 'rpc.weblogs.com', 'path' => '/RPC2' ), array( 'name' => 'blogg.de', 'host' => 'xmlrpc.blogg.de', 'path' => '/' ), array( 'name' => 'Yahoo!', 'host' => 'api.my.yahoo.com', 'path' => '/RPC2' ), array( 'name' => 'Blogbot.dk', 'host' => 'blogbot.dk', 'path' => '/io/xml-rpc.php' ) ); $conf_array = array(); foreach($this->services AS $key => $service) { $conf_array[] = $service['name']; } $propbag->add('configuration', $conf_array); } function introspect_config_item($name, &$propbag) { $propbag->add('type', 'boolean'); $propbag->add('name', $name); $propbag->add('description', sprintf(PLUGIN_EVENT_WEBLOGPING_PING, $name)); return true; } function generate_content(&$title) { $title = PLUGIN_EVENT_WEBLOGPING_TITLE . ' ' . PLUGIN_EVENT_WEBLOGPING_DESC; } function event_hook($event, &$bag, &$eventData) { global $serendipity; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'backend_display':?> <fieldset style="margin: 5px"> <legend><?php echo PLUGIN_EVENT_WEBLOGPING_PING; ?></legend><?php foreach($this->services AS $index => $service) { // Detect if the current checkbox needs to be saved. We use the field chk_timestamp to see, // if the form has already been submitted and individual changes shall be preserved $selected = (($serendipity['POST']['chk_timestamp'] && $serendipity['POST']['announce_entries_' . $service['name']]) || (!isset($serendipity['POST']['chk_timestamp']) && $this->get_config($service['name']) == 'true') ? 'checked="checked"' : ''); $onclick = ''; if (!empty($service['supersedes'])) { $onclick = 'onclick="'; $supersedes = explode(', ', $service['supersedes']); foreach($supersedes AS $sid => $servicename) { $onclick .= 'document.getElementById(\'serendipity[announce_entries_' . $servicename . ']\').checked = false; '; } $onclick .= '"'; } $title = sprintf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING, $service['name']) . (!empty($service['supersedes']) ? ' ' . sprintf(PLUGIN_EVENT_WEBLOGPING_SUPERSEDES, $service['supersedes']) : '');?> <input <?php echo $onclick; ?> style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" name="serendipity[announce_entries_<?php echo $service['name']; ?>]" id="serendipity[announce_entries_<?php echo $service['name']; ?>]" value="true" <?php echo $selected; ?> /> <label title="<?php echo $title; ?>" style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[announce_entries_<?php echo $service['name']; ?>]"> <?php echo $service['name']; ?> </label><?php }?> </fieldset><?php return true; break; case 'backend_publish': // First cycle through list of services to remove superseding services which may have been checked foreach ($this->services as $index => $service) { if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) { $supersedes = explode(', ', $service['supersedes']); foreach($supersedes AS $sid => $servicename) { // A service has been checked that is superseded by another checked meta-service. Remove that service from the list of services to be ping'd unset($serendipity['POST']['announce_entries_' . $servicename]); } } } foreach ($this->services as $index => $service) { if (isset($serendipity['POST']['announce_entries_' . $service['name']])) { printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...<br />', $service['host']); # XXX append $serendipity['indexFile'] to baseURL? $args = array( new XML_RPC_Value( $serendipity['blogTitle'], 'string' ), new XML_RPC_Value( $serendipity['baseURL'], 'string' ) ); if ($service['extended']) { # the checkUrl: for when the main page is not really the main page $args[] = new XML_RPC_Value( '', 'string' ); # the rssUrl $args[] = new XML_RPC_Value( $serendipity['baseURL'] . 'rss.php?version=2.0', 'string' ); } $message = new XML_RPC_Message( $service['extended'] ? 'weblogUpdates.extendedPing' : 'weblogUpdates.ping', $args ); $client = new XML_RPC_Client( $service['path'], $service['host'] ); # 15 second timeout may not be long enough for weblogs.com $result = $client->send($message, 15); } } return true; break; case 'frontend_display': case 'backend_insert': case 'backend_update': case 'backend_draft': default: return false; break; } } else { return false; } }}/* vim: set sts=4 ts=4 expandtab : */?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -