Plugin Directory

Changeset 176996


Ignore:
Timestamp:
11/25/2009 06:34:59 PM (16 years ago)
Author:
finalcut
Message:

added filter for posts to use the random feed file

Location:
feedlist/trunk/feedList
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • feedlist/trunk/feedList/feedlist.php

    r157336 r176996  
    66    Author: Bill Rawlinson
    77    Author URI: http://blog.rawlinson.us/
    8     Version: 2.24
     8    Version: 2.50
    99*/
    1010
     
    8585                    ($this->args['feedsToShow'] > sizeof($feedInfo)) ? sizeof($feedInfo) : $this->args['feedsToShow'];
    8686
     87
    8788                    // we will fetch each feed, then coallate items
    8889                    for($i=0;$i<$this->args['feedsToShow'];$i++){
     90
    8991                        $thisFeed = $feedInfo[$i];
    9092
     
    137139
    138140                // coallate feed items
    139                 echo $this->output;
     141                return $this->output;
    140142
    141143            }
     
    185187                    $Translations['fr_FR']['ReadMore'] = 'Lisez davantage';
    186188               
    187                 $feedListFile = '/feeds.txt'; // IF you are going to use the random feedlist generator make sure this holds the correct name for your feed file:
     189                $feedListFile = ABSPATH .  'wp-content\plugins\feeds.txt'; // IF you are going to use the random feedlist generator make sure this holds the correct name for your feed file:
    188190
    189191                // Build an array out of the settings and send them back:
     
    219221                            'max_characters' => 0,
    220222                            'max_char_wordbreak' => true,
    221                             'file'=>$settings['file'],
     223                            'file'=>$settings['feedListFile'],
    222224                            'feedsToShow'=>0,
     225                            'itemsPerFeed'=>1,
    223226                            'mergeFeeds'=>false,
    224227                            'show_date_per_item' => false,
     
    501504                */
    502505                $x = file($file);
    503                 return preg_split("/--NEXT--/", join('', file($file)));
     506                return preg_split("/--NEXT--/", join('', $x));
    504507            }
    505508
     
    535538                    $i++;
    536539                }
     540
    537541                return $a;
    538542            }
     
    586590            return preg_replace_callback("/<!--rss:(.*)-->/", "feedListFilter", $text);
    587591        }
     592        function rssLinkListFileFilter($text)
     593        {
     594            return preg_replace_callback("/<!--rssFile:(.*)-->/", "feedListFileFilter", $text);
     595        }
    588596
    589597
     
    606614
    607615        function randomFeedList($args){
     616                echo processRandomFeedList($args);
     617        }
     618
     619        function processRandomFeedList($args){
    608620            if(!is_array($args)){
    609621                $args = parse_str($args,$a);
     
    611623            }
    612624            $feed = new FeedList($args);
     625            $feed->Debug("called");
    613626            return $feed->FeedListFile();
    614627        }
     
    633646
    634647            $feed = new FeedList($args);
    635 
    636648            return $feed->FeedListFilter();
     649        }
     650
     651        function feedListFileFilter($args){
     652            $args = explode(",",$args[1]);
     653
     654
     655            if(count($args) == 1 && !strpos($args[0],":=")){
     656                $a = array();
     657                $a["file"] = $args[0];
     658                $args = $a;
     659            } else {
     660                $a = array();
     661                foreach($args as $arg){
     662                    $arg = explode(":=",$arg);
     663                    $a[$arg[0]] = $arg[1];
     664                }
     665                $args = $a;
     666
     667            }
     668
     669            return processRandomFeedList($args);
     670
    637671        }
    638672
     
    642676        {
    643677            add_filter('the_content', 'rssLinkListFilter');
     678            add_filter('the_content', 'rssLinkListFileFilter');
    644679        }
    645680
  • feedlist/trunk/feedList/readme.txt

    r157336 r176996  
    55Requires at least: 1.5
    66Tested up to: 2.8.4
    7 Stable tag: 2.24
     7Stable tag: 2.50
    88
    99Allows you to display lists of links from an rss or atom feed on your blog.
     
    9393
    9494    23 Sep 2009         fixed a variety of issues identified at http://code.google.com/p/wp-feedlist/issues/list (issues: 15, 17, 22, 30, 31, 32, 37)
     95
     96    25 Nov 2009         Added filter for posts to use the random feed file
    9597-------------------------------------------------------------------------------------------------------
    9698 
     
    107109limited testing with non UTF-8 encoding.
    108110
     111== KNOWN BUG ==
     112    using the rssFile filter results in a duplication of the feedList display
    109113
    110114
     
    179183
    180184
     185        * random file:
     186            <!--rssFile:[FilePath]-->
     187
     188            NOTE: if you aren't using named parameters with the filter only provide the full path to the file or else it won't work.
     189            NOTE: if you don't provide a filepath the default one set in the file, feedlist.php near line 187 will be used (typically siteroot\wp-content\plugins\feeds.txt)
     190           
     191            * Named Parameters
     192            <!--rssFile:feedsToShow:=1,num_items:=3,file:=c:\dev\websites\wordpress\wp-content\plugins\feeds2.txt-->
     193
     194            NOTE: this example will pull one feed from the file, and then show 3 items fro the feed
    181195
    182196
     
    257271
    258272    ADVANCED:
    259         <?php randomFeedList("feedsToShow=2&itemsPerFeed=3") ?>
     273        <?php randomFeedList("feedsToShow=2&num_items=3") ?>
    260274
    261275        there are ALOT of parameters you can pass into randomFeedList.  I am taking a different approach to it here than I do elsewhere in the feedList plugin.
     
    266280    file - the path to your feedfile (default: '.wp-content/plugins/feeds.txt')
    267281    feedsToShow - the number of feeds to poll from your feedfile (default: 5)
    268     itemsPerFeed - the number of items to show from each feed polled (default: 1)
     282    num_items - the number of items to show from each feed polled (default: 1)
    269283    show_description - show the description of each item or not (default: false)
    270284    randomItemsPerFeed - not only can you show random feeds from the feed file but you can also show random items from each feed (default: true)
Note: See TracChangeset for help on using the changeset viewer.