Changeset 6167
- Timestamp:
- 06/04/08 20:33:44 (6 months ago)
- Location:
- trunk/lib/model
- Files:
-
- 5 modified
-
blog.attachment.php (modified) (5 diffs)
-
blog.blogSetting.php (modified) (11 diffs)
-
blog.category.php (modified) (2 diffs)
-
blog.entry.php (modified) (6 diffs)
-
blog.rss.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/model/blog.attachment.php
r5998 r6167 156 156 function deleteAttachment($blogid, $parent, $name) { 157 157 global $database; 158 requireModel('blog. rss');158 requireModel('blog.feed'); 159 159 if (!Validator::filename($name)) 160 160 return false; … … 212 212 } 213 213 function deleteTotalAttachment($blogid) { 214 requireModel('blog. rss');214 requireModel('blog.feed'); 215 215 $d = dir(ROOT."/attach/$blogid"); 216 216 while($file = $d->read()) { … … 225 225 function deleteAttachmentMulti($blogid, $parent, $names) { 226 226 global $database; 227 requireModel('blog. rss');227 requireModel('blog.feed'); 228 228 $files = explode('!^|', $names); 229 229 foreach ($files as $name) { … … 252 252 253 253 function downloadAttachment($name) { 254 requireModel('blog. rss');254 requireModel('blog.feed'); 255 255 global $database; 256 256 $name = POD::escapeString($name); … … 260 260 function setEnclosure($name, $order) { 261 261 global $database; 262 requireModel('blog. rss');262 requireModel('blog.feed'); 263 263 requireModel('blog.attachment'); 264 264 $name = POD::escapeString($name); -
trunk/lib/model/blog.blogSetting.php
r6029 r6167 6 6 function setBlogTitle($blogid, $title) { 7 7 global $blog; 8 requireModel('blog. rss');8 requireModel('blog.feed'); 9 9 if ($title == $blog['title']) 10 10 return true; … … 17 17 function setBlogDescription($blogid, $description) { 18 18 global $blog; 19 requireModel('blog. rss');19 requireModel('blog.feed'); 20 20 if ($description == $blog['description']) 21 21 return true; … … 77 77 function setPrimaryDomain($blogid, $name) { 78 78 global $database, $blog; 79 requireModel('blog. rss');79 requireModel('blog.feed'); 80 80 $name = UTF8::lessenAsEncoding(strtolower(trim($name)), 32); 81 81 if ($name == $blog['name']) … … 97 97 function setSecondaryDomain($blogid, $domain) { 98 98 global $database, $blog; 99 requireModel('blog. rss');99 requireModel('blog.feed'); 100 100 $domain = UTF8::lessenAsEncoding(strtolower(trim($domain)), 64); 101 101 if ($domain == $blog['secondaryDomain']) … … 120 120 function setDefaultDomain($blogid, $default) { 121 121 global $blog; 122 requireModel('blog. rss');122 requireModel('blog.feed'); 123 123 $default = $default == 1 ? 1 : 0; 124 124 if (empty($blog['secondaryDomain']) && $default == 1) … … 136 136 function useBlogSlogan($blogid, $useSloganOnPost, $useSloganOnCategory, $useSloganOnTag) { 137 137 global $blog; 138 requireModel('blog. rss');138 requireModel('blog.feed'); 139 139 requireComponent('Needlworks.Cache.PageCache'); 140 140 $useSloganOnPost = $useSloganOnPost ? 1 : 0; … … 168 168 function publishPostEolinSyncOnRSS($blogid, $publishEolinSyncOnRSS) { 169 169 global $blog; 170 requireModel('blog. rss');170 requireModel('blog.feed'); 171 171 $publishEolinSyncOnRSS = $publishEolinSyncOnRSS ? 1 : 0; 172 172 if ($publishEolinSyncOnRSS == $blog['publishEolinSyncOnRSS']) … … 181 181 function setEntriesOnRSS($blogid, $entriesOnRSS) { 182 182 global $blog; 183 requireModel('blog. rss');183 requireModel('blog.feed'); 184 184 if ($entriesOnRSS == $blog['entriesOnRSS']) 185 185 return true; … … 192 192 function setCommentsOnRSS($blogid, $commentsOnRSS) { 193 193 global $blog; 194 requireModel('blog. rss');194 requireModel('blog.feed'); 195 195 if ($commentsOnRSS == $blog['commentsOnRSS']) 196 196 return true; … … 205 205 function setPublishWholeOnRSS($blogid, $publishWholeOnRSS) { 206 206 global $blog; 207 requireModel('blog. rss');207 requireModel('blog.feed'); 208 208 $publishWholeOnRSS = $publishWholeOnRSS ? 1 : 0; 209 209 if ($publishWholeOnRSS == $blog['publishWholeOnRSS']) … … 217 217 function setBlogLanguage($blogid, $language, $blogLanguage) { 218 218 global $blog; 219 requireModel('blog. rss');219 requireModel('blog.feed'); 220 220 if (($language == $blog['language']) && ($blogLanguage == $blog['blogLanguage'])) 221 221 return true; -
trunk/lib/model/blog.category.php
r6030 r6167 294 294 function modifyCategory($blogid, $id, $name, $bodyid) { 295 295 global $database; 296 requireModel('blog. rss');296 requireModel('blog.feed'); 297 297 if($id==0) checkRootCategoryExistence($blogid); 298 298 if ((empty($name)) && (empty($bodyid))) … … 578 578 function setCategoryVisibility($blogid, $id, $visibility) { 579 579 global $database; 580 requireModel('blog. rss');580 requireModel('blog.feed'); 581 581 if($id == 0) return false; 582 582 $parentVisibility = getParentCategoryVisibility($blogid, $id); -
trunk/lib/model/blog.entry.php
r6115 r6167 512 512 global $database, $blog, $gCacheStorage; 513 513 requireModel("blog.attachment"); 514 requireModel("blog. rss");514 requireModel("blog.feed"); 515 515 requireModel("blog.category"); 516 516 requireModel("blog.tag"); … … 631 631 requireModel('blog.attachment'); 632 632 requireModel('blog.category'); 633 requireModel('blog. rss');633 requireModel('blog.feed'); 634 634 635 635 if($entry['id'] == 0) return false; … … 757 757 requireModel('blog.attachment'); 758 758 requireModel('blog.category'); 759 requireModel('blog. rss');759 requireModel('blog.feed'); 760 760 761 761 if($entry['id'] == 0) return -11; … … 912 912 function deleteEntry($blogid, $id) { 913 913 global $database, $gCacheStorage; 914 requireModel("blog. rss");914 requireModel("blog.feed"); 915 915 requireModel("blog.category"); 916 916 requireModel("blog.attachment"); … … 945 945 global $database; 946 946 requireModel("blog.category"); 947 requireModel("blog. rss");947 requireModel("blog.feed"); 948 948 949 949 $targets = array_unique(preg_split('/,/', $entries, -1, PREG_SPLIT_NO_EMPTY)); … … 984 984 function setEntryVisibility($id, $visibility) { 985 985 global $database; 986 requireModel("blog. rss");986 requireModel("blog.feed"); 987 987 requireModel("blog.category"); 988 988 requireComponent('Needlworks.Cache.PageCache'); -
trunk/lib/model/blog.rss.php
r5684 r6167 9 9 } 10 10 11 function refresh RSS($blogid) {11 function refreshFeed($blogid, $mode = 'both') { 12 12 global $database, $serviceURL, $defaultURL, $blog, $service; 13 13 $channel = array(); … … 65 65 $content .= "<p><strong><a href=\"" . htmlspecialchars($entryURL) . "\">" . _t('글 전체보기') . "</a></strong></p>"; 66 66 } 67 67 $row['repliesCount'] = $row['comments'] + $row['trackbacks']; 68 68 $item = array( 69 69 'id' => $row['id'], … … 73 73 'author' => '('.RSSMessage($row['author']).')', 74 74 'pubDate' => Timestamp::getRFC1123($row['published']), 75 'updDate' => Timestamp::getRFC1123($row['modified']), 75 76 'comments' => $entryURL . '#entry' . $row['id'] . 'comment', 76 'guid' => "$defaultURL/" . $row['id'] 77 'guid' => "$defaultURL/" . $row['id'], 78 'replies' => array( 79 'count' => $row['repliesCount']) 77 80 ); 78 81 if (isset($service['useNumericURLonRSS'])) { … … 101 104 array_push($channel['items'], $item); 102 105 } 103 $path = ROOT . '/cache/rss'; 104 if (file_exists($path)) { 105 if (!is_dir($path)) 106 return false; 107 } else { 108 if (!mkdir($path)) 109 return false; 110 @chmod($path, 0777); 111 } 112 $path .= "/$blogid.xml"; 113 $fileHandle = fopen($path, 'w'); 114 $rss = array('channel' => $channel); 115 if (fwrite($fileHandle, publishRSS($blogid, $rss))) { 106 // RSS 107 if($mode == 'both' || $mode == 'rss') { 108 $path = ROOT . '/cache/rss'; 109 if (file_exists($path)) { 110 if (!is_dir($path)) 111 return false; 112 } else { 113 if (!mkdir($path)) 114 return false; 115 @chmod($path, 0777); 116 } 117 $path .= "/$blogid.xml"; 118 $fileHandle = fopen($path, 'w'); 119 $rss = array('channel' => $channel); 120 if (fwrite($fileHandle, publishRSS($blogid, $rss))) { 121 @chmod($path, 0666); 122 fireEvent('refreshRSS',$rss); 123 $result = true; 124 } else $result = false; 116 125 fclose($fileHandle); 117 @chmod($path, 0666); 118 fireEvent('refreshRSS',$rss); 119 return true; 120 } 121 fclose($fileHandle); 122 return false; 126 } 127 // ATOM 128 if($mode == 'both' || $mode == 'atom') { 129 $path = ROOT . '/cache/atom'; 130 if (file_exists($path)) { 131 if (!is_dir($path)) 132 return false; 133 } else { 134 if (!mkdir($path)) 135 return false; 136 @chmod($path, 0777); 137 } 138 $path .= "/$blogid.xml"; 139 $fileHandle = fopen($path, 'w'); 140 $rss = array('channel' => $channel); 141 if (fwrite($fileHandle, publishATOM($blogid, $rss))) { 142 @chmod($path, 0666); 143 fireEvent('refreshATOM',$rss); 144 $result = true; 145 } else $result = false; 146 fclose($fileHandle); 147 } 148 if($result) return true; 149 else return false; 123 150 } 124 151 … … 143 170 return $channel; 144 171 } 145 function getResponse RSSTotal($blogid) {172 function getResponseFeedTotal($blogid, $mode = 'rss') { 146 173 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 147 174 if(empty($blogid)) $blogid = getBlogId(); … … 154 181 $channel['items'] = $merged; 155 182 $rss = array('channel' => $channel); 156 return publishRSS($blogid, $rss); 157 } 158 159 function getResponseRSSByEntryId($blogid, $entryId) { 183 if($mode == 'rss') return publishRSS($blogid, $rss); 184 else if($mode == 'atom') return publishATOM($blogid, $rss); 185 return false; 186 } 187 188 function getResponseFeedByEntryId($blogid, $entryId, $mode = 'rss') { 160 189 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 161 190 if(empty($blogid)) $blogid = getBlogId(); … … 168 197 $channel['items'] = $merged; 169 198 $rss = array('channel' => $channel); 170 return publishRSS($blogid, $rss); 171 } 172 173 function getCommentRSSTotal($blogid, $rawMode = false) { 199 if($mode == 'rss') return publishRSS($blogid, $rss); 200 else if($mode == 'atom') return publishATOM($blogid, $rss); 201 return false; 202 } 203 204 function getCommentFeedTotal($blogid, $rawMode = false, $mode = 'rss') { 174 205 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 175 206 $channel = initializeRSSchannel($blogid); … … 199 230 if($rawMode == true) return $channel['items']; 200 231 $rss = array('channel' => $channel); 201 return publishRSS($blogid, $rss); 202 } 203 204 function getCommentRSSByEntryId($blogid = null, $entryId, $rawMode = false) { 232 if($mode == 'rss') return publishRSS($blogid, $rss); 233 else if($mode == 'atom') return publishATOM($blogid, $rss); 234 return false; 235 } 236 237 function getCommentFeedByEntryId($blogid = null, $entryId, $rawMode = false, $mode = 'rss') { 205 238 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 206 239 … … 246 279 if($rawMode == true) return $channel['items']; 247 280 $rss = array('channel' => $channel); 248 return publishRSS($blogid, $rss); 249 } 250 251 252 function getTrackbackRSSTotal($blogid, $rawMode = false) { 281 if($mode == 'rss') return publishRSS($blogid, $rss); 282 else if($mode == 'atom') return publishATOM($blogid, $rss); 283 return false; 284 } 285 286 287 function getTrackbackFeedTotal($blogid, $rawMode = false, $mode = 'rss') { 253 288 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 254 289 … … 278 313 if($rawMode == true) return $channel['items']; 279 314 $rss = array('channel' => $channel); 280 return publishRSS($blogid, $rss); 281 } 282 283 function getTrackbackRSSByEntryId($blogid = null, $entryId, $rawMode = false) { 315 if($mode == 'rss') return publishRSS($blogid, $rss); 316 else if($mode == 'atom') return publishATOM($blogid, $rss); 317 return false; 318 } 319 320 function getTrackbackFeedByEntryId($blogid = null, $entryId, $rawMode = false, $mode = 'rss') { 284 321 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 285 322 … … 326 363 if($rawMode == true) return $channel['items']; 327 364 $rss = array('channel' => $channel); 328 return publishRSS($blogid, $rss); 329 } 330 331 function getCommentNotifiedRSSTotal($blogid) { 365 if($mode == 'rss') return publishRSS($blogid, $rss); 366 else if($mode == 'atom') return publishATOM($blogid, $rss); 367 return false; 368 } 369 370 function getCommentNotifiedFeedTotal($blogid, $mode = 'rss') { 332 371 global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; 333 372 … … 364 403 } 365 404 $rss = array('channel' => $channel); 366 return publishRSS($blogid, $rss); 405 if($mode == 'rss') return publishRSS($blogid, $rss); 406 else if($mode == 'atom') return publishATOM($blogid, $rss); 407 return false; 367 408 } 368 409 … … 421 462 @unlink(ROOT . "/cache/rss/".getBlogId().".xml"); 422 463 } 464 465 466 function publishATOM($blogid, $data) { 467 global $blog; 468 $blogid = getBlogId(); 469 ob_start(); 470 echo '<?xml version="1.0" encoding="UTF-8"?>', CRLF; 471 echo '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0">', CRLF; 472 echo ' <title type="html">', htmlspecialchars($data['channel']['title'], ENT_QUOTES), '</title>', CRLF; 473 echo ' <id>', $data['channel']['link'], '</id', CRLF; 474 echo ' <link rel="alternate" type="text/html" hreflang="', $data['channel']['language'] ,'" href="', $data['channel']['link'] , ' />', CRLF; 475 echo ' <subtitle type="html">', htmlspecialchars($data['channel']['description'], ENT_QUOTES), '</subtitle>', CRLF; 476 echo ' <updated>', $data['channel']['pubDate'], '</updated>', CRLF; 477 echo ' <generator>', $data['channel']['generator'], '</generator>', CRLF; 478 479 foreach ($data['channel']['items'] as $item) { 480 echo ' <entry>', CRLF; 481 echo ' <title type="html">', htmlspecialchars($item['title'], ENT_QUOTES), '</title>', CRLF; 482 echo ' <link rel="alternate" type="text/html" href="', $item['link'], '" />', CRLF; 483 if(isset($item['replies'])) { 484 echo ' <link rel="replies" type="application/atom+xml" href="', $data['channel']['link'], '/atom/response/', $item['id'], '" thr:count="', $item['replies']['count'] ,'"/>', CRLF; 485 } 486 foreach ($item['categories'] as $category) { 487 if ($category = trim($category)) 488 echo ' <category term="', htmlspecialchars($category, ENT_QUOTES), '" />', CRLF; 489 } 490 echo ' <author>', CRLF; 491 echo ' <name>', htmlspecialchars($item['author'], ENT_QUOTES), '</name>', CRLF; 492 echo ' </author>', CRLF; 493 echo ' <id>', $item['link'] ,'</id>', CRLF; 494 if(isset($item['updDate'])) 495 echo ' <updated>', $item['updDate'], '</updated>', CRLF; 496 echo ' <published>', $item['pubDate'], '</published>', CRLF; 497 /* if (!empty($item['enclosure'])) { 498 echo ' <enclosure url="', $item['enclosure']['url'], '" length="', $item['enclosure']['length'], '" type="', $item['enclosure']['type'], '" />', CRLF; 499 }*/ 500 echo ' <summary type="html">', htmlspecialchars($item['description'], ENT_QUOTES), '</summary>', CRLF; 501 502 echo ' </entry>', CRLF; 503 } 504 echo '</feed>', CRLF; 505 $atom = ob_get_contents(); 506 ob_end_clean(); 507 return $atom; 508 } 423 509 ?>
