| 205 | | public function get_rss_html($rss_sources, $number_of_items_to_display=20) |
|---|
| 206 | | { |
|---|
| 207 | | $old_error_level = error_reporting(E_ERROR); |
|---|
| 208 | | $item_date_array = array(); |
|---|
| 209 | | $item_date_array_index = 0; |
|---|
| | 137 | public function get_rss($rss_sources, $number_of_items_to_display = 20) { |
|---|
| | 138 | $old_error_level = error_reporting(E_ERROR); |
|---|
| | 139 | $item_date_array = array(); |
|---|
| | 140 | $item_date_array_index = 0; |
|---|
| | 141 | |
|---|
| | 142 | foreach ($rss_sources as $rss_sources_key => $rss_source) { |
|---|
| | 143 | $i = 0; |
|---|
| | 144 | $publication_interval_total = null; |
|---|
| | 145 | /* running total of the difference between the date of the current item and the previous one */ |
|---|
| | 146 | $average_publication_interval = null; |
|---|
| | 147 | $previous_item_date = null; |
|---|
| | 148 | $rss = fetch_rss( $rss_source['url'] ); |
|---|
| | 149 | if (!$rss) { |
|---|
| | 150 | throw new Exception(_(magpie_error())); |
|---|
| | 151 | } else { |
|---|
| | 152 | //$rss_sources[$rss_sources_key]['rss'] = $rss; |
|---|
| | 153 | //$rss->show_channel(); |
|---|
| | 154 | //$rss->show_list(); |
|---|
| | 155 | |
|---|
| | 156 | /* Sort the array in chronological order */ |
|---|
| | 157 | |
|---|
| | 158 | /* foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ |
|---|
| | 159 | if (!uasort($rss->items, array("RssPressReview", "cmp_date_item"))) { |
|---|
| | 160 | throw new Exception(_('uasort() failed')); |
|---|
| | 161 | } |
|---|
| | 162 | /* foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ |
|---|
| | 163 | |
|---|
| | 164 | /* Calculate the publication interval for this source */ |
|---|
| | 165 | foreach ($rss->items as $item) { |
|---|
| | 166 | $date = self::get_item_date($item); |
|---|
| | 167 | |
|---|
| | 168 | if ($date == -1) { |
|---|
| | 169 | /* |
|---|
| | 170 | * If we do not know the date, for statistics purposes, |
|---|
| | 171 | * we will set the date as if a news item as published |
|---|
| | 172 | * every default_publication_interval, starting now. |
|---|
| | 173 | */ |
|---|
| | 174 | $date = time() - ($i * $rss_sources[$rss_sources_key]['default_publication_interval']); |
|---|
| | 175 | } |
|---|
| | 176 | |
|---|
| | 177 | if ($i > 0) { |
|---|
| | 178 | $publication_interval_total += $previous_item_date - $date; |
|---|
| | 179 | } |
|---|
| | 180 | |
|---|
| | 181 | $previous_item_date = $date; |
|---|
| | 182 | |
|---|
| | 183 | /* Memorize each date, and publication intervals so we can determine the "oldest" item to publish */ |
|---|
| | 184 | |
|---|
| | 185 | $item_date_array[$item_date_array_index]['date']=$date; |
|---|
| | 186 | $item_date_array[$item_date_array_index]['rss_sources_key']=$rss_sources_key; |
|---|
| | 187 | $item_date_array_index++; |
|---|
| | 188 | $i++; |
|---|
| | 189 | }// End foreach items |
|---|
| | 190 | |
|---|
| | 191 | |
|---|
| | 192 | if ($i >= 2 && $publication_interval_total != 0) { |
|---|
| | 193 | $average_publication_interval = $publication_interval_total/($i-1); |
|---|
| | 194 | $rss_sources[$rss_sources_key]['average_publication_interval'] = $average_publication_interval; |
|---|
| | 195 | } else { |
|---|
| | 196 | $rss_sources[$rss_sources_key]['average_publication_interval'] = $rss_sources[$rss_sources_key]['default_publication_interval']; |
|---|
| | 197 | } |
|---|
| | 198 | //echo "<p>$i items, average_publication_interval (days) = ". $rss_sources[$rss_sources_key]['average_publication_interval']/(3600 * 24) . "</p>\n"; |
|---|
| | 199 | |
|---|
| | 200 | $rss_sources[$rss_sources_key]['number_of_items'] = $i; |
|---|
| | 201 | } |
|---|
| | 202 | }// End foreach rss feeds |
|---|
| | 203 | |
|---|
| 211 | | foreach ($rss_sources as $rss_sources_key => $rss_source) |
|---|
| 212 | | { |
|---|
| 213 | | //echo "<h1>$rss_source[url]</h1>"; |
|---|
| 214 | | $i = 0; |
|---|
| 215 | | $publication_interval_total = null; //running total of the difference between the date of the current item and the previous one |
|---|
| 216 | | $average_publication_interval = null; |
|---|
| 217 | | $previous_item_date=null; |
|---|
| 218 | | $rss = fetch_rss( $rss_source['url'] ); |
|---|
| 219 | | if ( !$rss ) |
|---|
| 220 | | { |
|---|
| 221 | | echo _("Error: ") . magpie_error() ; |
|---|
| 222 | | } |
|---|
| 223 | | else |
|---|
| 224 | | { |
|---|
| 225 | | //$rss_sources[$rss_sources_key]['rss']=$rss; |
|---|
| 226 | | //$rss->show_channel(); |
|---|
| 227 | | //$rss->show_list(); |
|---|
| 228 | | |
|---|
| 229 | | /* Sort the array in chronological order */ |
|---|
| 230 | | |
|---|
| 231 | | /*foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ |
|---|
| 232 | | if(!uasort($rss->items, array("RssPressReview","cmp_date_item"))) |
|---|
| 233 | | { |
|---|
| 234 | | echo "Error: uasort() failed<br />\n"; |
|---|
| 235 | | } |
|---|
| 236 | | /*foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ |
|---|
| 237 | | |
|---|
| 238 | | /* Calculate the publication interval for this source */ |
|---|
| 239 | | foreach ($rss->items as $item) |
|---|
| 240 | | { |
|---|
| 241 | | $date = self::get_item_date($item); |
|---|
| 242 | | |
|---|
| 243 | | if ($date == -1) |
|---|
| 244 | | { |
|---|
| 245 | | //If we do not know the date, for statistics purposes, we will set the date as if a news item as published every default_publication_interval, starting now. |
|---|
| 246 | | $date = time() - ($i * $rss_sources[$rss_sources_key]['default_publication_interval']); |
|---|
| 247 | | } |
|---|
| 248 | | |
|---|
| 249 | | if($i >0) |
|---|
| 250 | | { |
|---|
| 251 | | $publication_interval_total += $previous_item_date - $date; |
|---|
| 252 | | } |
|---|
| 253 | | |
|---|
| 254 | | $previous_item_date = $date; |
|---|
| 255 | | |
|---|
| 256 | | /* Memorize each date, and publication intervals so we can determine the "oldest" item to publish */ |
|---|
| 257 | | |
|---|
| 258 | | $item_date_array[$item_date_array_index]['date']=$date; |
|---|
| 259 | | $item_date_array[$item_date_array_index]['rss_sources_key']=$rss_sources_key; |
|---|
| 260 | | $item_date_array_index++; |
|---|
| 261 | | $i++; |
|---|
| 262 | | }// End foreach items |
|---|
| 263 | | |
|---|
| 264 | | |
|---|
| 265 | | if($i >= 2 && $publication_interval_total != 0) |
|---|
| 266 | | { |
|---|
| 267 | | $average_publication_interval = $publication_interval_total/($i-1); |
|---|
| 268 | | $rss_sources[$rss_sources_key]['average_publication_interval']=$average_publication_interval; |
|---|
| 269 | | } |
|---|
| 270 | | else |
|---|
| 271 | | { |
|---|
| 272 | | $rss_sources[$rss_sources_key]['average_publication_interval']=$rss_sources[$rss_sources_key]['default_publication_interval']; |
|---|
| 273 | | } |
|---|
| 274 | | //echo "<p>$i items, average_publication_interval (days) = ". $rss_sources[$rss_sources_key]['average_publication_interval']/(3600 * 24) . "</p>\n"; |
|---|
| 275 | | |
|---|
| 276 | | $rss_sources[$rss_sources_key]['number_of_items']=$i; |
|---|
| 277 | | } |
|---|
| 278 | | }// End foreach rss feeds |
|---|
| | 205 | $all_feed_publication_interval_total = null; |
|---|
| | 206 | reset($rss_sources); |
|---|
| | 207 | foreach ($rss_sources as $rss_source) { |
|---|
| | 208 | $all_feed_publication_interval_total += $rss_source['average_publication_interval']; |
|---|
| | 209 | } |
|---|
| | 210 | $all_feed_publication_interval = $all_feed_publication_interval_total / count($rss_sources); |
|---|
| | 211 | |
|---|
| | 212 | for ($i = 0; isset($item_date_array[$i]); $i++) { |
|---|
| | 213 | $average_publication_interval = $rss_sources[$item_date_array[$i]['rss_sources_key']]['average_publication_interval']; |
|---|
| | 214 | $adjust_factor = $all_feed_publication_interval / $average_publication_interval; |
|---|
| | 215 | $item_date_array[$i]['adjusted_date'] = time() - ((time() - $item_date_array[$i]['date']) * $adjust_factor); |
|---|
| | 216 | } |
|---|
| 280 | | |
|---|
| 281 | | $all_feed_publication_interval_total = null; |
|---|
| 282 | | reset($rss_sources); |
|---|
| 283 | | foreach ($rss_sources as $rss_source) |
|---|
| 284 | | { |
|---|
| 285 | | $all_feed_publication_interval_total+= $rss_source['average_publication_interval']; |
|---|
| 286 | | } |
|---|
| 287 | | $all_feed_publication_interval = $all_feed_publication_interval_total / count($rss_sources); |
|---|
| 288 | | //echo "<p>all_feed_publication_interval (days) = ". $all_feed_publication_interval/(3600 * 24) . "</p>\n"; |
|---|
| 289 | | |
|---|
| 290 | | for($i=0; isset($item_date_array[$i]); $i++) |
|---|
| 291 | | { |
|---|
| 292 | | $average_publication_interval = $rss_sources[$item_date_array[$i]['rss_sources_key']]['average_publication_interval']; |
|---|
| 293 | | $adjust_factor = $all_feed_publication_interval/$average_publication_interval; |
|---|
| 294 | | $item_date_array[$i]['adjusted_date']= time()- ((time()-$item_date_array[$i]['date'])*$adjust_factor); |
|---|
| 295 | | } |
|---|
| 296 | | |
|---|
| 297 | | //echo "<pre>\n"; |
|---|
| 298 | | //print_r($rss_sources); |
|---|
| 299 | | //print_r($item_date_array); |
|---|
| 300 | | |
|---|
| 301 | | usort($item_date_array, array("RssPressReview","cmp")); |
|---|
| 302 | | //print_r($item_date_array); |
|---|
| 303 | | //echo "</pre>\n"; |
|---|
| 304 | | |
|---|
| 305 | | if(count($item_date_array)<$number_of_items_to_display) |
|---|
| 306 | | { |
|---|
| 307 | | $number_of_items_to_display = count($item_date_array); |
|---|
| 308 | | } |
|---|
| 309 | | |
|---|
| 310 | | $min_adjusted_date_to_display = $item_date_array[$number_of_items_to_display-1]['adjusted_date']; |
|---|
| 311 | | |
|---|
| 312 | | /************** Now we actually display the feeds **************/ |
|---|
| 313 | | $sidx=0; |
|---|
| 314 | | $rss_html_all_feeds=''; |
|---|
| 315 | | //print_r($rss_sources); |
|---|
| 316 | | reset($rss_sources); |
|---|
| 317 | | foreach ($rss_sources as $rss_sources_key => $rss_source) |
|---|
| 318 | | { |
|---|
| 319 | | //echo "<h3>$rss_source[url]</h3>"; |
|---|
| 320 | | $rss = fetch_rss( $rss_source['url'] ); |
|---|
| 321 | | if ( !$rss ) |
|---|
| 322 | | { |
|---|
| 323 | | echo _("Error: ") . magpie_error() ; |
|---|
| 324 | | } |
|---|
| 325 | | else |
|---|
| 326 | | { |
|---|
| 327 | | //$rss->show_channel(); |
|---|
| 328 | | //$rss->show_list(); |
|---|
| 329 | | $rss_html = ''; |
|---|
| 330 | | $rss_header=''; |
|---|
| 331 | | if ($rss_sources_key!=0) |
|---|
| 332 | | { |
|---|
| 333 | | //$rss_header .= "<hr />\n"; |
|---|
| 334 | | } |
|---|
| 335 | | $rss_header .= "<p class=textegris>"._('Source: ')."<b>"; |
|---|
| 336 | | $channel_title = $this->convert_string_encoding($rss->channel['title']); |
|---|
| 337 | | if(!empty($rss->channel['link'])) |
|---|
| 338 | | { |
|---|
| 339 | | $rss_header .= "<a class='y' href='".$rss->channel['link']."'>$channel_title</a>"; |
|---|
| 340 | | } |
|---|
| 341 | | else |
|---|
| 342 | | { |
|---|
| 343 | | $rss_header .= $channel_title; |
|---|
| 344 | | } |
|---|
| 345 | | $rss_header .= "</b></p>\n"; |
|---|
| 346 | | $rss_header .= "<ul>\n"; |
|---|
| 347 | | $header_is_displayed = false; |
|---|
| 348 | | $i = 0; |
|---|
| 349 | | /* Sort the items by date, so we get the most recent first */ |
|---|
| 350 | | if(!uasort($rss->items, array("RssPressReview","cmp_date_item"))) |
|---|
| 351 | | { |
|---|
| 352 | | echo "Error: uasort() failed<br />\n"; |
|---|
| 353 | | } |
|---|
| 354 | | |
|---|
| 355 | | foreach ($rss->items as $item) |
|---|
| 356 | | { |
|---|
| 357 | | $date = self::get_item_date($item); |
|---|
| 358 | | $realdate = $date; |
|---|
| 359 | | if ($date == -1) |
|---|
| 360 | | { |
|---|
| 361 | | //If we do not know the date, for statistics purposes, we will set the date as if a news item as published every default_publication_interval, starting now. |
|---|
| 362 | | $date = time() - ($i * $rss_sources[$rss_sources_key]['default_publication_interval']); |
|---|
| 363 | | } |
|---|
| 364 | | |
|---|
| 365 | | $average_publication_interval = $rss_sources[$rss_sources_key]['average_publication_interval']; |
|---|
| 366 | | |
|---|
| 367 | | $adjust_factor = $all_feed_publication_interval/$average_publication_interval; |
|---|
| 368 | | $adjusted_date = time()- ((time()-$date)*$adjust_factor); |
|---|
| 369 | | //echo "<pre>";print_r($item);echo"</pre>"; |
|---|
| 370 | | /* setlocale(LC_TIME, "fr_CA"); |
|---|
| 371 | | $display_date= strftime("%x", $realdate); |
|---|
| 372 | | echo "$item[title] ($display_date): adjusted_date $adjusted_date, min_adjusted_date_to_display $min_adjusted_date_to_display<br>"; |
|---|
| 373 | | echo "average_publication_interval: $average_publication_interval, adjust_factor: $adjust_factor, date: $date, $adjusted_date: $adjusted_date<br>";*/ |
|---|
| 374 | | if ($adjusted_date >= $min_adjusted_date_to_display) |
|---|
| 375 | | { |
|---|
| 376 | | if(!$header_is_displayed) |
|---|
| 377 | | { |
|---|
| 378 | | $rss_html .= $rss_header; |
|---|
| 379 | | $header_is_displayed = true; |
|---|
| 380 | | } |
|---|
| 381 | | if(!empty($item['link'])) |
|---|
| 382 | | { |
|---|
| 383 | | $href = $item['link']; |
|---|
| 384 | | } |
|---|
| 385 | | else |
|---|
| 386 | | { |
|---|
| 387 | | $href = false; |
|---|
| 388 | | } |
|---|
| 389 | | $title = $this->convert_string_encoding($item['title']); |
|---|
| 390 | | |
|---|
| 391 | | if(!empty($item['summary'])) |
|---|
| 392 | | { |
|---|
| 393 | | $summary = $this->convert_string_encoding($item['summary']); |
|---|
| 394 | | } |
|---|
| 395 | | else |
|---|
| 396 | | { |
|---|
| 397 | | $summary = ''; |
|---|
| 398 | | } |
|---|
| 399 | | if($realdate!= -1) |
|---|
| 400 | | { |
|---|
| 401 | | setlocale(LC_TIME, "fr_CA"); |
|---|
| 402 | | $display_date= strftime("%x", $realdate); |
|---|
| 403 | | } |
|---|
| 404 | | else |
|---|
| 405 | | { |
|---|
| 406 | | $display_date=''; |
|---|
| 407 | | } |
|---|
| 408 | | |
|---|
| 409 | | $author=''; |
|---|
| 410 | | if(!empty($item['dc']['creator'])) |
|---|
| 411 | | { |
|---|
| 412 | | $author = trim($item['dc']['creator']); |
|---|
| 413 | | } |
|---|
| 414 | | elseif (!empty($item['author'])) |
|---|
| 415 | | { |
|---|
| 416 | | $author = trim($item['author']); |
|---|
| 417 | | } |
|---|
| 418 | | elseif (!empty($item['author_name'])) |
|---|
| 419 | | { |
|---|
| 420 | | $author = trim($item['author_name']); |
|---|
| 421 | | } |
|---|
| 422 | | |
|---|
| 423 | | if(!empty($author)) |
|---|
| 424 | | { |
|---|
| 425 | | $author = $this->convert_string_encoding($author); |
|---|
| 426 | | $author = "par $author"; |
|---|
| 427 | | } |
|---|
| 428 | | $dhtml_id = "summary_".mt_rand(1, 10000). "_".$sidx; |
|---|
| 429 | | $rss_html .= "<li>\n"; |
|---|
| 430 | | $rss_html .= "<span class='textegrispetit'>$display_date</span><span class='y' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; |
|---|
| 431 | | if($href) |
|---|
| 432 | | { |
|---|
| 433 | | $rss_html .= "<a class='y' href='$href'>\n"; |
|---|
| 434 | | } |
|---|
| 435 | | $rss_html .= "<b>$title</b></span><br />\n"; |
|---|
| 436 | | if($href) |
|---|
| 437 | | { |
|---|
| 438 | | $rss_html .= "</a>\n"; |
|---|
| 439 | | } |
|---|
| 440 | | $rss_html .= "<div style='z-index: 1000; position: relative'>\n"; |
|---|
| 441 | | $rss_html .= "<div style='z-index: 1000;' id='$dhtml_id' class='introduction'> |
|---|
| 442 | | <p>$author ($channel_title) $display_date</p>\n"; |
|---|
| 443 | | $rss_html .= "<p>$summary</p></div>\n"; |
|---|
| 444 | | $rss_html .= "</div>\n"; |
|---|
| 445 | | $rss_html .= "</li>\n"; |
|---|
| 446 | | |
|---|
| 447 | | } |
|---|
| 448 | | $i++; |
|---|
| 449 | | $sidx++; |
|---|
| 450 | | }// End foreach items |
|---|
| 451 | | |
|---|
| 452 | | if($header_is_displayed) |
|---|
| 453 | | { |
|---|
| 454 | | $rss_html .= "</ul>\n"; |
|---|
| 455 | | } |
|---|
| 456 | | $rss_html_all_feeds .= $rss_html; |
|---|
| 457 | | } |
|---|
| 458 | | }// End foreach rss feeds |
|---|
| 459 | | return $rss_html_all_feeds; |
|---|
| 460 | | error_reporting($old_error_level); |
|---|
| | 218 | usort($item_date_array, array("RssPressReview", "cmp")); |
|---|
| | 219 | |
|---|
| | 220 | if (count($item_date_array) < $number_of_items_to_display) { |
|---|
| | 221 | $number_of_items_to_display = count($item_date_array); |
|---|
| | 222 | } |
|---|
| | 223 | |
|---|
| | 224 | $min_adjusted_date_to_display = $item_date_array[$number_of_items_to_display - 1]['adjusted_date']; |
|---|
| | 225 | |
|---|
| | 226 | /************** Now we actually display the feeds **************/ |
|---|
| | 227 | $sidx = 0; |
|---|
| | 228 | reset($rss_sources); |
|---|
| | 229 | foreach ($rss_sources as $rss_sources_key => $rss_source) { |
|---|
| | 230 | $rss = fetch_rss($rss_source['url']); |
|---|
| | 231 | if (!$rss) { |
|---|
| | 232 | throw new Exception(_(magpie_error())); |
|---|
| | 233 | } else { |
|---|
| | 234 | unset($rss_info_tmp); |
|---|
| | 235 | $rss_info_tmp['title'] = $rss->channel['title']; |
|---|
| | 236 | $rss_info_tmp['link'] = $rss->channel['link']; |
|---|
| | 237 | |
|---|
| | 238 | $i = 0; |
|---|
| | 239 | /* Sort the items by date, so we get the most recent first */ |
|---|
| | 240 | if (!uasort($rss->items, array("RssPressReview","cmp_date_item"))) { |
|---|
| | 241 | throw new Exception(_('uasort() failed')); |
|---|
| | 242 | } |
|---|
| | 243 | |
|---|
| | 244 | $rss_info_tmp['items'] = array(); |
|---|
| | 245 | foreach ($rss->items as $item){ |
|---|
| | 246 | $date = self::get_item_date($item); |
|---|
| | 247 | $realdate = $date; |
|---|
| | 248 | if ($date == -1) { |
|---|
| | 249 | /* |
|---|
| | 250 | * If we do not know the date, for statistics purposes, |
|---|
| | 251 | * we will set the date as if a news item as published |
|---|
| | 252 | * every default_publication_interval, starting now. |
|---|
| | 253 | */ |
|---|
| | 254 | $date = time() - ($i * $rss_sources[$rss_sources_key]['default_publication_interval']); |
|---|
| | 255 | } |
|---|
| | 256 | |
|---|
| | 257 | $average_publication_interval = $rss_sources[$rss_sources_key]['average_publication_interval']; |
|---|
| | 258 | |
|---|
| | 259 | $adjust_factor = $all_feed_publication_interval / $average_publication_interval; |
|---|
| | 260 | $adjusted_date = time() - ((time() - $date) * $adjust_factor); |
|---|
| | 261 | if ($adjusted_date >= $min_adjusted_date_to_display) { |
|---|
| | 262 | |
|---|
| | 263 | $author = ''; |
|---|
| | 264 | if(!empty($item['dc']['creator'])) { |
|---|
| | 265 | $author = trim($item['dc']['creator']); |
|---|
| | 266 | } elseif (!empty($item['author'])) { |
|---|
| | 267 | $author = trim($item['author']); |
|---|
| | 268 | } elseif (!empty($item['author_name'])) { |
|---|
| | 269 | $author = trim($item['author_name']); |
|---|
| | 270 | } |
|---|
| | 271 | |
|---|
| | 272 | array_push($rss_info_tmp['items'], array( |
|---|
| | 273 | "title" => $item['title'], |
|---|
| | 274 | "summary" => $item['summary'], |
|---|
| | 275 | "author" => $author, |
|---|
| | 276 | "date" => $realdate, |
|---|
| | 277 | "link" => $item['link'], |
|---|
| | 278 | "id" => "summary_" . mt_rand(1, 10000). "_" . $sidx |
|---|
| | 279 | )); |
|---|
| | 280 | } |
|---|
| | 281 | $i++; |
|---|
| | 282 | $sidx++; |
|---|
| | 283 | }// End foreach items |
|---|
| | 284 | $rss_info[] = $rss_info_tmp; |
|---|
| | 285 | } |
|---|
| | 286 | }// End foreach rss feeds |
|---|
| | 287 | return $rss_info; |
|---|
| | 288 | error_reporting($old_error_level); |
|---|
| | 289 | } |
|---|
| | 290 | |
|---|
| | 291 | function get_rss_header() { |
|---|
| | 292 | static $done_header = false; |
|---|
| | 293 | |
|---|
| | 294 | if (!$done_header) { |
|---|
| | 295 | $done_header = true; |
|---|
| | 296 | return ' |
|---|
| | 297 | <style> |
|---|
| | 298 | div.introduction { |
|---|
| | 299 | font-size: 12px; |
|---|
| | 300 | padding: 5px; |
|---|
| | 301 | border: 1px solid #324C48; |
|---|
| | 302 | background-color: #E0EBE9; |
|---|
| | 303 | visibility: hidden; |
|---|
| | 304 | position: absolute; |
|---|
| | 305 | left: 25px; |
|---|
| | 306 | top: 0px; |
|---|
| | 307 | width: 350px; |
|---|
| | 308 | -moz-opacity: 0.95; filter: alpha(opacity=95); |
|---|
| | 309 | } |
|---|
| | 310 | |
|---|
| | 311 | </style> |
|---|
| | 312 | |
|---|
| | 313 | <script language="JavaScript" type="text/javascript"> |
|---|
| | 314 | function MM_findObj(n, d) { //v4.0 |
|---|
| | 315 | var p,i,x; |
|---|
| | 316 | if(!d) d=document; |
|---|
| | 317 | if((p=n.indexOf("?"))>0&&parent.frames.length) { |
|---|
| | 318 | d=parent.frames[n.substring(p+1)].document; |
|---|
| | 319 | n=n.substring(0,p); |
|---|
| 462 | | |
|---|
| 463 | | } |
|---|
| 464 | | |
|---|
| | 321 | if(!(x=d[n])&&d.all) x=d.all[n]; |
|---|
| | 322 | for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; |
|---|
| | 323 | for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); |
|---|
| | 324 | if(!x && document.getElementById) x=document.getElementById(n); return x; |
|---|
| | 325 | } |
|---|
| | 326 | |
|---|
| | 327 | function changestyle(couche, style) { |
|---|
| | 328 | if (!(layer = MM_findObj(couche))) return; |
|---|
| | 329 | layer.style.visibility = style; |
|---|
| | 330 | } |
|---|
| | 331 | |
|---|
| | 332 | function changeclass(objet, myClass) |
|---|
| | 333 | { |
|---|
| | 334 | objet.className = myClass; |
|---|
| | 335 | } |
|---|
| | 336 | </script>'; |
|---|
| | 337 | } |
|---|
| | 338 | } |
|---|
| | 339 | |
|---|
| | 340 | public function get_rss_html($rss_sources, $number_of_items_to_display = 20) { |
|---|
| | 341 | $rss_result = $this->get_rss($rss_sources, $number_of_items_to_display); |
|---|
| | 342 | |
|---|
| | 343 | $html = ''; |
|---|
| | 344 | foreach ($rss_result as $feed) { |
|---|
| | 345 | $html .= "<p class=textegris>"._('Source: ')."<b>"; |
|---|
| | 346 | if(!empty($feed['link'])) { |
|---|
| | 347 | $html .= "<a class='y' href='".$feed['link']."'>" . $feed['title'] . "</a>"; |
|---|
| | 348 | } else { |
|---|
| | 349 | $html .= $channel_title; |
|---|
| | 350 | } |
|---|
| | 351 | $html .= "</b></p>\n"; |
|---|
| | 352 | $html .= "<ul>\n"; |
|---|
| | 353 | |
|---|
| | 354 | foreach ($feed['items'] as $item) { |
|---|
| | 355 | if ($item['date'] != -1) { |
|---|
| | 356 | setlocale("LC_TIME", "fr_CA"); |
|---|
| | 357 | $display_date = strftime("%x", $item['date']); |
|---|
| | 358 | } else { |
|---|
| | 359 | $display_date = ''; |
|---|
| | 360 | } |
|---|
| | 361 | |
|---|
| | 362 | $dhtml_id = "summary_".mt_rand(1, 10000). "_".$sidx; |
|---|
| | 363 | $html .= "<li>\n"; |
|---|
| | 364 | $html .= "<span class='textegrispetit'>$display_date</span>"; |
|---|
| | 365 | $html .= "<span class='y' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; |
|---|
| | 366 | if ($item['link']) { |
|---|
| | 367 | $html .= "<a class='y' href='{$item['link']}'><b>{$item['title']}</b></span></a><br />"; |
|---|
| | 368 | } else { |
|---|
| | 369 | $html .= "<b>{$item['title']}</b></span><br />"; |
|---|
| | 370 | } |
|---|
| | 371 | $html .= "<div style='z-index: 1000; position: relative'>\n"; |
|---|
| | 372 | $html .= "<div style='z-index: 1000;' id='$dhtml_id' class='introduction'><p>{$item['author']} ({$feed['title']}) $display_date</p>\n"; |
|---|
| | 373 | $html .= "<p>{$item['summary']}</p></div>\n"; |
|---|
| | 374 | $html .= "</div>\n"; |
|---|
| | 375 | $html .= "</li>\n"; |
|---|
| | 376 | } |
|---|
| | 377 | $html .= "</ul>\n"; |
|---|
| | 378 | } |
|---|
| | 379 | return $this->get_rss_header() . $html; |
|---|
| | 380 | } |
|---|
| | 381 | } |
|---|