PluginProbe
wp-forecast / 3.6
wp-forecast v3.6
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
wp-forecast / class-wpf_widget.php

class-wpf_widget.php in wp-forecast 3.6, at class-wpf_widget.php

105 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !class_exists('wpf_widget') )
4 {
5 class wpf_widget extends WP_Widget
6 {
7 function wpf_widget()
8 {
9 $widget_ops = array('classname' => 'wp_forecast_widget',
10 'description' => 'WP Forecast Widget');
11 $control_ops = array('width' => 300, 'height' => 150);
12 $this->WP_Widget('wp-forecast', 'WP Forecast',
13 $widget_ops, $control_ops);
14 }
15
16 function widget( $args, $instance )
17 {
18 pdebug(1,"Start of function class wpf_widget::widget ()");
19
20 // get widget params from instance
21 $title = $instance['title'];
22 $wpfcid = $instance['wpfcid'];
23
24 if (trim($wpfcid) =="")
25 $wpfcid="A";
26
27 // pass title to show function
28 $args['title'] = $title;
29
30 if ( $wpfcid == "?")
31 $wpf_vars=get_wpf_opts("A");
32 else
33 $wpf_vars=get_wpf_opts($wpfcid);
34
35 if (!empty($language_override)) {
36 $wpf_vars['wpf_language']=$language_override;
37 }
38
39 show($wpfcid,$args,$wpf_vars);
40
41 pdebug(1,"End of function class wpf_widget::widget () ");
42 }
43
44 function update( $new_instance, $old_instance )
45 {
46 pdebug(1,"Start of wpf_widget::update()");
47
48 return $new_instance;
49
50 pdebug(1,"End of wpf_widget::update()");
51 }
52
53 function form( $instance )
54 {
55 pdebug(1,"Start of wpf_widget::form()");
56
57 $count = wpf_get_option('wp-forecast-count');
58
59 // get translation
60 $locale = get_locale();
61 if ( empty($locale) )
62 $locale = 'en_US';
63 if(function_exists('load_textdomain'))
64 load_textdomain("wp-forecast_".$locale,ABSPATH .
65 "wp-content/plugins/wp-forecast/lang/".$locale.".mo");
66
67 $title = esc_attr($instance['title']);
68 $wpfcid = esc_attr($instance['wpfcid']);
69
70 // code for widget title form
71 $out = "";
72 $out .= '<p><label for="'. $this->get_field_id('title') . '" >';
73 $out .= __("Title:","wp-forecast_".$locale);
74 $out .= '<input class="widefat" id="'.
75 $this->get_field_id('title') . '" name="'.
76 $this->get_field_name('title') .
77 '" type="text" value="'. $title.'" /></label></p>';
78
79 // print out widget selector
80 $out .='<p><label for ="'. $this->get_field_id('wpfcid') . '" >';
81 $out .= __('Available widgets',"wp-forecast_".$locale);
82 $out .= "<select name='". $this->get_field_name("wpfcid") ."' size='1' >";
83 // option for choose dialog
84 $out .="<option value='?' ";
85 if ( $wpfcid == $id )
86 $out .=" selected='selected' ";
87 $out .=">?</option>";
88
89 for ($i=0;$i<$count;$i++) {
90 $id = get_widget_id( $i );
91 $out .="<option value='".$id."' ";
92 if ( $wpfcid == $id or ($wpfcid == "" and $id="A"))
93 $out .=" selected='selected' ";
94 $out .=">".$id."</option>";
95 }
96 $out .= "</select></label></p>";
97 echo $out;
98
99 pdebug(1,"End of wpf_widget::form()");
100 }
101 }
102
103 }
104 ?>
105