| | 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> |
|---|
| | 125 | END; |
|---|
| | 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> </p> |
|---|
| | 153 | </div> |
|---|
| | 154 | END; |
|---|
| | 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 | |
|---|
| | 165 | END; |
|---|
| | 166 | return $output; |
|---|
| | 167 | } |
|---|