Dotclear

source: plugins/sitemaps/_public.php @ 975

Revision 975, 2.4 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 ------------------------------------
11if (!defined('DC_RC_PATH')) { return; }
12
13$core->tpl->addBlock('SitemapEntries'        ,array('sitemapsTemplates','SitemapEntries'));
14$core->tpl->addBlock('SitemapEntryIf'        ,array('sitemapsTemplates','SitemapEntryIf'));
15$core->tpl->addValue('SitemapEntryLoc'       ,array('sitemapsTemplates','SitemapEntryLoc'));
16$core->tpl->addValue('SitemapEntryFrequency' ,array('sitemapsTemplates','SitemapEntryFrequency'));
17$core->tpl->addValue('SitemapEntryPriority'  ,array('sitemapsTemplates','SitemapEntryPriority'));
18$core->tpl->addValue('SitemapEntryLastmod'   ,array('sitemapsTemplates','SitemapEntryLastmod'));
19
20class sitemapsTemplates
21{
22     public static function SitemapEntries($attr,$content)
23     {
24          return
25               '<?php if ($_ctx->exists("sitemap_urls")) : ?>'."\n".
26               '<?php while ($_ctx->sitemap_urls->fetch()) : ?>'.$content.'<?php endwhile; ?>'.
27               '<?php endif; ?>'."\n";
28     }
29     
30     public static function SitemapEntryIf($attr,$content)
31     {
32          $if = '';
33          if (isset($attr['has_attr'])) {
34               switch ($attr['has_attr']) {
35                    case 'frequency'    : $if = '!is_null($_ctx->sitemap_urls->frequency)'; break;
36                    case 'priority'     : $if = '!is_null($_ctx->sitemap_urls->priority)'; break;
37                    case 'lastmod'      : $if = '!is_null($_ctx->sitemap_urls->lastmod)'; break;
38               }
39          }
40          if (!empty($if)) {
41               return '<?php if ('.$if.') : ?>'.$content.'<?php endif; ?>';
42          }
43          else {
44               return $content;
45          }
46     }
47     
48     public static function SitemapEntryLoc($attr)
49     {
50          $f = $GLOBALS['core']->tpl->getFilters($attr);
51          return '<?php echo '.sprintf($f,'$_ctx->sitemap_urls->loc').'; ?>';
52     }
53
54     public static function SitemapEntryFrequency($attr)
55     {
56          $f = $GLOBALS['core']->tpl->getFilters($attr);
57          return '<?php echo '.sprintf($f,'$_ctx->sitemap_urls->frequency').'; ?>';
58     }
59
60     public static function SitemapEntryPriority($attr)
61     {
62          $f = $GLOBALS['core']->tpl->getFilters($attr);
63          return '<?php echo '.sprintf($f,'$_ctx->sitemap_urls->priority').'; ?>';
64     }
65
66     public static function SitemapEntryLastmod($attr)
67     {
68          $f = $GLOBALS['core']->tpl->getFilters($attr);
69          return '<?php echo '.sprintf($f,'$_ctx->sitemap_urls->lastmod').'; ?>';
70     }
71}
72?>
Note: See TracBrowser for help on using the repository browser.

Sites map