'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']) ; $kind = attribute_escape($instance['appKind']) ; $Country = attribute_escape($instance['Country']) ; echo $before_widget .$before_title . $wtitle . $after_title; $language = get_option("AppStore_language"); $doc = new DOMDocument(); $feed = "http://itunes.apple.com/".$Country."/rss/".$kind."/limit=".$topCount."/xml"; $feedUpdateIntervall = $instance['feedUpdateIntervall']; if ($feedUpdateIntervall == "") { $feedUpdateIntervall = 60*60*60; } else { $feedUpdateIntervall = $feedUpdateIntervall*60*60; } if ((time() - $feedUpdateIntervall) < $instance['feedUpdateTime']) { $doc = $instance['feedCache']; } else { //$doc->load($feed); @$doc->loadXML(get_remote_file($feed)); $instance['feedCache'] = $doc; $instance['feedUpdateTime'] = time(); } $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'] = ''; $instance['appKind'] = strip_tags($new_instance['appKind']); return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'freePaid' => '', 'topCount' => '', 'Country' => '', 'feedCache' => '', 'feedUpdateTime' => '', 'feedUpdateIntervall' => '', 'appKind' => '' ) ); $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']) ; $appKind= attribute_escape($instance['appKind']) ; if ($freePaid == "free" ) { $checked = "checked" ; } else { $checked = "" ; } if ($topCount == "" ) { $topCount = "10" ; } if ($title == "" ) { $title = "Top Apps" ; } if ($Country == "" ) { $Country = "AT" ; } if ($feedUpdateIntervall == "" ) { $feedUpdateIntervall = "60" ; } if ($appKind == "" ) { $appKind = "topfreeapplications"; } $Countries = getCountries(); $appKinds = array( "topfreeapplications" => __("iPhone kostenlos","appstore"), "toppaidapplications" => __("iPhone kostenpflichtig","appstore"), "topgrossingapplications" => __("iPhone umsatzstark","appstore"), "topfreeipadapplications" => __("iPad kostenlos","appstore"), "toppaidipadapplications" => __("iPad kostenpflichtig","appstore"), "topgrossingipadapplications" => __("iPad umsatzstark","appstore"), "newapplications" => __("neue Apps","appstore"), "newfreeapplications" => __("neue kostenlose Apps","appstore"), "newpaidapplications" => __("neue kostenpflichtige Apps","appstore"), "topmacapps" => __("Mac alle","appstore"), "topfreemacapps" => __("Mac kostenlos","appstore"), "topgrossingmacapps" => __("Mac Umsatzstark","appstore"), "toppaidmacapps" => __("Mac kostenpflichtig","appstore") ); asort($appKinds); ?>