Dotclear

source: plugins/pollsFactory/index.php @ 2102

Revision 2102, 3.1 KB checked in by JcDenis, 14 years ago (diff)

pollsFactory 0.2:

  • Fixed bug with end of poll
  • Fixed bug with admin filters on polls list
  • Fixed display of admin menu
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of pollsFactory, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009-2010 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_CONTEXT_ADMIN')){return;}
14
15# Check user perms
16dcPage::check('admin');
17
18# Objects
19$s = $core->blog->settings;
20$fact = new pollsFactory($core);
21
22# Default values
23$echo = '';
24$show_filters = false;
25$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
26
27# Messages
28$msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : '';
29$msg_list = array(
30     'savesetting' => __('Configuration successfully saved'),
31     'createpoll' => __('Poll successfully created'),
32     'editperiod' => __('Poll period successfully updated'),
33     'deletepoll' => __('Poll successfully deleted'),
34     'deletequery' => __('Queries successfully deleted'),
35     'reorderquery' => __('Queries successfully reordered'),
36     'createquery' => __('Query successfully created'),
37     'deletenewquery' => __('New query successfully deleted'),
38     'deleteoption' => __('Options successfully deleted'),
39     'createoption' => __('Option successfully created'),
40     'finishquery' => __('Query successfully completed'),
41     'finishpoll' => __('Poll successfully completed'),
42     'selectresponses' => __('Responses succesfully selected')
43);
44if (isset($msg_list[$msg])) {
45     $msg = sprintf('<p class="message">%s</p>',$msg_list[$msg]);
46}
47
48# Menus
49$start_tab = $s->pollsFactory_active ? 'polls' : 'setting';
50$default_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : $start_tab;
51$tabs = array(
52     'setting' => __('Options'),
53     'polls' => __('Polls list'),
54     'addpoll' => __('Create poll'),
55     'viewpoll' => __('Poll results')
56);
57
58# Page
59if (!file_exists(dirname(__FILE__).'/inc/index.'.$default_tab.'.php')) {
60     $default_tab = 'setting';
61}
62require dirname(__FILE__).'/inc/index.'.$default_tab.'.php';
63
64if (!isset($tabs[$default_tab])) {
65     $tabs[$default_tab] = __('Edit');
66}
67
68
69# Display
70echo '
71<html><head>
72<title>'.__('Polls factory').'</title>'.
73dcPage::jsDatePicker().
74dcPage::jsLoad('js/_posts_list.js').
75(!$show_filters ? dcPage::jsLoad('js/filter-controls.js') : '').
76dcPage::jsPageTabs($default_tab).
77dcPage::jsColorPicker().
78dcPage::jsToolMan().
79dcPage::jsLoad('index.php?pf=pollsFactory/js/admin.js').
80'
81</head>
82<body>
83<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.__('Polls factory').'</h2>';
84
85foreach($tabs as $k => $v)
86{
87     if ($default_tab == $k) {
88          echo '<div class="multi-part" id="'.$k.'" title="'.$v.'">'.(!empty($msg) ? $msg : '').$echo.'</div>';
89     } else {
90          echo '<a href="'.$p_url.'&amp;tab='.$k.'" class="multi-part">'.$v.'</a>';
91     }
92}
93
94echo 
95dcPage::helpBlock('pollsFactory').'
96<hr class="clear"/>
97<p class="right">
98pollsFactory - '.$core->plugins->moduleInfo('pollsFactory','version').'&nbsp;
99<img alt="'.__('Polls factory').'" src="index.php?pf=pollsFactory/icon.png" />
100</p></body></html>';
101?>
Note: See TracBrowser for help on using the repository browser.

Sites map