1 | <?php
|
---|
2 |
|
---|
3 | require_once('LLReader/Plugin.php');
|
---|
4 |
|
---|
5 | class LLReader_Plugin_Filter_SearchEntry2Feed extends LLReader_Plugin {
|
---|
6 | public function execute ($llr) {
|
---|
7 | $config = $this->get_config();
|
---|
8 | $maches_entries = array();
|
---|
9 |
|
---|
10 | $feeds = $llr->get_feeds();
|
---|
11 | foreach ( $feeds as $feed ) {
|
---|
12 |
|
---|
13 | $err_rep = ini_get('error_reporting');
|
---|
14 | error_reporting(E_ALL ^ E_NOTICE);
|
---|
15 |
|
---|
16 | foreach ( $feed as $entry ) {
|
---|
17 |
|
---|
18 | $pattern = mb_convert_encoding($config['regex'], 'UTF-8', 'EUC-JP, SJIS, UTF-8');
|
---|
19 | if ( preg_match_all($pattern , $entry->title, $maches) ) {
|
---|
20 | $maches_entries[] = $entry;
|
---|
21 | $llr->log(mb_convert_encoding($feed->title, 'EUC-JP', 'UTF-8')
|
---|
22 | . ':' . mb_convert_encoding($entry->title, 'EUC-JP', 'UTF-8'));
|
---|
23 | }
|
---|
24 | else {
|
---|
25 |
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | error_reporting($err_rep);
|
---|
30 | }
|
---|
31 | //new LLReader_Feed($maches_entries[0]->__toString());
|
---|
32 | //$llr->p(mb_convert_encoding($maches_entries[0]->title, 'EUC-JP', 'UTF-8'));
|
---|
33 | }
|
---|
34 |
|
---|
35 | private function entry2feed ($llr, $feed, $entries) {
|
---|
36 | $output = "<?xml version=\"1.0\"?>
|
---|
37 | <rss version=\"2.0\">
|
---|
38 | <channel>
|
---|
39 | <title>{$feed->title}</title>
|
---|
40 | <link>http://www.tracypeterson.com/RSS/RSS.php</link>
|
---|
41 | <description>$feed->description</description>
|
---|
42 | <language>$feed->language</language>
|
---|
43 | <pubDate>$feed->date</pubDate>
|
---|
44 | <lastBuildDate>$feed->lastBuildDate</lastBuildDate>
|
---|
45 | <docs>http://someurl.com</docs>
|
---|
46 | <managingEditor>you@youremail.com</managingEditor>
|
---|
47 | <webMaster>you@youremail.com</webMaster>
|
---|
48 | ";
|
---|
49 |
|
---|
50 | foreach ($entries as $entry)
|
---|
51 | {
|
---|
52 | $output .= "<item><title>" . $entry->title . "</title>
|
---|
53 | <link>" . $entry->link . "</link>
|
---|
54 |
|
---|
55 | <description>".htmlentities(strip_tags($line['description']))."</description>
|
---|
56 | </item>";
|
---|
57 | }
|
---|
58 |
|
---|
59 | return new LLReader_Feed($output);
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | ?> |
---|