Changeset 130
- Timestamp:
- 03/06/08 03:03:21 (9 months ago)
- Files:
-
- trunk/Phergie/Plugin/FeedTicker.php (modified) (4 diffs)
- trunk/Phergie/phergie.ini (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/FeedTicker.php
r104 r130 27 27 28 28 /** 29 * Filter feed title data 30 * 31 * @see run() 32 * @var array 33 */ 34 protected $filterTitle = null; 35 36 /** 37 * Filter feed url data 38 * 39 * @see run() 40 * @var array 41 */ 42 protected $filterUrl = null; 43 44 /** 45 * Filter article title data 46 * 47 * @see run() 48 * @var array 49 */ 50 protected $filterArticle = null; 51 52 /** 29 53 * Cache of the last update to check for new entries 30 54 * … … 65 89 * @return void 66 90 */ 67 public function init() 68 { 91 public function init() 92 { 93 // Global Feed Title, Feed URL and Article Title Filters 94 $globalTitle = trim($this->getPluginIni('filter_title')); 95 $globalUrl = trim($this->getPluginIni('filter_url')); 96 $globalArticle = trim($this->getPluginIni('filter_article')); 97 69 98 $i = 0; 70 99 $this->feeds = array(); 71 100 do { 101 // Feed and Chan data 72 102 $feed = $this->getPluginIni('feed' . $i); 73 $chans = $this->getPluginIni('chans' . $i); 103 $chans = $this->getPluginIni('chans' . $i); 104 // Feed Title, Feed URL and Article Title Filter Data 105 $filterTitle = $this->getPluginIni('filter_title' . $i); 106 $filterUrl = $this->getPluginIni('filter_url' . $i); 107 $filterArticle = $this->getPluginIni('filter_article' . $i); 108 74 109 if (!empty($feed) && !empty($chans)) { 75 110 $this->feeds[] = array($feed, preg_split('#[\s\r\n,]+#', $chans)); 111 // Feed Title, Feed URL and Article Title Filters 112 $this->filterTitle[] = trim(trim(implode('|', array($globalTitle, $filterTitle)), '|')); 113 $this->filterUrl[] = trim(trim(implode('|', array($globalUrl, $filterUrl)), '|')); 114 $this->filterArticle[] = trim(trim(implode('|', array($globalArticle, $filterArticle)), '|')); 76 115 } 77 116 } while (++$i < 10); … … 188 227 $articles = array_reverse($articles); 189 228 foreach ($articles as $article) { 190 if (!isset ($this->cache[$id]) 191 || array_search($article, $this->cache[$id]) === false) { 229 if ((!isset ($this->cache[$id]) 230 || array_search($article, $this->cache[$id]) === false) && 231 $this->filterCheck($id, $article[0], $article[1], $article[3])) { 192 232 // Decode and trim article title 193 233 $article[0] = $this->decode($article[0], 40); … … 204 244 } 205 245 246 // Checks the given feed Title and URL as well as article title against the feed filters 247 protected function filterCheck($id, $title, $url, $article) { 248 // Feed Title, Feed URL and Article Title Filters 249 $filterTitle = $this->filterTitle[$id]; 250 $filterUrl = $this->filterUrl[$id]; 251 $filterArticle = $this->filterArticle[$id]; 252 253 // Check against the filters if any are set 254 if (($filterTitle && preg_match('/'.$filterTitle.'/im', $title, $match)) || 255 ($filterUrl && preg_match('/'.$filterUrl.'/im', $url, $match)) || 256 ($filterArticle && preg_match('/'.$filterArticle.'/im', $article, $match))) { 257 return false; 258 } 259 return true; 260 } 261 206 262 /** 207 263 * Transliterates a UTF-8 string into corresponding ASCII characters and trunk/Phergie/phergie.ini
r129 r130 134 134 ;----------------------------------------------------------------------------- 135 135 136 ; feedticker.feed0 :137 ; a double quote-enclosed comma-delimited list of feed URLs; this setting138 ; may be repeated with a different number (i.e. feed1, feed2, etc.)139 feedticker.feed0 = ""140 141 ; feedticker.chans0 :142 ; a comma- or space-delimited list of channels where the feedN should be143 ; syndicated144 feedticker.chans0 = ""145 146 136 ; feedticker.delay : 147 137 ; the frequency, in seconds, at which the feeds are checked for new data; … … 157 147 feedticker.format = "" 158 148 149 ;# Feed Ticker: Filter Settings # 150 ; feedticker.filter_title: 151 ; a double quote-enclosed regex string filter; this is the global filter 152 ; setting used to filter the feed title of all the feeds 153 feedticker.filter_title = "" 154 155 ; feedticker.filter_url : 156 ; a double quote-enclosed regex string filter; this is the global filter 157 ; setting used to filter the feed url of all the feeds 158 feedticker.filter_url = "" 159 160 ; feedticker.filter_article: 161 ; a double quote-enclosed regex string filter; this is the global filter 162 ; setting used to filter the article title of all the feeds 163 feedticker.filter_article = "" 164 165 ; feedticker.feed0 : 166 ; a double quote-enclosed comma-delimited list of feed URLs; this setting 167 ; may be repeated with a different number (i.e. feed1, feed2, etc.) 168 feedticker.feed0 = "" 169 170 ; feedticker.chans0 : 171 ; a comma- or space-delimited list of channels where the feedN should be 172 ; syndicated 173 feedticker.chans0 = "" 174 175 ; feedticker.filter_title0 : 176 ; a double quote-enclosed regex string filter; this setting allows you to 177 ; filter each feed title independently and may be repeated with a different 178 ; number. (i.e. filter_title1, filter_title2, etc.) 179 feedticker.filter_title0 = "" 180 181 ; feedticker.filter_url0 : 182 ; a double quote-enclosed regex string filter; this setting allows you to 183 ; filter each feed url independently and may be repeated with a different 184 ; number. (i.e. filter_url1, filter_url2, etc.) 185 feedticker.filter_url0 = "" 186 187 ; feedticker.filter_article0 : 188 ; a double quote-enclosed regex string filter; this setting allows you to 189 ; filter each article title independently and may be repeated with a 190 ; different number. (i.e. filter_article1, filter_article2, etc.) 191 feedticker.filter_article0 = "" 192 159 193 ;----------------------------------------------------------------------------- 160 194 ; Karma