WordPress.org

Plugin Directory

Changeset 220354


Ignore:
Timestamp:
03/21/10 15:35:30 (4 years ago)
Author:
stefsoton
Message:

upload version 0.9 non-standard chars bug fixed

Location:
google-news-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • google-news-widget/trunk/google-news-widget.php

    r220203 r220354  
    44 * Plugin URI: http://www.stefaniamarchisio.com/goggle-news-widget-shortcode-plugin/ 
    55 * Description: A customizable list of Google News given language/country, (searchkey(s) or topic) and the number of displayable news. It works as both widget and shortcode. 
    6  * Version: 0.7 
     6 * Version: 0.9 
    77 * Author: Stefania Marchisio 
    88 * Author URI: http://stefaniamarchisio.com/about/ 
     
    6363    function WP_gNews() { 
    6464        /* Widget settings. */ 
    65         $widget_ops = array( 'classname' => 'googlenews', 'description' => __('A customizable list of Google News given language/country, (searchkey(s) or topic) and the number of displayable news. Also available as shortcode.', 'googlenews') ); 
     65        $widget_ops = array( 'classname' => 'googlenews', 'description' => __('A customizable list of Google News given language/country, (searchkey(s) or topic) and the number of displayable news. It works as both widget and shortcode.', 'googlenews') ); 
    6666 
    6767        /* Widget control settings. */ 
     
    9898        echo $before_widget; 
    9999 
    100         /* Define the feed according to params entered */ 
    101     $feed = "http://news.google.com/news?cf=all&ned=" . $location. "&output=rss"; 
    102         if ( $geo ) { $feed .= "&geo=$geo"; } 
    103     if ( $name ) { $feed .= "&q=$name"; } 
    104     if ( $topic ) { $feed .= "&topic=$topic"; } 
    105  
    106     /* Display the widget title if one was input (before and after defined by themes). */ 
    107     if ( $title ) { 
    108            if ( $lkbtitle ) $title = "<a target='" . $target . "' href='$feed' title='$title'>$title</a>"; 
    109           echo $before_title . $title . $after_title; 
    110         } 
     100        /* Display the widget title if one was input (before and after defined by themes). */ 
     101        if ( $title ) { 
     102       if ( $lkbtitle ) $title = "<a target='" . $target . "' href='$feed' title='$title'>$title</a>"; 
     103       echo $before_title . $title . $after_title; 
     104    } 
     105        /* Define the feed according to params entered */ 
     106        $feed = "http://news.google.com/news?cf=all&ned=" . $location. "&output=rss"; 
     107    if ( $geo ) { $feed .= "&geo=$geo"; } 
     108        if ( $name ) { $feed .= "&q=$name"; } 
     109        if ( $topic ) { $feed .= "&topic=$topic"; } 
    111110 
    112111    echo gnw_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     
    161160        <p> 
    162161            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Widget Title:', 'googlenews'); ?></label> 
    163             <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:95%;" /> 
     162            <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" /> 
    164163        </p> 
    165164 
    166165    <!-- Link Title to Feed? Checkbox --> 
    167166    <p> 
    168     <label for="<?php echo $this->get_field_id( 'lkbtitle' ); ?>"><?php _e('Link Widget Title to Feed URL?', 'googlenews'); ?></label> 
    169     <input class="checkbox" type="checkbox" <?php checked( $instance['lkbtitle'], 'on' ); ?> id="<?php echo $this->get_field_id( 'lkbtitle' ); ?>" name="<?php echo $this->get_field_name( 'lkbtitle' ); ?>" />  
     167        <label for="<?php echo $this->get_field_id( 'lkbtitle' ); ?>"><?php _e('Link Widget Title to Feed URL?', 'googlenews'); ?></label> 
     168        <input class="checkbox" type="checkbox" <?php checked( $instance['lkbtitle'], 'on' ); ?> id="<?php echo $this->get_field_id( 'lkbtitle' ); ?>" name="<?php echo $this->get_field_name( 'lkbtitle' ); ?>" />  
    170169    </p> 
    171170 
    172     <!-- Location: Select Box --> 
    173     <p> 
    174     <label for="<?php echo $this->get_field_id( 'location' ); ?>"><?php _e('Location:', 'googlenews'); ?></label>  
    175     <select id="<?php echo $this->get_field_id( 'location' ); ?>" name="<?php echo $this->get_field_name( 'location' ); ?>" class="widefat" style="width:95%;"> 
     171        <!-- Search Keyword(s): Text Input --> 
     172        <p> 
     173            <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('Search keyword(s):', 'googlenews'); ?></label> 
     174            <input id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" /> 
     175        </p> 
     176    <p align="center">=== OR ===</p> 
     177        <!-- Topic: Select Box --> 
     178        <p> 
     179        <label for="<?php echo $this->get_field_id( 'topic' ); ?>"><?php _e('Topic:', 'googlenews'); ?></label>  
     180        <select id="<?php echo $this->get_field_id( 'topic' ); ?>" name="<?php echo $this->get_field_name( 'topic' ); ?>" class="widefat" style="width:100%;"> 
     181// options in Google News on 20 Feb 2010 
     182<option value="" <?php if ('' == $instance['topic']) echo 'selected';?>>Top Stories (default)</option> 
     183<option value="w" <?php if ('w' == $instance['topic']) echo 'selected';?>>World</option> 
     184<option value="n" <?php if ('n' == $instance['topic']) echo 'selected';?>>Nation</option> 
     185<option value="b" <?php if ('b' == $instance['topic']) echo 'selected';?>>Business</option> 
     186<option value="t" <?php if ('t' == $instance['topic']) echo 'selected';?>>Sci/Tecn</option> 
     187<option value="e" <?php if ('e' == $instance['topic']) echo 'selected';?>>Entertainment</option> 
     188<option value="s" <?php if ('s' == $instance['topic']) echo 'selected';?>>Sports</option> 
     189<option value="m" <?php if ('m' == $instance['topic']) echo 'selected';?>>Health</option> 
     190<option value="ir" <?php if ('ir' == $instance['topic']) echo 'selected';?>>Spotlight</option> 
     191<option value="po" <?php if ('po' == $instance['topic']) echo 'selected';?>>Most Popular</option> 
     192        </select> 
     193        </p> 
     194 
     195        <!-- Location: Select Box --> 
     196        <p> 
     197        <label for="<?php echo $this->get_field_id( 'location' ); ?>"><?php _e('Location:', 'googlenews'); ?></label>  
     198        <select id="<?php echo $this->get_field_id( 'location' ); ?>" name="<?php echo $this->get_field_name( 'location' ); ?>" class="widefat" style="width:100%;"> 
    176199 
    177200// Locations in news.google.com on 4 Mar 10 
     
    247270<option value="hk" <?php if ("hk" == $instance['location']) echo 'selected';?>>香港版 (Hong Kong)</option> 
    248271// End Locations in news.google.com on 4 Mar 10 
    249     </select> 
    250     </p> 
    251  
    252     <!-- Local (city, state or zipcode): Text Input --> 
    253     <p> 
    254     <label for="<?php echo $this->get_field_id( 'geo' ); ?>"><?php _e('Local:', 'googlenews'); ?> (U.S. and Canada English only)</label> 
    255     <input id="<?php echo $this->get_field_id( 'geo' ); ?>" name="<?php echo $this->get_field_name( 'geo' ); ?>" value="<?php echo $instance['geo']; ?>" style="width:95%;" /> 
    256     </p> 
    257  
    258 <fieldset style="margin: 10px; border: 1px solid grey; padding: 10px"> 
    259 <legend> Choose between searchkey(s) and topic </legend> 
    260  
    261     <!-- Search Keyword(s): Text Input --> 
    262     <p> 
    263     <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('Search keyword(s):', 'googlenews'); ?></label> 
    264     <input id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:95%;" /> 
    265     <p align="center">=== OR ===</p> 
    266     <!-- Topic: Select Box --> 
    267     <label for="<?php echo $this->get_field_id( 'topic' ); ?>"><?php _e('Topic:', 'googlenews'); ?></label>  
    268     <select id="<?php echo $this->get_field_id( 'topic' ); ?>" name="<?php echo $this->get_field_name( 'topic' ); ?>" class="widefat" style="width:95%;"> 
    269 // options in Google News on 20 Feb 2010 
    270 <option value="" <?php if ('' == $instance['topic']) echo 'selected';?>>Top Stories (default)</option> 
    271 <option value="w" <?php if ('w' == $instance['topic']) echo 'selected';?>>World</option> 
    272 <option value="n" <?php if ('n' == $instance['topic']) echo 'selected';?>>Nation</option> 
    273 <option value="b" <?php if ('b' == $instance['topic']) echo 'selected';?>>Business</option> 
    274 <option value="t" <?php if ('t' == $instance['topic']) echo 'selected';?>>Sci/Tecn</option> 
    275 <option value="e" <?php if ('e' == $instance['topic']) echo 'selected';?>>Entertainment</option> 
    276 <option value="s" <?php if ('s' == $instance['topic']) echo 'selected';?>>Sports</option> 
    277 <option value="m" <?php if ('m' == $instance['topic']) echo 'selected';?>>Health</option> 
    278 <option value="ir" <?php if ('ir' == $instance['topic']) echo 'selected';?>>Spotlight</option> 
    279 <option value="po" <?php if ('po' == $instance['topic']) echo 'selected';?>>Most Popular</option> 
    280     </select> 
    281 <span style="font-size: 0.9em;">Note: Google (not me) imposes to choose between the two options.</span> 
    282     </p> 
    283 </fieldset> 
    284  
    285     <!-- N. articles to display: Text Input --> 
    286     <p> 
    287     <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Num. of News:', 'googlenews'); ?></label> 
    288     <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" style="width:20%;" /> 
    289     </p> 
    290  
    291     <!-- Show Publication Date? Checkbox --> 
    292     <p> 
    293     <label for="<?php echo $this->get_field_id( 'pubdate' ); ?>"><?php _e('Show publication date?', 'googlenews'); ?></label> 
    294     <input class="checkbox" type="checkbox" <?php checked( $instance['pubdate'], 'on' ); ?> id="<?php echo $this->get_field_id( 'pubdate' ); ?>" name="<?php echo $this->get_field_name( 'pubdate' ); ?>" />  
    295     </p> 
    296  
    297     <!-- Show Publication Time? Checkbox --> 
    298     <p> 
    299     <label for="<?php echo $this->get_field_id( 'pubtime' ); ?>"><?php _e('Show publication time?', 'googlenews'); ?></label> 
    300     <input class="checkbox" type="checkbox" <?php checked( $instance['pubtime'], 'on' ); ?> id="<?php echo $this->get_field_id( 'pubtime' ); ?>" name="<?php echo $this->get_field_name( 'pubtime' ); ?>" />  
    301     </p> 
     272 
     273        </select> 
     274        </p> 
     275 
     276        <!-- Widget Title: Text Input --> 
     277        <p> 
     278            <label for="<?php echo $this->get_field_id( 'geo' ); ?>"><?php _e('Local:', 'googlenews'); ?></label> 
     279            <input id="<?php echo $this->get_field_id( 'geo' ); ?>" name="<?php echo $this->get_field_name( 'geo' ); ?>" value="<?php echo $instance['geo']; ?>" style="width:100%;" /> 
     280        </p> 
     281 
     282        <!-- N. articles to display: Text Input --> 
     283        <p> 
     284            <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Num. of News:', 'googlenews'); ?></label> 
     285            <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" style="width:20%;" /> 
     286        </p> 
     287 
     288        <!-- Show Publication Date? Checkbox --> 
     289        <p> 
     290            <label for="<?php echo $this->get_field_id( 'pubdate' ); ?>"><?php _e('Show publication date?', 'googlenews'); ?></label> 
     291            <input class="checkbox" type="checkbox" <?php checked( $instance['pubdate'], 'on' ); ?> id="<?php echo $this->get_field_id( 'pubdate' ); ?>" name="<?php echo $this->get_field_name( 'pubdate' ); ?>" />  
     292        </p> 
     293 
     294        <!-- Show Publication Time? Checkbox --> 
     295        <p> 
     296            <label for="<?php echo $this->get_field_id( 'pubtime' ); ?>"><?php _e('Show publication time?', 'googlenews'); ?></label> 
     297            <input class="checkbox" type="checkbox" <?php checked( $instance['pubtime'], 'on' ); ?> id="<?php echo $this->get_field_id( 'pubtime' ); ?>" name="<?php echo $this->get_field_name( 'pubtime' ); ?>" />  
     298        </p> 
    302299 
    303300    <!-- Show Excerpt? Checkbox --> 
     
    353350function gnews_funct($atts) { 
    354351     extract(shortcode_atts(array( 
     352     "search" => '', 
     353     "topic" => '', 
    355354     "location" => '', 
    356355     "local" => '', 
    357      "search" => '', 
    358      "topic" => '', 
    359356     "num" => '3', 
    360357     "list" => 'UL', 
     
    369366     /* Display name from widget settings if one was input. */ 
    370367     $feed = "http://news.google.com/news?cf=all&ned=" . $location. "&output=rss"; 
    371      if ( $local ) { $feed .= "&geo=$local"; } 
     368     if ( $local) { $feed .= "&geo=$local"; } 
    372369     if ( $search ) { $feed .= "&q=$search"; } 
    373370     if ( $topic ) { $feed .= "&topic=$topic"; } 
     
    393390                foreach ($rss->channel->item as $item ) { 
    394391                    $flist .= "<li>"; 
    395                     if ($item->title || $item->description) { 
     392                                         
     393                                        if ($item->title || $item->description) { 
    396394 
    397395                    if ( $item->link ) { 
     
    400398                    } 
    401399 
    402                     $flist .= isset( $item->title ) ? htmlentities($item->title) : htmlentities($item->description); 
     400                    $flist .= isset( $item->title ) ? $item->title : $item->description; 
    403401 
    404402                    if ( $item->link ) 
     
    430428 
    431429            // otherwise check whether it is an Atom format feed 
    432             } elseif (array_key_exists('entry', $rss)) { 
    433  
    434                 $flist = "<$list>\n"; 
    435                 $flist .= "We have a Atom feed!<br>"; 
    436                 $i = 0; 
    437  
    438                 foreach ($rss->entry as $entry ) { 
    439                     $flist .= "<li>"; 
    440                     if ($entry->title && $entry->id && $entry->updated) { 
    441  
    442                     if ( $entry->link ) { 
    443                         $motext = isset( $entry->summary ) ? htmlentities($entry->summary): htmlentities($entry->title); 
    444                         $flist .= "<a target='". $target . "' href='$entry->link' title='$motext'>"; 
    445                     } 
    446  
    447                     $flist .= htmlentities($entry->title); 
    448  
    449                     if ( $entry->link ) $flist .= "</a>"; 
    450   
    451                     if ( $entry->updated && $pubdate !== false && $pubdate !== "false" ) 
    452                         $flist .= ' - ' . date ( 'd M y', strtotime( $entry->updated )); 
    453  
    454                           if ( $entry->updated && $pubtime !== false && $pubtime !== "false") 
    455                         $flist .= ' at ' . date ( 'H:i', strtotime( $entry->updated ));  
    456  
    457                     if ( $entry->summary && $excerpt != false && $excerpt != "false") { 
    458                         if ( $charex > '0' ) {  
    459                             $flist .= '<br/>'. substr($entry->summary, 0, $charex); 
    460                             $flist .= ' <a target="' . $target . '" href="' . esc_url( $entry->link ) . '">[...]</a>'; 
    461                         } else { 
    462                             $flist .= '<br/>'. $entry->summary; 
    463                         } 
    464                     }  
    465  
    466                     //$flist .= "Entry $i "; 
    467                     } else { 
    468                         $flist .= "No standard <entry> in file"; 
    469                     } 
    470                     $flist .= "</li>"; 
    471  
    472                     $i++; 
    473                     if ($i >= $num) break; 
    474                 } // foreach 
    475  
    476                 $flist .= "</".$list.">\n"; 
    477  
    478430            } else { 
    479                 $flist .= "No typical RSS or Atom feed or search criteria not supported by Google."; 
     431               $flist .= "No typical RSS feed by Google or they have changed their feed format after the relase of this plugin. Please let me know about this."; 
    480432            } 
    481433        } else { 
     
    487439    // if pubauthor has been selected 
    488440    if ($pubauthor !== false && $pubauthor !== "false") { 
    489         $flist .= '<p style="text-align:center; font-size: 0.8em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/portfolio/">Google News Widget/Shortcode</a></p>'; 
     441        $flist .= '<p style="text-align:center; font-size: 0.8em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/portfolio/">Google News Wizard/Shortcode</a></p>'; 
    490442    } 
    491443    return $flist; 
  • google-news-widget/trunk/readme.txt

    r220203 r220354  
    55Requires at least: 2.8 
    66Tested up to: 2.9.2 
    7 Stable tag: 0.7 
     7Stable tag: 0.9 
    88 
    99A customizable list of Google News given language-country, searchkey(s) or topic, number of news and whether you want publication date, time.  
     
    4343== Changelog == 
    4444 
     45= 0.9 =  
     46 
     47* Fixed a bug (introduced in 0.8) which showed the widget title twice 
     48* Amended the 0.7 changelog/Upgrade notice as a few changes were forgotten 
     49 
     50= 0.8 = (never released. used to test the bug-fix) 
     51 
     52* Fixed a bug which prevented non-standard chars to be displayed properly 
     53 
    4554= 0.7 = 
    4655 
    4756* New feature: added selection of local news (working for Usa and Canada English only) 
     57* New feature: Made the widget title linkable to the feed URL 
    4858* Added proper error messages for: empty, non-existing URLs and invalid/misformatted feeds content 
    4959* Added defaults for target and list (widget fields) 
    5060* Added instruction to hide Warnings from the xmlsimple_load_file function 
    5161* Fixed a bug which prevented proper display of description/summary with tags 
     62* Made it fully compatible with RSS standards where link and title might be omitted 
     63* Used the native PHP class simpleXML instead of the Wordpress feed parser (Magpie) 
    5264 
    5365= 0.6 = 
     
    8193== Upgrade Notice == 
    8294 
     95= 0.9 = 
     96* Non-standard chars are properly displayed  
     97 
     98= 0.8 = 
     99* Never released. Used internally for tests. 
     100 
    83101= 0.7 = 
    84102* New feature: added selection of local news (working for Usa and Canada English only) 
     103* New feature: Made the widget title linkable to the feed URL 
    85104* Added proper error messages for: empty, non-existing URLs and invalid/misformatted feeds content 
    86105 
Note: See TracChangeset for help on using the changeset viewer.