Changeset 690020
- Timestamp:
- 04/01/2013 01:09:13 PM (13 years ago)
- Location:
- ttlive/trunk
- Files:
-
- 2 edited
-
index.php (modified) (8 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ttlive/trunk/index.php
r620683 r690020 4 4 Plugin URI: http://www.svbb-tischtennis.de/ 5 5 Description: A simple wordpress plugin to get the data from the ttlive-system and show it on my wp-post or wp-page 6 Version: 0. 76 Version: 0.8 7 7 Author: finalan 8 8 Author URI: http://www.svbb-tischtennis.de … … 18 18 'tableclassname' => '', // Klassenname der Tabelle 19 19 'own_team' => '', // Name des eigenen Teams 20 'runde' => 1, // Vorrunde = 1 (default), Rückrunde = 2 20 'runde' => 1, // Vorrunde = 1 (default), Rückrunde = 2 21 'showxdays' => 0, // 14Tage: Anzahl der Tage die dargestellt werden sollen 22 'max' => 0, // 14Tage: Anzahl der Tage die maximal dargestell werden sollen 23 'widget' => 0, // 14Tage: Für die Darstellung in einem Widget 21 24 //START nur für die Tabelle 22 25 'teamalias' => '', // Teamname:Alias;Teamname2:Alias2; … … 32 35 'refresh' => get_option('TTLive_refreshHours'), // Anzahl Stunden bis die Daten erneut vom Live-System aktualisiert werden sollen 33 36 ), $atts ); 34 37 //print_r($atts); 35 38 36 39 if ($a['runde'] == 1) { $runde = "1"; } … … 54 57 case "14Tage": 55 58 $area = ""; 56 if ( $a['display_type']==0):59 if ( $a['display_type'] == 0 ): 57 60 $area .= "&Area=PlanLast"; 58 61 else: … … 61 64 $a['filename'] = "wp-content/plugins/ttlive/ttlive-files/ttlive". DS . "14Days" .$area . ".xml"; 62 65 $a['url'] = $a['baseurl']."/Export/default.aspx?SpartenID=".get_option('TTLive_divisionID')."&Format=XML&SportArt=96&".$area; 63 $retval = getTTLive14Tage($a); 66 if ( $a['widget'] == 1 ) { 67 $retval = getTTLive14TageDataForWidget($a); 68 } else { 69 $retval = getTTLive14Tage($a); 70 } 64 71 break; 65 72 default: … … 364 371 if($xml = simplexml_load_file($params['filename'], NULL, ($debug==1)?LIBXML_NOERROR:NULL)) 365 372 { 373 $expiration_date = new DateTime(); 374 $date_interval = new DateInterval('P'.$params['showxdays'].'D'); 375 $date_interval->invert = $params['display_type']; 376 $expiration_date->sub($date_interval); 377 366 378 $plan .= "<table class='" . $tableclassname . "'>\n"; 367 $plan .= "<tr><th style='text-align:center'>Datum</th>\n";379 $plan .= "<tr><th></th><th style='text-align:center'>Datum</th>\n"; 368 380 $plan .= "<th style='text-align:center'>Zeit</th>\n"; 369 381 $plan .= "<th style='text-align:left'>Staffel</th>\n"; … … 383 395 $time = $attribute->Zeit; 384 396 if ($time == "00:00") { $time = ""; } 385 $thedate = strftime('%d.%m.%Y', strtotime($attribute->Datum)); 386 $plan .= "<tr"; 387 if ($zeile % 2 !=0) { 388 //ungerade 389 $plan .= " class='even'>"; 390 } else { 391 //gerade 392 $plan .= " class='odd'>"; 393 } 394 $plan .= "<td>". $attribute->Tag . ", " .$thedate ."</td>\n"; 395 $plan .= "<td>".$time."</td>\n"; 396 $staffel = explode(", ", $attribute->Staffelname); 397 $search = array("Bezirksklasse", "Beziksliga", "Kreisliga", "Kreisklasse", "Landesliga", "Nord", "Süd", "Ost", "West", "Mitte"); 398 $replace = array("BK", "BL", "KL", "KK", "LL", "N", "S", "O", "W", "M"); 399 $newstaffel = str_replace($search, $replace, $staffel[1]); 400 if ($staffel[0] == "Pokal Herren"): 401 $newstaffel = "Pokal He"; 402 endif; 403 $plan .= "<td>".$newstaffel."</td>\n"; 404 $isHeimteam = false; 405 if ((strstr($attribute->Heimmannschaft, "Herren")) or (strstr($attribute->Heimmannschaft, "Jungen")) or (strstr($attribute->Heimmannschaft, "Schüler")) or (strstr($attribute->Heimmannschaft, "Damen")) or (strstr($attribute->Heimmannschaft, "Senioren"))) 406 { 407 $isHeimteam = true; 408 $plan .= "<td style='text-align:right;'><b>".$attribute->Heimmannschaft."</b></td>\n"; 409 } 410 else 411 { 412 $plan .= "<td style='text-align:right;'>".$attribute->Heimmannschaft."</td>\n"; 413 } 414 $plan .= "<td> -</td>"; 415 if ((strstr($attribute->Gastmannschaft, "Herren")) or (strstr($attribute->Gastmannschaft, "Jungen")) or (strstr($attribute->Gastmannschaft, "Sch�ler")) or (strstr($attribute->Gastmannschaft, "Damen")) or (strstr($attribute->Gastmannschaft, "Senioren"))) 416 { 417 $plan .= "<td><b>".$attribute->Gastmannschaft."</b></td>\n"; 418 } 419 else 420 { 421 $plan .= "<td>".$attribute->Gastmannschaft."</td>\n"; 422 } 423 if ($params['display_type']==0) /*Rueckschau*/ 424 { 425 $array = explode ( ':', $attribute->Ergebnis ); 426 $color="black"; 427 if ((intval($array[0])) > (intval($array[1]))) 428 { 429 if ($isHeimteam) 397 $thedate = new Datetime(strftime('%d.%m.%Y', strtotime($attribute->Datum))); 398 $hide = false; 399 if ($params['showxdays'] > 0 ) { 400 if ( $params['display_type'] ) { 401 if ( $thedate > $expiration_date ) { $hide = true; } 402 } else { 403 if ( $thedate < $expiration_date ) { $hide = true; } 404 } 405 } 406 if ($params['max'] > 0 ) { 407 if ( $zeile > $params['max'] ) { $hide = true; } 408 } 409 410 if ( !$hide) { 411 $plan .= "<tr"; 412 if ($zeile % 2 !=0) { 413 //ungerade 414 $plan .= " class='even'>"; 415 } else { 416 //gerade 417 $plan .= " class='odd'>"; 418 } 419 $plan .= '<td>'.$marker.$attribute->Tag.'</td><td>'.$thedate->format('d.m.Y').'</td>'."\n"; 420 $plan .= "<td>$time</td>\n"; 421 $staffel = explode(", ", $attribute->Staffelname); 422 $search = array("Bezirksklasse", "Beziksliga", "Kreisliga", "Kreisklasse", "Landesliga", "Nord", "Süd", "Ost", "West", "Mitte"); 423 $replace = array("BK", "BL", "KL", "KK", "LL", "N", "S", "O", "W", "M"); 424 $newstaffel = str_replace($search, $replace, $staffel[1]); 425 if ($staffel[0] == "Pokal Herren"): 426 $newstaffel = "Pokal He"; 427 endif; 428 $plan .= "<td>".$newstaffel."</td>\n"; 429 $isHeimteam = false; 430 if ((strstr($attribute->Heimmannschaft, "Herren")) or (strstr($attribute->Heimmannschaft, "Jungen")) or (strstr($attribute->Heimmannschaft, "Schüler")) or (strstr($attribute->Heimmannschaft, "Damen")) or (strstr($attribute->Heimmannschaft, "Senioren"))) 431 { 432 $isHeimteam = true; 433 $plan .= "<td style='text-align:right;'><b>".$attribute->Heimmannschaft."</b></td>\n"; 434 } 435 else 436 { 437 $plan .= "<td style='text-align:right;'>".$attribute->Heimmannschaft."</td>\n"; 438 } 439 $plan .= "<td> -</td>"; 440 if ((strstr($attribute->Gastmannschaft, "Herren")) or (strstr($attribute->Gastmannschaft, "Jungen")) or (strstr($attribute->Gastmannschaft, "Sch�ler")) or (strstr($attribute->Gastmannschaft, "Damen")) or (strstr($attribute->Gastmannschaft, "Senioren"))) 441 { 442 $plan .= "<td><b>".$attribute->Gastmannschaft."</b></td>\n"; 443 } 444 else 445 { 446 $plan .= "<td>".$attribute->Gastmannschaft."</td>\n"; 447 } 448 if ($params['display_type']==0) /*Rueckschau*/ 449 { 450 $array = explode ( ':', $attribute->Ergebnis ); 451 $color="black"; 452 if ((intval($array[0])) > (intval($array[1]))) 430 453 { 431 $color="green"; 454 if ($isHeimteam) 455 { 456 $color="green"; 457 } 458 else 459 { 460 $color="red"; 461 } 462 } 463 if ((intval($array[1])) > (intval($array[0]))) 464 { 465 if (!$isHeimteam) 466 { 467 $color="green"; 468 } 469 else 470 { 471 $color="red"; 472 } 473 } 474 if ($color!="black") 475 { 476 $plan .= "<td style='text-align:center; color:".$color ."'>"; 432 477 } 433 478 else 434 479 { 435 $ color="red";480 $plan .= "<td style='text-align:center;'>"; 436 481 } 437 } 438 if ((intval($array[1])) > (intval($array[0]))) 439 { 440 if (!$isHeimteam) 482 483 if ($attribute->Link) 484 { 485 $plan .="<a style=\"text-align: center; color:".$color ."\" href=\"".htmlentities($attribute->Link) ."\" target=\"_blank\">"; 486 } 487 $plan .=$attribute->Ergebnis; 488 if ($attribute->Link) 441 489 { 442 $color="green"; 443 } 444 else 445 { 446 $color="red"; 447 } 448 } 449 if ($color!="black") 450 { 451 $plan .= "<td style='text-align:center; color:".$color ."'>"; 452 } 453 else 454 { 455 $plan .= "<td style='text-align:center;'>"; 456 } 457 458 if ($attribute->Link) 459 { 460 $plan .="<a style=\"text-align: center; color:".$color ."\" href=\"".htmlentities($attribute->Link) ."\" target=\"_blank\">"; 490 $plan .="</a>"; 491 } 492 $plan .= "</td>\n"; 461 493 } 462 $plan .=$attribute->Ergebnis; 463 if ($attribute->Link) 464 { 465 $plan .="</a>"; 466 } 467 $plan .= "</td>\n"; 468 } 469 $plan .= "</tr>\n"; 494 $plan .= "</tr>\n"; 495 } 470 496 } 471 497 $plan .= "</table>\n"; 472 498 $plan .= "<br/>\n"; 473 499 return $plan; 500 } 501 else 502 { 503 return 'Konnte TT-Live-XML nicht laden'; 504 } 505 } 506 507 function getTTLive14TageDataForWidget(&$params){ 508 $debug = 0; 509 /** 510 * XML aus lokalem tmp Folder laden 511 */ 512 $tableclassname = get_option('TTLive_tableclassname_TeamSpielplan'); 513 if ($params['tableclassname'] != '') { $tableclassname = $params['tableclassname']; } 514 515 refreshTTLiveData($params); 516 if($xml = simplexml_load_file($params['filename'], NULL, ($debug==1)?LIBXML_NOERROR:NULL)) 517 { 518 $expiration_date = new DateTime(); 519 $date_interval = new DateInterval('P'.$params['showxdays'].'D'); 520 $date_interval->invert = $params['display_type']; 521 $expiration_date->sub($date_interval); 522 523 $zeile; 524 $plan .= '<dl>'; 525 foreach($xml->Content->Spiel as $key => $attribute) 526 { 527 $zeile++; 528 $dateOld = $attribute->Datum; 529 $time = $attribute->Zeit; 530 if ($time == "00:00") { $time = ""; } 531 $thedate = new Datetime(strftime('%d.%m.%Y', strtotime($attribute->Datum))); 532 $hide = false; 533 if ($params['showxdays'] > 0 ) { 534 if ( $params['display_type'] ) { 535 if ( $thedate > $expiration_date ) { $hide = true; } 536 } else { 537 if ( $thedate < $expiration_date ) { $hide = true; } 538 } 539 } 540 if ($params['max'] > 0 ) { 541 if ( $zeile > $params['max'] ) { $hide = true; } 542 } 543 544 if ( !$hide) { 545 546 $plan .= '<dt>'.$marker.$attribute->Tag.', '.$thedate->format('d.m.Y'); 547 $plan .= " - $time Uhr<br />"; 548 $staffel = explode(", ", $attribute->Staffelname); 549 $search = array("Bezirksklasse", "Beziksliga", "Kreisliga", "Kreisklasse", "Landesliga", "Nord", "Süd", "Ost", "West", "Mitte", "Pokal Herren", "Pokal Damen"); 550 $replace = array("BK", "BL", "KL", "KK", "LL", "N", "S", "O", "W", "M", "Pokal He", "Pokal Da"); 551 $newstaffel = str_replace($search, $replace, $staffel[1]); 552 if ( $newstaffel == $attribute->Staffelname ) { 553 $newstaffel = $attribute->Staffelname; 554 } 555 $plan .= "<em>$attribute->Staffelname</em></dt>\n"; 556 $isHeimteam = false; 557 if ((strstr($attribute->Heimmannschaft, "Herren")) or (strstr($attribute->Heimmannschaft, "Jungen")) or (strstr($attribute->Heimmannschaft, "Schüler")) or (strstr($attribute->Heimmannschaft, "Damen")) or (strstr($attribute->Heimmannschaft, "Senioren"))) 558 { 559 $isHeimteam = true; 560 $plan .= "<dd><em>".$attribute->Heimmannschaft."</em>\n"; 561 } 562 else 563 { 564 $plan .= "<dd>".$attribute->Heimmannschaft."\n"; 565 } 566 $plan .= " - "; 567 if ((strstr($attribute->Gastmannschaft, "Herren")) or (strstr($attribute->Gastmannschaft, "Jungen")) or (strstr($attribute->Gastmannschaft, "Sch�ler")) or (strstr($attribute->Gastmannschaft, "Damen")) or (strstr($attribute->Gastmannschaft, "Senioren"))) 568 { 569 $plan .= "<em>$attribute->Gastmannschaft</em><br />\n"; 570 } 571 else 572 { 573 $plan .= $attribute->Gastmannschaft."<br />\n"; 574 } 575 if ($params['display_type']==0) /*Rueckschau*/ 576 { 577 $array = explode ( ':', $attribute->Ergebnis ); 578 $color="black"; 579 if ((intval($array[0])) > (intval($array[1]))) 580 { 581 if ($isHeimteam) 582 { 583 $color="green"; 584 $plan .= 'Heimsieg: '; 585 } 586 else 587 { 588 $color="red"; 589 $plan .= 'Ergebnis: '; 590 } 591 } 592 if ((intval($array[1])) > (intval($array[0]))) 593 { 594 if (!$isHeimteam) 595 { 596 $color="green"; 597 $plan .= 'Auswärtssieg: '; 598 } 599 else 600 { 601 $color="red"; 602 $plan .= 'Ergebnis: '; 603 } 604 } 605 606 if ($attribute->Link) 607 { 608 $plan .="<a style=\"color:".$color ."\" href=\"".htmlentities($attribute->Link) ."\" target=\"_blank\">"; 609 } 610 $plan .= $attribute->Ergebnis; 611 if ($attribute->Link) 612 { 613 $plan .="</a>"; 614 } 615 //$plan .= "</dd>\n"; 616 } 617 $plan .= "</dd>\n"; 618 } 619 } 620 $plan .= "</dl>\n"; 621 if ( $zeile ) { return $plan; } else { return false; } 474 622 } 475 623 else … … 673 821 register_deactivation_hook( __FILE__, 'TTLive_remove' ); 674 822 823 /** 824 * Adds TTLive_Widget widget. 825 */ 826 class TTLive_Widget extends WP_Widget { 827 828 /** 829 * Register widget with WordPress. 830 */ 831 public function __construct() { 832 parent::__construct( 833 'ttlive_widget', // Base ID 834 'TTLive_Widget', // Name 835 array( 'description' => __( 'TTLive Widget', 'text_domain' ), ) // Args 836 ); 837 } 838 839 /** 840 * Front-end display of widget. 841 * 842 * @see WP_Widget::widget() 843 * 844 * @param array $args Widget arguments. 845 * @param array $instance Saved values from database. 846 */ 847 public function widget( $args, $instance ) { 848 extract( $args ); 849 $title = apply_filters( 'widget_title', $instance['title'] ); 850 $maxnumber = apply_filters( 'widget_title', $instance['maxnumber'] ); 851 $showxdays = apply_filters( 'widget_title', $instance['showxdays'] ); 852 $title_results = apply_filters( 'widget_title', $instance['title_results'] ); 853 $title_preview = apply_filters( 'widget_title', $instance['title_preview'] ); 854 855 echo $before_widget; 856 if ( ! empty( $title ) ) { 857 echo $before_title . $title . $after_title; 858 } 859 $header .= "<em>$title_results</em>"; 860 $arr = array("elementname" => "14Tage", "display_type" => "0", "widget" => "1", "showxdays" => $showxdays, "max" => $maxnumber); 861 if ( empty($maxnumber) ) unset($arr["max"]); 862 if ( empty($showxdays) ) unset($arr["showxdays"]); 863 $tmp = ttlive_func($arr,null); 864 echo $header.$tmp; 865 $arr["display_type"] = "1"; 866 echo "<em>$title_preview</em>"; 867 echo ttlive_func($arr,null); 868 echo $after_widget; 869 } 870 871 /** 872 * Sanitize widget form values as they are saved. 873 * 874 * @see WP_Widget::update() 875 * 876 * @param array $new_instance Values just sent to be saved. 877 * @param array $old_instance Previously saved values from database. 878 * 879 * @return array Updated safe values to be saved. 880 */ 881 public function update( $new_instance, $old_instance ) { 882 $instance = array(); 883 $instance['title'] = strip_tags( $new_instance['title'] ); 884 $instance['title_results'] = strip_tags( $new_instance['title_results'] ); 885 $instance['title_preview'] = strip_tags( $new_instance['title_preview'] ); 886 $instance['showxdays'] = strip_tags( $new_instance['showxdays'] ); 887 $instance['maxnumber'] = strip_tags( $new_instance['maxnumber'] ); 888 889 return $instance; 890 } 891 892 /** 893 * Back-end widget form. 894 * 895 * @see WP_Widget::form() 896 * 897 * @param array $instance Previously saved values from database. 898 */ 899 public function form( $instance ) { 900 if ( isset( $instance[ 'title' ] ) ) { 901 $title = $instance[ 'title' ]; 902 } 903 else { 904 $title = __( 'Neuer Titel', 'text_domain' ); 905 } 906 if ( isset( $instance[ 'title_results' ] ) ) { 907 $title_results = $instance[ 'title_results' ]; 908 } 909 else { 910 $title_results = __( 'Ergebnisse', 'text_domain' ); 911 } 912 if ( isset( $instance[ 'title_preview' ] ) ) { 913 $title_preview = $instance[ 'title_preview' ]; 914 } 915 else { 916 $title_preview = __( 'Vorschau', 'text_domain' ); 917 } 918 if ( isset( $instance[ 'showxdays' ] ) ) { 919 $showxdays = $instance[ 'showxdays' ]; 920 } 921 else { 922 $showxdays = __( '', 'text_domain' ); 923 } 924 if ( isset( $instance[ 'maxnumber' ] ) ) { 925 $maxnumber = $instance[ 'maxnumber' ]; 926 } 927 else { 928 $maxnumber = __( '', 'text_domain' ); 929 } 930 ?> 931 <p> 932 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Titel:' ); ?></label> 933 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 934 </p> 935 <label for="<?php echo $this->get_field_id( 'title_results' ); ?>"><?php _e( 'Titel Ergebnisse:' ); ?></label> 936 <input class="widefat" id="<?php echo $this->get_field_id( 'title_results' ); ?>" name="<?php echo $this->get_field_name( 'title_results' ); ?>" type="text" value="<?php echo esc_attr( $title_results ); ?>" /> 937 </p> 938 <label for="<?php echo $this->get_field_id( 'title_preview' ); ?>"><?php _e( 'Title Vorschau:' ); ?></label> 939 <input class="widefat" id="<?php echo $this->get_field_id( 'title_preview' ); ?>" name="<?php echo $this->get_field_name( 'title_preview' ); ?>" type="text" value="<?php echo esc_attr( $title_preview ); ?>" /> 940 </p> 941 <p> 942 <label for="<?php echo $this->get_field_id( 'showxdays' ); ?>"><?php _e( 'Anzahl der Tage:' ); ?></label> 943 <input class="widefat" id="<?php echo $this->get_field_id( 'showxdays' ); ?>" name="<?php echo $this->get_field_name( 'showxdays' ); ?>" type="text" value="<?php echo esc_attr( $showxdays ); ?>" /> 944 </p> 945 <p> 946 <label for="<?php echo $this->get_field_id( 'maxnumber' ); ?>"><?php _e( 'Max. Spiele:' ); ?></label> 947 <input class="widefat" id="<?php echo $this->get_field_id( 'maxnumber' ); ?>" name="<?php echo $this->get_field_name( 'maxnumber' ); ?>" type="text" value="<?php echo esc_attr( $maxnumber ); ?>" /> 948 </p> 949 <?php 950 } 951 952 } // class Foo_Widget 953 // register Foo_Widget widget 954 add_action( 'widgets_init', create_function( '', 'register_widget( "ttlive_widget" );' ) ); 955 675 956 add_shortcode( 'ttlive', 'TTLive_func' ); 676 957 ?> -
ttlive/trunk/readme.txt
r620684 r690020 4 4 Tags: 5 5 Requires at least: 3.0.1 6 Tested up to: 3. 4.17 Stable tag: 0. 76 Tested up to: 3.5.1 7 Stable tag: 0.8 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 13 13 == Description == 14 14 15 A simple wordpress plugin to get the data from the ttlive-system and display in your wp-post or wp-page with shortcode. 15 A simple wordpress plugin to get the data from the ttlive-system and display in your wp-post or wp-page with shortcode. You can also use a widget to show the match-results and preview in a sidebar. 16 16 17 17 Tischtennislive is a german online sport result system (http://www.tischtennislive.de). TTLive-Plugin help you, to show current team results on your WP-Page or WP-Posts. … … 36 36 `own_team` - Name des eigenen Teams 37 37 `runde` - Vorrunde = [ttlive runde=1] (default), Rückrunde = [ttlive runde=2] 38 `showxdays` - 14Tage: Anzahl der Tage die dargestellt werden sollen (default = 14) 39 `max` - 14Tage: Anzahl der Tage die maximal dargestellt werden sollen (default = 0) 40 `widget` - 14Tage: Für die Darstellung in einem Widget - default = 0 --> legt man den Schalter auf 1, wird eine Darstellung optimiert für ein Sidebar-Widget verwendet 38 41 `teamalias` - Nur für die Tabelle: "Teamname:Alias;Teamname2:Alias2;..." 39 42 `showleague` - Nur für die Tabelle: Ueberschrift-Anzeige der Liga (default: 1) … … 77 80 == Changelog == 78 81 82 = 0.8 = 83 * added new parameter showxdays --> 14Tage: Anzahl der Tage die dargestell werden sollen (default = 14) 84 * added new parameter max --> 14Tage: Anzahl der Tage die maximal dargestellt werden sollen (default = 0) 85 * added TTLive_Widget --> you can use the widget to show the 14Tage-View in a sidebar 86 79 87 = 0.7 = 80 88 * bugfix: classes even and odd - to show tablerows in different colors
Note: See TracChangeset
for help on using the changeset viewer.