Changeset 1071883
- Timestamp:
- 01/20/2015 07:20:46 PM (11 years ago)
- Location:
- nastrikejcz/trunk
- Files:
-
- 2 added
- 1 edited
-
nastrikej.php (modified) (8 diffs)
-
views/admin-competitions.php (added)
-
views/admin-positions.php (added)
Legend:
- Unmodified
- Added
- Removed
-
nastrikejcz/trunk/nastrikej.php
r973504 r1071883 5 5 Plugin URI: http://www.nastrikej.cz 6 6 Description: Rozpis hasičských soutěží/výsledků z celé ČR 7 Version: 0. 27 Version: 0.3 8 8 Author: vEnCa-X 9 9 Author URI: http://www.venca-x.cz … … 11 11 */ 12 12 13 class Nastrikej extends WP_Widget 13 define("URL", "http://www.nastrikej.cz/json/"); 14 15 class NastrikejCompetitions extends WP_Widget 14 16 { 15 17 16 protected $url = "http://www.nastrikej.cz/json/";17 18 18 public function __construct() 19 19 { 20 parent::__construct( false, $name = __( 'Nastříkej ' ) );20 parent::__construct( false, $name = __( 'Nastříkej - soutěže' ) ); 21 21 } 22 22 23 23 public function form( $instance ) 24 24 { 25 $instance = wp_parse_args( 26 (array) $instance 27 ); 28 29 if ( !empty( $instance['title'] ) ) 25 $instance = wp_parse_args( (array) $instance ); 26 27 if ( isset( $instance['title'] ) ) 30 28 { 31 29 $title = $instance['title']; … … 35 33 $title = __( 'Soutěže', 'wptuts-countdowner-locale' ); 36 34 } 35 36 if ( isset( $instance['seasonId'] ) ) 37 { 38 $seasonId = $instance['seasonId']; 39 } 40 else 41 { 42 $seasonId = ""; 43 } 37 44 38 if ( !empty( $instance['seasonId'] ) ) 39 { 40 $seasonId = $instance['seasonId']; 41 } 42 else 43 { 44 $seasonId = ""; 45 } 46 47 if ( !empty( $instance['teamsId'] ) ) 45 if ( isset( $instance['teamsId'] ) ) 48 46 { 49 47 $teamsId = $instance['teamsId']; … … 55 53 56 54 // Display the admin form 57 include( plugin_dir_path( __FILE__ ) . '/views/admin .php' );55 include( plugin_dir_path( __FILE__ ) . '/views/admin-competitions.php' ); 58 56 } 59 57 … … 63 61 64 62 $instance['title'] = strip_tags( $new_instance['title'] ); 65 $instance['seasonId'] = strip_tags( $new_instance['seasonId'] ); 63 $instance['seasonId'] = strip_tags( $new_instance['seasonId'] ); 66 64 $instance['teamsId'] = esc_sql( $new_instance['teamsId'] ); 67 65 return $instance; … … 74 72 echo $before_widget; 75 73 76 $title = apply_filters( 'wptuts_countdowner_title', $instance['title']);77 $seasonId = apply_filters( 'season_id', $instance['seasonId'] );78 79 $url = $this->url. "competition-in-season/" . $seasonId;74 $title = apply_filters('widget_title', $instance['title']); 75 $seasonId = $instance['seasonId']; 76 77 $url = URL . "competition-in-season/" . $seasonId; 80 78 if( is_array( $instance['teamsId'] ) ) 81 79 { … … 84 82 85 83 //echo "".$url.""; 86 84 87 85 $json = file_get_contents( $url ); 88 86 $data = json_decode( $json, TRUE ); 89 90 $table = "<table id='nastrikej'>87 88 $table = "<table class='nastrikej'> 91 89 <tr> 92 90 <th>Datum</th> 93 91 <th>Místo</th> 94 </tr>"; 95 foreach ( $data["competitions"] as $competition ) 92 </tr>"; 93 foreach ( $data["competitions"] as $competition ) 94 { 95 $table.="<tr>"; 96 $table.="<td class='competition'>" . $competition["date"] . " </td><td class='competition-village'><a href='" . $competition["href"] . "'>" . $competition["village"] . "</a></td>"; 97 $table.="</tr>"; 98 99 if( count( $competition["results"] ) > 0 ) 100 { 101 foreach( $competition["results"] as $result) 102 { 103 $video = ""; 104 foreach( $result["youtubes"] as $youtube ) 96 105 { 97 $table.="<tr>"; 98 $table.="<td class='competition'>" . $competition["date"] . " </td><td class='competition-village'><a href='" . $competition["href"] . "'>" . $competition["village"] . "</a></td>"; 99 $table.="</tr>"; 100 101 if( count( $competition["results"] ) > 0 ) 102 { 103 foreach( $competition["results"] as $result) 104 { 105 $video = ""; 106 foreach( $result["youtubes"] as $youtube ) 107 { 108 $video.= " <a href='" . $youtube . "' target='_blank' class='competition-video'><img src='http://www.nastrikej.cz/pictures/video-icon.png' alt='video'></a> "; 109 } 110 111 $table.="<tr>"; 112 $table.="<td colspan=\"2\" class='competition-result'><small> {$result["position"]}. {$result["team"]}, čas: {$result["time"]}</small>".$video."</td>"; 113 //,{$result["position"]}.místo"; 114 $table.="</tr>"; 115 } 116 } 117 118 } 106 $video.= " <a href='" . $youtube . "' target='_blank' class='competition-video'><img src='http://www.nastrikej.cz/pictures/video-icon.png' alt='video'></a> "; 107 } 108 109 $table.="<tr>"; 110 $table.="<td colspan=\"2\" class='competition-result'><small> {$result["position"]}. {$result["team"]}, čas: {$result["time"]}</small>".$video."</td>"; 111 $table.="</tr>"; 112 } 113 } 114 } 115 119 116 $table.= "</table>"; 120 117 121 118 include( plugin_dir_path( __FILE__ ) . '/views/widget.php' ); 122 119 … … 126 123 } 127 124 128 add_action('widgets_init', create_function('', 'return register_widget("nastrikej");')); 125 class NastrikejPositions extends WP_Widget 126 { 127 128 public function __construct() 129 { 130 parent::__construct( false, $name = __( 'Nastříkej - pořadí' ) ); 131 } 132 133 public function form( $instance ) 134 { 135 $instance = wp_parse_args( 136 (array) $instance 137 ); 138 139 if ( isset( $instance['title'] ) ) 140 { 141 $title = $instance['title']; 142 } 143 else 144 { 145 $title = __( 'Pořadí', 'wptuts-countdowner-locale' ); 146 } 147 148 if ( isset( $instance['seasonId'] ) ) 149 { 150 $seasonId = $instance['seasonId']; 151 } 152 else 153 { 154 $seasonId = ""; 155 } 156 157 if ( isset( $instance['teamsId'] ) ) 158 { 159 $teamsId = $instance['teamsId']; 160 } 161 else 162 { 163 $teamsId = array(); 164 } 165 166 if ( isset( $instance['countTeamsAround'] ) ) 167 { 168 $countTeamsAround = $instance['countTeamsAround']; 169 } 170 else 171 { 172 $countTeamsAround = -1; 173 } 174 175 // Display the admin form 176 include( plugin_dir_path( __FILE__ ) . '/views/admin-positions.php' ); 177 } 178 179 public function update( $new_instance, $old_instance ) 180 { 181 $instance = $old_instance; 182 183 $instance['title'] = strip_tags( $new_instance['title'] ); 184 $instance['seasonId'] = strip_tags( $new_instance['seasonId'] ); 185 $instance['teamsId'] = esc_sql( $new_instance['teamsId'] ); 186 $instance['countTeamsAround'] = strip_tags( $new_instance['countTeamsAround'] ); 187 return $instance; 188 } 189 190 public function widget( $args, $instance ) 191 { 192 extract( $args, EXTR_SKIP ); 193 194 echo $before_widget; 195 196 $title = apply_filters('widget_title', $instance['title']); 197 $seasonId = $instance['seasonId']; 198 if(isset($instance['countTeamsAround'])) 199 { 200 $countTeamsAround = $instance['countTeamsAround']; 201 } 202 203 //positions 204 $url = URL . "positions-in-season/" . $seasonId; 205 if( is_array( $instance['teamsId'] ) ) 206 { 207 $url.= "?team=" . implode( "x", $instance['teamsId'] ); 208 } 209 210 if(isset($countTeamsAround)) 211 { 212 $url .= "&countTeamsAround=" . $countTeamsAround; 213 } 214 215 $json = file_get_contents( $url ); 216 $data = json_decode( $json, TRUE ); 217 218 //positions 219 $table = "<table class='nastrikej'> 220 <tr> 221 <th>Pořadí</th> 222 <th>Družstvo</th> 223 <th>Body</th> 224 </tr>"; 225 226 foreach( $data["positions"] as $aRowPosition ) 227 { 228 $strongStartTag = ""; 229 $strongEndTag = ""; 230 if($aRowPosition['strong'] === TRUE) 231 { 232 $strongStartTag = "<strong>"; 233 $strongEndTag = "</strong>"; 234 } 235 $table.= "<tr> 236 <td>{$strongStartTag}{$aRowPosition['position']}{$strongEndTag}.</td> 237 <td><a href='{$aRowPosition['team_href']}' target='_blank'>{$strongStartTag}{$aRowPosition['team']}{$strongEndTag}</a></td> 238 <td>{$strongStartTag}{$aRowPosition['points']}{$strongEndTag}</td> 239 </tr>"; 240 } 241 242 $table.= "</table>"; 243 244 include( plugin_dir_path( __FILE__ ) . '/views/widget.php' ); 245 246 echo $after_widget; 247 } 248 249 } 250 251 252 add_action('widgets_init', create_function('', 'return register_widget("nastrikejCompetitions");')); 253 add_action('widgets_init', create_function('', 'return register_widget("nastrikejPositions");')); 129 254 130 255 ?>
Note: See TracChangeset
for help on using the changeset viewer.