Changeset 56
- Timestamp:
- 10/07/07 17:42:00 (6 years ago)
- Files:
-
- 25 added
- 1 removed
- 2 modified
-
sitemaps/files/lib/data (deleted)
-
sitemaps/files/lib/page/SitemapsPage.class.php (modified) (3 diffs)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/LICENSE (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/eventlistener.xml (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/data (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/data/board (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/data/board/SitemapsBoard.class.php (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/data/thread (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/data/thread/SitemapsThread.class.php (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/system (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/system/event (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/system/event/listener (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/files/lib/system/event/listener/SitemapsPageWBBListener.class.php (added)
-
sitemaps/optionals/de.easy-coding.wbb.sitemaps/package.xml (added)
-
sitemaps/package.xml (modified) (2 diffs)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/LICENSE (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/eventlistener.xml (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files/lib (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files/lib/system (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files/lib/system/event (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files/lib/system/event/listener (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/files/lib/system/event/listener/TaggingReloadedSitemapsPageListener.class.php (added)
-
taggingreloaded/optionals/de.easy-coding.wcf.sitemaps.taggingreloaded/package.xml (added)
Legend:
- Unmodified
- Added
- Removed
-
sitemaps/files/lib/page/SitemapsPage.class.php
r41 r56 2 2 // wcf imports 3 3 require_once(WCF_DIR.'lib/page/AbstractPage.class.php'); 4 require_once(WBB_DIR.'lib/data/board/SitemapsBoard.class.php');5 require_once(WBB_DIR.'lib/data/thread/SitemapsThread.class.php');6 4 7 5 /** … … 9 7 * 10 8 * @author Torben Brodt 11 * @package de.easy-coding.w bb.data.page.sitemaps9 * @package de.easy-coding.wcf.sitemaps 12 10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> 13 11 */ 14 12 class SitemapsPage extends AbstractPage { 15 protected $index = true; 16 protected $rewriter = null; 17 protected $boardIDs = array(); 18 protected $offset = 0; 19 protected $limit = 0; 20 protected $boards = array(), $threads = array(); 21 protected $thread_posts_per_page=0; 22 protected $board_threads_per_page=0; 13 protected $type; 23 14 24 /** 25 * @see Page::readParameters() 26 */ 27 public function readParameters() { 28 parent::readParameters(); 15 public $index = false; 16 public $rewriter; 17 18 /** 19 * @see Page::readParameters() 20 */ 21 public function readParameters() { 22 parent::readParameters(); 23 24 if (intval(count($_GET)) == intval(1)) { 25 $this->index = true; 26 } 29 27 30 28 // SEO MOD … … 33 31 $this->rewriter = new PublicSEORewriter(); 34 32 } 33 } 34 35 /** 36 * 37 * @param type 38 */ 39 public function setType($type) { 40 $this->type = $type; 41 } 42 43 /** 44 * @see Page::assignVariables() 45 */ 46 public function readData() { 47 parent::readData(); 48 49 // send header 50 @header('Content-Type: application/xml; charset='.CHARSET); 51 echo '<?xml version="1.0" encoding="'.CHARSET.'"?>'; 52 53 switch($this->type) { 54 case 'sitemapindex': 55 echo '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">'; 56 break; 57 case 'urlset': 58 echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" 59 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 60 xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 61 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">'; 62 break; 63 } 64 } 65 66 /** 67 * @see Page::show() 68 */ 69 public function show() { 70 parent::show(); 35 71 36 if (isset($_REQUEST['boardID']) && $_REQUEST['boardID'] == 0) { 37 $this->index = false; 38 39 } else if(isset($_REQUEST['boardID'])) { 40 $this->boardIDs = ArrayUtil::toIntegerArray(explode(',', $_REQUEST['boardID'])); 41 } 42 } 43 44 /** 45 * how many posts in one thread 46 */ 47 protected function threadPostsPerPage() { 48 if($this->thread_posts_per_page > 0) 49 return $this->thread_posts_per_page; 50 51 $sql = "SELECT opt.optionValue 52 FROM wcf".WCF_N."_option opt 53 WHERE opt.optionName = 'thread_posts_per_page' 54 LIMIT 1;"; 55 $result = WCF::getDB()->sendQuery($sql); 56 $row = WCF::getDB()->fetchArray($result); 57 $this->thread_posts_per_page = $row['optionValue']; 58 } 59 60 /** 61 * how many threads in one forum 62 */ 63 protected function boardThreadsPerPage() { 64 if($this->board_threads_per_page > 0) 65 return $this->board_threads_per_page; 66 67 $sql = "SELECT opt.optionValue 68 FROM wcf".WCF_N."_option opt 69 WHERE opt.optionName = 'board_threads_per_page' 70 LIMIT 1;"; 71 $result = WCF::getDB()->sendQuery($sql); 72 $row = WCF::getDB()->fetchArray($result); 73 $this->board_threads_per_page = $row['optionValue']; 74 } 75 76 /** 77 * Gets the threads for the sitemaps. 78 */ 79 protected function readThreads() { 80 require_once(WBB_DIR.'lib/data/thread/FeedThread.class.php'); 81 // accessible boards 82 require_once(WBB_DIR.'lib/data/board/Board.class.php'); 83 $boardIDs = Board::getAccessibleBoards(array('canViewBoard', 'canEnterBoard', 'canReadThread')); 84 85 // get threads 86 if (!empty($boardIDs)) { 87 88 // read count 89 $this->threadPostsPerPage(); 90 91 $sql = "SELECT post.*, thread.* 92 FROM wbb".WBB_N."_thread thread 93 LEFT JOIN wbb".WBB_N."_post post 94 ON (post.postID = thread.firstPostID) 95 WHERE thread.boardID IN (".$boardIDs.") 96 ".(count($this->boardIDs) ? "AND thread.boardID IN (".implode(',', $this->boardIDs).")" : "")." 97 AND thread.isDeleted = 0 98 AND thread.isDisabled = 0 99 AND thread.movedThreadID = 0 100 ORDER BY thread.time DESC"; 101 if($this->limit > 0) { 102 $sql .= " LIMIT ".$this->limit; 103 } 104 if($this->offset > 0) { 105 $sql .= " OFFSET ".$this->offset; 106 } 107 108 $i=0; 109 $result = WCF::getDB()->sendQuery($sql); 110 while ($row = WCF::getDB()->fetchArray($result)) { 111 $pages = ceil($row['replies']/$this->thread_posts_per_page); 112 $this->threads[$i] = new FeedThread($row); 113 114 if($this->rewriter === null) { 115 $this->threads[$i]->url = sprintf('index.php?page=Thread&threadID=%d', $row['threadID']); 116 } else { 117 $this->rewriter->publicCacheThreads($row['threadID'], $row); 118 $this->threads[$i]->url = $this->rewriter->publicParseThreadURLs($row['threadID'], ''); 119 } 120 121 for($j=2; $j<$pages; $j++) { 122 $i++; 123 $this->threads[$i] = new FeedThread($row['threadID'], $row); 124 125 if($this->rewriter === null) { 126 $this->threads[$i]->url = sprintf('index.php?page=Thread&threadID=%d&pageNo=%d', $row['threadID'], $j); 127 } else { 128 $this->threads[$i]->url = $this->rewriter->publicParseMultipleThreadURLs($row['threadID'], $j, ''); 129 } 130 } 131 $i++; 132 133 // titles are not used again.. clear cache 134 if($this->rewriter !== null) $this->rewriter->clearCache(); 135 } 136 } 137 } 138 139 /** 140 * Gets the boards for the sitemaps overview and for the numbered board pages. 141 */ 142 protected function readBoards() { 143 // accessible boards 144 require_once(WBB_DIR.'lib/data/board/Board.class.php'); 145 $boardIDs = Board::getAccessibleBoards(array('canViewBoard', 'canEnterBoard', 'canReadThread')); 146 147 // get threads 148 if (!empty($boardIDs)) { 149 150 // read count 151 $this->boardThreadsPerPage(); 152 153 $sql = "SELECT board.* 154 FROM wbb".WBB_N."_board board 155 WHERE board.threads > 0 156 AND board.boardID IN (".$boardIDs.") 157 ".(count($this->boardIDs) ? "AND board.boardID IN (".implode(',', $this->boardIDs).")" : "")." 158 ORDER BY board.time DESC"; 159 if($this->limit > 0) { 160 $sql .= " LIMIT ".$this->limit; 161 } 162 if($this->offset > 0) { 163 $sql .= " OFFSET ".$this->offset; 164 } 165 166 $i=0; 167 $result = WCF::getDB()->sendQuery($sql); 168 while ($row = WCF::getDB()->fetchArray($result)) { 169 $pages = ceil($row['threads']/$this->board_threads_per_page); 170 $this->boards[$i] = new SitemapsBoard($row['boardID'], $row); 171 $this->boards[$i]->full = true; 172 if(intval($this->boards[$i]->getThreads()) == 0) { 173 continue; 174 } 175 176 if($this->rewriter === null) { 177 $this->boards[$i]->url = sprintf('index.php?page=Board&boardID=%d', $row['boardID']); 178 } else { 179 $this->boards[$i]->url = $this->rewriter->publicParseBoardURLs($row['boardID'], ''); 180 } 181 182 for($j=2; $j<$pages; $j++) { 183 $i++; 184 $this->boards[$i] = new Board($row['boardID'], $row); 185 186 if($this->rewriter === null) { 187 $this->boards[$i]->url = sprintf('index.php?page=Board&boardID=%d&pageNo=%d', $row['boardID'], $j); 188 } else { 189 $this->boards[$i]->url = $this->rewriter->publicParseMultipleBoardURLs($row['boardID'], $j, ''); 190 } 191 } 192 193 $i++; 194 195 196 // titles are not used again.. clear cache 197 if($this->rewriter !== null) $this->rewriter->clearCache(); 198 } 199 } 200 } 201 202 /** 203 * @see Page::readData() 204 */ 205 public function readData() { 206 parent::readData(); 207 208 // get threads 209 if (count($this->boardIDs)) { 210 $this->readThreads(); 211 } 212 // get board sitemaps/numbers 213 else { 214 $this->readBoards(); 215 } 216 } 217 218 /** 219 * @see Page::show() 220 */ 221 public function show() { 222 parent::show(); 223 224 // send header 225 @header('Content-Type: application/xml; charset='.CHARSET); 226 echo '<?xml version="1.0" encoding="'.CHARSET.'"?>'; 227 228 // send thread content 229 if (count($this->boardIDs)) { 230 $tpl = '<url><loc>'.PAGE_URL.'/%s</loc><lastmod>%s</lastmod></url>'; 231 echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" 232 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 233 xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 234 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">'; 235 foreach($this->threads as $thread) { 236 printf($tpl, $thread->url, date('c', $thread->time)); 237 } 238 echo '</urlset>'; 239 } 240 // send overview content (sitemapindex) 241 else if($this->index) { 242 $tpl = '<sitemap><loc>'.PAGE_URL.'/index.php?page=Sitemaps&boardID=%d</loc><lastmod>%s</lastmod></sitemap>'; 243 echo '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">'; 244 printf($tpl, 0, date('c')); 245 $boards = array_filter($this->boards, create_function('$a','return isset($a->full);')); 246 foreach($boards as $board) { 247 printf($tpl, $board->boardID, date('c', $board->time)); 248 } 249 echo '</sitemapindex>'; 250 } 251 // send board contents 252 else { 253 $tpl = '<url><loc>'.PAGE_URL.'/%s</loc><lastmod>%s</lastmod></url>'; 254 echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" 255 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 256 xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 257 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">'; 258 foreach($this->boards as $board) { 259 printf($tpl, $board->url, date('c', $board->time)); 260 } 261 echo '</urlset>'; 262 } 263 264 exit; 265 } 72 switch($this->type) { 73 case 'sitemapindex': 74 echo '</sitemapindex>'; 75 break; 76 case 'urlset': 77 echo '</urlset>'; 78 break; 79 } 80 } 266 81 } 267 82 ?> -
sitemaps/package.xml
r41 r56 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!DOCTYPE package SYSTEM "http://www.woltlab.com/DTDs/package.dtd"> 3 <package name="de.easy-coding.wcf. data.page.sitemaps">4 <package Information>5 <package Name>Sitemaps</packageName>6 <package Description><![CDATA[Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling.]]></packageDescription>7 <package Description languagecode="de"><![CDATA[Sitemaps stellen eine einfache Möglichkeit fÃŒr Webmaster dar, Suchmaschinen Seiten auf Ihren Websites zu melden, die zum Durchsuchen verfÃŒgbar sind.]]></packageDescription>8 <version>1. 1.5</version>3 <package name="de.easy-coding.wcf.sitemaps"> 4 <packageinformation> 5 <packagename>Sitemaps</packagename> 6 <packagedescription><![CDATA[Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling.]]></packagedescription> 7 <packagedescription languagecode="de"><![CDATA[Sitemaps stellen eine einfache Möglichkeit fÃŒr Webmaster dar, Suchmaschinen Seiten auf Ihren Websites zu melden, die zum Durchsuchen verfÃŒgbar sind.]]></packagedescription> 8 <version>1.2.0</version> 9 9 <date>DATE</date> 10 <plugin>com.woltlab.w bb</plugin>11 </package Information>10 <plugin>com.woltlab.wcf</plugin> 11 </packageinformation> 12 12 13 <author Information>13 <authorinformation> 14 14 <author>Torben Brodt</author> 15 15 <authorURL>http://www.easy-coding.de/trac/wcf</authorURL> 16 </author Information>16 </authorinformation> 17 17 18 18 <requiredpackages> 19 <requiredpackage minversion="3.0.0">com.woltlab.wbb</requiredpackage>20 19 <requiredpackage minversion="1.0.0">com.woltlab.wcf</requiredpackage> 21 20 </requiredpackages> 22 21 23 22 <optionalpackages> 23 <optionalpackage file="optionals/de.easy-coding.wbb.sitemaps.tar.gz" minversion="1.0.0">de.easy-coding.wbb.sitemaps</optionalpackage> 24 24 <optionalpackage file="optionals/de.easy-coding.wcf.data.page.publicseorewriter.tar.gz" minversion="1.0.1">de.easy-coding.wcf.data.page.publicseorewriter</optionalpackage> 25 25 </optionalpackages> … … 32 32 </instructions> 33 33 34 <instructions type="update" fromversion="1.1.5"> 35 <files>files.tar</files> 36 </instructions> 37 34 38 <instructions type="update" fromversion="1.1.4"> 35 < templates>files.tar</templates>39 <files>files.tar</files> 36 40 </instructions> 37 41 38 42 <instructions type="update" fromversion="1.1.3"> 39 < templates>files.tar</templates>43 <files>files.tar</files> 40 44 </instructions> 41 45 42 46 <instructions type="update" fromversion="1.1.2"> 43 < templates>files.tar</templates>47 <files>files.tar</files> 44 48 </instructions> 45 49 46 50 <instructions type="update" fromversion="1.1.1"> 47 < templates>files.tar</templates>51 <files>files.tar</files> 48 52 </instructions> 49 53 50 54 <instructions type="update" fromversion="1.1.0"> 55 <files>files.tar</files> 56 </instructions> 57 58 <instructions type="update" fromversion="1.0.2"> 59 <files>files.tar</files> 51 60 <templates>templates.tar</templates> 52 61 </instructions> 53 62 54 <instructions type="update" fromversion="1.0.2"> 63 <instructions type="update" fromversion="1.0.1"> 64 <files>files.tar</files> 55 65 <templates>templates.tar</templates> 56 <files>files.tar</files>57 </instructions>58 59 <instructions type="update" fromversion="1.0.1">60 <templates>templates.tar</templates>61 <files>files.tar</files>62 66 </instructions> 63 67 64 68 <instructions type="update" fromversion="1.0.0"> 69 <files>files.tar</files> 65 70 <templates>templates.tar</templates> 66 71 </instructions>
