[geeklog-cvs] geeklog: Added an option to exclude plugins from inclusion in th...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu May 21 09:47:36 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/7efa429d3a44
changeset: 7041:7efa429d3a44
user: Dirk Haun <dirk at haun-online.de>
date: Thu May 21 15:03:47 2009 +0200
description:
Added an option to exclude plugins from inclusion in the sitemap. Defaults to the Links plugin
diffstat:
plugins/xmlsitemap/functions.inc | 31 +++++++++++++++++++------------
plugins/xmlsitemap/install_defaults.php | 11 ++++++++---
plugins/xmlsitemap/language/english.php | 1 +
plugins/xmlsitemap/language/english_utf-8.php | 1 +
plugins/xmlsitemap/language/japanese_utf-8.php | 1 +
public_html/docs/history | 2 ++
6 files changed, 32 insertions(+), 15 deletions(-)
diffs (175 lines):
diff -r 9350f45a2fc9 -r 7efa429d3a44 plugins/xmlsitemap/functions.inc
--- a/plugins/xmlsitemap/functions.inc Thu May 21 09:09:56 2009 +0200
+++ b/plugins/xmlsitemap/functions.inc Thu May 21 15:03:47 2009 +0200
@@ -194,20 +194,28 @@
/**
* Create XML sitemap(s) or update existing one(s)
*
-* @param type string plugin name
-* @return boolean TRUE = success, FALSE = otherwise
+* @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
*/
function XMLSMAP_update($type = NULL, $include = NULL, $exclude = NULL)
{
global $_CONF, $_XMLSMAP_CONF;
if (($type !== NULL)
- AND !in_array(strtolower($type), $_XMLSMAP_CONF['types'])) {
+ AND !in_array(strtolower($type), $_XMLSMAP_CONF['types'])) {
// Notified about content change, but from an irrelevant plugin, one
// that doesn't implement 'plugin_getiteminfo_xxx' function.
return TRUE;
}
+ if (($type !== NULL) &&
+ in_array(strtolower($type, $_XMLSMAP_CONF['exclude']))) {
+ // plugin is on our exclude list, so ignore
+ return TRUE;
+ }
+
require_once $_CONF['path'] . 'plugins/xmlsitemap/xmlsitemap.class.php';
$charset = COM_getCharset();
@@ -224,7 +232,7 @@
}
// Set types
- $types = $_XMLSMAP_CONF['types'];
+ $types = array_diff($_XMLSMAP_CONF['types'], $_XMLSMAP_CONF['exclude']);
if ($include !== NULL) {
if (($index = array_search($exclude, $types)) === FALSE) {
$types[] = $include;
@@ -328,8 +336,8 @@
case 'frequencies':
$value = strtolower(trim($value));
- $valid_change_freqs = array('always', 'hourly', 'daily', 'weekly',
- 'monthly', 'yearly', 'never');
+ $valid_change_freqs = array('always', 'hourly', 'daily',
+ 'weekly', 'monthly', 'yearly', 'never');
if (!is_numeric($key) AND in_array($key, $enabled_plugins)
AND (in_array($value, $valid_change_freqs))) {
@@ -402,8 +410,6 @@
if ($group == 'xmlsitemap') {
if (is_array($changes) AND (count($changes) > 0)) {
/**
- * @note
- *
* At this time, changes in configuration is not reflected in
* $_XMLSMAP_CONF yet. So we have to reload them from DB.
*/
@@ -412,9 +418,9 @@
foreach ($changes as $name) {
if ($name == 'sitemap_file') {
XMLSITEMAP_changeFile($name, 'xmlsitemap_filename');
- } else if ($name == 'mobile_sitemap_file') {
+ } elseif ($name == 'mobile_sitemap_file') {
XMLSITEMAP_changeFile($name, 'xmlsitemap_mobile');
- } else {
+ } elseif ($name != 'exclude') {
XMLSITEMAP_checkChange($name);
}
}
@@ -450,7 +456,8 @@
switch ($status) {
case 'installed':
- if (is_callable('plugin_getiteminfo_' . $type)) {
+ if (is_callable('plugin_getiteminfo_' . $type) &&
+ !in_array($type, $_XMLSMAP_CONF['exclude'])) {
// A new plugin supporting plugin_getiteminfo_xxx() was
// installed
$_XMLSMAP_CONF['types'][] = $type;
@@ -499,7 +506,7 @@
if (in_array($type, $_XMLSMAP_CONF['types'])) {
if ($status == 'enabled') {
$include = $type;
- } else if ($status == 'disabled') {
+ } elseif ($status == 'disabled') {
$exclude = $type;
}
diff -r 9350f45a2fc9 -r 7efa429d3a44 plugins/xmlsitemap/install_defaults.php
--- a/plugins/xmlsitemap/install_defaults.php Thu May 21 09:09:56 2009 +0200
+++ b/plugins/xmlsitemap/install_defaults.php Thu May 21 15:03:47 2009 +0200
@@ -60,6 +60,9 @@
// Content types
$_XMLSMAP_DEFAULT['types'] = array('article', 'staticpages', 'calendar');
+// Plugins to exclude from sitemap
+$_XMLSMAP_DEFAULT['exclude'] = array('links');
+
// Priorities (must be between 0.0 and 1.0; default value is 0.5)
$_XMLSMAP_DEFAULT['priorities'] = array(
'article' => 0.5,
@@ -99,16 +102,18 @@
'text', 0, 0, NULL, 20, FALSE, $me);
$c->add('types', $_XMLSMAP_DEFAULT['types'], '%text', 0, 0, NULL, 30,
TRUE, $me);
+ $c->add('exclude', $_XMLSMAP_DEFAULT['exclude'], '%text', 0, 0, NULL,
+ 40, TRUE, $me);
// Priorities
$c->add('fs_pri', NULL, 'fieldset', 0, 1, NULL, 0, TRUE, $me);
$c->add('priorities', $_XMLSMAP_DEFAULT['priorities'], '*text', 0, 1,
- NULL, 40, TRUE, $me);
+ NULL, 50, TRUE, $me);
// Frequencies
$c->add('fs_freq', NULL, 'fieldset', 0, 2, NULL, 0, TRUE, $me);
- $c->add('frequencies', $_XMLSMAP_DEFAULT['frequencies'], '@select', 0, 2,
- 20, 50, TRUE, $me);
+ $c->add('frequencies', $_XMLSMAP_DEFAULT['frequencies'], '@select', 0,
+ 2, 20, 60, TRUE, $me);
}
return TRUE;
diff -r 9350f45a2fc9 -r 7efa429d3a44 plugins/xmlsitemap/language/english.php
--- a/plugins/xmlsitemap/language/english.php Thu May 21 09:09:56 2009 +0200
+++ b/plugins/xmlsitemap/language/english.php Thu May 21 15:03:47 2009 +0200
@@ -48,6 +48,7 @@
'sitemap_file' => 'Sitemap file name',
'mobile_sitemap_file' => 'Mobile Sitemap file name',
'types' => 'Contents of sitemap',
+ 'exclude' => 'Plugins to exclude from sitemap',
'priorities' => '',
'frequencies' => '',
);
diff -r 9350f45a2fc9 -r 7efa429d3a44 plugins/xmlsitemap/language/english_utf-8.php
--- a/plugins/xmlsitemap/language/english_utf-8.php Thu May 21 09:09:56 2009 +0200
+++ b/plugins/xmlsitemap/language/english_utf-8.php Thu May 21 15:03:47 2009 +0200
@@ -48,6 +48,7 @@
'sitemap_file' => 'Sitemap file name',
'mobile_sitemap_file' => 'Mobile Sitemap file name',
'types' => 'Contents of sitemap',
+ 'exclude' => 'Plugins to exclude from sitemap',
'priorities' => '',
'frequencies' => '',
);
diff -r 9350f45a2fc9 -r 7efa429d3a44 plugins/xmlsitemap/language/japanese_utf-8.php
--- a/plugins/xmlsitemap/language/japanese_utf-8.php Thu May 21 09:09:56 2009 +0200
+++ b/plugins/xmlsitemap/language/japanese_utf-8.php Thu May 21 15:03:47 2009 +0200
@@ -48,6 +48,7 @@
'sitemap_file' => 'ãµã¤ãããããã¡ã¤ã«å',
'mobile_sitemap_file' => 'ã¢ãã¤ã«ãµã¤ããããå',
'types' => 'ãµã¤ããããã®å
容',
+ 'exclude' => 'Plugins to exclude from sitemap',
'priorities' => '',
'frequencies' => '',
);
diff -r 9350f45a2fc9 -r 7efa429d3a44 public_html/docs/history
--- a/public_html/docs/history Thu May 21 09:09:56 2009 +0200
+++ b/public_html/docs/history Thu May 21 15:03:47 2009 +0200
@@ -37,6 +37,8 @@
XMLSitemap plugin
-----------------
+- Added an option to exclude plugins from inclusion in the sitemap. Defaults
+ to the Links plugin [Dirk]
- Remove sitemap files when uninstalling the plugin [Dirk]
- Don't include Links in the sitemap.xml automatically [Dirk]
- Fixed "missing argument 2" error when changing config options (reported by
More information about the geeklog-cvs
mailing list