'widget_AppStore_Widget', 'description' => 'Zeigt die Top 10 der AppStore Charts' ); $this->WP_Widget('AppStore_Widget', 'Appstore', $widget_ops); if ( is_active_widget(false, false, $this->id_base) ) add_action( 'wp_head', array(&$this, 'recent_widget_style') ); } function recent_widget_style() { // echo ''; } function widget($args, $instance) { extract($args, EXTR_SKIP); $wtitle = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Top 10 Apps' ) : $instance['title']); //$freePaid = apply_filters('widget_title', empty( $instance['freePaid'] ) ? __( 'free' ) : $instance['freePaid']); $topCount = apply_filters('widget_title', empty( $instance['topCount'] ) ? __( '10' ) : $instance['topCount']); $freePaid = attribute_escape($instance['freePaid']) ; $Country = attribute_escape($instance['Country']) ; echo $before_widget .$before_title . $wtitle . $after_title; $language = get_option("AppStore_language"); $doc = new DOMDocument(); if ($freePaid == "free") { $feed = RSS_TOPFREE.$Country."/lang=".$language."/limit=".$topCount."/xml"; } else { $feed = RSS_TOPPAID.$Country."/lang=".$language."/limit=".$topCount."/xml"; } $feedUpdateIntervall = $instance['feedUpdateIntervall']; if ($feedUpdateIntervall == "") { $feedUpdateIntervall = 60*60*60; } else { $feedUpdateIntervall = $feedUpdateIntervall*60*60; } echo $instance['feedUpdateTime'].'
'; if ((time() - $feedUpdateIntervall) < $instance['feedUpdateTime']) { //echo "Cache
"; $doc = $instance['feedCache']; } else { //echo'Load
'; $doc->load($feed); $instance['feedCache'] = $doc; $instance['feedUpdateTime'] = time(); } //echo $instance['feedUpdateTime'].'
'; $appList = '"; echo $appList; echo $after_widget; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['freePaid'] = strip_tags($new_instance['freePaid']); $instance['topCount'] = strip_tags($new_instance['topCount']); $instance['Country'] = strip_tags($new_instance['Country']); $instance['feedUpdateIntervall'] = strip_tags($new_instance['feedUpdateIntervall']); $instance['feedCache'] = ''; $instance['feedUpdateTime'] = ''; return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'freePaid' => '', 'topCount' => '', 'Country' => '', 'feedCache' => '', 'feedUpdateTime' => '', 'feedUpdateIntervall' => '' ) ); $title = attribute_escape($instance['title']); $freePaid = attribute_escape($instance['freePaid']) ; $topCount = attribute_escape($instance['topCount']) ; $Country = attribute_escape($instance['Country']) ; $feedCache = attribute_escape($instance['feedCache']) ; $feedUpdateTime = attribute_escape($instance['feedUpdateTime']) ; $feedUpdateIntervall= attribute_escape($instance['feedUpdateIntervall']) ; if ($freePaid == "free" ) { $checked = "checked" ; } else { $checked = "" ; } if ($topCount == "" ) { $topCount = "10" ; } if ($title == "" ) { $title = "Top Apps" ; } if ($Country == "" ) { $Country = "143445" ; } if ($feedUpdateIntervall == "" ) { $feedUpdateIntervall = "60" ; } $Countries = array( 143441 => "United States", 143442 => "France", 143443 => "Germany", 143444 => "United Kingdom", 143445 => "Austria", 143446 => "Belgium", 143447 => "Finland", 143448 => "Greece", 143449 => "Ireland", 143450 => "Italy", 143451 => "Luxembourg", 143452 => "Netherlands", 143453 => "Portugal", 143454 => "Spain", 143455 => "Canada", 143456 => "Sweden", 143457 => "Norway", 143458 => "Denmark", 143459 => "Switzerland", 143460 => "Australia", 143461 => "New Zealand", 143462 => "Japan" ); asort($Countries); ?>