[geeklog-hg] geeklog: Added "PLG_collectSitemapItems" function for plugins to...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Jul 16 08:17:41 EDT 2015
changeset 9614:51c27818e8ab
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/51c27818e8ab
user: Kenji ITO <mystralkk at gmail.com>
date: Thu Jul 16 21:16:57 2015 +0900
description:
Added "PLG_collectSitemapItems" function for plugins to return XML sitemap items (feature request #0001757)
diffstat:
plugins/xmlsitemap/xmlsitemap.class.php | 413 ++++++++++++++++---------------
system/lib-plugins.php | 55 ++++-
2 files changed, 260 insertions(+), 208 deletions(-)
diffs (truncated from 744 to 300 lines):
diff -r 88ff905f0291 -r 51c27818e8ab plugins/xmlsitemap/xmlsitemap.class.php
--- a/plugins/xmlsitemap/xmlsitemap.class.php Sun Jul 12 07:01:16 2015 +0900
+++ b/plugins/xmlsitemap/xmlsitemap.class.php Thu Jul 16 21:16:57 2015 +0900
@@ -6,9 +6,9 @@
// +---------------------------------------------------------------------------+
// | xmlsitemap.class.php |
// | |
-// | Google Sitemap Generator classes |
+// | Google Sitemap Generator class |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2009-2014 by the following authors: |
+// | Copyright (C) 2009-2015 by the following authors: |
// | |
// | Authors: Kenji ITO - geeklog AT mystral-kk DOT net |
// | Dirk Haun - dirk AT haun-online DOT de |
@@ -36,28 +36,28 @@
* @package XMLSitemap
*/
-if (stripos($_SERVER['PHP_SELF'], 'xmlsitemap.class.php') !== FALSE) {
+if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file cannot be used on its own.');
}
/**
-* This is the built-in Geeklog class for creating the Google sitemap.
-*
-* USAGE:
-*
-* <code>
-* $sitemap = new SitemapXML();
-* $sitemap->setFileNames('path_to_sitemap_file',
-* 'path_to_mobile_sitemap_file');
-* // $sitemap->setTypes(array('article', 'staticpages'));
-* // $sitemap->setPriority('article', 0.6);
-* // $sitemap->setPriority('staticpages', 0.4);
-* // $sitemap->setChangeFreq('article', 'weekly');
-* // $sitemap->setChangeFreq('staticpages', 'monthly');
-* $sitemap->create();
-* </code>
-*
-*/
+ * This is the built-in Geeklog class for creating an XML sitemap.
+ *
+ * USAGE:
+ *
+ * <code>
+ * $sitemap = new SitemapXML();
+ * $sitemap->setFileNames('path_to_sitemap_file',
+ * 'path_to_mobile_sitemap_file');
+ * // $sitemap->setTypes(array('article', 'staticpages'));
+ * // $sitemap->setPriority('article', 0.6);
+ * // $sitemap->setPriority('staticpages', 0.4);
+ * // $sitemap->setChangeFreq('article', 'weekly');
+ * // $sitemap->setChangeFreq('staticpages', 'monthly');
+ * $sitemap->create();
+ * </code>
+ *
+ */
class SitemapXML
{
// Constants
@@ -66,41 +66,43 @@
const PING_INTERVAL = 3600; // 1 hour
const LB = "\n";
- // Vars
- private $_num_entries;
- private $_encoding;
- private $_changeFreqs;
- private $_priorities;
- private $_types;
- private $_filename;
- private $_mobile_filename;
+ /**
+ * @var
+ */
+ private $encoding;
+ private $num_entries;
+ private $changeFreqs;
+ private $priorities;
+ private $types;
+ private $filename;
+ private $mobile_filename;
// Valid expressions for 'changefreq' field
- private $_valid_change_freqs = array('always', 'hourly', 'daily', 'weekly',
+ private $valid_change_freqs = array('always', 'hourly', 'daily', 'weekly',
'monthly', 'yearly', 'never');
/**
- * Constructor
- *
- * @param string $encoding the encoding of contents
- */
+ * Constructor
+ *
+ * @param string $encoding the encoding of contents
+ */
public function __construct($encoding = '')
{
- $this->_num_entries = 0;
$this->setEncoding($encoding);
- $this->_changeFreqs = array();
- $this->_priorities = array();
+ $this->num_entries = 0;
+ $this->changeFreqs = array();
+ $this->priorities = array();
// Set only 'article' as default value
$this->setTypes(array('article'));
}
/**
- * Set the encoding of contents
- *
- * @param string $encoding the encoding of contents
- * @return void
- */
+ * Set the encoding of contents
+ *
+ * @param string $encoding the encoding of contents
+ * @return void
+ */
public function setEncoding($encoding)
{
if ($encoding == '') {
@@ -110,58 +112,48 @@
$encoding = 'iso-8859-1';
}
- $this->_encoding = $encoding;
+ $this->encoding = $encoding;
}
/**
- * Return the encoding of the source content
- *
- * @return string the encoding of contents
- */
- public function getEncoding()
- {
- return $this->_encoding;
- }
-
- /**
- * Set the name(s) of the sitemap file (and optionally the mobile
- * sitemap file)
- *
- * NOTE: Sitemap files must be located in the top directory of the site,
- * i.e., the same directory as "lib-common.php".
- *
- * @param string $filename name of sitemap file
- * @param string $mobile_filename name of mobile sitemap file
- */
+ * Set the name(s) of the sitemap file (and optionally the mobile
+ * sitemap file)
+ *
+ * NOTE: Sitemap files must be located in the top directory of the site,
+ * i.e., the same directory as "lib-common.php".
+ *
+ * @param string $filename name of sitemap file
+ * @param string $mobile_filename name of mobile sitemap file
+ */
public function setFileNames($filename = '', $mobile_filename = '')
{
global $_CONF;
if ($filename != '') {
- $this->_filename = $_CONF['path_html'] . basename($filename);
+ $this->filename = $_CONF['path_html'] . basename($filename);
}
if ($mobile_filename != '') {
- $this->_mobile_filename = $_CONF['path_html'] . basename($mobile_filename);
+ $this->mobile_filename = $_CONF['path_html'] . basename($mobile_filename);
}
}
/**
- * Return the names of sitemap files
- *
- * @return array names of the sitemap and mobile sitemap
- */
+ * Return the names of sitemap files
+ *
+ * @return array names of the sitemap and mobile sitemap
+ */
public function getFileNames()
{
- return array($this->_filename, $this->_mobile_filename);
+ return array($this->filename, $this->mobile_filename);
}
/**
- * Check if a string stands for a valid value of priority
- *
- * @param string $str a string for a priority
- * @return float a valid value or 0.5 (default value)
- */
+ * Check if a string stands for a valid value of priority
+ *
+ * @param string $str a string for a priority
+ * @return float a valid value or 0.5 (default value)
+ */
public function checkPriority($str)
{
$v = (float) $str;
@@ -170,112 +162,116 @@
}
/**
- * Set the priority of the item
- *
- * @param string $type 'article', 'staticpages', ...
- * @param float $value the value of priority
- */
+ * Set the priority of the item
+ *
+ * @param string $type 'article', 'staticpages', ...
+ * @param float $value the value of priority
+ */
public function setPriority($type, $value)
{
$value = $this->checkPriority($value);
if ($value != 0.5) {
- $this->_priorities[$type] = $value;
+ $this->priorities[$type] = $value;
}
}
/**
- * Return the value of priority
- *
- * @param string $type 'article', 'staticpages', ...
- * @return float 0.0..1.0 (default value is 0.5)
- */
+ * Return the value of priority
+ *
+ * @param string $type 'article', 'staticpages', ...
+ * @return float 0.0..1.0 (default value is 0.5)
+ */
public function getPriority($type)
{
- if (isset($this->_priorities[$type])) {
- return (float) $this->_priorities[$type];
+ if (isset($this->priorities[$type])) {
+ return (float) $this->priorities[$type];
} else {
return 0.5;
}
}
/**
- * Check if a string stands for a proper frequency
- *
- * @param string $str a string for a frequency
- * @return string a valid string or an empty string
- */
+ * Check if a string stands for a proper frequency
+ *
+ * @param string $str a string for a frequency
+ * @return string a valid string or an empty string
+ */
public function checkChangeFreq($str)
{
$str = strtolower($str);
- return in_array($str, $this->_valid_change_freqs) ? $str : '';
+ return in_array($str, $this->valid_change_freqs) ? $str : '';
}
/**
- * Set the change frequency of the item
- *
- * @param string $type 'article', 'staticpages', ...
- * @param string $value any of 'always', 'hourly', 'daily', 'weekly',
- * 'monthly', 'yearly', 'never'
- */
+ * Set the change frequency of the item
+ *
+ * @param string $type 'article', 'staticpages', ...
+ * @param string $value any of 'always', 'hourly', 'daily', 'weekly',
+ * 'monthly', 'yearly', 'never'
+ */
public function setChangeFreq($type, $value)
{
$value = $this->checkChangeFreq($value);
if ($value != '') {
- $this->_change_freqs[$type] = $value;
+ $this->changeFreqs[$type] = $value;
}
}
/**
- * Return the value of change frequency
- *
- * @param string $type 'article', 'staticpages', ...
More information about the geeklog-cvs
mailing list