forked from itkservice/flatPages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_public.php
89 lines (79 loc) · 2.37 KB
/
_public.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of flatPages, a plugin for DotClear2.
# Copyright (c) 2010 Pep and contributors.
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) return;
// Public behaviors definition and binding
/**
*
*/
class flatpagesPublicBehaviors
{
/**
*
*/
public static function addTplPath($core)
{
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
}
/**
*
*/
public static function templateBeforeBlock()
{
$args = func_get_args();
array_shift($args);
if ($args[0] == 'Entries') {
if (!empty($args[1])) {
$attrs = $args[1];
if (!empty($attrs['type']) && $attrs['type'] == 'flatpage') {
$p = "<?php \$params['post_type'] = 'flatpage'; ?>\n";
if (!empty($attrs['basename'])) {
$p .= "<?php \$params['post_url'] = '".$attrs['basename']."'; ?>\n";
}
return $p;
}
}
}
}
/**
*
*/
public static function coreBlogGetPosts($rs)
{
$rs->extend("rsFlatpageBase");
}
/**
*
*/
public static function sitemapsURLsCollect($sitemaps)
{
global $core;
if ($core->blog->settings->sitemaps->sitemaps_flatpages_url) {
$freq = $sitemaps->getFrequency($core->blog->settings->sitemaps->sitemaps_flatpages_fq);
$prio = $sitemaps->getPriority($core->blog->settings->sitemaps->sitemaps_flatpages_pr);
$rs = $core->blog->getPosts(array('post_type' => 'flatpage','post_status' => 1,'no_content' => true));
$rs->extend('rsFlatpages');
while ($rs->fetch()) {
if ($rs->post_password != '') continue;
$sitemaps->addEntry($rs->getURL(),$prio,$freq,$rs->getISO8601Date());
}
}
}
public static function initCommentsWikibar($modes)
{
$modes[] = 'flatpage';
}
}
$core->addBehavior('coreBlogGetPosts', array('flatpagesPublicBehaviors','coreBlogGetPosts'));
$core->addBehavior('publicBeforeDocument',array('flatpagesPublicBehaviors','addTplPath'));
$core->addBehavior('templateBeforeBlock', array('flatpagesPublicBehaviors','templateBeforeBlock'));
$core->addBehavior('sitemapsURLsCollect', array('flatpagesPublicBehaviors','sitemapsURLsCollect'));
$core->addBehavior('initCommentsWikibar', array('flatpagesPublicBehaviors','initCommentsWikibar'));
?>