Dotclear

source: plugins/dayMode/_prepend.php @ 947

Revision 947, 2.2 KB checked in by pep, 15 years ago (diff)

dayMode : Modification du niveau de permission + déplacement de l'option d'activation dans le panneau de préférences du blog (closes #120, #124).

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of dayMode, a plugin for Dotclear 2.
5#
6# Copyright (c) 2006-2009 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 ------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14$GLOBALS['__autoload']['dcCalendar'] = dirname(__FILE__).'/class.dc.calendar.php';
15$GLOBALS['__autoload']['dcDayTools'] = dirname(__FILE__).'/class.dc.calendar.php';
16
17class 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          $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
54     }
55
56     // Admin behaviors
57     public static function adminBlogPreferencesForm(&$core,&$settings)
58     {
59          echo
60          '<fieldset><legend>'.__('Daily Archives').'</legend>'.
61          '<p><label class="classic">'.
62          form::checkbox('daymode_active','1',$settings->daymode_active).
63          __('Enable daily archives and calendar').'</label></p>'.
64          '</fieldset>';
65     }
66     
67     public static function adminBeforeBlogSettingsUpdate(&$settings)
68     {
69          $settings->setNameSpace('daymode');
70          try {
71               $settings->put('daymode_active',!empty($_POST['daymode_active']),'boolean');
72          }
73          catch (Exception $e) {
74               $settings->drop('daymode_active');
75               $settings->put('daymode_active',!empty($_POST['daymode_active']),'boolean');
76          }
77          $settings->setNameSpace('system');
78     }
79}
80?>
Note: See TracBrowser for help on using the repository browser.

Sites map