Revision 975,
1.3 KB
checked in by pep, 15 years ago
(diff) |
Sitemaps : initial import in DC Lab.
|
Line | |
---|
1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Sitemaps, a plugin for DotClear2. |
---|
5 | # Copyright (c) 2006-2009 Pep and contributors. |
---|
6 | # Licensed under the GPL version 2.0 license. |
---|
7 | # See LICENSE file or |
---|
8 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
9 | # |
---|
10 | # -- END LICENSE BLOCK ------------------------------------ |
---|
11 | if (!defined('DC_RC_PATH')) { return; } |
---|
12 | |
---|
13 | $GLOBALS['__autoload']['dcSitemaps'] = dirname(__FILE__).'/class.dc.sitemaps.php'; |
---|
14 | |
---|
15 | // Behavior(s) |
---|
16 | $GLOBALS['core']->addBehavior('publicBeforeDocument', array('sitemapsBehaviors','addTemplatePath')); |
---|
17 | |
---|
18 | class sitemapsBehaviors |
---|
19 | { |
---|
20 | public static function addTemplatePath($core) |
---|
21 | { |
---|
22 | $core->tpl->setPath($core->tpl->getPath(),dirname(__FILE__).'/default-templates'); |
---|
23 | } |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | // URL Handler(s) |
---|
28 | $GLOBALS['core']->url->register('gsitemap','sitemap.xml','^sitemap[_\.]xml$',array('sitemapsUrlHandlers','sitemap')); |
---|
29 | |
---|
30 | class sitemapsUrlHandlers extends dcUrlHandlers |
---|
31 | { |
---|
32 | public static function sitemap($args) |
---|
33 | { |
---|
34 | global $core,$_ctx; |
---|
35 | |
---|
36 | if (!$core->blog->settings->sitemaps_active) { |
---|
37 | self::p404(); |
---|
38 | } |
---|
39 | |
---|
40 | $sitemap = new dcSitemaps($core); |
---|
41 | $_ctx->sitemap_urls = staticRecord::newFromArray($sitemap->getURLs()); |
---|
42 | if ($_ctx->sitemap_urls->isEmpty()) { |
---|
43 | self::p404(); |
---|
44 | } |
---|
45 | else { |
---|
46 | self::serveDocument('sitemap.xml','text/xml'); |
---|
47 | exit; |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.