Changeset 14612


Ignore:
Timestamp:
2007/06/14 00:09:08 (17 years ago)
Author:
adati
Message:
 
Location:
branches/dev/html/test/adachi/LLReader
Files:
73 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/dev/html/test/adachi/LLReader/LLReader.php

    r14611 r14612  
    11<?php 
    22require_once('LLReader/Util.php'); 
    3 require_once('LLReader/Feed.php'); 
    43//require_once('LLReader/Constant.php'); 
    54 
     
    87    private $plugins; 
    98    private $feeds; 
    10  
     9     
    1110    public function __construct($config){ 
    12         $this->config = $config; 
     11        $this->config  = $config; 
     12        $this->plugins = array(); 
     13        $this->feeds   = array(); 
    1314    } 
    14  
     15     
    1516    public function run () { 
    1617        $this->load_plugins(); 
    17  
     18         
    1819        $phases = array( 
    1920            'Subscription', 
     
    3031        } 
    3132    } 
    32  
     33     
    3334    private function load_plugins () { 
    3435        foreach ($this->config['plugins'] as $name => $config) { 
     
    3637            $include = preg_replace('/_/', '/', $class) . '.php'; 
    3738            $ret     = include_once($include); 
    38  
     39             
    3940            $err = 0; 
    40  
     41             
    4142            if ($ret) { 
    4243                if ( preg_match("/^(.+?)_/", $name, $matches) ) { 
     
    5152            } 
    5253            else { 
    53                 $this->log('[ERR] ' . $class . " not found"); 
     54                $this->log('[ERR] ' . $class . ' not found'); 
    5455                $err++; 
    5556            } 
    5657        } 
    57  
     58         
    5859        if ($err) { 
    59             $this->log('[Die] ' . 'function load_plugins()'); 
    60             exit(); 
     60            $this->_die('function load_plugins()'); 
    6161        } 
    6262    } 
    63  
     63     
    6464    public function log ($msg) { 
    6565        LLReader_Util::log($msg); 
    6666    } 
    67  
     67     
    6868    public function p ($var) { 
    6969        LLReader_Util::p($var); 
    7070    } 
    71  
     71     
     72    public function _die ($msg) { 
     73        $this->log('[DIE] ' . $msg); 
     74        exit(); 
     75    } 
     76     
    7277    private function get_plugins ($phase) { 
    7378        if ( empty($this->plugins[$phase]) ) { 
    74             return array(); 
     79            return array(); 
    7580        } 
    7681        return $this->plugins[$phase]; 
    7782    } 
    78  
     83     
    7984    public function get_feeds () { 
    8085        return $this->feeds; 
    8186    } 
     87     
     88    public function add_feed ($feed) { 
     89        $this->feeds[] = $feed; 
     90    } 
    8291} 
    8392?> 
  • branches/dev/html/test/adachi/LLReader/LLReader/Feed.php

    r14611 r14612  
    44  
    55class LLReader_Feed extends XML_Feed_Parser { 
    6  
     6    public static function entries2feed ($entries, $feed = null, $feed_info = array()) { 
     7        $xml = ''; 
     8        return new LLReader_Feed($xml); 
     9    } 
    710} 
    811 
  • branches/dev/html/test/adachi/LLReader/LLReader/Plugin/Subscription/Simple.php

    r14611 r14612  
    22 
    33require_once('LLReader/Plugin.php'); 
     4require_once('LLReader/Feed.php'); 
    45 
    56class LLReader_Plugin_Subscription_Simple extends LLReader_Plugin { 
    6     function execute ($llr) { 
     7    public function execute ($llr) { 
    78        $config = $this->get_config(); 
    8         $llr->p($config); 
     9        $urls   = array(); 
     10         
     11        if ( is_array($config['urls']) ) { 
     12            $urls = $config['urls']; 
     13        } 
     14        else { 
     15            $urls = array($config['urls']); 
     16        } 
     17         
     18        foreach ( $urls as $url ) { 
     19            $xml = file_get_contents($url); 
     20             
     21            try { 
     22                $feed = new LLReader_Feed($xml); 
     23                $llr->add_feed($feed); 
     24            } 
     25            catch ( XML_Feed_Parser_Exception $e ) { 
     26                $llr->log('[Warning] Feed invalid: ' . $e->getMessage()); 
     27            } 
     28        } 
    929    } 
    1030} 
  • branches/dev/html/test/adachi/LLReader/pless_release.php

    r14611 r14612  
    11<?php 
    22 
    3 ini_set('include_path', ini_get('include_path') . ';./;./Lib'); 
     3$_ps = PATH_SEPARATOR; 
     4$_include_path = ini_get('include_path') . $_ps . './' . $_ps . './Lib'; 
     5 
     6ini_set('include_path', $_include_path); 
    47 
    58require_once('LLReader.php'); 
     
    811    'plugins' => array( 
    912        'Subscription_Simple' => array( 
    10             'urls' => array( 
    11                 '', 
    12                 '' 
    13             ), 
    14         )/*, 
    15         'Publish_Mail'=> array( 
    16             'to' => array( 
    17                 '', 
    18                 '', 
    19             ), 
    20             'from' => '' 
    21         )*/ 
     13            'urls' => array('http://feeds.feedburner.jp/cnet/rss') 
     14        ), 
     15        'Filter_SearchEntry2Feed' => array( 
     16            'regex' => '/¥é¥¤¥Ö¥É¥¢/i' 
     17        ), 
    2218    ) 
    2319); 
Note: See TracChangeset for help on using the changeset viewer.