]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/sitemap.php
Add XMLStringer for building XML strings
[quix0rs-gnu-social.git] / scripts / sitemap.php
old mode 100644 (file)
new mode 100755 (executable)
index b49bfe2..51a9bbd
@@ -18,7 +18,8 @@ index_map();
 # ------------------------------------------------------------------------------
 
 # 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'];
@@ -40,7 +41,8 @@ function index_map() {
 }
 
 # Generate sitemap of standard site elements.
-function standard_map() {
+function standard_map()
+{
     global $output_paths;
 
     $standard_map_urls .= url(
@@ -77,7 +79,8 @@ function standard_map() {
 }
 
 # Generate sitemaps of all notices.
-function notices_map() {
+function notices_map()
+{
     global $output_paths;
 
     $notices = DB_DataObject::factory('notice');
@@ -115,7 +118,8 @@ function notices_map() {
 }
 
 # Generate sitemaps of all users.
-function user_map() {
+function user_map()
+{
     global $output_paths;
 
     $users = DB_DataObject::factory('user');
@@ -208,7 +212,8 @@ function user_map() {
 # ------------------------------------------------------------------------------
 
 # Generate a <url></url> element.
-function url($url_args) {
+function url($url_args)
+{
     $url        = preg_replace('/&/', '&amp;', $url_args['url']); # escape ampersands for XML
     $lastmod    = $url_args['lastmod'];
     $changefreq = $url_args['changefreq'];
@@ -238,7 +243,8 @@ function url($url_args) {
     return $url_out;
 }
 
-function sitemap($sitemap_args) {
+function sitemap($sitemap_args)
+{
     $url        = preg_replace('/&/', '&amp;', $sitemap_args['url']); # escape ampersands for XML
     $lastmod    = $sitemap_args['lastmod'];
 
@@ -259,7 +265,8 @@ function sitemap($sitemap_args) {
 }
 
 # 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 .
@@ -269,7 +276,8 @@ function urlset($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 .
@@ -279,7 +287,8 @@ function sitemapindex($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) {
@@ -297,7 +306,8 @@ function array_to_map($url_list, $filename_prefix) {
 # ------------------------------------------------------------------------------
 
 # 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])) {
@@ -321,7 +331,7 @@ function parse_args() {
     $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 {
@@ -338,7 +348,8 @@ function parse_args() {
 }
 
 # Ensure paths end with a "/".
-function trailing_slash($path) {
+function trailing_slash($path)
+{
     if (preg_match('/\/$/', $path) == 0) {
         $path .= '/';
     }
@@ -347,24 +358,26 @@ function trailing_slash($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!';
     }