# ------------------------------------------------------------------------------
# Generate index sitemap of all other sitemaps.
-function index_map() {
+function index_map()
+{
global $output_paths;
$output_dir = $output_paths['output_dir'];
$output_url = $output_paths['output_url'];
}
# Generate sitemap of standard site elements.
-function standard_map() {
+function standard_map()
+{
global $output_paths;
$standard_map_urls .= url(
)
);
- $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog', 'privacy', 'source');
+ $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog',
+ 'privacy', 'source', 'badge');
foreach($docs as $title) {
$standard_map_urls .= url(
}
# Generate sitemaps of all notices.
-function notices_map() {
+function notices_map()
+{
global $output_paths;
$notices = DB_DataObject::factory('notice');
}
# Generate sitemaps of all users.
-function user_map() {
+function user_map()
+{
global $output_paths;
$users = DB_DataObject::factory('user');
# ------------------------------------------------------------------------------
# Generate a <url></url> element.
-function url($url_args) {
+function url($url_args)
+{
$url = preg_replace('/&/', '&', $url_args['url']); # escape ampersands for XML
$lastmod = $url_args['lastmod'];
$changefreq = $url_args['changefreq'];
return $url_out;
}
-function sitemap($sitemap_args) {
+function sitemap($sitemap_args)
+{
$url = preg_replace('/&/', '&', $sitemap_args['url']); # escape ampersands for XML
$lastmod = $sitemap_args['lastmod'];
}
# Generate a <urlset></urlset> element.
-function urlset($urlset_text) {
+function urlset($urlset_text)
+{
$urlset = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
$urlset_text .
}
# Generate a <urlset></urlset> element.
-function sitemapindex($sitemapindex_text) {
+function sitemapindex($sitemapindex_text)
+{
$sitemapindex = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
$sitemapindex_text .
}
# Generate a sitemap from an array containing <url></url> elements and write it to a file.
-function array_to_map($url_list, $filename_prefix) {
+function array_to_map($url_list, $filename_prefix)
+{
global $output_paths;
if ($url_list) {
# ------------------------------------------------------------------------------
# Parse command line arguments.
-function parse_args() {
+function parse_args()
+{
$args = getopt('f:d:u:');
if (is_null($args[f]) && is_null($args[d]) && is_null($args[u])) {
$output_url = $args[u];
if (file_exists($output_dir)) {
- if (is_writable($output_dir) === FALSE) {
+ if (is_writable($output_dir) === false) {
error("$output_dir is not writable.");
}
} else {
}
# Ensure paths end with a "/".
-function trailing_slash($path) {
+function trailing_slash($path)
+{
if (preg_match('/\/$/', $path) == 0) {
$path .= '/';
}
}
# Write data to disk.
-function write_file($path, $data) {
+function write_file($path, $data)
+{
if (is_null($path)) {
error('No path specified for writing to.');
} elseif (is_null($data)) {
error('No data specified for writing.');
}
- if (($fh_out = fopen($path,'w')) === FALSE) {
+ if (($fh_out = fopen($path,'w')) === false) {
error("couldn't open $path for writing.");
}
- if (fwrite($fh_out, $data) === FALSE) {
+ if (fwrite($fh_out, $data) === false) {
error("couldn't write to $path.");
}
}
# Display an error message and exit.
-function error ($error_msg) {
+function error ($error_msg)
+{
if (is_null($error_msg)) {
$error_msg = 'error() was called without any explanation!';
}