Dotclear

source: plugins/maintenance/_config.php @ 2227:bfa7b3467627

Revision 2227:bfa7b3467627, 3.1 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Continue clean and document code for plugins and themes admin pages

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
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_CONTEXT_MODULE')) { return; }
13
14$core->blog->settings->addNamespace('maintenance');
15$maintenance = new dcMaintenance($core);
16$tasks = $maintenance->getTasks();
17
18$combo_ts = array(
19     __('Never')              => 0,
20     __('Every week')         => 604800,
21     __('Every two weeks')    => 1209600,
22     __('Every month')        => 2592000,
23     __('Every two months')   => 5184000
24);
25
26if (!empty($_POST['save'])) {
27
28     try {
29          $core->blog->settings->maintenance->put(
30               'plugin_message', 
31               !empty($_POST['settings_plugin_message']), 
32               'boolean', 
33               'Display alert message of late tasks on plugin page', 
34               true, 
35               true
36          );
37
38          foreach($tasks as $t) {
39               if (!empty($_POST['settings_recall_type']) && $_POST['settings_recall_type'] == 'all') {
40                    $ts = $_POST['settings_recall_time'];
41               }
42               else {
43                    $ts = empty($_POST['settings_ts_'.$t->id()]) ? 0 : $_POST['settings_ts_'.$t->id()];
44               }
45               $core->blog->settings->maintenance->put(
46                    'ts_'.$t->id(), 
47                    abs((integer) $ts), 
48                    'integer', 
49                    sprintf('Recall time for task %s', $t->id()), 
50                    true, 
51                    $t->blog()
52               );
53          }
54
55          dcPage::addSuccessNotice(__('Maintenance plugin has been successfully configured.'));
56          http::redirect($list->getURL('module=maintenance&conf=1'));
57     }
58     catch(Exception $e) {
59          $core->error->add($e->getMessage());
60     }
61}
62
63echo 
64'<p>'.__('Set up reminders for maintenance tasks.').'</p>'.
65
66'<h4 class="pretty-title">'.__('Activation').'</h4>'.
67'<p><label for="settings_plugin_message" class="classic">'.
68form::checkbox('settings_plugin_message', 1, $core->blog->settings->maintenance->plugin_message).
69__('Display alert messages on late tasks').'</label></p>'.
70
71'<p class="info">'.sprintf(
72     __('You can place list of late tasks on your %s.'),
73     '<a href="preferences.php#user-favorites">'.__('Dashboard').'</a>'
74).'</p>'.
75
76'<h4 class="pretty-title vertical-separator">'.__('Frequency').'</h4>'.
77
78'<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_all'), 'all').' '.
79'<label class="classic" for="settings_recall_all">'.
80'<strong>'.__('Use one recall time for all tasks').'</strong></label>'.
81
82'<p class="field wide vertical-separator"><label for="settings_recall_time">'.__('Recall time for all tasks:').'</label>'.
83form::combo('settings_recall_time', $combo_ts, 'seperate', 'recall-for-all').
84'</p>'.
85
86'<p class="vertical-separator">'.form::radio(array('settings_recall_type', 'settings_recall_separate'), 'separate', 1).' '.
87'<label class="classic" for="settings_recall_separate">'.
88'<strong>'.__('Use one recall time per task').'</strong></label>';
89
90foreach($tasks as $t)
91{
92     echo
93     '<div class="two-boxes">'.
94
95     '<p class="field wide"><label for="settings_ts_'.$t->id().'">'.$t->task().'</label>'.
96     form::combo('settings_ts_'.$t->id(), $combo_ts, $t->ts(), 'recall-per-task').
97     '</p>'.
98
99     '</div>';
100}
Note: See TracBrowser for help on using the repository browser.

Sites map