PluginProbe
Uji Countdown / 1.2
Uji Countdown v1.2
3.0 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 36 releases
uji-countdown / uji-countdown-add.php

uji-countdown-add.php in Uji Countdown 1.2, at uji-countdown-add.php

288 lines 11.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 ////////////////////////////////////ADD NEW STYLE////////////////////////////////////
4
5 function sel_size($sz){
6 $ujic_txt_sz = array("Ultra Small"=>"12", "Very Small"=>"15", "Small"=>"25", "Medium"=>"35", "Large"=>"45", "Very Large"=>"55");
7 $select = '<option value="" class="seltit"> - Select Countdown Size - </option>';
8 foreach($ujic_txt_sz as $size=>$key){
9 $sel = ((int)$key == $sz) ? ' selected="selected"' : '';
10 $select .= '<option value="'.$key.'" class="seltit" '.$sel.'>'.$size.'</option>';
11 }
12 return $select;
13 }
14 function rad_pos($ipos){
15 $ujic_pos = array("none", "left", "center", "right");
16 $pos = '';
17 $i=0;
18 foreach($ujic_pos as $p){
19 $sel = ($p == $ipos) ? ' checked="checked"' : '';
20 $pos .= '<input name="ujic_pos" type="radio" value="'.$p.'" '.$sel.' />
21 <span id="uji_pos_'.$i.'">'.ucfirst($p).' </span>';
22 $i++;
23 }
24 return $pos;
25 }
26 function chk_pos($id, $ichk){
27 $sel = ($ichk == 1) ? ' checked="checked"' : '';
28 $chk = '<input name="'.$id.'" id="'.$id.'" type="checkbox" value="1" '.$sel.' />';
29 return $chk;
30 }
31 function ujic_add_new(){
32 ujic_save_newstyle();
33 $ujic_name = !empty($_POST['ujic_name']) ? $_POST['ujic_name'] : '';
34 $ujic_txt_size = !empty($_POST['ujic_txt_size']) ? $_POST['ujic_txt_size'] : 35;
35 $ujic_col_dw = !empty($_POST['ujic_col_dw']) ? $_POST['ujic_col_dw'] : '#3A3A3A';
36 $ujic_col_up = !empty($_POST['ujic_col_up']) ? $_POST['ujic_col_up'] : '#635b63';
37 $ujic_pos = !empty($_POST['ujic_pos']) ? $_POST['ujic_pos'] : 'none';
38 $ujic_col_txt = !empty($_POST['ujic_col_txt']) ? $_POST['ujic_col_txt'] : '#FFFFFF';
39 $ujic_col_sw = !empty($_POST['ujic_col_sw']) ? $_POST['ujic_col_sw'] : '#000000';
40 $ujic_ani = !empty($_POST['ujic_ani']) ? $_POST['ujic_ani'] : '0';
41 $ujic_txt = !empty($_POST['ujic_txt']) ? $_POST['ujic_txt'] : '0';
42 $ujic_maint = "Add New Countdown Style";
43 $ujic_title = "Create New Timer Style";
44 $ujic_save = "Save this style";
45 $ujic_update = '';
46 $ujic_form = 'options-general.php?page=ujic-count&save=ok';
47 $ujic_cancel = '';
48
49 if(isset($_GET['edit']) && !empty($_GET['edit'])){
50 $id = $_GET['edit'];
51 global $wpdb;
52 $table_name = $wpdb->prefix ."uji_counter";
53 $ujic_data = $wpdb->get_row("SELECT * FROM $table_name WHERE id = $id");
54 $ujic_name = $ujic_data->title;
55 $ujic_txt_size = $ujic_data->size;
56 $ujic_col_dw = $ujic_data->col_dw;
57 $ujic_col_up = $ujic_data->col_up;
58 $ujic_pos = $ujic_data->ujic_pos;
59 $ujic_col_txt = $ujic_data->col_txt;
60 $ujic_col_sw = $ujic_data->col_sw;
61 $ujic_ani = $ujic_data->ujic_ani;
62 $ujic_txt = $ujic_data->ujic_txt;
63 $ujic_maint = "Edit Countdown Style";
64 $ujic_title = "Edit style: <strong>".$ujic_data->title."</strong>";
65 $ujic_save = "Update this style";
66 $ujic_update = ' ujic-update"';
67 $ujic_form = 'options-general.php?page=ujic-count&edit='.$id;
68 $ujic_cancel = '<a href="options-general.php?page=ujic-count" class="button-primary cancel"> Cancel Add New </a>';
69 }
70 ?>
71 <div class="wrap" id="ujic_box">
72 <h2> <?php echo $ujic_maint ?></h2>
73
74 <div class="metabox-holder">
75 <div class="postbox">
76 <div class="handlediv" title="Click to toggle"><br /></div>
77 <h3 class="hndle"><span><?php echo $ujic_title ?></span></h3>
78 <div class="inside">
79 <div id="ujic-add" class="form-table <?php echo $ujic_update ?>">
80 <form action="<?php echo $ujic_form ?>" method="post">
81 <div>
82 <label>Timer Title:</label>
83 <input name="ujic_name" id="ujic_name" type="text" class="normal-text" value="<?php echo $ujic_name ?>"/><br/>
84 </div>
85 <div>
86 <label>Countdown Size:</label>
87 <select id="ujic_txt_sz" name="ujic_txt_sz">
88 <?php echo sel_size($ujic_txt_size); ?>
89
90 </select>
91 </div>
92 <div>
93 <label>Select Box Color:</label>
94 <div class="fleft">
95 <span> Bottom: </span>
96 <div id="colorSelector"><div style="background-color: <?php echo $ujic_col_dw ?>"></div></div>
97 <input name="ujic_col_dw" id="ujic_col_dw" type="text" value="<?php echo $ujic_col_dw ?>" class="small-text"/>
98 </div>
99 <div class="fleft">
100 <span> Up: </span>
101 <div id="colorSelector2"><div style="background-color: <?php echo $ujic_col_up ?>"></div></div>
102 <input name="ujic_col_up" id="ujic_col_up" type="text" value="<?php echo $ujic_col_up ?>" class="small-text"/>
103 </div>
104 </div>
105 <div>
106 <label>Alignment:</label>
107 <?php echo rad_pos($ujic_pos) ?>
108 </div>
109 <div>
110 <label>Text Color:</label>
111 <div class="fleft">
112 <span> Number Color: </span>
113 <div id="colorSelector3"><div style="background-color: <?php echo $ujic_col_txt ?>"></div></div>
114 <input name="ujic_col_txt" id="ujic_col_txt" type="text" value="<?php echo $ujic_col_txt ?>" class="small-text"/>
115 </div>
116 <div class="fleft">
117 <span> Shadow Color: </span>
118 <div id="colorSelector4"><div style="background-color: <?php echo $ujic_col_sw ?>"></div></div>
119 <input name="ujic_col_sw" id="ujic_col_sw" type="text" value="<?php echo $ujic_col_sw ?>" class="small-text"/>
120 </div>
121 </div>
122 <div>
123 <label>Animation for seconds:</label>
124 <div class="fleft">
125 <?php echo chk_pos('ujic_ani', $ujic_ani) ?>
126 </div>
127 </div>
128 <div>
129 <label>Display time label text:</label>
130 <div class="fleft">
131 <?php echo chk_pos('ujic_txt', $ujic_txt) ?>
132 </div>
133 <input type="hidden" name="ujic_save" value="save" />
134 </div>
135 <p class="submit">
136 <input class="button-primary" type="submit" name="submit" value="<?php echo $ujic_save ?>" />
137 <?php echo $ujic_cancel; ?>
138 </p>
139 </form>
140 </div>
141 </div>
142 </div>
143 <h3>Preview Your Style:</h3>
144 <div id="ujic-pre">
145 <div id="ujiCountdown" class="hasCountdown">
146 <span class="countdown_row countdown_show4">
147 <span class="countdown_section">
148 <span class="countdown_amount">3</span>
149 <span class="countdown_amount">4</span>
150 <span class="countdown_txt">Days</span>
151 </span>
152 <span class="countdown_section">
153 <span class="countdown_amount">1</span>
154 <span class="countdown_amount">0</span>
155 <span class="countdown_txt">Hours</span>
156 </span>
157 <span class="countdown_section">
158 <span class="countdown_amount">2</span>
159 <span class="countdown_amount">3</span>
160 <span class="countdown_txt">Minutes</span>
161 </span>
162 <span class="countdown_section">
163 <span class="countdown_amount">5</span>
164 <span class="countdown_amount">9</span>
165 <span class="countdown_txt">Seconds</span>
166 </span>
167 </span>
168 </div>
169 </div>
170 <?php ujic_saved(); ?>
171 </div>
172 <div class="metabox-holder">
173 <div class="postbox">
174 <div class="handlediv" title="Click to toggle"><br /></div>
175 <h3 class="hndle"><span>Uji Countdown Premium</span></h3>
176 <div class="inside">
177 <a href="http://www.wpmanage.com/uji-countdown" target="_blank"><img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps3.png'; ?>" style="padding-left:28px" /></a>
178 </div>
179 </div>
180 <div class="postbox">
181 <div class="handlediv" title="Click to toggle"><br /></div>
182 <h3 class="hndle"><span>Add Countdown in Post or Page</span></h3>
183 <div class="inside">
184 <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps.jpg'; ?>" />
185 </div>
186 </div>
187 <div class="postbox">
188 <div class="handlediv" title="Click to toggle"><br /></div>
189 <h3 class="hndle"><span>Add Countdown From Widgets</span></h3>
190 <div class="inside">
191 <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps2.jpg'; ?>" />
192 </div>
193 </div>
194
195 </div>
196 <?php }
197 function ujic_save_newstyle(){
198 global $wpdb;
199 $table_name = $wpdb->prefix ."uji_counter";
200
201 if(isset($_GET['del']) && !empty($_GET['del'])){
202 $cname = $wpdb->get_var("SELECT title FROM $table_name WHERE id = '".$_GET['del']."'");
203 $wpdb->query("DELETE FROM $table_name WHERE id = '".$_GET['del']."'");
204 echo '<div class="updated">Your countdown style named: '.$cname .' was deleted </div>';
205 }
206 if(isset($_POST['ujic_save'])){
207
208 $ujic_form_err = '';
209
210 if(!empty($_POST['ujic_name']) && (!isset($_GET['edit']) || empty($_GET['edit']))){
211 $cname = $wpdb->get_var("SELECT title FROM $table_name WHERE title = '".$_POST['ujic_name']."'");
212 if(!empty($cname)){
213 $ujic_form_err .= 'This name already exist. Please change name <br/>';
214 }
215 }
216
217 if(empty($_POST['ujic_name'])){
218 $ujic_form_err .= 'Please complete Timer Title <br/>';
219 }
220 if(empty($_POST['ujic_txt_sz'])){
221 $ujic_form_err .= 'Please complete Countdown Size: <br/>';
222 }
223 if(empty($_POST['ujic_col_dw']) || empty($_POST['ujic_col_up'])){
224 $ujic_form_err .= 'Please select Box Color <br/>';
225 }
226 if(empty($_POST['ujic_col_txt']) || empty($_POST['ujic_col_sw'])){
227 $ujic_form_err .= 'Please select Text Color <br/>';
228 }
229 if(!empty($ujic_form_err)) echo '<div class="error">'.$ujic_form_err.' </div>';
230 else if (empty($ujic_form_err)){
231 if(!isset($_GET['edit']) || empty($_GET['edit'])){
232 $ujic_ani = isset($_POST['ujic_ani']) ? $_POST['ujic_ani'] : 0;
233 $ujic_txt = isset($_POST['ujic_txt']) ? $_POST['ujic_txt'] : 0;
234
235 $wpdb->query($wpdb->prepare("INSERT INTO $table_name(time, title, size, col_dw, col_up, ujic_pos, col_txt, col_sw, ujic_ani, ujic_txt)
236 VALUES (utc_timestamp(), %s, %d, %s, %s, %s, %s, %s, %d, %d)",
237 trim($_POST['ujic_name']), $_POST['ujic_txt_sz'], $_POST['ujic_col_dw'], $_POST['ujic_col_up'], $_POST['ujic_pos'], $_POST['ujic_col_txt'], $_POST['ujic_col_sw'], $ujic_ani, $ujic_txt ));
238
239 echo '<div class="updated">Your countdown style was added </div>';
240
241 }else{
242 $ujic_ani = isset($_POST['ujic_ani']) ? $_POST['ujic_ani'] : 0;
243 $ujic_txt = isset($_POST['ujic_txt']) ? $_POST['ujic_txt'] : 0;
244 $wpdb->query( $wpdb->prepare("UPDATE $table_name SET title=%s, size=%d, col_dw=%s, col_up=%s, ujic_pos=%s, col_txt=%s, col_sw=%s, ujic_ani=%d, ujic_txt=%d WHERE id=%d", trim($_POST['ujic_name']), $_POST['ujic_txt_sz'], $_POST['ujic_col_dw'], $_POST['ujic_col_up'], $_POST['ujic_pos'], $_POST['ujic_col_txt'], $_POST['ujic_col_sw'], $ujic_ani, $ujic_txt, $_GET['edit']) );
245 echo '<div class="updated">Your countdown style was updated </div>';
246 }
247 }
248 }
249 }
250 function ujic_saved(){
251 global $wpdb;
252 $table_name = $wpdb->prefix ."uji_counter";
253 $ujic_datas = $wpdb->get_results("SELECT * FROM $table_name ORDER BY `time` DESC");
254 if(!empty($ujic_datas)){
255 ?>
256 <h3>Countdown Styles:</h3>
257 <table class="widefat">
258 <thead>
259 <tr>
260 <th>Added in</th>
261 <th>Title</th>
262 <th>Change</th>
263 </tr>
264 </thead>
265 <tfoot>
266 <tr>
267 <th>Added in</th>
268 <th>Title</th>
269 <th>Change</th>
270 </tr>
271 </tfoot>
272 <tbody>
273 <?php
274 $ujictab='';
275 foreach($ujic_datas as $ujic)
276 {
277 $ujictab .='<tr><td>'.$ujic->time.'</td><td>'.$ujic->title.'</td><td><a href="options-general.php?page=ujic-count&edit='.$ujic->id.'">Edit</a> | <a href="options-general.php?page=ujic-count&del='.$ujic->id.'">Delete</a></td></tr>';
278 }
279 echo $ujictab;
280 ?>
281 </tbody>
282 </table>
283 <?php
284
285 }
286 }
287
288 ?>