<?php
/*
Plugin Name: SitemapView
Plugin URI: http://bueltge.de/wp-sitemapview-plugin/63/
Description: Import Googles sitemap.xml for a list af all posts and sites (SEO-Workaround). You can format with css. You can create sitemap.xml with a Plugin for WordPress: <a href="http://www.arnebrachhold.de/2005/06/05/google-sitemaps-generator-v2-final">Arne Brachhold</a>)
Version: 1.1
Author: Frank Bueltge
Author URI: http://bueltge.de
*/

/*
------------------------------------------------------
INSTRUCTIONS
------------------------------------------------------
0. Edit on Line 27 and 28
1. Upload this file into your wp-content/plugins directory.
2. Activate the Links Page plugin in your WordPress admin panel.
3. Create a new static page.
4. Add <!--sitemapview--> to the static page content where you want the links to appear.
Z. optional: format with css: id: sitemapview and class: sitemapview
Example:
    #sitemapview li {
    font-size: .85em;
    line-height: 1.8em;
    }
------------------------------------------------------
*/

/*
------------------------------------------------------
Edit here !
------------------------------------------------------*/
// URI to your sitemap.xml of your Blog
$url 'http://bueltge.de/sitemap.xml';
// How many links to view ?
$number 500;
// Do you will replace your damainname from the link ?
// 0 for false, 1 for true
$replace_domain 0;
/* 
------------------------------------------------------
End Edit
------------------------------------------------------ */

function sitemapview_page_callback() {
    global 
$url$number$replace_domain;
    
    
$domain get_bloginfo('url');
    
$file_content = @file_get_contents($url);
    
$items preg_match_all("/<url[ ]?.*>(.*)<\/url>/Uis"$file_content$array_items);
    
$array_items $array_items[1];
    if(!empty(
$array_items)) {
        echo 
'<ul id="sitemapview" class="sitemapview">';
        if (
$number>sizeof($array_items)) $number=sizeof($array_items);
        for(
$n=0;$n<$number;$n++) { //Nur die angegebene Anzahl soll angezeigt werden
            
preg_match("/<loc>(.*)<\/loc>/Uis"$array_items[$n], $array_link); //URLs auslesen
            
preg_match("/<loc>(.*)<\/loc>/Uis"$array_items[$n], $array_title); //Titel auslesen
            
if ($replace_domain == 1) {
                echo 
'<li><a href="'.$array_link[1].'" title="'.$array_title[1].'">'.str_replace($domain,''$array_title[1]).'</a></li>'//Link
            
} else {
                echo 
'<li><a href="'.$array_link[1].'" title="'.$array_title[1].'">'.$array_title[1].'</a></li>'//Link
            
}
        }
        echo 
'</ul>';
    }
}

define('SITEMAPVIEW_PAGE''<!--sitemapview-->');

function 
sitemapview_page($data) {
    
$start strpos($dataSITEMAPVIEW_PAGE);
    if(
$start !== false) {
        
ob_start();
        
sitemapview_page_callback();
        
$content ob_get_contents();
        
ob_end_clean();
        
$data substr_replace($data$content$startstrlen(SITEMAPVIEW_PAGE));
    }
    return 
$data;
}

if(
function_exists('add_filter'))
    
add_filter('the_content''sitemapview_page');
?>