-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseful-banner-manager-banners.php
688 lines (617 loc) · 52.2 KB
/
useful-banner-manager-banners.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
<?php
if ( ! current_user_can( 'manage_options' ) ) {
die( 'Access Denied' );
}
$upload_dir = wp_upload_dir();
?>
<div class="wrap">
<div style="margin: 20px 0; text-align: center; display: inline-block">
<div style="float: left; text-align: justify; width: 400px; border: 1px solid #DFDFDF; padding: 10px; padding-bottom: 6px;">
<div style="float: left; margin-right: 10px;">
<a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank"><img src="http://rubensargsyan.com/images/ubm-premium.png" alt="UBM Premium" style="border: none" /></a>
</div>
<div style="font-size: 11px">"UBM Premium" plugin is the advenced version of the "Useful Banner Manager" plugin which supports more features like impressions, clicks and CTR of the banners. It also allows you to add the links of flash banners outside.
<div style="margin-top: 14px;"><a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">"UBM Premium" homepage</a></div>
</div>
</div>
<div style="float: right; margin-left: 50px; text-align: justify; width: 400px; border: 1px solid #DFDFDF; padding: 10px; padding-bottom: 6px;">
<div style="float: left; margin-right: 10px;">
<a href="http://rubensargsyan.com/wordpress-plugin-useful-video-player/" target="_blank"><img src="http://rubensargsyan.com/images/useful-video-player.png" alt="UBM Premium" style="border: none" /></a>
</div>
<div style="font-size: 11px">"Useful Video Player" plugin allows you to embed videos to your WordPress powered website without hassle.
<div style="margin-top: 7px;">Among the basic features other plugins might offer you, this plugin will enable you to use videos as ads, add overlay text and images.</div>
<div style="margin-top: 7px;"><a href="http://rubensargsyan.com/wordpress-plugin-useful-video-player/" target="_blank">"Useful Video Player" homepage</a></div>
</div>
</div>
</div>
<h1><?php echo( $useful_banner_manager_plugin_title ); ?></h1>
<h2><?php _e( 'Banners', 'useful-banner-manager' ); ?></h2>
<?php
if ( isset( $_GET[ $useful_banner_manager_plugin_prefix . 'banner_id' ] ) && is_numeric( $_GET[ $useful_banner_manager_plugin_prefix . 'banner_id' ] ) && $_GET[ $useful_banner_manager_plugin_prefix . 'banner_id' ] > 0 ) {
if ( $_GET['page'] == 'useful-banner-manager/useful-banner-manager-banners.php' ) {
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'save_banner' ] ) ) {
$banner_id = $_GET[ $useful_banner_manager_plugin_prefix . 'banner_id' ];
$banner_old_name = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_name' ];
$banner_old_type = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_type' ];
$banner_old_file = $banner_id . '-' . $banner_old_name . '.' . $banner_old_type;
$errors = array();
if ( $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['error'] == 0 ) {
$banner_name_parts = explode( '.', $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['name'] );
array_pop( $banner_name_parts );
$banner_name = implode( '.', $banner_name_parts );
$banner_file_parts = explode( '.', $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['name'] );
$banner_type = array_pop( $banner_file_parts );
$available_formats = array( 'jpg', 'jpeg', 'gif', 'png', 'swf' );
if ( ! in_array( strtolower( $banner_type ), $available_formats ) ) {
$errors[] = 'banner_type';
}
$banner_tmp_file = $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['tmp_name'];
} else {
$banner_name = $banner_old_name;
$banner_type = $banner_old_type;
}
if ( trim( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_title' ] ) == '' ) {
$banner_title = '';
$errors[] = 'banner_title';
} else {
$banner_title = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_title' ] ) );
}
$banner_alt = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_alt' ] ) );
$banner_link = esc_url_raw( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_link' ] );
if ( $banner_link == '' ) {
$link_target = '';
} else {
if ( in_array( $_POST[ $useful_banner_manager_plugin_prefix . 'link_target' ], array( '_self', '_top', '_blank', '_parent' ) ) ) {
$link_target = $_POST[ $useful_banner_manager_plugin_prefix . 'link_target' ];
} else {
$link_target = '_self';
}
}
if ( $banner_link == '' ) {
$link_rel = '';
}else{
if ( in_array( $_POST[ $useful_banner_manager_plugin_prefix . 'link_rel' ], array( 'nofollow', 'dofollow' ) ) ) {
$link_rel = $_POST[ $useful_banner_manager_plugin_prefix . 'link_rel' ];
} else {
$link_rel = 'dofollow';
}
}
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) && ! in_array( 'banner_type', $errors ) ) {
if ( $banner_type == 'swf' ) {
$errors[] = 'swf_auto_sizes';
} else {
list( $banner_width, $banner_height ) = @ getimagesize( $banner_tmp_file );
}
} elseif ( ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) {
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width'] > 0 ) {
$banner_width = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width' ];
} else {
$banner_width = '';
$errors[] = 'banner_width';
}
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ] > 0 ) {
$banner_height = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ];
} else {
$banner_height = '';
$errors[] = 'banner_height';
}
}
if ( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] == '' ) {
$active_until = -1;
}else{
$active_until = trim( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] );
if ( ! preg_match( '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $active_until ) || $active_until < date( 'Y-m-d' ) ) {
unset( $active_until );
$errors[] = 'active_until';
}
}
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] >= 0 ){
$banner_order = $_POST[$useful_banner_manager_plugin_prefix . 'banner_order'];
}else{
$errors[] = 'banner_order';
}
$wrapper_id = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_id' ] ) );
$wrapper_class = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_class' ] ) );
switch( $_POST[ $useful_banner_manager_plugin_prefix . 'is_visible' ] ) {
case 'no':
$is_visible = 'no';
break;
default:
$is_visible = 'yes';
}
$current_user = wp_get_current_user();
$banner_edited_by = $current_user->user_login;
$last_edited_date = date( 'Y-m-d' );
if ( empty( $errors ) ) {
$banner_data = array(
'banner_name' => $banner_name,
'banner_type' => $banner_type,
'banner_title' => $banner_title,
'banner_alt' => $banner_alt,
'banner_link' => $banner_link,
'link_target' => $link_target,
'link_rel' => $link_rel,
'banner_width' => $banner_width,
'banner_height' => $banner_height,
'active_until' => $active_until,
'banner_order' => $banner_order,
'wrapper_id' => $wrapper_id,
'wrapper_class' => $wrapper_class,
'is_visible' => $is_visible,
'banner_edited_by' => $banner_edited_by,
'last_edited_date' => $last_edited_date
);
useful_banner_manager_update_banner( $banner_id, $banner_data );
if ( $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['error'] == 0 ) {
if ( file_exists( $upload_dir['basedir'] . '/useful_banner_manager_banners/' . $banner_old_file ) ) {
unlink( $upload_dir['basedir'] . '/useful_banner_manager_banners/' . $banner_old_file );
}
move_uploaded_file( $banner_tmp_file, $upload_dir['basedir'] . '/useful_banner_manager_banners/' . $banner_id . '-' . $banner_name . '.' . $banner_type );
}
echo( '<div id="message" class="updated fade"><p><strong>' . __( 'The banner is edited.', 'useful-banner-manager' ) . '</strong></p></div>' );
} else {
echo( '<div id="message" class="updated fade"><p><strong>' . ( ( count( $errors ) > 1 ) ? __( 'The following fields are wrong:', 'useful-banner-manager' ) : __( 'The following field is wrong:', 'useful-banner-manager' ) ) );
foreach ( $errors as $error ) {
echo( '<p>' . ucwords( str_replace( '_', ' ', $error ) ) . '</p>' );
}
echo( '</strong></p></div>' );
}
}
}
$banner_id = $_GET[ $useful_banner_manager_plugin_prefix . 'banner_id' ];
$banner = useful_banner_manager_get_banner( $banner_id );
if ( empty( $banner ) ) {
echo( '<p>' . __('The banner ID is wrong.', 'useful-banner-manager' ) . '</p>' );
} else {
?>
<form method="post" enctype="multipart/form-data">
<table id="useful_banner_manager_edit_banner">
<tr>
<td colspan="2"><h3><?php echo( sprintf( __( 'Edit the banner "%s"', 'useful-banner-manager' ), $banner->banner_title ) ); ?></h3></td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner File', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<p>
<?php
if ( $banner->banner_type == 'swf' ) {
?>
<object width="<?php echo( $banner->banner_width ); ?>" height="<?php echo( $banner->banner_height ); ?>">
<param name="movie" value="<?php echo( $upload_dir['baseurl'] ); ?>/useful_banner_manager_banners/<?php echo( $banner->id . '-' . $banner->banner_name ); ?>.<?php echo( $banner->banner_type ); ?>">
<param name="wmode" value="transparent">
<embed src="<?php echo( $upload_dir['baseurl'] ); ?>/useful_banner_manager_banners/<?php echo( $banner->id . '-' . $banner->banner_name ); ?>.<?php echo( $banner->banner_type ); ?>" width="<?php echo( $banner->banner_width ); ?>" height="<?php echo( $banner->banner_height ); ?>" wmode="transparent">
</embed>
</object>
<?php
} else {
?>
<img src="<?php echo( $upload_dir['baseurl'] ); ?>/useful_banner_manager_banners/<?php echo( $banner->id . '-' . $banner->banner_name ); ?>.<?php echo( $banner->banner_type ); ?>" width="<?php echo( $banner->banner_width ); ?>" height="<?php echo( $banner->banner_height ); ?>" alt="<?php echo( $banner->banner_alt ); ?>" />
<?php
}
?>
</p>
<input type="hidden" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_name" value="<?php echo( $banner->banner_name ); ?>" />
<input type="hidden" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_type" value="<?php echo( $banner->banner_type ); ?>" />
<input type="file" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_file" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_file" /> <small><?php _e( 'The banner type can be jpg, jpeg, gif, png or swf.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Title', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_title" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_title" style="width: 300px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $banner_title . '"' ); } else { echo( 'value="' . $banner->banner_title . '"' ); } ?> /> <?php _e( '(required)', 'useful-banner-manager' ); ?>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Image Alt', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_alt" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_alt" style="width: 300px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $banner_alt . '"' ); } else { echo( 'value="' . $banner->banner_alt . '"' ); } ?> /> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Link', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_link" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_link" style="width: 300px" <?php if ( ! empty ( $errors ) ) { echo( 'value="' . $banner_link . '"' ); } else { echo( 'value="' . $banner->banner_link . '"' ); } ?> /> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?> <?php echo( sprintf( __( '(You can add link to swf file if you use %s)', 'useful-banner-manager' ), '<a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">"UBM Premium"</a>' ) ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Link Target', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<select id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_target" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_target" style="width: 80px">
<option value="_self" <?php if ( ! empty( $errors ) && $link_target == '_self' ) { echo( 'selected="selected"' ); } elseif ( empty( $errors ) && $banner->link_target == '_self' ) { echo( 'selected="selected"' ); } ?>>_self</option>
<option value="_top" <?php if ( ! empty( $errors ) && $link_target == '_top' ) { echo( 'selected="selected"' ); } elseif ( ( empty( $errors ) ) && $banner->link_target == '_top' ) { echo( 'selected="selected"' ); } ?>>_top</option>
<option value="_blank" <?php if ( ! empty( $errors ) && $link_target == '_blank' ) { echo( 'selected="selected"' ); } elseif ( ( empty( $errors ) ) && $banner->link_target == '_blank' ) { echo( 'selected="selected"' ); } ?>>_blank</option>
<option value="_parent" <?php if ( ! empty( $errors ) && $link_target == '_parent' ) { echo( 'selected="selected"' ); } elseif ( ( empty( $errors ) ) && $banner->link_target == '_parent' ) { echo( 'selected="selected"' ); } ?>>_parent</option>
</select> <?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?> <small><?php echo( sprintf( __( '(You can add link target to swf file if you use %s)', 'useful-banner-manager' ), '<a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">"UBM Premium"</a>' ) ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Link Rel', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<select id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_rel" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_rel" style="width: 80px">
<option value="dofollow" <?php if ( ! empty( $errors ) && $link_rel == 'dofollow' ) { echo( 'selected="selected"' ); } elseif ( ( empty( $errors ) ) && $banner->link_rel == 'dofollow' ) { echo( 'selected="selected"' ); } ?>>dofollow</option>
<option value="nofollow" <?php if ( ! empty( $errors ) && $link_rel == 'nofollow' ) { echo( 'selected="selected"' ); } elseif ( ( empty( $errors ) ) && $banner->link_rel == 'nofollow' ) { echo( 'selected="selected"' ); } ?>>nofollow</option>
</select> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Sizes', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<label><?php _e( 'Auto:', 'useful-banner-manager' ); ?> <input type="checkbox" name="<?php echo($useful_banner_manager_plugin_prefix); ?>auto_sizes" onclick="if(jQuery(this).is(':checked')){ jQuery('#'<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width').attr('disabled',true); jQuery('#'<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height').attr('disabled',true); }else{ jQuery('#'<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width').removeAttr('disabled'); jQuery('#'<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height').removeAttr('disabled'); }" <?php if ( ! empty( $errors ) && isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'checked="checked"' ); } ?> /></label> <small><?php _e( 'Check this to set the original sizes of the banner, not for swf files.', 'useful-banner-manager' ); ?></small>
<table>
<tr>
<td><label for="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width"><?php _e( 'Width:', 'useful-banner-manager' ); ?></label></td>
<td><input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width" style="width: 50px" <?php if ( ! empty( $errors ) && ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'value="' . $banner_width . '"' ); } else { echo( 'value="' . $banner->banner_width . '"' ); } ?> /><?php _e( 'px', 'useful-banner-manager' ); ?> <?php _e( '(required if the banner is swf file)', 'useful-banner-manager' ); ?></td>
</tr>
<tr>
<td><label for="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height"><?php _e( 'Height:', 'useful-banner-manager' ); ?></label></td>
<td><input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height" style="width: 50px" <?php if ( ! empty( $errors ) && ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'value="' . $banner_height . '"' ); } else { echo( 'value="' . $banner->banner_height . '"' ); } ?> /><?php _e( 'px', 'useful-banner-manager' ); ?> <?php _e( '(required if the banner is swf file)', 'useful-banner-manager' ); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Active Until', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>active_until" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>active_until" class="datepicker" style="width: 100px" <?php if ( ! empty( $errors ) ) { if( in_array( 'active_until', $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] ) . '"'); } elseif ( $active_until != -1 ) { echo( 'value="' . $active_until . '"' ); } } elseif ( $banner->active_until != -1 ) { echo( 'value="' . $banner->active_until . '"' ); } ?> /> <small><?php _e( 'Leave empty if there is no date.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Order', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_order" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_order" style="width: 50px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] ) . '"' ); } else { echo( 'value="' . $banner->banner_order . '"' ); } ?> /> <small><?php _e( 'Set the number depends on which the banner will be shown on more top places.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Wrapper ID', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_id" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_id" style="width: 100px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $wrapper_id . '"' ); } else { echo( 'value="' . $banner->wrapper_id . '"' ); } ?> /> <small><?php _e( 'ID of the tag "div" wrapping the banner.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Wrapper Class', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_class" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_class" style="width: 100px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $wrapper_class . '"' ); } else { echo( 'value="' . $banner->wrapper_class . '"' ); } ?> /> <small><?php _e( 'Class or classes of the tag "div" wrapping the banner.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Is Visible', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<label><?php _e( 'Yes:', 'useful-banner-manager' ); ?><input type="radio" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>is_visible" value="yes" <?php if ( ! empty( $errors ) && $is_visible != 'no' ) { echo( 'checked="checked"' ); }elseif ( ( empty( $errors ) ) && $banner->is_visible == 'yes' ) { echo( 'checked="checked"' ); } ?> /></label> <label><?php _e( 'No:', 'useful-banner-manager' ); ?><input type="radio" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>is_visible" value="no" <?php if ( ! empty( $errors ) && $is_visible == 'no' ) { echo( 'checked="checked"' ); }elseif ( ( empty( $errors ) ) && $banner->is_visible == 'no' ) { echo( 'checked="checked"' ); } ?> /></label>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
<p class="submit">
<input name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>save_banner" type="submit" class="button" value="<?php _e( 'Save', 'useful-banner-manager' ); ?>" /> <a href="admin.php?page=useful-banner-manager/useful-banner-manager-banners.php"><?php _e( 'Cancel', 'useful-banner-manager' ); ?></a>
</p>
</form>
<script type="text/javascript">
if(jQuery.isFunction(jQuery.fn.datepicker)){
jQuery('.datepicker').datepicker({ yearRange: '-0:+20', changeYear: true, dateFormat: 'yy-mm-dd' });
}
</script>
<?php
}
}else{
if ( $_GET['page'] == 'useful-banner-manager/useful-banner-manager-banners.php' ) {
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'add_banner' ] ) ) {
$errors = array();
$banner_name_parts = explode( '.', $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['name'] );
array_pop( $banner_name_parts );
$banner_name = implode( '.', $banner_name_parts );
$banner_file_parts = explode( '.', $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['name'] );
$banner_type = array_pop( $banner_file_parts );
$available_formats = array( 'jpg', 'jpeg', 'gif', 'png', 'swf' );
if ( ! in_array( strtolower( $banner_type ), $available_formats ) ) {
$errors[] = 'banner_type';
}
$banner_tmp_file = $_FILES[ $useful_banner_manager_plugin_prefix . 'banner_file' ]['tmp_name'];
if ( trim( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_title' ] ) == '' ) {
$banner_title = '';
$errors[] = 'banner_title';
} else {
$banner_title = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_title' ] ) );
}
$banner_alt = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_alt' ] ) );
$banner_link = esc_url_raw( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_link' ] );
if ( $banner_link == '' ) {
$link_target = '';
} else {
if ( in_array( $_POST[ $useful_banner_manager_plugin_prefix . 'link_target' ], array( '_self', '_top', '_blank', '_parent' ) ) ) {
$link_target = $_POST[ $useful_banner_manager_plugin_prefix . 'link_target' ];
} else {
$link_target = '_self';
}
}
if ( $banner_link == '' ) {
$link_rel = '';
}else{
if ( in_array( $_POST[ $useful_banner_manager_plugin_prefix . 'link_rel' ], array( 'nofollow', 'dofollow' ) ) ) {
$link_rel = $_POST[ $useful_banner_manager_plugin_prefix . 'link_rel' ];
} else {
$link_rel = 'dofollow';
}
}
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) && ! in_array( 'banner_type', $errors ) ) {
if ( $banner_type == 'swf' ) {
$errors[] = 'swf_auto_sizes';
} else {
list( $banner_width, $banner_height ) = @ getimagesize( $banner_tmp_file );
}
} elseif ( ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) {
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width'] > 0 ) {
$banner_width = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_width' ];
} else {
$banner_width = '';
$errors[] = 'banner_width';
}
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ] > 0 ) {
$banner_height = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_height' ];
} else {
$banner_height = '';
$errors[] = 'banner_height';
}
}
$added_date = date( 'Y-m-d' );
if ( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] == '' ) {
$active_until = -1;
}else{
$active_until = trim( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] );
if ( ! preg_match( '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $active_until ) || $active_until < date( 'Y-m-d' ) ) {
unset( $active_until );
$errors[] = 'active_until';
}
}
if ( is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] >= 0 ){
$banner_order = $_POST[$useful_banner_manager_plugin_prefix . 'banner_order'];
}else{
$errors[] = 'banner_order';
}
$wrapper_id = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_id' ] ) );
$wrapper_class = esc_attr( stripslashes( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_class' ] ) );
switch( $_POST[ $useful_banner_manager_plugin_prefix . 'is_visible' ] ) {
case 'no':
$is_visible = 'no';
break;
default:
$is_visible = 'yes';
}
$current_user = wp_get_current_user();
$banner_added_by = $current_user->user_login;
if ( empty( $errors ) ) {
$banner_data = array(
'banner_name' => $banner_name,
'banner_type' => $banner_type,
'banner_title' => $banner_title,
'banner_alt' => $banner_alt,
'banner_link' => $banner_link,
'link_target' => $link_target,
'link_rel' => $link_rel,
'banner_width' => $banner_width,
'banner_height' => $banner_height,
'added_date' => $added_date,
'active_until' => $active_until,
'banner_order' => $banner_order,
'wrapper_id' => $wrapper_id,
'wrapper_class' => $wrapper_class,
'is_visible' => $is_visible,
'banner_added_by' => $banner_added_by
);
$added_banner_id = useful_banner_manager_add_banner( $banner_data );
move_uploaded_file( $banner_tmp_file, $upload_dir['basedir'] . '/useful_banner_manager_banners/' . $added_banner_id . '-' . $banner_name . '.' . $banner_type );
echo('<div id="message" class="updated fade"><p><strong>' . __( 'New banner is added.', 'useful-banner-manager' ) . '</strong></p></div>');
}else{
echo( '<div id="message" class="updated fade"><p><strong>' . ( ( count( $errors ) > 1 ) ? __( 'The following fields are wrong:', 'useful-banner-manager' ) : __( 'The following field is wrong:', 'useful-banner-manager' ) ) );
foreach ( $errors as $error ) {
echo( '<p>' . ucwords( str_replace( '_', ' ', $error ) ) . '</p>' );
}
echo( '</strong></p></div>' );
}
}
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'delete' ] ) ) {
if ( isset( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_id' ] ) && is_numeric( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_id' ] ) && $_POST[ $useful_banner_manager_plugin_prefix . 'banner_id' ] > 0 ) {
$banner_id = $_POST[ $useful_banner_manager_plugin_prefix . 'banner_id' ];
useful_banner_manager_delete_banner( $banner_id );
echo('<div id="message" class="updated fade"><p><strong>' . __( 'The banner is deleted.', 'useful-banner-manager' ) . '</strong></p></div>');
}
}
}
?>
<form method="post" enctype="multipart/form-data">
<table id="useful_banner_manager_add_banner">
<tr>
<td colspan="2"><h3><?php _e( 'Add banner', 'useful-banner-manager' ); ?></h3></td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner File', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="file" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_file" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_file" /> <?php _e( '(required)', 'useful-banner-manager' ); ?> <small><?php _e( 'The banner type can be jpg, jpeg, gif, png or swf.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Title', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_title" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_title" style="width: 300px" <?php if ( ! empty( $errors ) ){ echo( 'value="' . $banner_title . '"' ); } ?> /> <?php _e( '(required)', 'useful-banner-manager' ); ?>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Image Alt', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_alt" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_alt" style="width: 300px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $banner_alt . '"' ); } ?> /> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Link', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_link" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_link" style="width: 300px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . $banner_link . '"'); } ?> /> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?> <?php echo( sprintf( __( '(You can add link to swf file if you use %s)', 'useful-banner-manager' ), '<a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">"UBM Premium"</a>' ) ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Link Target', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<select id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_target" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_target" style="width: 80px">
<option value="_self" <?php if ( ! empty( $errors ) && $link_target == '_self' ) { echo( 'selected="selected"' ); } elseif ( empty( $errors ) ) { echo( 'selected="selected"' ); } ?>>_self</option>
<option value="_top" <?php if ( ! empty( $errors ) && $link_target == '_top' ) { echo( 'selected="selected"' ); } ?>>_top</option>
<option value="_blank" <?php if ( ! empty( $errors ) && $link_target == '_blank' ) { echo( 'selected="selected"' ); } ?>>_blank</option>
<option value="_parent" <?php if ( ! empty( $errors ) && $link_target == '_parent' ) { echo( 'selected="selected"' ); } ?>>_parent</option>
</select> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?> <?php echo( sprintf( __( '(You can add link target to swf file if you use %s)', 'useful-banner-manager' ), '<a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">"UBM Premium"</a>' ) ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Link Rel', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<select id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_rel" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>link_rel" style="width: 80px">
<option value="dofollow" <?php if ( ! empty( $errors ) && $link_rel == 'dofollow' ) { echo( 'selected="selected"' ); } elseif ( empty( $errors ) ) { echo( 'selected="selected"' ); } ?>>dofollow</option>
<option value="nofollow" <?php if ( ! empty( $errors ) && $link_rel == 'nofollow' ) { echo( 'selected="selected"' ); } ?>>nofollow</option>
</select> <small><?php _e( 'Not for swf files.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Sizes', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<label><?php _e( 'Auto:', 'useful-banner-manager' ); ?> <input type="checkbox" name="<?php echo($useful_banner_manager_plugin_prefix); ?>auto_sizes" onclick="if(jQuery(this).is(':checked')){ jQuery('#<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width').attr('disabled',true); jQuery('#<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height').attr('disabled',true); }else{ jQuery('#<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width').removeAttr('disabled'); jQuery('#<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height').removeAttr('disabled'); }" <?php if ( ! empty( $errors ) && isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'checked="checked"' ); } ?> /></label> <small><?php _e( 'Check this to set the original sizes of the banner, not for swf files.', 'useful-banner-manager' ); ?></small>
<table>
<tr>
<td><label for="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width"><?php _e( 'Width:', 'useful-banner-manager' ); ?></label></td>
<td><input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_width" style="width: 50px" <?php if ( ! empty( $errors ) && ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'value="' . $banner_width . '"' ); } ?> /><?php _e( 'px', 'useful-banner-manager' ); ?> <?php _e( '(required if the banner is swf file)', 'useful-banner-manager' ); ?></td>
</tr>
<tr>
<td><label for="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height"><?php _e( 'Height:', 'useful-banner-manager' ); ?></label></td>
<td><input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_height" style="width: 50px" <?php if ( ! empty( $errors ) && ! isset( $_POST[ $useful_banner_manager_plugin_prefix . 'auto_sizes' ] ) ) { echo( 'value="' . $banner_height . '"' ); } ?> /><?php _e( 'px', 'useful-banner-manager' ); ?> <?php _e( '(required if the banner is swf file)', 'useful-banner-manager' ); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Active Until', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>active_until" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>active_until" class="datepicker" style="width: 100px" <?php if ( ! empty( $errors ) ) { if( in_array( 'active_until', $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'active_until' ] ) . '"'); } elseif ( $active_until != -1 ) { echo( 'value="' . $active_until . '"' ); } } ?> /> <small><?php _e( 'Leave empty if there is no date.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Banner Order', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_order" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_order" style="width: 50px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'banner_order' ] ) . '"' ); } else { echo( 'value="0"' ); } ?> /> <small><?php _e( 'Set the number depends on which the banner will be shown on more top places.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Wrapper ID', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_id" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_id" style="width: 100px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_id' ] ) . '"' ); } else { echo( 'value=""' ); } ?> /> <small><?php _e( 'ID of the tag "div" wrapping the banner.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Wrapper Class', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<input type="text" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_class" id="<?php echo( $useful_banner_manager_plugin_prefix ); ?>wrapper_class" style="width: 100px" <?php if ( ! empty( $errors ) ) { echo( 'value="' . esc_attr( $_POST[ $useful_banner_manager_plugin_prefix . 'wrapper_class' ] ) . '"' ); } else { echo( 'value=""' ); } ?> /> <small><?php _e( 'Class or classes of the tag "div" wrapping the banner.', 'useful-banner-manager' ); ?></small>
</td>
</tr>
<tr>
<td width="25%" valign="middle"><strong><?php _e( 'Is Visible', 'useful-banner-manager' ); ?></strong></td>
<td width="75%">
<label><?php _e( 'Yes:', 'useful-banner-manager' ); ?><input type="radio" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>is_visible" value="yes" <?php if ( ! empty( $errors ) && $is_visible != 'no' ) { echo( 'checked="checked"' ); } elseif ( empty( $errors ) ) { echo( 'checked="checked"' ); } ?> /></label> <label><?php _e( 'No:', 'useful-banner-manager' ); ?><input type="radio" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>is_visible" value="no" <?php if ( ! empty( $errors ) && $is_visible == 'no' ) { echo( 'checked="checked"' ); } ?> /></label>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
<p class="submit">
<input name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>add_banner" type="submit" class="button" value="<?php _e( 'Add banner', 'useful-banner-manager' ); ?>" />
</p>
</form>
<script type="text/javascript">
if(jQuery.isFunction(jQuery.fn.datepicker)){
jQuery('.datepicker').datepicker({ yearRange: '-0:+20', changeYear: true, dateFormat: 'yy-mm-dd' });
}
</script>
<br />
<?php $banners = useful_banner_manager_get_banners(); ?>
<style>
.widefat td{
padding: 3px 7px;
vertical-align: middle;
}
.widefat tbody th.check-column{
padding: 7px 0;
vertical-align: middle;
}
</style>
<h3><?php _e( 'Manage banners', 'useful-banner-manager' ); ?></h3>
<table class="widefat fixed" cellspacing="0" id="useful_banner_manager_manage_banners" width="100%">
<thead>
<tr>
<th scope="col" width="3%"><?php _e( 'ID', 'useful-banner-manager' ); ?></th>
<th scope="col" width="5%"><?php _e( 'Type', 'useful-banner-manager' ); ?></th>
<th scope="col" width="12%"><?php _e( 'Title', 'useful-banner-manager' ); ?></th>
<th scope="col" width="23%"><?php _e( 'Link', 'useful-banner-manager' ); ?></th>
<th scope="col" width="6%"><?php _e( 'Rel', 'useful-banner-manager' ); ?></th>
<th scope="col" width="9%"><?php _e( 'Added Date', 'useful-banner-manager' ); ?></th>
<th scope="col" width="9%"><?php _e( 'Active Until', 'useful-banner-manager' ); ?></th>
<th scope="col" width="5%"><?php _e( 'Order', 'useful-banner-manager' ); ?></th>
<th scope="col" width="7%"><?php _e( 'Is Visible', 'useful-banner-manager' ); ?></th>
<th scope="col" width="8%"><?php _e( 'Added By', 'useful-banner-manager' ); ?></th>
<th scope="col" width="5%"></th>
<th scope="col" width="8%"></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'ID', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Type', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Title', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Link', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Rel', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Added Date', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Active Until', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Order', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Is Visible', 'useful-banner-manager' ); ?></th>
<th scope="col"><?php _e( 'Added By', 'useful-banner-manager' ); ?></th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ( $banners as $banner ) {
?>
<tr class="alternate">
<td><?php echo( $banner->id ); ?></td>
<td><?php echo( $banner->banner_type ); ?></td>
<td><?php echo( $banner->banner_title ); ?></td>
<td><?php echo( $banner->banner_link ); ?></td>
<td><?php echo( $banner->link_rel ); ?></td>
<td><?php echo( $banner->added_date ); ?></td>
<td><?php echo( ( $banner->active_until == -1 ) ? __( 'No date', 'useful-banner-manager' ) : $banner->active_until ); ?></td>
<td><?php echo( $banner->banner_order ); ?></td>
<td><?php echo( $banner->is_visible ); ?></td>
<td><?php echo( $banner->banner_added_by ); ?></td>
<td>
<form method="get">
<p class="submit">
<input type="submit" class="button" value="<?php _e( 'Edit', 'useful-banner-manager' ); ?>" />
<input type="hidden" name="page" value="useful-banner-manager/useful-banner-manager-banners.php" />
<input type="hidden" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_id" value="<?php echo( $banner->id ); ?>" />
</p>
</form>
</td>
<td>
<form method="post">
<p class="submit">
<input name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>delete" type="submit" class="button" value="<?php _e( 'Delete', 'useful-banner-manager' ); ?>" onclick="javascript:if(!confirm('<?php echo( sprintf( __( 'Are you sure you want to delete the banner "%s"?', 'useful-banner-manager' ), $banner->banner_title ) ); ?>')){ return false; }" />
<input type="hidden" name="<?php echo( $useful_banner_manager_plugin_prefix ); ?>banner_id" value="<?php echo( $banner->id ); ?>" />
</p>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>