Skip to content

Commit

Permalink
Merge pull request #2 from atlan79/1.4-panel-widget-revision
Browse files Browse the repository at this point in the history
1.4 panel widget revision
  • Loading branch information
atlan79 committed Feb 11, 2014
2 parents e63945c + 58ed3da commit 9929bde
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 174 deletions.
67 changes: 21 additions & 46 deletions bvn-satellite-panel.php
Expand Up @@ -6,7 +6,7 @@
*
* @author Thomas Winter
* @license https://github.com/atlan79/bvn-satellite/blob/master/LICENSE.md MIT
* @version 1.2
* @version 1.4
*/
/*
* Functions start here
Expand Down Expand Up @@ -127,6 +127,23 @@ function bvn_satellite_option_page() {
$api_club = get_option('bvn_satellite_api_club');

?>

<style type="text/css" media="screen">
.bvn-satellite-log th {
font-weight: bold;
}
.bvn-satellite-log td, .bvn-satellite-log th {
padding: 1px 5px 1px 5px;
}
td.bvn-satellite-url {
font-family: "Courier New", Courier, monospace;
vertical-align: top;
}
td.bvn-satellite-max {
width: 100%;
}
</style>

<div class="wrap">
<h2><?php echo __('BVN Satellite Settings','bvn-satellite-panel'); ?></h2>
<h3><?php echo __('Dropdown Options Selection','bvn-satellite-panel'); ?></h3>
Expand Down Expand Up @@ -163,21 +180,7 @@ function bvn_satellite_option_page() {
<input name="submit" value="<?php echo __('Clear Clubs','bvn-satellite-panel'); ?>" type="submit" />
</p>
</form>
<style type="text/css" media="screen">
.bvn-satellite-log th {
font-weight: bold;
}
.bvn-satellite-log td, .bvn-satellite-log-log th {
padding: 1px 5px 1px 5px;
}
td.bvn-satellite-url {
font-family: "Courier New", Courier, monospace;
vertical-align: top;
}
td.bvn-satellite-right {
width: 50%;
}
</style>

<div class="bvn-satellite-log">
<table class="form-table ">
<?php bvn_satellite_show_list($arClubOptionsList); ?>
Expand All @@ -200,21 +203,7 @@ function bvn_satellite_option_page() {
<input name="submit" value="<?php echo __('Clear Leagues','bvn-satellite-panel'); ?>" type="submit" />
</p>
</form>
<style type="text/css" media="screen">
.bvn-satellite-log th {
font-weight: bold;
}
.bvn-satellite-log td, .bvn-satellite-log th {
padding: 1px 5px 1px 5px;
}
td.bvn-satellite-url {
font-family: "Courier New", Courier, monospace;
vertical-align: top;
}
td.bvn-satellite-max {
width: 100%;
}
</style>

<div class="bvn-satellite-log">
<table class="form-table">
<?php bvn_satellite_show_list($arLigaOptionsList); ?>
Expand All @@ -237,21 +226,7 @@ function bvn_satellite_option_page() {
<input name="submit" value="<?php echo __('Clear Teams','bvn-satellite-panel'); ?>" type="submit" />
</p>
</form>
<style type="text/css" media="screen">
.bvn-satellite-log th {
font-weight: bold;
}
.bvn-satellite-log td, .bvn-satellite-log th {
padding: 1px 5px 1px 5px;
}
td.bvn-satellite-url {
font-family: "Courier New", Courier, monospace;
vertical-align: top;
}
td.bvn-satellite-max {
width: 100%;
}
</style>

<div class="bvn-satellite-log">
<table class="form-table">
<?php bvn_satellite_show_list($arTeamOptionsList); ?>
Expand Down
201 changes: 78 additions & 123 deletions bvn-satellite.php
Expand Up @@ -3,7 +3,7 @@
Plugin Name: BVN Satellite
Plugin URI: http://www.bvn.ch
Description: Reads Data from the BVN.ch API and displays them in a WordPress Widget
Version: 1.3
Version: 1.4
Author: Thomas Winter
Author URI: http://www.houseofwinter.ch
@license https://github.com/atlan79/bvn-satellite/blob/master/LICENSE.md MIT
Expand Down Expand Up @@ -49,6 +49,7 @@ public function widget( $args, $instance ) {
$api_limit = apply_filters( 'widget_api_limit', $instance['api_limit'] );
$api_league_id = apply_filters( 'widget_api_league_id', $instance['api_league_id'] );
$api_highlight = apply_filters( 'widget_api_highlight', $instance['api_highlight'] );
$api_title = apply_filters( 'widget_api_title', $instance['api_title'] );

switch ($api_realm) {
case 'liga':
Expand All @@ -64,6 +65,9 @@ public function widget( $args, $instance ) {

echo $before_widget; // pre-widget code from theme

echo '<div>'."\n";
echo ' <div class="widget-title">' . $api_title . '</div>'."\n";

if( !empty($api_model) ) {

if($api_model == "ranking") {
Expand All @@ -82,8 +86,9 @@ public function widget( $args, $instance ) {
//print_r($objGames);
}
} else {
echo __( 'API Path not specified', 'text_domain' );
echo __( 'API Model not specified', 'text_domain' );
}
echo '</div>'."\n";

echo $after_widget; // post-widget code from theme
}
Expand All @@ -105,52 +110,18 @@ public function form( $instance ) {
'api_view' => '',
'api_limit' => '',
'api_league_id' => '',
'api_highlight' => '') );
if ( isset( $instance[ 'api_model' ] ) ) {
$api_model = $instance[ 'api_model' ];
} else {
$api_model = __( 'New api_model', 'text_domain' );
}
if ( isset( $instance[ 'api_realm' ] ) ) {
$api_realm = $instance[ 'api_realm' ];
} else {
$api_realm = __( 'New api_realm', 'text_domain' );
}
if ( isset( $instance[ 'api_liga' ] ) ) {
$api_liga = $instance[ 'api_liga' ];
} else {
$api_liga = __( 'Liga', 'text_domain' );
}
if ( isset( $instance[ 'api_club' ] ) ) {
$api_club = $instance[ 'api_club' ];
} else {
$api_club = __( 'Club', 'text_domain' );
}
if ( isset( $instance[ 'api_team' ] ) ) {
$api_team = $instance[ 'api_team' ];
} else {
$api_team = __( 'Team', 'text_domain' );
}
if ( isset( $instance[ 'api_view' ] ) ) {
$api_view = $instance[ 'api_view' ];
} else {
$api_view = __( 'New api_view', 'text_domain' );
}
if ( isset( $instance[ 'api_limit' ] ) ) {
$api_limit = $instance[ 'api_limit' ];
} else {
$api_limit = __( 'New api_limit', 'text_domain' );
}
if ( isset( $instance[ 'api_league_id' ] ) ) {
$api_league_id = $instance[ 'api_league_id' ];
} else {
$api_league_id = __( 'New league_id', 'text_domain' );
}
if ( isset( $instance[ 'api_highlight' ] ) ) {
$api_highlight = $instance[ 'api_highlight' ];
} else {
$api_highlight = __( 'New highlight', 'text_domain' );
}
'api_highlight' => '',
'api_title') );
if ( isset( $instance[ 'api_model' ] ) ) { $api_model = $instance[ 'api_model' ]; } else { $api_model = __( 'New api_model', 'text_domain' ); }
if ( isset( $instance[ 'api_realm' ] ) ) { $api_realm = $instance[ 'api_realm' ]; } else { $api_realm = __( 'New api_realm', 'text_domain' ); }
if ( isset( $instance[ 'api_liga' ] ) ) { $api_liga = $instance[ 'api_liga' ]; } else { $api_liga = __( 'Liga', 'text_domain' ); }
if ( isset( $instance[ 'api_club' ] ) ) { $api_club = $instance[ 'api_club' ]; } else { $api_club = __( 'Club', 'text_domain' ); }
if ( isset( $instance[ 'api_team' ] ) ) { $api_team = $instance[ 'api_team' ]; } else { $api_team = __( 'Team', 'text_domain' ); }
if ( isset( $instance[ 'api_view' ] ) ) { $api_view = $instance[ 'api_view' ]; } else { $api_view = __( 'New api_view', 'text_domain' ); }
if ( isset( $instance[ 'api_limit' ] ) ) { $api_limit = $instance[ 'api_limit' ]; } else { $api_limit = __( 'New api_limit', 'text_domain' ); }
if ( isset( $instance[ 'api_league_id' ] ) ) { $api_league_id = $instance[ 'api_league_id' ]; } else { $api_league_id = __( 'New league_id', 'text_domain' ); }
if ( isset( $instance[ 'api_highlight' ] ) ) { $api_highlight = $instance[ 'api_highlight' ]; } else { $api_highlight = __( 'New highlight', 'text_domain' ); }
if ( isset( $instance[ 'api_title' ] ) ) { $api_title = $instance[ 'api_title' ]; } else { $api_title = __( 'New title', 'text_domain' ); }

//$objAPIListRealm = $this->bvnch->getRealmList();
$arRealmOptionsList = array ("liga","club","team");
Expand Down Expand Up @@ -195,91 +166,73 @@ public function form( $instance ) {
}

?>

<p>
<label for="<?php echo $this->get_field_id( 'api_model' ); ?>" style="width:30%"><?php _e( 'API Model:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_model' ); ?>" name="<?php echo $this->get_field_name( 'api_model' ); ?>" class="widefat" style="width:100%;"
onchange='api_toggle2(<?php echo $this->get_field_id( 'api_model' ); ?>, <?php echo $this->get_field_id( 'api_realm' ); ?>, <?php echo $this->get_field_id( 'api_league_id' ); ?>)'>
<option value="matches" <?php if ( 'matches' == esc_attr( $instance['api_model'] ) ) echo 'selected="selected"'; ?>>Matches</option>
<option value="ranking" <?php if ( 'ranking' == esc_attr( $instance['api_model'] ) ) echo 'selected="selected"'; ?>>Ranking</option>
</select><br />

<label for="<?php echo $this->get_field_id( 'api_realm' ); ?>" style="display: block"><?php _e( 'Games Realm:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_realm' ); ?>" name="<?php echo $this->get_field_name( 'api_realm' ); ?>" class="widefat" style="width:100%;">
<option <?php if ( '' == esc_attr( $instance['api_realm'] ) ) echo 'selected="selected"'; ?>>- select realm -</option>
<?php foreach ($arRealmOptionsList as $realm) { ?>
<option value="<?= $realm ?>" <?php if ( $realm == esc_attr( $instance['api_realm'] ) ) echo 'selected="selected"'; ?>><?= $realm ?></option>
<label for="<?php echo $this->get_field_id( 'api_title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'api_title' ); ?>" name="<?php echo $this->get_field_name( 'api_title' ); ?>" type="text" value="<?php echo esc_attr( $api_title ); ?>" class="widefat" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'api_model' ); ?>" style="width:30%"><?php _e( 'API Model:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_model' ); ?>" name="<?php echo $this->get_field_name( 'api_model' ); ?>" class="widefat">
<option value="matches" <?php selected( $instance['api_model'], 'matches' ); ?>><?php _e('Spiele'); ?></option>
<option value="ranking" <?php selected( $instance['api_model'], 'ranking' ); ?>><?php _e('Rangliste'); ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('api_realm'); ?>"><?php _e( 'Select Games Realm:' ); ?></label>
<select id="<?php echo $this->get_field_id('api_realm'); ?>" name="<?php echo $this->get_field_name('api_realm'); ?>" class="widefat">
<option value=""><?php _e('- select realm -', 'text_domain'); ?></option>
<?php foreach ( $arRealmOptionsList as $realm ) { ?>
<option value="<?= $realm ?>" <?php selected( $instance['api_realm'], $realm ); ?>><?= $realm ?></option>
<?php } ?>
</select><br />
</select><br />

<label for="<?php echo $this->get_field_id( 'api_club' ); ?>" style="display: block"><?php _e( 'Club Games:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_club' ); ?>" name="<?php echo $this->get_field_name( 'api_club' ); ?>" class="widefat" style="width:100%;">
<option value="" <?php if ( '' == esc_attr( $instance['api_club'] ) ) echo 'selected="selected"'; ?>>- select Club -</option>
<?php foreach ($arApiClubList as $value => $option) { ?>
<option value="<?= $value ?>" <?php if ( $value == esc_attr( $instance['api_club'] ) ) echo 'selected="selected"'; ?>><?= $option ?></option>
<label for="<?php echo $this->get_field_id( 'api_club' ); ?>"><?php _e( 'Select Club:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_club' ); ?>" name="<?php echo $this->get_field_name( 'api_club' ); ?>" class="widefat">
<option value=""><?php _e('- select club -', 'text_domain'); ?></option>
<?php foreach ($arApiClubList as $value => $option) { ?>
<option value="<?= $value ?>" <?php selected( $instance['api_club'], $value ); ?>><?= $option ?></option>
<?php } ?>
</select><br />
</select><br />

<label for="<?php echo $this->get_field_id( 'api_liga' ); ?>" style="display: block"><?php _e( 'Liga Games:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_liga' ); ?>" name="<?php echo $this->get_field_name( 'api_liga' ); ?>" class="widefat" style="width:100%;">
<option value="" <?php if ( '' == esc_attr( $instance['api_liga'] ) ) echo 'selected="selected"'; ?>>- select Liga -</option>
<?php foreach ($arApiLigaList as $value => $option) { ?>
<option value="<?= $value ?>" <?php if ( $value == esc_attr( $instance['api_liga'] ) ) echo 'selected="selected"'; ?>><?= $option ?></option>
<label for="<?php echo $this->get_field_id( 'api_liga' ); ?>"><?php _e( 'Select League:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_liga' ); ?>" name="<?php echo $this->get_field_name( 'api_liga' ); ?>" class="widefat">
<option value=""><?php _e('- select league -', 'text_domain'); ?></option>
<?php foreach ($arApiLigaList as $value => $option) { ?>
<option value="<?= $value ?>" <?php selected( $instance['api_liga'], $value ); ?>><?= $option ?></option>
<?php } ?>
</select><br />
</select><br />

<label for="<?php echo $this->get_field_id( 'api_team' ); ?>" style="display: block"><?php _e( 'Team Games:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_team' ); ?>" name="<?php echo $this->get_field_name( 'api_team' ); ?>" class="widefat" style="width:100%;">
<option value="" <?php if ( '' == esc_attr( $instance['api_team'] ) ) echo 'selected="selected"'; ?>>- select Team -</option>
<label for="<?php echo $this->get_field_id( 'api_team' ); ?>"><?php _e( 'Select Team:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_team' ); ?>" name="<?php echo $this->get_field_name( 'api_team' ); ?>" class="widefat">
<option value=""><?php _e('- select team -', 'text_domain'); ?></option>
<?php foreach ($arApiTeamList as $value => $option) { ?>
<option value="<?= $value ?>" <?php if ( $value == esc_attr( $instance['api_team'] ) ) echo 'selected="selected"'; ?>><?= $option ?></option>
<option value="<?= $value ?>" <?php selected( $instance['api_team'], $value ); ?>><?= $option ?></option>
<?php } ?>
</select><br />

<label for="<?php echo $this->get_field_id( 'api_view' ); ?>" style="display: block"><?php _e( 'API View:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'api_view' ); ?>" name="<?php echo $this->get_field_name( 'api_view' ); ?>" type="text" value="<?php echo esc_attr( $api_view ); ?>" style="width:100%;" /><br />

<label for="<?php echo $this->get_field_id( 'api_limit' ); ?>" style="display: block"><?php _e( 'API Limit:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'api_limit' ); ?>" name="<?php echo $this->get_field_name( 'api_limit' ); ?>" type="text" value="<?php echo esc_attr( $api_limit ); ?>" style="width:100%;" /><br />

<label for="<?php echo $this->get_field_id( 'api_league_id' ); ?>" style="display: block"><?php _e( 'Liga Ranking:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_league_id' ); ?>" name="<?php echo $this->get_field_name( 'api_league_id' ); ?>" class="widefat" style="width:100%;">
<option value="" <?php if ( '' == esc_attr( $instance['api_league_id'] ) ) echo 'selected="selected"'; ?>>- select Liga -</option>
</select><br />

<label for="<?php echo $this->get_field_id('api_view'); ?>"><?php _e( 'View:' ); ?></label>
<select name="<?php echo $this->get_field_name('api_view'); ?>" id="<?php echo $this->get_field_id('api_view'); ?>" class="widefat">
<option value="all"<?php selected( $instance['api_view'], 'all' ); ?>><?php _e( 'Normal View' ); ?></option>
<option value="last"<?php selected( $instance['api_view'], 'last' ); ?>><?php _e( 'Last Games' ); ?></option>
<option value="next"<?php selected( $instance['api_view'], 'next' ); ?>><?php _e( 'Next Games' ); ?></option>
</select>
<label for="<?php echo $this->get_field_id('api_limit'); ?>"><?php _e( 'Number of games to show:' ); ?></label>
<input id="<?php echo $this->get_field_id('api_limit'); ?>" name="<?php echo $this->get_field_name('api_limit'); ?>" type="text" value="<?php echo $api_limit == -1 ? '' : intval( $api_limit ); ?>" size="3" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'api_league_id' ); ?>"><?php _e( 'Select League Ranking:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'api_league_id' ); ?>" name="<?php echo $this->get_field_name( 'api_league_id' ); ?>" class="widefat">
<option value=""><?php _e('- select league -', 'text_domain'); ?></option>
<?php foreach ($arApiLigaList as $value => $option) { ?>
<option value="<?= $value ?>" <?php if ( $value == esc_attr( $instance['api_league_id'] ) ) echo 'selected="selected"'; ?>><?= $option ?></option>
<option value="<?= $value ?>" <?php selected( $instance['api_liga'], $value ); ?>><?= $option ?></option>
<?php } ?>
</select><br />

<label for="<?php echo $this->get_field_id( 'api_highlight' ); ?>"><?php _e( 'Highlight:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'api_highlight' ); ?>" name="<?php echo $this->get_field_name( 'api_highlight' ); ?>" type="text" value="<?php echo esc_attr( $api_highlight ); ?>" style="width:100%;" /><br />
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'api_highlight' ); ?>"><?php _e( 'Highlight:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'api_highlight' ); ?>" name="<?php echo $this->get_field_name( 'api_highlight' ); ?>" type="text" value="<?php echo esc_attr( $api_highlight ); ?>" class="widefat" />
</p>
<script type="text/javascript">
function api_toggle2(control, opt1, opt2) {
if (document.getElementById(control).value == 'matches') {
document.getElementById(opt1).style.display = 'block';
document.getElementById(opt2).style.display = 'none';
} else {
document.getElementById(opt1).style.display = 'none';
document.getElementById(opt2).style.display = 'block';
}
}
function api_toggle3(control, opt1, opt2, opt3) {
if (document.getElementById(control).value == 'liga') {
document.getElementById(opt1).style.display = 'block';
document.getElementById(opt2).style.display = 'none';
document.getElementById(opt3).style.display = 'none';
} else {
if (document.getElementById(control).value == 'club') {
document.getElementById(opt1).style.display = 'none';
document.getElementById(opt2).style.display = 'block';
document.getElementById(opt3).style.display = 'none';
} else {
document.getElementById(opt1).style.display = 'none';
document.getElementById(opt2).style.display = 'none';
document.getElementById(opt3).style.display = 'block';
}
}
}
</script>
<?php
}

Expand All @@ -302,8 +255,9 @@ public function update( $new_instance, $old_instance ) {
'api_team' => '',
'api_view' => '',
'api_limit' => '',
'api_league_id' => '',
'api_highlight' => '') );
'api_league_id' => '',
'api_highlight' => '',
'api_title' => '') );
$instance['api_model'] = strip_tags($new_instance['api_model']);
$instance['api_realm'] = strip_tags($new_instance['api_realm']);
$instance['api_liga'] = strip_tags($new_instance['api_liga']);
Expand All @@ -313,6 +267,7 @@ public function update( $new_instance, $old_instance ) {
$instance['api_limit'] = strip_tags($new_instance['api_limit']);
$instance['api_league_id'] = strip_tags($new_instance['api_league_id']);
$instance['api_highlight'] = strip_tags($new_instance['api_highlight']);
$instance['api_title'] = strip_tags($new_instance['api_title']);

return $instance;
}
Expand Down

0 comments on commit 9929bde

Please sign in to comment.