Changeset 1459

Show
Ignore:
Timestamp:
12/14/07 12:55:20 (8 months ago)
Author:
bwerdmuller
Message:

Exporting as HTML is now happily possible.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/export/blog.php

    r1458 r1459  
    1212                header('Content-Disposition: attachment'); 
    1313                header("Content-type: text/xml"); 
    14                 echo export_as_rss($_SESSION['userid']); 
     14                echo export_blog_as_rss($_SESSION['userid']); 
    1515         
    1616        } 
  • devel/mod/export/lib.php

    r1458 r1459  
    1010            if (defined('context') && context == 'weblog') { 
    1111                if ($page_owner == $_SESSION['userid']) { 
     12                        $PAGE->menu_sub[]= array ( 
     13                        'name' => 'blog:export:html', 
     14                        'html' => "<a href=\"{$CFG->wwwroot}mod/export/blogashtml.php/export.html\">". __gettext("Download blog as HTML") ."</a>" 
     15                    ); 
    1216                    $PAGE->menu_sub[]= array ( 
    13                         'name' => 'blog:export', 
     17                        'name' => 'blog:export:rss', 
    1418                        'html' => "<a href=\"{$CFG->wwwroot}mod/export/blog.php/export.rss\">". __gettext("Download blog as RSS") ."</a>" 
    1519                    ); 
     
    2125        } 
    2226         
    23         function export_as_rss($blog_id = -1) { 
     27        /** 
     28         * Exports a weblog as RSS 
     29         * 
     30         * @param int $blog_id The ID of the blog to export 
     31         * @return string The RSS feed 
     32         */ 
     33        function export_blog_as_rss($blog_id = -1) { 
    2434                 
    2535                global $CFG; 
     
    8090                return $output; 
    8191        } 
     92         
     93        /** 
     94         * Exports a blog as HTML 
     95         * 
     96         * @param int $blog_id The blog to export 
     97         * @return string The HTML file 
     98         */ 
     99        function export_blog_as_html($blog_id = -1) { 
     100             
     101            global $CFG; 
     102             
     103            if ($blog_id < 0) { 
     104                $blog_id = $_SESSION['id']; 
     105            } 
     106            $blog_id = (int) $blog_id; 
     107             
     108            $name = user_info("name", $blog_id); 
     109            $username = user_info("username", $blog_id); 
     110 
     111            $rssweblog = __gettext("Weblog items"); 
     112            $rssdescription = sprintf(__gettext("The weblog for %s, hosted on %s."),$name,$CFG->sitename); 
     113 
     114            $output .= <<< END 
     115            <html> 
     116                <head> 
     117                    <title>{$name}: {$rssweblog}</title> 
     118                </head> 
     119                <body> 
     120                    <h1>{$name}: {$rssweblog}</h1> 
     121                    <p><i>{$rssdescription}</i></p> 
     122                    <p> 
     123                        <a href="{$CFG->wwwroot}{$username}/weblog/">{$CFG->wwwroot}{$username}/weblog/</a> 
     124                    </p> 
     125END; 
     126 
     127                $where = run("users:access_level_sql_where",$_SESSION['userid']); 
     128                if ($posts = get_records_select('weblog_posts','('.$where.') AND weblog = '.$blog_id,null,'posted DESC','*')) { 
     129                    foreach($posts as $entry) { 
     130                        $title = (stripslashes($entry->title)); 
     131                        $link = url . $username . "/weblog/" . $entry->ident . ".html"; 
     132                        $body = (run("weblogs:text:process",stripslashes($entry->body))); 
     133                        $pubdate = gmdate("D, d M Y H:i:s T", $entry->posted); 
     134                        $keywordtags = ""; 
     135                        if ($keywords = get_records_select('tags','tagtype = ? AND ref = ?',array('weblog',$entry->ident))) { 
     136                            foreach($keywords as $keyword) { 
     137                                if (!empty($keywordtags)) 
     138                                    $keywordtags .= ", "; 
     139                                $keywordtags .= stripslashes($keyword->tag); 
     140                            } 
     141                        } 
     142                        if (!empty($keywordtags)) { 
     143                                $keywordtags = "<p>Keywords: {$keywordtags}</p>"; 
     144                        } 
     145                        $output .= <<< END 
     146                    <div class="weblog-post"> 
     147                            <h2>{$title}</h2> 
     148                            <p>{$pubdate}</p> 
     149                            <p><i><a href="{$link}">{$link}</a></i></p> 
     150                            {$body} 
     151                            {$keywordtags} 
     152                            <p>&nbsp;</p> 
     153                    </div> 
     154END; 
     155                    } 
     156                } 
     157 
     158                //$output .= run("weblogs:rss:getitems", array($blog_id, 10000,null,"complete")); 
     159 
     160                $output .= <<< END 
     161 
     162                </body> 
     163            </html> 
     164     
     165END; 
     166            return $output; 
     167        } 
    82168 
    83169?>