Dotclear

source: plugins/dcSiteMap/_public.php @ 3169

Revision 3169, 1.7 KB checked in by gaetan13, 10 years ago (diff)

Add a simple sitemap on your blog

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2010 Gaetan Guillard and contributors
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK ------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14$core->url->register('dcsitemap','sitemap','^sitemap(?:/(.+))?$',array('urlSiteMap','sitemap'));
15
16$core->tpl->addValue('SiteMapURL',array('tplSiteMap','SiteMapURL'));
17$core->tpl->addValue('SiteMapPageTitle',array('tplSiteMap','SiteMapPageTitle'));
18
19
20class urlSiteMap extends dcUrlHandlers
21{
22     public static function sitemap($args)
23     {
24          global $core;
25
26          if (!$core->blog->settings->dcsitemap->dsm_flag) {
27               self::p404();
28               exit;
29          }
30                   
31          $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
32          self::serveDocument('site_map.html');
33          exit;
34     }
35}
36
37class tplSiteMap
38{
39     public static function SiteMapURL($attr)
40     {
41          $f = $GLOBALS['core']->tpl->getFilters($attr);
42          return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("dcsitemap")').'; ?>';
43     }
44     
45     public static function SiteMapPageTitle($attr)
46     {
47          $f = $GLOBALS['core']->tpl->getFilters($attr);
48          return '<?php echo '.sprintf($f,'$core->blog->settings->dcsitemap->dsm_title').'; ?>';
49     }
50               
51     # Widget function
52     public static function dcSiteMapWidget($w)
53     {
54          global $core;
55         
56          if ($w->homeonly && $core->url->type != 'default') {
57               return;
58          }
59         
60          $res =
61          '<div class="sitemap">'.
62          '<h2><a href="'.$core->blog->url.$core->url->getBase('dcsitemap').'">'.
63          ($w->title ? html::escapeHTML($w->title) : __('Site map')).
64          '</a></h2>'.
65          '</div>';
66         
67          return $res;
68     }
69}
70?>
Note: See TracBrowser for help on using the repository browser.

Sites map