[geeklog-hg] geeklog: Allow XMLSitemap Plugin to Ping Search Engines when new...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Wed Feb 5 09:23:57 EST 2014
changeset 9477:75bd685e64fe
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/75bd685e64fe
user: Kenji ITO <mystralkk at gmail.com>
date: Wed Feb 05 23:22:36 2014 +0900
description:
Allow XMLSitemap Plugin to Ping Search Engines when new content is added (feature requests #0001573)
diffstat:
plugins/xmlsitemap/autoinstall.php | 25 +-
plugins/xmlsitemap/configuration_validation.php | 11 +-
plugins/xmlsitemap/functions.inc | 182 ++++++++++++++------
plugins/xmlsitemap/install_defaults.php | 65 ++++--
plugins/xmlsitemap/install_updates.php | 34 +++-
plugins/xmlsitemap/language/english.php | 13 +-
plugins/xmlsitemap/language/english_utf-8.php | 13 +-
plugins/xmlsitemap/language/japanese_utf-8.php | 17 +-
plugins/xmlsitemap/sql/mssql_install.php | 6 +-
plugins/xmlsitemap/sql/mssql_updates.php | 4 +-
plugins/xmlsitemap/sql/mysql_install.php | 4 +-
plugins/xmlsitemap/sql/mysql_updates.php | 4 +-
plugins/xmlsitemap/sql/pgsql_install.php | 4 +-
plugins/xmlsitemap/sql/pgsql_updates.php | 4 +-
plugins/xmlsitemap/xmlsitemap.class.php | 212 ++++++++++++++++++-----
public_html/docs/english/xmlsitemap.html | 108 ++++++++++++
public_html/docs/japanese/xmlsitemap.html | 108 ++++++++++++
17 files changed, 641 insertions(+), 173 deletions(-)
diffs (truncated from 1597 to 300 lines):
diff -r 1f6433ff633f -r 75bd685e64fe plugins/xmlsitemap/autoinstall.php
--- a/plugins/xmlsitemap/autoinstall.php Mon Feb 03 21:32:20 2014 +0900
+++ b/plugins/xmlsitemap/autoinstall.php Wed Feb 05 23:22:36 2014 +0900
@@ -2,13 +2,13 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | XMLSitemap Plugin 1.0 |
+// | XMLSitemap Plugin 2.0 |
// +---------------------------------------------------------------------------+
// | autoinstall.php |
// | |
// | This file provides helper functions for the automatic plugin install. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors: |
+// | Copyright (C) 2009-2014 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -52,11 +52,11 @@
$info = array(
'pi_name' => $pi_name,
'pi_display_name' => $pi_display_name,
- 'pi_version' => '1.0.1',
+ 'pi_version' => '2.0.0',
'pi_gl_version' => '1.8.0',
'pi_homepage' => 'http://www.geeklog.net/',
);
-
+
$groups = array(
$pi_admin => 'Has full access to ' . $pi_display_name . ' features'
);
@@ -87,19 +87,19 @@
* Load plugin configuration from database
*
* @param string $pi_name Plugin name
-* @return boolean TRUE on success, otherwise FALSE
+* @return boolean true on success, otherwise false
* @see plugin_initconfig_xmlsitemap
*
*/
function plugin_load_configuration_xmlsitemap($pi_name)
{
global $_CONF;
-
+
$base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
-
+
require_once $_CONF['path_system'] . 'classes/config.class.php';
require_once $base_path . 'install_defaults.php';
-
+
return plugin_initconfig_xmlsitemap();
}
@@ -107,7 +107,7 @@
* Check if the plugin is compatible with this Geeklog version
*
* @param string $pi_name Plugin name
-* @return boolean TRUE: plugin compatible; FALSE: not compatible
+* @return boolean true: plugin compatible; false: not compatible
*
*/
function plugin_compatible_with_this_version_xmlsitemap($pi_name)
@@ -117,6 +117,7 @@
// check if we support the DBMS the site is running on
$dbFile = $_CONF['path'] . 'plugins/' . $pi_name . '/sql/'
. $_DB_dbms . '_install.php';
+
if (! file_exists($dbFile)) {
return false;
}
@@ -128,14 +129,14 @@
* Perform post-install operations
*
* @param string $pi_name Plugin name
-* @return boolean TRUE: plugin compatible; FALSE: not compatible
+* @return boolean true: plugin compatible; false: not compatible
*/
function plugin_postinstall_xmlsitemap($pi_name)
{
global $_CONF, $_XMLSMAP_CONF;
-
+
require_once $_CONF['path'] . 'plugins/xmlsitemap/functions.inc';
-
+
// Create an XML sitemap for the first time
return XMLSMAP_update();
}
diff -r 1f6433ff633f -r 75bd685e64fe plugins/xmlsitemap/configuration_validation.php
--- a/plugins/xmlsitemap/configuration_validation.php Mon Feb 03 21:32:20 2014 +0900
+++ b/plugins/xmlsitemap/configuration_validation.php Wed Feb 05 23:22:36 2014 +0900
@@ -2,11 +2,11 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | XML Sitemap |
+// | XML Sitemap 2.0 |
// +---------------------------------------------------------------------------+
// | configuration_validation.php |
// | |
-// | List of validation rules for the Links plugin configurations |
+// | List of validation rules for the Links plugin configurations |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2007-2010 by the following authors: |
// | |
@@ -30,7 +30,7 @@
// | |
// +---------------------------------------------------------------------------+
-if (strpos(strtolower($_SERVER['PHP_SELF']), 'configuration_validation.php') !== false) {
+if (stripos($_SERVER['PHP_SELF'], 'configuration_validation.php') !== false) {
die('This file can not be used on its own!');
}
@@ -54,4 +54,9 @@
'rule' => array('inList', array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'), true)
);
+// Ping target
+$_CONF_VALIDATE['xmlsitemap']['ping_google'] = array('rule' => 'boolean');
+$_CONF_VALIDATE['xmlsitemap']['ping_bing'] = array('rule' => 'boolean');
+$_CONF_VALIDATE['xmlsitemap']['ping_ask'] = array('rule' => 'boolean');
+
?>
diff -r 1f6433ff633f -r 75bd685e64fe plugins/xmlsitemap/functions.inc
--- a/plugins/xmlsitemap/functions.inc Mon Feb 03 21:32:20 2014 +0900
+++ b/plugins/xmlsitemap/functions.inc Wed Feb 05 23:22:36 2014 +0900
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | XMLSitemap Plugin 1.0 |
+// | XMLSitemap Plugin 2.0 |
// +---------------------------------------------------------------------------+
// | functions.inc |
// | |
@@ -10,7 +10,7 @@
// | API method and 2) implements all the common code needed by the XMLSitemap |
// | Plugin's PHP files. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors: |
+// | Copyright (C) 2009-2014 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -38,24 +38,21 @@
* @package XMLSitemap
*/
-if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.inc') !== FALSE) {
+if (stripos($_SERVER['PHP_SELF'], 'functions.inc') !== false) {
die ('This file can not be used on its own.');
}
-/**
-* Language file Include
-*/
+// Language file Include
$langfile = $_CONF['path'] . 'plugins/xmlsitemap/language/' . $_CONF['language'] . '.php';
clearstatcache();
+
if (file_exists($langfile)) {
include_once $langfile;
} else {
include_once $_CONF['path'] . 'plugins/xmlsitemap/language/english.php';
}
-/**
-* Load the plugin configuration
-*/
+// Load the plugin configuration
$_XMLSMAP_CONF = XMLSMAP_loadConfig();
// +---------------------------------------------------------------------------+
@@ -81,7 +78,7 @@
/**
* Upgrade the plugin
*
-* @return boolean TRUE (= success)
+* @return boolean true (= success)
*/
function plugin_upgrade_xmlsitemap()
{
@@ -90,9 +87,10 @@
$installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
"pi_name = 'xmlsitemap'");
$code_version = plugin_chkVersion_xmlsitemap();
+
if ($installed_version == $code_version) {
// nothing to do
- return TRUE;
+ return true;
}
require_once $_CONF['path'] . 'plugins/xmlsitemap/autoinstall.php';
@@ -103,14 +101,13 @@
$inst_parms = plugin_autoinstall_xmlsitemap('xmlsitemap');
$pi_gl_version = $inst_parms['info']['pi_gl_version'];
-
- require_once $_CONF['path'] . 'plugins/xmlsitemap/sql/'
- . $_DB_dbms . '_updates.php';
-
- require_once $_CONF['path'] . 'plugins/xmlsitemap/install_updates.php';
+
+ require_once $_CONF['path'] . 'plugins/xmlsitemap/sql/' . $_DB_dbms . '_updates.php';
+ require_once $_CONF['path'] . 'plugins/xmlsitemap/install_updates.php';
$current_version = $installed_version;
$done = false;
+
while (! $done) {
switch ($current_version) {
case '1.0.0':
@@ -122,12 +119,17 @@
}
xmlsitemap_update_ConfValues_1_0_0();
-
xmlsitemap_update_ConfigSecurity_1_0_0();
$current_version = '1.0.1';
break;
+ case '1.0.1':
+ xmlsitemap_update_ConfValues_1_0_1();
+
+ $current_version = '2.0.0';
+ break;
+
default:
$done = true;
break;
@@ -136,7 +138,7 @@
DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'xmlsitemap'");
- return TRUE;
+ return true;
}
/**
@@ -171,7 +173,7 @@
/**
* Loads config infor with config.class.php
*
-* @return mixed XMLSitemap config array or FALSE
+* @return mixed XMLSitemap config array or false
*/
function XMLSMAP_loadConfig()
{
@@ -183,7 +185,7 @@
if ($config->group_exists('xmlsitemap')) {
return $config->get_config('xmlsitemap');
} else {
- return FALSE;
+ return false;
}
}
@@ -197,9 +199,9 @@
*/
function XMLSMAP_esc($str)
{
- static $encoding = NULL;
+ static $encoding = null;
- if ($encoding === NULL) {
+ if ($encoding === null) {
$encoding = COM_getCharset();;
}
@@ -218,23 +220,21 @@
* @param string $type plugin name
* @param string $include plugin to add after install/enabled
* @param string $exclude plugin to remove after uninstall/disabled
-* @return boolean TRUE = success, FALSE = otherwise
+* @return boolean true = success, false = otherwise
*/
-function XMLSMAP_update($type = NULL, $include = NULL, $exclude = NULL)
+function XMLSMAP_update($type = null, $include = null, $exclude = null)
{
global $_CONF, $_XMLSMAP_CONF;
- if (($type !== NULL)
- AND !in_array($type, $_XMLSMAP_CONF['types'])) {
+ if (($type !== null) && !in_array($type, $_XMLSMAP_CONF['types'])) {
// Notified about content change, but from an irrelevant plugin, one
// that doesn't implement 'plugin_getiteminfo_xxx' function.
- return TRUE;
+ return true;
}
- if (($type !== NULL) &&
- in_array($type, $_XMLSMAP_CONF['exclude'])) {
+ if (($type !== null) && in_array($type, $_XMLSMAP_CONF['exclude'])) {
More information about the geeklog-cvs
mailing list