1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # |
---|
4 | # This file is part of dayMode, a plugin for Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2006-2010 Pep 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 ------------------------------------ |
---|
12 | if (!defined('DC_RC_PATH')) return; |
---|
13 | |
---|
14 | $GLOBALS['__autoload']['dcCalendar'] = dirname(__FILE__).'/inc/class.dc.calendar.php'; |
---|
15 | $GLOBALS['__autoload']['dcDayTools'] = dirname(__FILE__).'/inc/class.dc.calendar.php'; |
---|
16 | |
---|
17 | class dayModeBehaviors |
---|
18 | { |
---|
19 | // Public behaviors |
---|
20 | public static function block() |
---|
21 | { |
---|
22 | $args = func_get_args(); |
---|
23 | array_shift($args); |
---|
24 | |
---|
25 | if ($args[0] == 'Entries') { |
---|
26 | $attrs = $args[1]; |
---|
27 | |
---|
28 | if (!empty($attrs['today'])) { |
---|
29 | $p = |
---|
30 | '<?php $today = dcDayTools::getEarlierDate(array("ts_type" => "day")); '. |
---|
31 | "\$params['post_year'] = \$today->year(); ". |
---|
32 | "\$params['post_month'] = \$today->month(); ". |
---|
33 | "\$params['post_day'] = \$today->day(); ". |
---|
34 | "unset(\$params['limit']); ". |
---|
35 | "unset(\$today); ". |
---|
36 | " ?>\n"; |
---|
37 | } |
---|
38 | else { |
---|
39 | $p = |
---|
40 | '<?php if ($_ctx->exists("day")) { '. |
---|
41 | "\$params['post_year'] = \$_ctx->day->year(); ". |
---|
42 | "\$params['post_month'] = \$_ctx->day->month(); ". |
---|
43 | "\$params['post_day'] = \$_ctx->day->day(); ". |
---|
44 | "unset(\$params['limit']); ". |
---|
45 | "} ?>\n"; |
---|
46 | } |
---|
47 | return $p; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | public static function addTplPath($core) |
---|
52 | { |
---|
53 | $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset'); |
---|
54 | if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) { |
---|
55 | $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.$tplset); |
---|
56 | } else { |
---|
57 | $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.DC_DEFAULT_TPLSET); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | // Admin behaviors |
---|
62 | public static function adminBlogPreferencesForm($core,$settings) |
---|
63 | { |
---|
64 | echo |
---|
65 | '<div class="fieldset"><h4>'.__('Daily Archives').'</h4>'. |
---|
66 | '<p><label class="classic">'. |
---|
67 | form::checkbox('daymode_active','1',$settings->daymode->daymode_active). |
---|
68 | __('Enable daily archives and calendar').'</label></p>'. |
---|
69 | '</div>'; |
---|
70 | } |
---|
71 | |
---|
72 | public static function adminBeforeBlogSettingsUpdate($settings) |
---|
73 | { |
---|
74 | $settings->addNameSpace('daymode'); |
---|
75 | try { |
---|
76 | $settings->daymode->put('daymode_active',!empty($_POST['daymode_active']),'boolean'); |
---|
77 | } |
---|
78 | catch (Exception $e) { |
---|
79 | $settings->daymode->drop('daymode_active'); |
---|
80 | $settings->daymode->put('daymode_active',!empty($_POST['daymode_active']),'boolean'); |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|