Dotclear

source: plugins/pollsFactory/inc/index.setting.php @ 2139

Revision 2139, 5.9 KB checked in by JcDenis, 14 years ago (diff)

pollsFactory 1.0:

  • Rewrited plugin
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$active = (boolean) $s->pollsFactory_active;
16$people_ident = (integer) $s->pollsFactory_people_ident;
17
18$public_show = (boolean) $s->pollsFactory_public_show;
19$public_pos = (boolean) $s->pollsFactory_public_pos;
20$public_full = (boolean) $s->pollsFactory_public_full;
21$public_graph = (boolean) $s->pollsFactory_public_graph;
22$public_tpltypes = @unserialize($s->pollsFactory_public_tpltypes);
23if (!is_array($public_tpltypes)) $public_tpltypes = array();
24
25$graph_options = @unserialize($s->pollsFactory_graph_options);
26if (!is_array($graph_options) || empty($graph_options)){
27     $graph_options = pollsFactoryChart::defaultOptions();
28}
29
30$section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
31
32if ($default_tab == 'setting' && $action == 'savesetting')
33{
34     try {
35          $s->setNameSpace('pollsFactory');
36          $s->put('pollsFactory_active',!empty($_POST['active']));
37          $s->put('pollsFactory_people_ident', (integer) $_POST['people_ident']);
38          $s->put('pollsFactory_public_show',!empty($_POST['public_show']));
39          $s->put('pollsFactory_public_pos',!empty($_POST['public_pos']));
40          $s->put('pollsFactory_public_full',!empty($_POST['public_full']));
41          $s->put('pollsFactory_public_graph',!empty($_POST['public_graph']));
42          $s->put('pollsFactory_public_tpltypes',serialize($_POST['public_tpltypes']));
43          $s->put('pollsFactory_graph_options',serialize($_POST['graph_options']));
44
45          if ($_POST['graph_options']['width'] != $graph_options['width ']
46           || $_POST['graph_options']['ttcolor'] != $graph_options['ttcolor'] 
47           || $_POST['graph_options']['txcolor'] != $graph_options['txcolor'] 
48           || $_POST['graph_options']['bgcolor'] != $graph_options['bgcolor'] 
49           || $_POST['graph_options']['chcolor'] != $graph_options['chcolor'] 
50           || $_POST['graph_options']['barcolor'] != $graph_options['barcolor'])
51          {
52               $s->put('pollsFactory_graph_trigger',time());
53          }
54
55          $s->setNameSpace('system');
56          $core->blog->triggerBlog();
57
58          http::redirect($p_url.'&tab=setting&msg='.$action.'&section='.$section);
59     }
60     catch (Exception $e) {
61          $core->error->add($e->getMessage());
62     }
63}
64
65$combo_people_ident = array(
66     __('cookie') => 0,
67     __('cookie and IP') => 1,
68     __('IP') => 2
69);
70$combo_public_show = array(
71     __('when poll is finished') => 0,
72     __('when people has voted') => 1
73);
74
75echo '
76<html>
77<head><title>'.__('Polls manager').'</title>'.$header.
78dcPage::jsColorPicker().
79dcPage::jsLoad('index.php?pf=pollsFactory/js/setting.js').
80"<script type=\"text/javascript\">\n//<![CDATA[\n".
81dcPage::jsVar('jcToolsBox.prototype.section',$section).
82"\n//]]>\n</script>\n".
83'</head>
84<body>
85<h2>'.html::escapeHTML($core->blog->name).
86' &rsaquo; <a href="'.$p_url.'&amp;tab=polls">'.__('Polls').'</a>'.
87' &rsaquo; '.__('Settings').
88' - <a class="button" href="'.$p_url.'&amp;tab=poll">'.__('New poll').'</a>'.
89'</h2>'.$msg.'
90<form id="setting-form" method="post" action="plugin.php">
91
92<fieldset id="setting-plugin"><legend>'. __('Plugin activation').'</legend>
93<p class="field"><label class="classic">'.
94form::checkbox(array('active'),'1',$active).' '.
95__('Enable extension').'</label></p>
96</fieldset>
97
98<fieldset id="setting-option"><legend>'. __('General rules').'</legend>
99<p class="field">'.__('User identification:').' '.
100form::combo(array('people_ident'),$combo_people_ident,$people_ident).'</p>
101<p class="field">'.__('Show reponse:').' '.
102form::combo(array('public_show'),$combo_public_show,$public_show).'</p>
103<p class="field"><label class="classic">'.
104form::checkbox('public_graph','1',$public_graph).' '.
105__('Use graphic results').'</label></p>
106</fieldset>
107
108
109<fieldset id="setting-graph"><legend>'. __('Graphic results settings').'</legend>
110<p class="field">'.__('Width:').' '.
111form::field(array('graph_options[width]'),7,4,$graph_options['width']).'</p>
112<p class="field">'.__('Title color:').' '.
113form::field(array('graph_options[ttcolor]'),7,7,$graph_options['ttcolor'],'colorpicker').'</p>
114<p class="field">'.__('Text color:').' '.
115form::field(array('graph_options[txcolor]'),7,7,$graph_options['txcolor'],'colorpicker').'</p>
116<p class="field">'.__('Background color:').' '.
117form::field(array('graph_options[bgcolor]'),7,7,$graph_options['bgcolor'],'colorpicker').'</p>
118<p class="field">'.__('Chart color:').' '.
119form::field(array('graph_options[chcolor]'),7,7,$graph_options['chcolor'],'colorpicker').'</p>
120<p class="field">'.__('Bar color:').' '.
121form::field(array('graph_options[barcolor]'),7,7,$graph_options['barcolor'],'colorpicker').'</p>
122</fieldset>
123
124<fieldset id="setting-display"><legend>'. __('Polls display').'</legend>
125<p>'.__('Show on:').'</p>';
126foreach($factory->getPublicUrlTypes($core) as $k => $v)
127{
128     echo 
129     '<p class="field"><label class="classic">'.__($k).' '.
130     form::checkbox(array('public_tpltypes[]'),$v,in_array($v,$public_tpltypes)).
131     '</label></p>';
132}
133echo '
134<p class="field"><label class="classic">'.__('Content:').' '.
135form::combo(array('public_full'),array(__('full content')=>1,__('only link to page of poll')=>0),$public_full).'
136</label></p>
137<p class="field"><label class="classic">'.__('Place:').' '.
138form::combo(array('public_pos'),array(__('after content')=>1,__('before content')=>0),$public_pos).'
139</label></p>
140</fieldset>
141
142<div class="clear">
143<p><input type="submit" name="save" value="'.__('save').'" />'.
144$core->formNonce().
145form::hidden(array('p'),'pollsFactory').
146form::hidden(array('tab'),'setting').
147form::hidden(array('action'),'savesetting').'
148</p></div>
149</form>
150'.dcPage::helpBlock('pollsFactory').$footer.'</body></html>';
151?>
Note: See TracBrowser for help on using the repository browser.

Sites map