|
Revision 812, 1.5 kB
(checked in by d0nut, 4 years ago)
|
|
maybe solved sitemaps requirements chaos
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | // wcf imports |
|---|
| 3 | require_once(WCF_DIR.'lib/page/AbstractPage.class.php'); |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * Prints a sitemap |
|---|
| 7 | * |
|---|
| 8 | * @author Torben Brodt |
|---|
| 9 | * @package de.easy-coding.wcf.sitemaps |
|---|
| 10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-3.0.html> |
|---|
| 11 | */ |
|---|
| 12 | class SitemapsPage extends AbstractPage { |
|---|
| 13 | protected $type; |
|---|
| 14 | |
|---|
| 15 | public $index = false; |
|---|
| 16 | |
|---|
| 17 | /** |
|---|
| 18 | * @see Page::readParameters() |
|---|
| 19 | */ |
|---|
| 20 | public function readParameters() { |
|---|
| 21 | parent::readParameters(); |
|---|
| 22 | |
|---|
| 23 | if (intval(count($_GET)) == intval(1)) { |
|---|
| 24 | $this->index = true; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * |
|---|
| 30 | * @param type |
|---|
| 31 | */ |
|---|
| 32 | public function setType($type) { |
|---|
| 33 | $this->type = $type; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * @see Page::assignVariables() |
|---|
| 38 | */ |
|---|
| 39 | public function readData() { |
|---|
| 40 | parent::readData(); |
|---|
| 41 | |
|---|
| 42 | // send header |
|---|
| 43 | @header('Content-Type: application/xml; charset='.CHARSET); |
|---|
| 44 | echo '<?xml version="1.0" encoding="'.CHARSET.'"?>'; |
|---|
| 45 | |
|---|
| 46 | switch($this->type) { |
|---|
| 47 | case 'sitemapindex': |
|---|
| 48 | echo '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">'; |
|---|
| 49 | break; |
|---|
| 50 | case 'urlset': |
|---|
| 51 | echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" |
|---|
| 52 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|---|
| 53 | xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 |
|---|
| 54 | http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">'; |
|---|
| 55 | break; |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * @see Page::show() |
|---|
| 61 | */ |
|---|
| 62 | public function show() { |
|---|
| 63 | parent::show(); |
|---|
| 64 | |
|---|
| 65 | switch($this->type) { |
|---|
| 66 | case 'sitemapindex': |
|---|
| 67 | echo '</sitemapindex>'; |
|---|
| 68 | break; |
|---|
| 69 | case 'urlset': |
|---|
| 70 | echo '</urlset>'; |
|---|
| 71 | break; |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | ?> |
|---|